* {
  box-sizing: border-box;
}

:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --line: #dbe3ec;
  --text: #17202b;
  --muted: #6a7787;
  --soft: #f6f8fb;
  --primary: #d56325;
  --primary-dark: #b94f1f;
  --teal: #0f766e;
  --danger: #c2410c;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

h1,
h2,
h3,
p {
  margin: 0;
  letter-spacing: 0;
}

.hidden {
  display: none !important;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(213, 99, 37, .08), rgba(15, 118, 110, .08)),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
  padding: 34px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(23, 32, 43, .10);
}

.login-logo,
.brand-logo {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-size: 22px;
  font-weight: 900;
}

.login-card h1 {
  margin-top: 18px;
  font-size: 26px;
}

.login-card p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: #192434;
  color: #ffffff;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 6px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.brand strong {
  display: block;
  font-size: 17px;
}

.brand span {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, .62);
  font-size: 12px;
}

.tabs {
  display: grid;
  gap: 6px;
  padding-top: 18px;
}

.tabs button {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, .76);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.tabs button:hover {
  background: rgba(255, 255, 255, .08);
  color: #ffffff;
}

.tabs button.active {
  background: #ffffff;
  color: var(--primary);
}

.logout-button {
  margin-top: auto;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, .82);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.workspace-head {
  min-height: 96px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.kicker {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

.workspace-head h1 {
  font-size: 26px;
}

.workspace-head p {
  margin-top: 8px;
  color: var(--muted);
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel {
  display: grid;
  gap: 16px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card,
.panel-card,
.list-panel,
.editor-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat-card {
  padding: 18px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  color: var(--text);
  font-size: 30px;
}

.panel-card {
  padding: 22px;
}

.manage-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.list-panel {
  overflow: hidden;
}

.list-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.list-head h2 {
  font-size: 17px;
}

.list-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.search-box {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.item-list {
  max-height: calc(100vh - 255px);
  overflow: auto;
  padding: 8px;
}

.list-item {
  width: 100%;
  min-height: 72px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.list-item:hover {
  background: var(--soft);
}

.list-item.active {
  background: #fff5ef;
  border-color: #f0c5ad;
}

.item-title {
  display: block;
  color: var(--text);
  font-weight: 800;
  line-height: 1.35;
}

.item-desc {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.editor-panel {
  min-height: 460px;
}

.editor-head {
  min-height: 68px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.editor-head h2 {
  font-size: 18px;
}

.editor-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.editor-body {
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.compact {
  margin-top: 18px;
  grid-template-columns: 1fr;
}

.wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  color: #445264;
  font-size: 13px;
  font-weight: 800;
}

.help-text {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 9px 11px;
  outline: none;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(213, 99, 37, .12);
}

textarea {
  min-height: 98px;
  resize: vertical;
  line-height: 1.55;
}

.form-section {
  margin-top: 8px;
  padding: 14px 16px;
  border-left: 4px solid var(--primary);
  background: #fff8f4;
  border-radius: 8px;
}

.form-section h3 {
  color: var(--text);
  font-size: 16px;
}

.form-section p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.image-uploader {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.upload-label {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.upload-label strong {
  color: #445264;
  font-size: 13px;
}

.upload-label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.upload-value,
.upload-file-input {
  display: none;
}

.upload-preview {
  min-height: 118px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  gap: 12px;
}

.upload-preview-item {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.upload-preview-item img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.remove-image {
  position: absolute;
  right: 8px;
  top: 8px;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, .5);
  background: rgba(23, 32, 43, .78);
  color: #ffffff;
  font-size: 12px;
}

.upload-empty {
  min-height: 118px;
  display: grid;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}

.upload-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.repeat-editor,
.file-import,
.rich-editor,
.subject-picker,
.video-uploader {
  padding: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.repeat-head,
.rich-editor-head,
.picker-head,
.file-import > div:first-child {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.repeat-head strong,
.rich-editor-head strong,
.picker-head strong,
.file-import strong {
  color: #445264;
  font-size: 13px;
}

.rich-editor-head span,
.picker-head span,
.file-import span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.advantage-editor {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.advantage-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1.4fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.row-index {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: #17202b;
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
}

.rich-toolbar,
.file-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.rich-value,
.question-file-input,
.video-file-input {
  display: none;
}

.video-uploader {
  display: grid;
  gap: 12px;
}

.video-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.video-preview-card {
  display: grid;
  gap: 8px;
}

.video-preview-card video {
  width: 100%;
  max-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
}

.video-preview-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}

.rich-box {
  margin-top: 12px;
  min-height: 240px;
  padding: 16px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  outline: none;
  line-height: 1.75;
  color: var(--text);
}

.rich-box:empty {
  display: block;
}

.rich-box:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(213, 99, 37, .12);
}

.rich-box:empty::before {
  content: attr(data-placeholder);
  color: #98a3b3;
}

.rich-box h3 {
  margin: 12px 0 8px;
  font-size: 18px;
}

.rich-box p {
  margin: 0 0 10px;
}

.rich-box ul,
.rich-box ol {
  margin: 8px 0 8px 22px;
  padding: 0;
}

.file-actions {
  margin-top: 12px;
}

.subject-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.subject-check {
  min-height: 64px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  cursor: pointer;
}

.subject-check input {
  width: 16px;
  min-height: 16px;
  grid-row: 1 / span 2;
}

.subject-check span {
  color: var(--text);
  font-weight: 900;
}

.subject-check small {
  color: var(--muted);
  font-size: 12px;
}

.subject-check.checked {
  border-color: #efc0a7;
  background: #fff5ef;
}

.form-actions {
  position: sticky;
  bottom: 0;
  margin: 18px -18px -18px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.right-actions {
  display: flex;
  gap: 10px;
}

button {
  border: 0;
  border-radius: 7px;
  padding: 10px 15px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  background: #e7f5f3;
  color: var(--teal);
}

.danger-button {
  background: #fff1ec;
  color: var(--danger);
}

.plain-button {
  background: #ffffff;
  color: var(--primary);
  border: 1px solid #efc0a7;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  background: #e7f5f3;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.off {
  background: #eef2f6;
  color: #6a7787;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.quick-card {
  padding: 16px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.quick-card strong {
  display: block;
  margin-bottom: 8px;
}

.quick-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.import-panel {
  border-color: #f0c5ad;
  background: #fffaf7;
}

.import-head {
  margin-bottom: 16px;
}

.import-head h2 {
  font-size: 18px;
}

.import-head p {
  margin-top: 6px;
  line-height: 1.55;
}

.import-textarea {
  min-height: 230px;
  font-family: Consolas, "Microsoft YaHei", monospace;
}

.record-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.record-table th,
.record-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.record-table th {
  background: var(--soft);
  color: #445264;
  font-size: 13px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 320px;
  color: var(--muted);
  text-align: center;
}

.muted {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  padding: 12px 16px;
  border-radius: 8px;
  background: #17202b;
  color: #ffffff;
  box-shadow: 0 16px 30px rgba(23, 32, 43, .18);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .manage-layout,
  .dashboard-grid,
  .quick-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 16px;
  }

  .workspace-head,
  .editor-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .repeat-head,
  .rich-editor-head,
  .picker-head,
  .file-import > div:first-child,
  .video-url-row,
  .form-actions,
  .right-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .advantage-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .row-index {
    width: 34px;
  }

  .upload-preview {
    grid-template-columns: 1fr;
  }

  .rich-toolbar,
  .file-actions {
    align-items: stretch;
  }

  .rich-toolbar button,
  .file-actions button,
  .form-actions button {
    width: 100%;
  }

  .item-list {
    max-height: none;
  }
}
