@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap");

:root {
  --font-sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  --bg: #eef2f6;
  --bg-subtle: #e2e8f0;
  --surface: #ffffff;
  --card: #ffffff;
  --text: #0f172a;
  --fg: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-soft: rgba(13, 148, 136, 0.12);
  --primary-2: #0891b2;
  --accent: #0d9488;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 40px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --radius-lg: 20px;
  --radius-sm: 10px;
  --topbar-bg: rgba(255, 255, 255, 0.72);
  --nav-pill: #f1f5f9;
}

body[data-theme="dark"] {
  --bg: #0c111d;
  --bg-subtle: #151b2b;
  --surface: #141b2d;
  --card: #141b2d;
  --text: #f1f5f9;
  --fg: #f1f5f9;
  --muted: #94a3b8;
  --line: #273449;
  --line-strong: #334155;
  --primary: #2dd4bf;
  --primary-hover: #5eead4;
  --primary-soft: rgba(45, 212, 191, 0.15);
  --primary-2: #22d3ee;
  --accent: #2dd4bf;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 16px 48px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
  --topbar-bg: rgba(12, 17, 29, 0.82);
  --nav-pill: #1e293b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 0% -20%, rgba(13, 148, 136, 0.09), transparent 50%),
    radial-gradient(ellipse 90% 60% at 100% 0%, rgba(8, 145, 178, 0.07), transparent 45%);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body[data-theme="dark"] {
  background-image:
    radial-gradient(ellipse 100% 70% at 0% -10%, rgba(45, 212, 191, 0.08), transparent 50%),
    radial-gradient(ellipse 80% 50% at 100% 0%, rgba(34, 211, 238, 0.06), transparent 45%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

body[data-theme="dark"] .topbar {
  border-bottom-color: var(--line);
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: nowrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.brand::before {
  content: "";
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--primary) 0%, var(--primary-2) 100%);
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.35);
}

body[data-theme="dark"] .brand::before {
  box-shadow: 0 4px 18px rgba(45, 212, 191, 0.25);
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  flex: 1;
  min-width: 0;
  padding: 4px;
  margin: 0 4px;
  background: var(--nav-pill);
  border-radius: 999px;
  border: 1px solid var(--line);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.nav::-webkit-scrollbar {
  height: 4px;
}

.nav::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}

.nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.nav a:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
}

body[data-theme="dark"] .nav a:hover {
  background: var(--bg-subtle);
  border-color: var(--line-strong);
}

body[data-page="system"] .nav a[data-nav="system"],
body[data-page="members"] .nav a[data-nav="members"],
body[data-page="profile"] .nav a[data-nav="profile"],
body[data-page="questions"] .nav a[data-nav="questions"],
body[data-page="diagnosis"] .nav a[data-nav="diagnosis"],
body[data-page="auth"] .nav a[data-nav="auth"] {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(13, 148, 136, 0.28);
  font-weight: 600;
}

body[data-theme="dark"][data-page="system"] .nav a[data-nav="system"],
body[data-theme="dark"][data-page="members"] .nav a[data-nav="members"],
body[data-theme="dark"][data-page="profile"] .nav a[data-nav="profile"],
body[data-theme="dark"][data-page="questions"] .nav a[data-nav="questions"],
body[data-theme="dark"][data-page="diagnosis"] .nav a[data-nav="diagnosis"],
body[data-theme="dark"][data-page="auth"] .nav a[data-nav="auth"] {
  border-color: rgba(45, 212, 191, 0.35);
}

.spacer {
  flex: 1;
}

/* ═══ 应用外壳：固定侧栏 + 主内容（桌面）；抽屉侧栏（窄屏）═══ */
.app-layout {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.app-sidebar {
  width: 272px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  z-index: 40;
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.04);
}

body[data-theme="dark"] .app-sidebar {
  box-shadow: 4px 0 32px rgba(0, 0, 0, 0.25);
}

.app-sidebar-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  padding: 22px 16px 18px;
}

.app-sidebar-head {
  margin-bottom: 8px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.app-sidebar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.brand-sidebar {
  font-size: 1.125rem;
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.sidebar-collapse-toggle {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--nav-pill);
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar-collapse-toggle:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--line-strong);
}

.app-sidebar.is-collapsed {
  width: 80px;
}

.app-sidebar.is-collapsed .app-sidebar-inner {
  padding: 18px 10px 14px;
}

.app-sidebar.is-collapsed .app-sidebar-brand-row {
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.app-sidebar.is-collapsed .brand-sidebar {
  font-size: 0;
  width: 100%;
  justify-content: center;
}

.app-sidebar.is-collapsed .sidebar-collapse-toggle {
  width: 100%;
}

.app-sidebar.is-collapsed .nav a {
  justify-content: center;
  padding: 12px 8px;
  font-size: 0;
  letter-spacing: 0;
}

.app-sidebar.is-collapsed .nav a::before {
  content: attr(data-sidebar-icon);
  font-size: 1.35rem;
  line-height: 1;
  display: block;
}

.app-sidebar.is-collapsed .ghost-btn-block {
  padding: 10px 8px;
  font-size: 13px;
  min-height: 40px;
}

@media (max-width: 960px) {
  .sidebar-collapse-toggle {
    display: none;
  }

  .app-sidebar .app-sidebar-brand-row {
    justify-content: flex-start;
  }

  .app-sidebar.is-collapsed {
    width: min(300px, 90vw);
  }

  .app-sidebar.is-collapsed .nav a {
    font-size: 14px;
    justify-content: flex-start;
    padding: 10px 14px;
  }

  .app-sidebar.is-collapsed .nav a::before {
    content: none;
    display: none;
  }

  .app-sidebar.is-collapsed .brand-sidebar {
    font-size: 1.125rem;
    width: auto;
    justify-content: flex-start;
  }
}

.app-sidebar .nav.nav-sidebar,
.app-sidebar .nav {
  flex: 1;
  min-height: 0;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  margin: 0;
  gap: 4px;
  background: transparent;
  border: none;
  border-radius: 0;
  scrollbar-width: thin;
}

.app-sidebar .nav::-webkit-scrollbar {
  width: 6px;
}

.app-sidebar .nav a {
  width: 100%;
  justify-content: flex-start;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
}

.app-sidebar-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ghost-btn-block {
  width: 100%;
  justify-content: center;
}

.app-main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-mobile-header {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  background: var(--topbar-bg);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.app-mobile-title {
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-scrim {
  display: none;
}

.nav-toggle {
  display: none;
}

.app-layout .app-mobile-header .nav-toggle {
  display: inline-flex;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 22px 72px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* 登录/注册页：无顶栏，内容收窄居中 */
body[data-page="auth"] .container.auth-only {
  max-width: 420px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 16px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
}

body[data-page="auth"] .auth-head {
  text-align: center;
  margin-bottom: 20px;
}

body[data-page="auth"] .auth-head h1 {
  font-size: clamp(1.4rem, 4vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

body[data-page="auth"] .form {
  grid-template-columns: 1fr;
}

.auth-card .form > button[type="submit"] {
  grid-column: 1 / -1;
}

.auth-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.auth-footer.auth-back {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.auth-footer-sep {
  color: var(--muted);
  user-select: none;
}

.link-btn {
  background: transparent;
  border: none;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, color 0.15s ease;
}

.link-btn:hover {
  color: var(--primary-hover);
  background: var(--primary-soft);
}

.page-head {
  margin: 0;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.page-head h1 {
  margin: 0 0 10px;
  font-size: clamp(1.5rem, 2.5vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-head .muted {
  max-width: 52rem;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
}

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

.card code,
.form-hint code {
  font-size: 0.88em;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin: 0;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  opacity: 0.85;
}

body[data-page="auth"] .card::before,
.modal-panel.card::before,
.card.chat-panel::before {
  display: none;
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  padding-left: 12px;
  border-left: none;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tabs button {
  background: var(--nav-pill);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 500;
}

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

body[data-theme="dark"] .tabs button.active {
  color: #0f172a;
}

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

.form.active {
  display: grid;
}

label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

label > input {
  margin-top: 2px;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input, select, textarea {
  background: var(--surface);
  color: var(--text);
}

textarea {
  resize: vertical;
  min-height: 120px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

input[readonly] {
  background: #f8fafc;
  color: #6b7280;
}

body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea {
  background: #0f172a;
  color: #e5e7eb;
  border-color: #334155;
}

body[data-theme="dark"] input[readonly] {
  background: #111827;
  color: #9ca3af;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

input.input-error {
  border-color: #ef4444 !important;
  outline: 2px solid rgba(239, 68, 68, 0.2);
}

button {
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

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

.form button {
  grid-column: span 2;
}

#form-profile-token #profile-token-load-btn,
#form-profile-token #profile-token-save-btn {
  grid-column: span 1;
}

@media (max-width: 720px) {
  #form-profile-token #profile-token-load-btn,
  #form-profile-token #profile-token-save-btn {
    grid-column: span 2;
  }
}

.form-hint {
  grid-column: span 2;
  margin: 0;
  font-size: 12px;
}

.ghost-btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.ghost-btn:hover {
  background: var(--nav-pill);
  border-color: var(--line-strong);
}

body[data-theme="dark"] .ghost-btn {
  background: var(--surface);
  color: var(--text);
}

body[data-theme="dark"] .ghost-btn:hover {
  background: var(--nav-pill);
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chat-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #f8fafc;
}

body[data-theme="dark"] .chat-panel {
  background: #0f172a;
}

.chat-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  flex-wrap: wrap;
}

body[data-theme="dark"] .chat-tools {
  background: rgba(15, 23, 42, 0.85);
}

.chat-tools label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.chat-tools input[type="date"] {
  min-width: 150px;
}

.chat-draw-mode-on {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary-hover) !important;
}

.chat-weakness-panel {
  margin: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--primary-soft);
}

body[data-theme="dark"] .chat-weakness-panel {
  background: var(--primary-soft);
  border-color: rgba(45, 212, 191, 0.35);
}

.chat-weakness-panel h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.chat-weakness-block {
  font-size: 13px;
  line-height: 1.5;
}

.chat-weakness-block + .chat-weakness-block {
  margin-top: 6px;
}

.chat-weakness-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chat-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

body[data-theme="dark"] .chat-meta {
  background: rgba(15, 23, 42, 0.85);
}

.chat-meta input[readonly] {
  background: #f3f4f6;
  color: #6b7280;
}

body[data-theme="dark"] .chat-meta input[readonly] {
  background: #111827;
  color: #9ca3af;
}

.chat-message-list {
  min-height: 360px;
  max-height: 520px;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-row {
  display: flex;
}

.chat-row.user {
  justify-content: flex-end;
}

.chat-row.assistant {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 14px;
  word-break: break-word;
}

.chat-row.user .chat-bubble {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-row.assistant .chat-bubble {
  background: #ffffff;
  color: #111827;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}

.chat-bubble-has-image {
  white-space: normal;
}

.chat-inline-image {
  margin-top: 8px;
  max-width: min(520px, 100%);
  width: 100%;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #fff;
  display: block;
}

.chat-image-actions {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.chat-image-download {
  font-size: 12px;
  text-decoration: none;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid var(--line-strong);
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
}

.chat-image-download:hover {
  background: var(--nav-pill);
}

.chat-image-download:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

body[data-theme="dark"] .chat-row.assistant .chat-bubble {
  background: #1f2937;
  color: #e5e7eb;
  border-color: #374151;
}

body[data-theme="dark"] .chat-inline-image {
  border-color: #475569;
  background: #0f172a;
}

body[data-theme="dark"] .chat-image-download {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: rgba(45, 212, 191, 0.35);
}

.chat-time {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.chat-row.user .chat-time {
  text-align: right;
}

.chat-day-divider {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.15);
  border-radius: 999px;
  padding: 3px 10px;
  margin: 2px 0;
}

.chat-composer {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

body[data-theme="dark"] .chat-composer {
  background: rgba(15, 23, 42, 0.85);
}

.chat-composer input {
  flex: 1;
}

.chat-composer button {
  min-width: 92px;
}

.chat-actions {
  padding: 0 12px 12px;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-panel {
  width: min(480px, calc(100vw - 32px));
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 22px 24px;
}

.modal-panel h3 {
  margin: 0 0 8px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.token-validate-tip {
  margin: 8px 0 0;
  font-size: 12px;
}

.token-validate-tip.ok {
  color: #10b981;
}

.token-validate-tip.warn {
  color: #f59e0b;
}

.token-validate-tip.error {
  color: #ef4444;
}

.token-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.token-input-row input {
  flex: 1;
}

.token-toggle-btn {
  min-width: 64px;
  padding: 8px 10px;
}

.table-wrap {
  overflow-x: auto;
}

.diag-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.diag-kpi-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--primary-soft);
}

body[data-theme="dark"] .diag-kpi-item {
  background: var(--primary-soft);
}

.diag-kpi-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.diag-kpi-value {
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
}

.diag-status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  border: 1px solid transparent;
}

.diag-status-pill.ok {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.3);
}

.diag-status-pill.warn {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.35);
}

.diag-status-pill.error {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.35);
}

.simple-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

body[data-theme="dark"] .simple-table {
  background: #111827;
}

.simple-table th,
.simple-table td {
  border-bottom: 1px solid #edf0f3;
  text-align: left;
  padding: 10px 8px;
  font-size: 13px;
  vertical-align: top;
}

.simple-table th {
  background: #f8fafc;
  color: #334155;
  font-weight: 600;
}

body[data-theme="dark"] .simple-table th {
  background: #1f2937;
  color: #cbd5e1;
}

.students-actions-cell {
  white-space: normal;
  line-height: 1.6;
}

.students-actions-cell .ghost-btn {
  padding: 4px 10px;
  font-size: 12px;
  vertical-align: baseline;
}

.students-subject-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px 14px;
  margin: 12px 0;
  max-height: 240px;
  overflow-y: auto;
}

.students-subject-check-grid .check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin: 0;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-subtle);
  color: var(--text);
  padding: 16px 18px;
  border-radius: var(--radius);
  min-height: 120px;
  margin: 0;
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.5;
}

body[data-theme="dark"] pre {
  background: #0a0f1a;
  color: #e2e8f0;
  border-color: var(--line);
}

/* ── 练习选择器（学生友好版） ── */
.practice-identity-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--line);
  border-radius: 8px;
}
.practice-identity-name { font-weight: 600; color: var(--text); }
.practice-identity-sep { color: var(--muted); }

.practice-mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 0;
}
.practice-mode-tab {
  padding: 8px 18px;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 0;
  transition: color 0.2s, border-color 0.2s;
}
.practice-mode-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.practice-mode-tab:hover { color: var(--primary); }

.practice-plans-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.practice-plan-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--surface);
  transition: box-shadow 0.2s;
}
.practice-plan-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.ppc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.ppc-kp-name { font-weight: 600; font-size: 15px; color: var(--text); }
.ppc-priority {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}
.ppc-priority.priority-high { background: #fef2f2; color: #dc2626; }
.ppc-priority.priority-medium { background: #eff6ff; color: #2563eb; }
.ppc-priority.priority-low { background: #f0fdf4; color: #16a34a; }
.ppc-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.ppc-status { color: var(--primary); }
.ppc-start-btn { font-size: 13px; padding: 6px 18px; }
.practice-plan-empty { text-align: center; padding: 24px 0; }

.practice-free-form { display: flex; flex-direction: column; gap: 14px; }
.practice-free-row { display: flex; align-items: center; gap: 12px; }
.practice-free-row label { width: 72px; font-size: 14px; color: var(--muted); flex-shrink: 0; }
.practice-free-row select {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

/* ── 练习做题页面 ── */
.practice-progress-bar {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 14px;
}

.practice-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border-radius: 3px;
  transition: width 0.4s ease;
}

.practice-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.practice-kp-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 3px 10px;
  border-radius: 20px;
}

.practice-counter {
  font-size: 13px;
  color: var(--muted);
}

.practice-question-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
}

.practice-question-content {
  font-size: 16px;
  line-height: 1.7;
  margin: 0 0 20px;
  white-space: pre-wrap;
}

.practice-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.practice-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}

.practice-option:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.practice-option.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.practice-option.correct {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.08);
}

.practice-option.wrong {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

.practice-option-key {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.practice-option.selected .practice-option-key { background: var(--primary); color: #fff; }
.practice-option.correct .practice-option-key { background: #22c55e; color: #fff; }
.practice-option.wrong .practice-option-key { background: #ef4444; color: #fff; }

.practice-short-answer {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  resize: vertical;
  transition: border-color 0.15s;
}

.practice-short-answer:focus {
  outline: none;
  border-color: var(--primary);
}

.practice-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.practice-feedback {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.practice-feedback-icon {
  font-size: 36px;
  text-align: center;
}

.practice-feedback-icon.correct::before { content: "✅"; }
.practice-feedback-icon.wrong::before { content: "❌"; }

.practice-mastery-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.practice-mastery-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.practice-mastery-track {
  flex: 1;
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.practice-mastery-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  border-radius: 4px;
  transition: width 0.6s ease;
}

.practice-mastery-score {
  font-size: 13px;
  font-weight: 700;
  color: #22c55e;
  min-width: 36px;
  text-align: right;
}

/* ── 完成汇总 ── */
.practice-summary-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 24px 0;
}

.summary-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 20px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.summary-stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
}

.summary-stat-label {
  font-size: 12px;
  color: var(--muted);
}

.practice-summary-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.practice-review-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.practice-review-item {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 14px;
}

.practice-review-item.correct { border-left: 4px solid #22c55e; }
.practice-review-item.wrong { border-left: 4px solid #ef4444; }

.practice-review-question { font-weight: 600; margin-bottom: 6px; }
.practice-review-answer { color: var(--muted); font-size: 13px; }

.superadmin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.superadmin-toolbar-left {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px 14px;
  min-width: 0;
}

.superadmin-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.superadmin-selected-hint {
  font-size: 13px;
}

.superadmin-th-cb,
.superadmin-td-cb {
  width: 44px;
  text-align: center;
  vertical-align: middle;
}

.superadmin-th-cb label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 13px;
}

.superadmin-td-cb input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.superadmin-row-btn {
  font-size: 12px !important;
  padding: 4px 10px !important;
}

.ghost-btn.danger {
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.45);
}

body[data-theme="dark"] .ghost-btn.danger {
  color: #fca5a5;
}

@media (max-width: 860px) {
  .form {
    grid-template-columns: 1fr;
  }

  .form button {
    grid-column: span 1;
  }

  .chat-meta {
    grid-template-columns: 1fr;
  }

  .diag-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .app-layout .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    height: 100dvh;
    width: min(300px, 90vw);
    transform: translateX(-102%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 80;
    box-shadow: none;
  }

  .app-layout .app-sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }

  .app-layout .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 70;
    border: none;
    padding: 0;
    margin: 0;
    background: rgba(15, 23, 42, 0.5);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
  }

  .app-layout .sidebar-scrim.is-open {
    opacity: 1;
    visibility: visible;
  }

  body.nav-drawer-open {
    overflow: hidden;
  }

  .app-layout .app-mobile-header {
    display: flex;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 12px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13px;
  }

  body[data-theme="dark"] .nav-toggle {
    background: var(--nav-pill);
    color: var(--text);
  }

  /* 旧版顶栏水平导航（无 app-layout 时） */
  .topbar .nav {
    display: none;
    width: 100%;
    order: 3;
    flex-wrap: wrap;
    border-radius: var(--radius);
    max-height: none;
    justify-content: flex-start;
  }

  .topbar .nav.open {
    display: flex;
  }

  .topbar .nav a {
    flex: 1 1 auto;
    min-width: calc(50% - 8px);
    text-align: center;
    justify-content: center;
  }

  .topbar-inner .spacer {
    display: none;
  }
}

/* ── 错题本 ─────────────────────────────────────────────── */
.wrongbook-stats-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.wrongbook-stat-box {
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  text-align: center;
  min-width: 90px;
}

.wrongbook-stat-box .wb-stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.wrongbook-stat-box .wb-stat-label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.wrongbook-stat-box.danger .wb-stat-num { color: #ef4444; }
.wrongbook-stat-box.success .wb-stat-num { color: #22c55e; }

.wrongbook-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wrongbook-item {
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.wrongbook-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.wrongbook-item-header .wb-kp-tag {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 12px;
}

.wrongbook-item-header .wb-status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}
.wb-status-badge.open { background: #fef2f2; color: #ef4444; }
.wb-status-badge.reviewing { background: #fffbeb; color: #f59e0b; }
.wb-status-badge.mastered { background: #f0fdf4; color: #22c55e; }

body[data-theme="dark"] .wb-status-badge.open { background: #450a0a; color: #fca5a5; }
body[data-theme="dark"] .wb-status-badge.reviewing { background: #451a03; color: #fcd34d; }
body[data-theme="dark"] .wb-status-badge.mastered { background: #052e16; color: #86efac; }

.wrongbook-item-body {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 8px;
  white-space: pre-wrap;
}

.wrongbook-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.wrongbook-item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.wrongbook-item-actions button {
  padding: 4px 12px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
}
.wrongbook-item-actions button:hover {
  background: var(--accent);
  color: #fff;
}
.wrongbook-item-actions button.danger:hover {
  background: #ef4444;
}

.wrongbook-analysis {
  margin-top: 8px;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  border: 1px dashed var(--line);
}
body[data-theme="dark"] .wrongbook-analysis {
  background: #1e293b;
}

.wrongbook-top-kps-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.wrongbook-top-kp {
  padding: 4px 12px;
  border-radius: 8px;
  background: #fef2f2;
  color: #ef4444;
  font-size: 13px;
}
body[data-theme="dark"] .wrongbook-top-kp {
  background: #450a0a;
  color: #fca5a5;
}

/* ── AI 导入结果 ─────────────────────────────────────────── */
.ai-import-result {
  margin-top: 14px;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.7;
}

.ai-import-result.success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
}

.ai-import-result.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

body[data-theme="dark"] .ai-import-result.success {
  background: #052e16;
  border-color: #166534;
  color: #86efac;
}

body[data-theme="dark"] .ai-import-result.error {
  background: #450a0a;
  border-color: #7f1d1d;
  color: #fca5a5;
}

.ai-import-result ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.ai-import-result li {
  margin-bottom: 2px;
}

/* ── 学生题库（questions.html 新版） ──────────────────────── */
.qbank-subject-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.qbank-subject-tab {
  padding: 6px 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.qbank-subject-tab:hover,
.qbank-subject-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.qbank-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 14px;
}

.qbank-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.qbank-filters select,
.qbank-filters input {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: inherit;
  font-size: 13px;
  min-width: 110px;
}

.qbank-filters button {
  padding: 6px 16px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
}

.qbank-unit-group {
  margin-bottom: 20px;
}

.qbank-unit-title {
  font-size: 15px;
  font-weight: 600;
  padding: 8px 0 8px 12px;
  border-left: 3px solid var(--accent);
  margin-bottom: 10px;
  color: var(--fg);
}

.qbank-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--bg);
}

.qbank-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.qbank-card-header .qbank-kp {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
}

.qbank-card-meta {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.qbank-difficulty-stars {
  color: #f59e0b;
  font-size: 12px;
}

.qbank-card-body {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 8px;
  white-space: pre-wrap;
}

.qbank-card-options {
  margin: 6px 0;
  font-size: 13px;
  color: var(--muted);
}

.qbank-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.qbank-card-actions button {
  padding: 4px 14px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
}

.qbank-card-actions button:hover {
  background: var(--accent);
  color: #fff;
}

.qbank-card-analysis {
  margin-top: 8px;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  border: 1px dashed var(--line);
  display: none;
}

body[data-theme="dark"] .qbank-card-analysis {
  background: #1e293b;
}

.qbank-card-analysis.open {
  display: block;
}

.qbank-empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
  font-size: 15px;
}

@media (max-width: 640px) {
  .qbank-filters {
    flex-direction: column;
  }
  .qbank-filters select,
  .qbank-filters input {
    width: 100%;
  }
}
