:root {
  --ink: #1a2140;
  --ink-soft: #3d4a66;
  --muted: #6b7285;
  --line: #e6e2f0;
  --bg: #f6f3fb;
  --card: #ffffff;
  --accent: #7c3aed;
  --accent-dark: #5b21b6;
  --accent-ink: #4c1d95;
  --accent-soft: rgba(124, 58, 237, 0.1);
  --orange: #ea580c;
  --orange-deep: #c2410c;
  --ok: #0f7a47;
  --warn: #b45309;
  --danger: #b91c1c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(26, 33, 64, 0.05), 0 12px 30px rgba(26, 33, 64, 0.06);
  --font: "Microsoft YaHei", "PingFang SC", "Segoe UI", -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink-soft);
  font-family: var(--font); font-size: 14.5px; line-height: 1.7;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, b { color: var(--ink); }
code { background: #f3effc; border: 1px solid #e6dcfa; border-radius: 6px; padding: 1px 6px; font-size: 12.5px; color: var(--accent-ink); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }

/* layout */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: #1e1430; color: #cbbfe4; padding: 22px 16px;
  display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, #a855f7, #ea580c);
  color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 18px;
}
.brand b { display: block; color: #fff; font-size: 15.5px; line-height: 1.4; }
.brand small { display: block; color: #a493c4; font-size: 11.5px; letter-spacing: 0.08em; }
.side-nav { display: grid; gap: 4px; }
.side-nav a { color: #cbbfe4; padding: 9px 12px; border-radius: 10px; font-size: 14.5px; }
.side-nav a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; text-decoration: none; }
.side-nav a.is-active { background: linear-gradient(135deg, rgba(168, 85, 247, 0.35), rgba(234, 88, 12, 0.28)); color: #fff; font-weight: 600; }
.side-foot { margin-top: auto; display: grid; gap: 8px; font-size: 13px; }
.side-foot a { color: #cbbfe4; }
.side-foot .link { background: none; border: 0; color: #a493c4; cursor: pointer; padding: 0; font: inherit; }
.side-foot .link:hover { color: #fff; }

.main { padding: 26px 30px 50px; min-width: 0; }
.topbar { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.topbar h1 { margin: 0; font-size: 24px; }
.topbar p { margin: 4px 0 0; font-size: 13px; }
.top-actions { display: flex; gap: 10px; align-items: center; }

/* buttons */
.btn {
  display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 8px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit; line-height: 1.4;
}
.btn:hover { border-color: #cbb6f5; text-decoration: none; }
.btn.primary { background: linear-gradient(135deg, #6d28d9, #c2410c); color: #fff; border: 0; box-shadow: 0 8px 18px rgba(124, 58, 237, 0.22); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.danger { color: var(--danger); border-color: #f2c9c9; }
.btn.danger:hover { background: #fdf2f2; }
.btn.full { width: 100%; justify-content: center; }

/* flash */
.flashes { display: grid; gap: 8px; margin-bottom: 16px; }
.flash { margin: 0; padding: 10px 14px; border-radius: 10px; font-size: 13.5px; border: 1px solid; }
.flash.ok { background: #f1fbf5; border-color: #c8e9d6; color: #0f6b41; }
.flash.error { background: #fdf3f3; border-color: #f2cccc; color: #a02020; }

/* cards & panels */
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card b { display: block; font-size: 24px; line-height: 1.2; }
.stat-card span { font-size: 12.5px; color: var(--muted); }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel.narrow { max-width: 620px; }
.panel-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-head p { margin: 0; font-size: 12.5px; }

/* table */
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table th { background: #faf7ff; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table td b { display: block; font-size: 13.5px; }
.admin-table td small { color: var(--muted); font-size: 11.5px; }
.row-actions { white-space: nowrap; }
.badge { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: #f3f0fa; color: var(--accent-ink); }
.badge.ok { background: #edf9f2; color: #0f6b41; }
.badge.warn { background: #fef6e8; color: #9a5b06; }

/* forms */
.edit-form .panel { margin-bottom: 16px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field > span em { font-style: normal; font-weight: 400; color: var(--muted); }
.field input, .field textarea, .upload-form input[type=file] {
  width: 100%; font: inherit; font-size: 14px; color: var(--ink);
  background: #fcfbff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; line-height: 1.6;
}
.field textarea { resize: vertical; }
.field textarea.code { font-family: Consolas, "Courier New", monospace; font-size: 12.5px; line-height: 1.65; }
.field input:focus, .field textarea:focus, .rich-editor:focus {
  outline: none; border-color: #b9a2f2; background: #fff; box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}
.field .over { color: var(--danger); }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.seo-notes { font-size: 12.5px; min-height: 18px; margin: 0 0 10px; }

.rich-wrap { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.rich-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; background: #faf7ff; border-bottom: 1px solid var(--line); }
.rich-toolbar button {
  border: 1px solid transparent; background: transparent; color: var(--ink-soft);
  font-size: 12.5px; padding: 5px 9px; border-radius: 7px; cursor: pointer; font-family: inherit;
}
.rich-toolbar button:hover { background: #fff; border-color: var(--line); color: var(--accent-ink); }
.rich-editor { min-height: 320px; padding: 16px 18px; font-size: 15px; line-height: 1.85; outline: none; }
.rich-editor h2 { font-size: 20px; margin: 1.2em 0 0.5em; }
.rich-editor h3 { font-size: 17px; margin: 1em 0 0.4em; }
.rich-editor p { margin: 0 0 0.9em; }
.rich-editor ul, .rich-editor ol { padding-left: 1.4em; }

.checks { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.build-output { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; }
.build-output summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.build-output pre { white-space: pre-wrap; word-break: break-all; font-size: 12px; background: #faf9fd; padding: 12px; border-radius: 10px; max-height: 380px; overflow: auto; }

/* media */
.upload-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.upload-form input[type=file] { width: auto; flex: 1 1 260px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.media-item { margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.media-item img { width: 100%; height: 130px; object-fit: cover; display: block; background: #f5f2fb; }
.media-item figcaption { padding: 10px 12px; display: grid; gap: 5px; }
.media-item code { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
.media-item small { color: var(--muted); font-size: 11.5px; }
.media-actions { display: flex; gap: 6px; align-items: center; }
.media-actions form { margin: 0; }

/* settings */
.config-list { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; margin: 0; font-size: 13.5px; }
.config-list dt { color: var(--muted); }
.config-list dd { margin: 0; color: var(--ink); }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(700px 320px at 15% 0%, rgba(168, 85, 247, 0.18), transparent 60%), radial-gradient(600px 300px at 90% 10%, rgba(234, 88, 12, 0.14), transparent 60%), #f6f3fb; }
.login-card { width: min(400px, 100% - 32px); background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 30px 28px; box-shadow: 0 20px 50px rgba(76, 29, 149, 0.1); }
.login-head { text-align: center; margin-bottom: 18px; }
.login-head .brand-mark { margin: 0 auto 12px; width: 46px; height: 46px; border-radius: 13px; font-size: 22px; }
.login-head h1 { font-size: 20px; margin: 0 0 4px; }
.login-head p { margin: 0; font-size: 12.5px; }
.login-card .flash { margin-bottom: 12px; }
.login-card .btn { margin-top: 6px; }
.login-card .hint { text-align: center; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; }
  .side-nav { grid-auto-flow: column; overflow-x: auto; gap: 2px; }
  .side-nav a { white-space: nowrap; font-size: 13px; padding: 7px 10px; }
  .side-foot { margin-left: auto; grid-auto-flow: column; align-items: center; }
  .main { padding: 18px 16px 40px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}

/* 选题库 / 批量导入 */
.progress { height: 10px; background: #f0ebfa; border-radius: 999px; overflow: hidden; margin: 8px 0; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, #7c3aed, #ea580c); border-radius: 999px; transition: width 0.3s ease; }
textarea.prompt {
  width: 100%; font-family: Consolas, "Courier New", monospace; font-size: 12.5px; line-height: 1.7;
  background: #faf8ff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  color: var(--ink-soft); resize: vertical;
}
.field select {
  width: 100%; font: inherit; font-size: 14px; color: var(--ink); background: #fcfbff;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
}
.field select:focus { outline: none; border-color: #b9a2f2; box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12); }
.import-help { font-size: 13px; color: var(--ink-soft); }
.import-help ul { padding-left: 1.3em; }
.import-help li { margin-bottom: 6px; }
