:root {
  color-scheme: light;
  --page: #eef5ff;
  --surface: #ffffff;
  --surface-muted: #f7f9fc;
  --line: #d8e1ee;
  --line-strong: #bdcbe0;
  --text: #172033;
  --muted: #667085;
  --blue: #1769ff;
  --blue-soft: #eaf2ff;
  --green: #087a55;
  --green-soft: #e7f7f0;
  --coral: #d94a64;
  --coral-dark: #bf3650;
  --danger: #d92d20;
  --shadow: 0 14px 38px rgba(36, 54, 82, 0.14);
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; }

body {
  overflow: hidden;
  background: var(--page);
  color: var(--text);
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

.admin-app { display: grid; grid-template-rows: 66px 1fr; width: 100%; height: 100%; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark, .rail-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid #b7cdf5;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
}
.brand strong { display: block; font-size: 16px; line-height: 1.35; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 96px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.connection-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #98a2b3; }
.connection-status[data-state="online"] { color: var(--green); font-weight: 700; }
.connection-status[data-state="online"]::before { background: #12a474; }
.connection-status[data-state="loading"] { color: var(--blue); }
.connection-status[data-state="loading"]::before { background: var(--blue); }

.button, .icon-command {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 14px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}
.button.primary { background: var(--blue); color: #fff; }
.button.primary:hover:not(:disabled) { background: #0f5ce0; }
.button.secondary, .icon-command { border-color: var(--line-strong); background: #fff; }
.button.secondary:hover:not(:disabled), .icon-command:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.button.publish { background: var(--coral); color: #fff; }
.button.publish:hover:not(:disabled) { background: var(--coral-dark); }
.button.danger { border-color: #f1b6b1; color: var(--danger); }
.button.compact { min-height: 30px; padding: 5px 10px; font-size: 12px; }

.admin-shell { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: 0; }
.section-rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 12px;
  border-right: 1px solid var(--line);
  background: #f8fbff;
}
.rail-button {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #475467;
  text-align: left;
}
.rail-button:hover { background: #f0f5fc; color: var(--text); }
.rail-button.active { border-color: #bcd2fb; background: var(--blue-soft); color: var(--blue); font-weight: 800; }
.rail-icon { width: 30px; height: 30px; font-size: 12px; }
.rail-button b { min-width: 22px; color: var(--muted); font-size: 11px; text-align: right; }
.rail-button.active b { color: var(--blue); }
.rail-footer { margin-top: auto; padding: 12px 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.rail-footer span, .rail-footer code { display: block; }
.rail-footer code { margin-top: 5px; color: #344054; font-size: 11px; overflow-wrap: anywhere; }

.content-workspace { display: grid; grid-template-columns: 330px minmax(0, 1fr); min-width: 0; min-height: 0; }
.content-list-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.list-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 16px 10px; }
.list-heading h1, .release-heading h1 { margin: 0; font-size: 18px; line-height: 1.35; }
.list-heading p, .release-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.icon-command { min-height: 32px; padding: 5px 11px; color: var(--blue); }
.search-field { display: flex; align-items: center; gap: 8px; margin: 0 16px 12px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-muted); }
.search-field:focus-within { border-color: var(--blue); background: #fff; }
.search-field span { color: #98a2b3; font-size: 18px; }
.search-field input { width: 100%; min-width: 0; height: 36px; border: 0; outline: 0; background: transparent; color: var(--text); }
.content-list { min-height: 0; overflow: auto; padding: 0 10px 18px; }
.list-group-title { display: flex; justify-content: space-between; margin: 8px 6px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.content-card {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  margin-bottom: 7px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  text-align: left;
}
.content-card:hover { border-color: #a9c4f4; background: #fbfdff; }
.content-card.active { border-color: var(--blue); box-shadow: inset 3px 0 0 var(--blue); }
.content-card.published { grid-template-columns: minmax(0, 1fr) auto; background: var(--surface-muted); }
.draft-check { display: grid; place-items: start center; padding-top: 2px; }
.draft-check input { width: 16px; height: 16px; accent-color: var(--blue); }
.card-main { min-width: 0; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-title-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.version-badge, .tier-badge, .draft-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.version-badge { background: #edf1f7; color: #475467; }
.tier-badge { background: #fff4e5; color: #9a5b00; }
.draft-badge { background: var(--green-soft); color: var(--green); }
.card-main p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-action { align-self: center; border: 0; background: transparent; color: var(--blue); font-size: 12px; font-weight: 700; }
.list-empty { padding: 34px 16px; color: var(--muted); text-align: center; }

.editor-pane { min-width: 0; min-height: 0; overflow: auto; background: var(--surface-muted); }
.empty-editor { display: grid; place-items: center; align-content: center; gap: 10px; height: 100%; color: var(--muted); }
.empty-editor span { display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--blue); font-weight: 800; }
.editor-header { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 68px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.96); }
.editor-header h2 { margin: 0; font-size: 16px; }
.editor-header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.editor-actions { display: flex; gap: 8px; }
.editor-body { padding: 18px 20px 32px; }
.form-section { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.form-section:last-child { border-bottom: 0; }
.form-section > h3 { margin: 0 0 12px; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-stack { display: grid; gap: 14px; }
.form-grid label, .form-stack label, .field-block { display: grid; gap: 6px; min-width: 0; }
.form-grid label > span, .form-stack label > span, .field-label { color: #475467; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 6px; outline: 0; background: #fff; color: var(--text); }
input, select { height: 39px; padding: 0 10px; }
textarea { min-height: 120px; resize: vertical; padding: 11px 12px; line-height: 1.65; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23, 105, 255, 0.09); }
input[readonly] { background: #f1f4f8; color: var(--muted); }
.prompt-editor { min-height: 390px; font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif; }
.prompt-selector-row { display: grid; grid-template-columns: minmax(0, 280px) 1fr; align-items: end; gap: 12px; margin-bottom: 10px; }
.prompt-status { color: var(--muted); font-size: 11px; }
.media-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.media-preview { display: grid; place-items: center; min-height: 200px; margin-top: 12px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #edf1f7; color: var(--muted); }
.media-preview img, .media-preview video { display: block; width: 100%; max-height: 360px; object-fit: contain; background: #101828; }

.release-workspace { min-width: 0; min-height: 0; overflow: auto; background: var(--surface-muted); }
.release-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--line); background: #fff; }
.release-list { padding: 18px 24px 40px; }
.release-row { display: grid; grid-template-columns: 120px 180px minmax(0, 1fr); gap: 16px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.release-row strong { color: var(--blue); }
.release-time { color: var(--muted); font-size: 12px; }
.release-items { display: flex; flex-wrap: wrap; gap: 6px; }
.release-items span { padding: 4px 7px; border: 1px solid var(--line); border-radius: 4px; background: #fff; font-size: 11px; }

.modal { padding: 0; border: 0; background: transparent; }
.modal::backdrop { background: rgba(20, 31, 48, 0.55); }
.modal-panel { width: min(520px, calc(100vw - 32px)); margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.close-button { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 4px; background: #f1f4f8; color: #475467; font-size: 20px; }
.modal-body { padding: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 13px 20px; border-top: 1px solid var(--line); background: var(--surface-muted); }
.form-message { min-height: 18px; margin: 0; color: var(--muted); font-size: 12px; }
.form-message.error { color: var(--danger); }
.form-message.success { color: var(--green); }
.preview-panel { width: min(860px, calc(100vw - 32px)); }
.preview-media { min-height: 220px; max-height: 58vh; margin: 18px 20px 0; overflow: hidden; border-radius: 6px; background: #101828; }
.preview-media video, .preview-media img { display: block; width: 100%; max-height: 58vh; object-fit: contain; }
.preview-media .no-media { display: grid; place-items: center; min-height: 220px; color: #cbd5e1; }
.preview-prompt { max-height: 220px; margin: 14px 20px 20px; overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-muted); white-space: pre-wrap; line-height: 1.65; }
.confirm-panel { width: min(430px, calc(100vw - 32px)); }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 20; max-width: 420px; padding: 11px 15px; border-radius: 6px; background: #172033; color: #fff; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: 0.18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #9f241b; }

@media (max-width: 1080px) {
  .admin-shell { grid-template-columns: 176px minmax(0, 1fr); }
  .content-workspace { grid-template-columns: 285px minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .wide { grid-column: 1; }
  .release-row { grid-template-columns: 100px minmax(0, 1fr); }
  .release-items { grid-column: 1 / -1; }
}
