:root {
  --bg: #f4f8fb;
  --bg-soft: #edf8f6;
  --panel: rgba(255, 255, 255, .9);
  --panel-solid: #ffffff;
  --ink: #17252f;
  --muted: #647785;
  --line: #d8e5eb;
  --line-strong: #bdd4dc;
  --accent: #22b8a8;
  --accent-dark: #087f7a;
  --accent-soft: #dff8f4;
  --blue: #3b82f6;
  --blue-soft: #e8f1ff;
  --orange: #f59e0b;
  --orange-soft: #fff6df;
  --danger: #e5484d;
  --danger-soft: #fff0f1;
  --success: #16a34a;
  --success-soft: #eaf9ee;
  --purple: #7c3aed;
  --purple-soft: #f1eaff;
  --shadow: 0 18px 50px rgba(24, 61, 74, .12);
  --shadow-soft: 0 10px 28px rgba(24, 61, 74, .08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, rgba(34, 184, 168, .16), transparent 28%),
    radial-gradient(circle at 92% 8%, rgba(59, 130, 246, .12), transparent 26%),
    linear-gradient(135deg, #fbfeff 0%, var(--bg) 46%, var(--bg-soft) 100%);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
.admin-link,
.admin-top-link {
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  box-shadow: 0 10px 22px rgba(8, 127, 122, .18);
  cursor: pointer;
  font-weight: 850;
}

button:hover:not(:disabled),
.admin-link:hover,
.admin-top-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(24, 61, 74, .15);
}

button:disabled {
  cursor: not-allowed;
  opacity: .5;
  box-shadow: none;
}

button.ghost {
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .82);
  box-shadow: none;
}

button.ghost:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

select,
input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, .92);
  padding: 0 13px;
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(34, 184, 168, .14);
}

.hidden {
  display: none !important;
}

.mobile-study-entry,
.mobile-study-top {
  display: none;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto auto auto 1fr;
  gap: 14px;
  border-right: 1px solid rgba(216, 229, 235, .86);
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(22px);
  padding: 20px;
  overflow: hidden;
}

.account-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .86);
  box-shadow: var(--shadow-soft);
  padding: 13px;
}

.account-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.account-status span,
.account-status b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-status span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.account-status b {
  color: var(--accent-dark);
  font-size: 12px;
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-form input {
  min-height: 38px;
  border-radius: 11px;
}

.auth-actions,
.account-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-actions button,
.account-actions button {
  min-height: 38px;
  padding: 0 10px;
}

.auth-message {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.auth-message.success {
  color: var(--success);
}

.auth-message.error {
  color: var(--danger);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-icon {
  display: block;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(24, 61, 74, .08));
}

.brand-text {
  min-width: 0;
}

.brand-text strong,
.brand-text small {
  display: block;
}

.brand-text strong {
  color: var(--ink);
  font-size: 20px;
  line-height: 1.12;
  font-weight: 950;
  letter-spacing: 0;
}

.brand-text small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.brand strong,
.brand small,
.field span {
  display: block;
}

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

.brand small,
.field span,
.topbar p,
.question-meta,
.card-title p,
.admin-hero span {
  color: var(--muted);
}

.topbar-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.admin-top-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, #17313c, var(--accent-dark));
  box-shadow: 0 10px 22px rgba(23, 49, 60, .16);
  padding: 0 16px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 900;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  font-size: 13px;
  font-weight: 850;
}

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

.stat-grid div,
.admin-stats div {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-solid);
  padding: 12px;
  box-shadow: var(--shadow-soft);
}

.stat-grid div::after,
.admin-stats div::after {
  content: "";
  position: absolute;
  inset: auto 10px 8px auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(34, 184, 168, .11);
}

.stat-grid b {
  display: block;
  font-size: 25px;
  line-height: 1.05;
}

.stat-grid span,
.admin-stats span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.side-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.side-actions button:first-child {
  grid-column: 1 / -1;
}

.chapters,
.admin-chapters {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.chapters {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.chapter-btn {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .88);
  box-shadow: none;
  text-align: left;
}

.chapter-btn.active {
  color: #fff;
  border-color: transparent;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .18), transparent 38%),
    linear-gradient(135deg, var(--accent-dark), var(--accent));
  box-shadow: 0 12px 26px rgba(8, 127, 122, .2);
}

.chapter-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-btn b {
  min-width: 34px;
  border-radius: 999px;
  background: rgba(23, 37, 47, .07);
  padding: 3px 7px;
  text-align: center;
  font-size: 12px;
}

.chapter-btn.active b {
  background: rgba(255, 255, 255, .24);
}

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

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 370px);
  align-items: end;
  gap: 18px;
  max-width: 1200px;
  margin: 0 auto 18px;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .95), rgba(244, 251, 250, .88));
  box-shadow: var(--shadow);
  padding: 22px;
}

.topbar h1,
.topbar p {
  margin: 0;
}

.topbar h1 {
  margin-top: 6px;
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1.12;
  letter-spacing: 0;
}

.topbar p {
  font-size: 13px;
  font-weight: 800;
}

.search {
  display: grid;
  gap: 7px;
}

.search span {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.question-shell {
  max-width: 1200px;
  margin: 0 auto;
}

.question-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.question-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 6px 16px rgba(24, 61, 74, .06);
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 850;
}

.question-meta span:first-child {
  color: var(--accent-dark);
  border-color: rgba(34, 184, 168, .3);
  background: var(--accent-soft);
}

.question-card {
  border: 1px solid rgba(255, 255, 255, .78);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: clamp(20px, 3vw, 32px);
}

.question-card h2 {
  margin: 0 0 20px;
  font-size: clamp(22px, 2.4vw, 32px);
  line-height: 1.5;
  letter-spacing: 0;
}

.options {
  display: grid;
  gap: 12px;
}

.option-btn {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  justify-content: stretch;
  gap: 13px;
  width: 100%;
  min-height: 64px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  box-shadow: none;
  text-align: left;
  white-space: normal;
}

.option-btn:hover {
  border-color: var(--accent);
  background: #fbfffe;
}

.option-btn b {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 15px;
}

.option-btn span {
  line-height: 1.55;
}

.option-btn.selected {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.option-btn.selected b {
  color: #fff;
  background: var(--blue);
}

.option-btn.correct {
  border-color: rgba(22, 163, 74, .55);
  background: var(--success-soft);
}

.option-btn.correct b {
  color: #fff;
  background: var(--success);
}

.option-btn.wrong {
  border-color: rgba(229, 72, 77, .56);
  background: var(--danger-soft);
}

.option-btn.wrong b {
  color: #fff;
  background: var(--danger);
}

.answer-panel,
.ai-panel,
.exam-panel,
.exam-analysis-panel,
.wrong-book-panel {
  display: grid;
  gap: 7px;
  margin-top: 16px;
  border-radius: 16px;
  padding: 15px;
  line-height: 1.65;
}

.answer-panel {
  border: 1px solid rgba(59, 130, 246, .22);
  background: var(--blue-soft);
}

.answer-panel.correct {
  border-color: rgba(22, 163, 74, .36);
  background: var(--success-soft);
}

.answer-panel.wrong {
  border-color: rgba(229, 72, 77, .34);
  background: var(--danger-soft);
}

.answer-panel.hidden,
.ai-panel.hidden,
.exam-panel.hidden,
.exam-analysis-panel.hidden,
.wrong-book-panel.hidden {
  display: none;
}

.wrong-book-panel {
  margin-top: 0;
  margin-bottom: 18px;
  border: 1px solid rgba(34, 184, 168, .28);
  background: linear-gradient(135deg, rgba(223, 248, 244, .88), rgba(255, 255, 255, .92));
}

.wrong-book-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.wrong-book-head strong,
.wrong-book-head span {
  display: block;
}

.wrong-book-head strong {
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 950;
}

.wrong-book-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.wrong-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wrong-chips button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, .82);
  box-shadow: none;
  padding: 0 12px;
  font-size: 13px;
}

.wrong-chips button.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
}

.wrong-chips b {
  margin-left: 4px;
}

.wrong-list {
  display: grid;
  gap: 8px;
  max-height: 292px;
  overflow: auto;
  padding-right: 2px;
}

.wrong-list button {
  display: grid;
  grid-template-columns: minmax(96px, 150px) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  width: 100%;
  border: 1px solid rgba(17, 24, 39, .08);
  border-radius: 12px;
  background: rgba(255, 255, 255, .78);
  box-shadow: none;
  padding: 10px 12px;
  color: var(--ink);
  text-align: left;
}

.wrong-list button:hover {
  border-color: rgba(34, 184, 168, .36);
  background: #fff;
}

.wrong-list b {
  color: var(--accent-dark);
  font-size: 12px;
  line-height: 1.55;
}

.wrong-list span {
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.55;
}

.answer-panel p {
  margin: 0;
  color: var(--muted);
}

.ai-panel {
  border: 1px solid rgba(124, 58, 237, .22);
  background:
    linear-gradient(135deg, rgba(250, 247, 255, .96), rgba(255, 255, 255, .92));
  box-shadow: 0 12px 28px rgba(84, 49, 150, .08);
}

.ai-panel > strong {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  background: rgba(124, 58, 237, .1);
  padding: 5px 10px;
  color: var(--purple);
  font-size: 14px;
  font-weight: 950;
}

.ai-panel.error {
  border-color: rgba(229, 72, 77, .34);
  background: var(--danger-soft);
  color: #991b1b;
}

.ai-content {
  display: grid;
  gap: 12px;
  max-width: 920px;
  color: #202944;
  font-size: 15px;
  line-height: 1.85;
}

.ai-content h3,
.ai-content h4,
.ai-content h5,
.ai-content p,
.ai-content ul {
  margin: 0;
}

.ai-content h3,
.ai-content h4,
.ai-content h5 {
  color: #3d247c;
  font-weight: 950;
  line-height: 1.35;
}

.ai-content h3 {
  margin-top: 2px;
  font-size: 18px;
}

.ai-content h4,
.ai-content h5 {
  font-size: 16px;
}

.ai-content p {
  padding: 0;
}

.ai-content strong {
  color: #111827;
  font-weight: 950;
}

.ai-content ul {
  display: grid;
  gap: 7px;
  padding-left: 1.25em;
}

.ai-content li {
  padding-left: 2px;
}

.ai-content hr {
  width: 100%;
  height: 1px;
  border: 0;
  background: linear-gradient(90deg, rgba(124, 58, 237, .22), transparent);
}

.ai-content code {
  border-radius: 6px;
  background: rgba(124, 58, 237, .09);
  padding: 1px 5px;
  color: #4c1d95;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.exam-panel {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin-top: 0;
  margin-bottom: 18px;
  border: 1px solid rgba(245, 158, 11, .32);
  background: linear-gradient(135deg, var(--orange-soft), rgba(255, 255, 255, .92));
}

.exam-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.exam-panel strong,
.exam-panel span,
.exam-analysis-panel strong,
.exam-analysis-panel p {
  display: block;
}

.exam-panel strong {
  color: #9a5d00;
  font-size: 17px;
}

.exam-panel span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.exam-panel.passed {
  border-color: rgba(22, 163, 74, .36);
  background: var(--success-soft);
}

.exam-panel.failed {
  border-color: rgba(229, 72, 77, .34);
  background: var(--danger-soft);
}

.exam-panel.passed strong {
  color: var(--success);
}

.exam-panel.failed strong {
  color: var(--danger);
}

.exam-analysis-panel {
  margin-top: 0;
  margin-bottom: 18px;
  border: 1px solid rgba(124, 58, 237, .22);
  background: linear-gradient(135deg, rgba(241, 234, 255, .92), rgba(255, 255, 255, .9));
  white-space: pre-wrap;
}

.exam-analysis-panel strong {
  color: var(--purple);
  font-size: 17px;
}

.exam-analysis-panel p {
  margin: 4px 0 0;
  color: var(--ink);
}

.exam-analysis-panel.muted p {
  color: var(--muted);
}

.exam-analysis-panel.error {
  border-color: rgba(229, 72, 77, .34);
  background: var(--danger-soft);
}

.exam-analysis-panel.error strong,
.exam-analysis-panel.error p {
  color: #991b1b;
}

.question-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.admin-page {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0;
}

.admin-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 255, 255, .76);
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .94), rgba(223, 248, 244, .76));
  box-shadow: var(--shadow);
  padding: 26px;
}

.admin-hero p,
.admin-hero h1,
.admin-hero span,
.card-title h2,
.card-title p {
  margin: 0;
}

.admin-brand-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.admin-brand-line img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.admin-hero p {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .08em;
}

.admin-hero h1 {
  margin: 7px 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.08;
}

.admin-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  box-shadow: 0 10px 22px rgba(8, 127, 122, .18);
  padding: 0 16px;
  text-decoration: none;
  font-weight: 850;
}

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

.admin-card {
  display: grid;
  gap: 15px;
  border: 1px solid rgba(255, 255, 255, .78);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px;
}

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

.card-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 950;
}

.card-title h2 {
  font-size: 22px;
}

.card-title p {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.5;
}

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

.admin-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.admin-message.success {
  color: var(--success);
}

.admin-message.error {
  color: var(--danger);
}

.admin-stats {
  display: grid;
  grid-template-columns: 1.4fr .7fr .7fr;
  gap: 10px;
}

.admin-stats b,
.admin-stats span {
  display: block;
}

.admin-stats b {
  overflow: hidden;
  font-size: 19px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-chapters {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding-right: 4px;
}

.admin-chapters span {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .88);
  padding: 9px 11px;
}

.admin-users {
  display: grid;
  gap: 10px;
}

.admin-user-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, .8fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .9);
  padding: 12px;
}

.admin-user-main {
  min-width: 0;
}

.admin-user-main strong,
.admin-user-main span {
  display: block;
}

.admin-user-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.admin-user-main span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.admin-user-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.admin-user-stats span {
  display: grid;
  gap: 2px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--muted);
  padding: 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.admin-user-stats b {
  color: var(--accent-dark);
  font-size: 18px;
}

.admin-user-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-user-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

button.ghost.danger {
  color: var(--danger);
  border-color: rgba(229, 72, 77, .3);
}

button.ghost.danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: rgba(229, 72, 77, .6);
}

.admin-empty {
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  padding: 16px;
  text-align: center;
}

.admin-chapters b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

  .sidebar {
    position: static;
    height: auto;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: none;
    align-items: start;
    padding: 16px;
    overflow: visible;
  }

  .brand,
  .chapters {
    grid-column: 1 / -1;
  }

  .chapters {
    max-height: 260px;
  }

  .workspace {
    padding-top: 18px;
  }

  .topbar,
  .admin-hero,
  .admin-grid,
  .admin-user-row {
    grid-template-columns: 1fr;
  }

  .admin-user-actions {
    justify-content: stretch;
  }

  .admin-user-actions button {
    flex: 1;
  }
}

@media (max-width: 640px) {
  body {
    background:
      linear-gradient(180deg, #f9fcfd 0%, var(--bg) 52%, var(--bg-soft) 100%);
  }

  button {
    min-height: 44px;
    border-radius: 12px;
    padding: 0 12px;
  }

  select,
  input {
    min-height: 42px;
    border-radius: 12px;
  }

  .sidebar {
    gap: 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(216, 229, 235, .86);
    padding: 12px;
  }

  .brand {
    gap: 10px;
  }

  .mobile-study-entry {
    display: inline-flex;
    grid-column: 1 / -1;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    border-radius: 14px;
    font-size: 16px;
  }

  .brand-icon {
    width: 44px;
    height: 44px;
  }

  .brand-text strong {
    font-size: 18px;
  }

  .brand-text small {
    margin-top: 3px;
    font-size: 12px;
  }

  .account-card {
    gap: 8px;
    border-radius: 14px;
    padding: 11px;
  }

  .auth-actions,
  .account-actions,
  .side-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-actions button,
  .account-actions button,
  .side-actions button {
    min-width: 0;
    padding: 0 8px;
    font-size: 13px;
  }

  .side-actions button:first-child {
    grid-column: auto;
  }

  .stat-grid {
    gap: 8px;
  }

  .stat-grid div {
    border-radius: 12px;
    padding: 10px;
  }

  .stat-grid b {
    font-size: 21px;
  }

  .chapters {
    display: flex;
    max-height: none;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px 7px;
    scroll-snap-type: x proximity;
  }

  .chapter-btn {
    flex: 0 0 auto;
    grid-template-columns: minmax(0, 1fr) auto;
    width: min(72vw, 250px);
    min-height: 40px;
    border-radius: 999px;
    padding: 0 10px 0 13px;
    scroll-snap-align: start;
  }

  .workspace {
    padding: 14px 12px 18px;
  }

  .topbar {
    gap: 14px;
    margin-bottom: 12px;
    padding: 16px;
  }

  .topbar h1 {
    font-size: 25px;
    line-height: 1.2;
  }

  .topbar p {
    font-size: 12px;
    line-height: 1.45;
  }

  .topbar-tools {
    grid-template-columns: 1fr auto;
    gap: 8px;
  }

  .admin-top-link {
    min-height: 42px;
    padding: 0 13px;
    border-radius: 12px;
  }

  .question-meta {
    gap: 7px;
    margin-bottom: 9px;
  }

  .question-meta span {
    padding: 6px 9px;
    font-size: 12px;
  }

  .topbar,
  .question-card,
  .admin-card,
  .admin-hero {
    border-radius: 18px;
  }

  .question-card {
    padding: 16px;
  }

  .question-card h2 {
    margin-bottom: 16px;
    font-size: 21px;
    line-height: 1.55;
  }

  .options {
    gap: 9px;
  }

  .option-btn {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 10px;
    min-height: 56px;
    padding: 10px;
  }

  .option-btn b {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }

  .option-btn span {
    font-size: 14px;
    line-height: 1.55;
  }

  .answer-panel,
  .ai-panel,
  .exam-panel,
  .exam-analysis-panel,
  .wrong-book-panel {
    border-radius: 14px;
    padding: 12px;
  }

  .question-actions,
  .admin-actions,
  .wrong-book-head {
    display: grid;
  }

  .question-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
  }

  .admin-actions,
  .wrong-book-head {
    grid-template-columns: 1fr;
  }

  .wrong-book-head {
    gap: 9px;
  }

  .wrong-chips {
    gap: 7px;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }

  .wrong-chips button {
    flex: 0 0 auto;
    min-height: 32px;
  }

  .wrong-list button {
    grid-template-columns: 1fr;
    gap: 4px;
    border-radius: 11px;
    padding: 9px 10px;
  }

  .admin-stats {
    grid-template-columns: 1fr;
  }

  body.study-focus {
    background: #f8fbfc;
  }

  body.study-focus .sidebar,
  body.study-focus .topbar,
  body.study-focus .question-meta,
  body.study-focus .exam-panel,
  body.study-focus .exam-analysis-panel,
  body.study-focus .wrong-book-panel {
    display: none;
  }

  body.study-focus .app {
    display: block;
    min-height: 100vh;
  }

  body.study-focus .workspace {
    min-height: 100vh;
    padding: 0;
  }

  body.study-focus .question-shell {
    min-height: 100vh;
    max-width: none;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    margin: 0;
  }

  body.study-focus .mobile-study-top {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(216, 229, 235, .9);
    background: rgba(248, 251, 252, .94);
    backdrop-filter: blur(16px);
    padding: 10px 12px;
  }

  body.study-focus .mobile-study-top button {
    min-height: 38px;
    padding: 0 12px;
  }

  body.study-focus .mobile-study-top div {
    min-width: 0;
    text-align: right;
  }

  body.study-focus .mobile-study-top strong,
  body.study-focus .mobile-study-top span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.study-focus .mobile-study-top strong {
    color: var(--accent-dark);
    font-size: 15px;
    font-weight: 950;
  }

  body.study-focus .mobile-study-top span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  body.study-focus .question-card {
    min-height: calc(100vh - 59px);
    display: grid;
    grid-template-rows: auto auto auto auto 1fr;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
    padding: 16px 14px 0;
  }

  body.study-focus .question-card h2 {
    margin: 0 0 14px;
    font-size: 21px;
    line-height: 1.62;
  }

  body.study-focus .options {
    gap: 10px;
  }

  body.study-focus .option-btn {
    min-height: 58px;
    border-radius: 14px;
    background: #fff;
  }

  body.study-focus .answer-panel,
  body.study-focus .ai-panel {
    margin-top: 12px;
    border-radius: 14px;
  }

  body.study-focus .ai-panel {
    margin-bottom: 10px;
  }
}

@media (max-width: 420px) {
  .account-card,
  .field {
    grid-column: 1 / -1;
  }

  .sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-bottom: 10px;
  }

  .stat-grid {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .side-actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .topbar-tools {
    grid-template-columns: 1fr;
  }

  .admin-top-link {
    width: 100%;
  }

  .question-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin: 14px -16px -16px;
    border-top: 1px solid rgba(216, 229, 235, .9);
    border-radius: 0 0 18px 18px;
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(16px);
    padding: 10px;
  }

  .question-actions button {
    min-height: 42px;
    font-size: 13px;
  }

  body.study-focus .question-actions {
    margin: 12px -14px 0;
    border-radius: 0;
  }
}
