:root {
  color-scheme: light;
  --ink: #171a24;
  --muted: #6d6a72;
  --quiet: #9a9498;
  --canvas: #f2e8df;
  --surface: #fffdfa;
  --surface-soft: #f8f2ed;
  --line: #e2d9d3;
  --line-strong: #d4c8c1;
  --blue: #3041ab;
  --blue-dark: #253386;
  --blue-soft: #eceefa;
  --green: #177249;
  --green-soft: #eaf7f0;
  --red: #b53a3a;
  --red-soft: #fff0ef;
  --amber: #8a5a00;
  --amber-soft: #fff7e6;
  --sidebar: 256px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  overflow: hidden;
  color: var(--ink);
  background: radial-gradient(circle at 100% 0%, rgba(48, 65, 171, .14), transparent 34rem), var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.app-shell {
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 24px 18px 20px;
  color: white;
  border-right: 1px solid rgba(31, 41, 112, .5);
  background: linear-gradient(160deg, #3041ab 0%, #28378f 58%, #202c72 100%);
  box-shadow: 16px 0 50px rgba(35, 45, 121, .12);
  backdrop-filter: blur(20px);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; }
.brand img, .mobile-brand img { object-fit: contain; mix-blend-mode: normal; border-radius: 10px; background: #f2e8df; }
.brand img { width: 38px; height: 38px; }
.brand-copy strong { display: block; color: white; font-size: 15px; font-weight: 760; letter-spacing: -.035em; }
.brand-copy span { display: block; margin-top: 2px; color: rgba(255,255,255,.66); font-size: 10px; }

.nav-label, .tool-label {
  margin: 0 10px 8px;
  color: rgba(255,255,255,.52);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.side-nav { display: grid; gap: 5px; }

.nav-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 13px;
  border: 0;
  border-radius: 12px;
  color: rgba(255,255,255,.76);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}

.nav-button:hover { color: white; background: rgba(255,255,255,.08); }
.nav-button.active { color: #202c72; background: #f2e8df; box-shadow: 0 8px 22px rgba(18,24,70,.18); }
.nav-button strong { font-size: 12px; font-weight: 720; }
.nav-button span:last-child { color: rgba(255,255,255,.48); font-size: 10px; }
.nav-button.active span:last-child { color: #3041ab; }

.study-tools { margin-top: 24px; padding-top: 21px; border-top: 1px solid rgba(255,255,255,.14); }
.jump-trigger {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  color: rgba(255,255,255,.82);
  background: rgba(255,255,255,.1);
  font-size: 10px;
  font-weight: 690;
  text-align: left;
  cursor: pointer;
}
.jump-trigger strong { color: white; font-size: 18px; font-weight: 450; }
.jump-trigger:hover { color: var(--blue-dark); border-color: #f2e8df; background: #f2e8df; }
.jump-trigger:hover strong { color: var(--blue); }

.subtle-button:hover, .secondary-button:hover { border-color: var(--line-strong); background: #fff; }
.sidebar .filter-button:hover { color: white; border-color: rgba(255,255,255,.34); background: rgba(255,255,255,.13); }
.sidebar .filter-button.active:hover { color: #202c72; border-color: #f2e8df; background: #f2e8df; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.filter-button {
  padding: 7px 9px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  color: rgba(255,255,255,.72);
  background: rgba(255,255,255,.08);
  font-size: 9px;
  font-weight: 680;
  cursor: pointer;
}

.filter-button.active { color: #202c72; border-color: #f2e8df; background: #f2e8df; }
.filter-button span { font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin-top: 17px; }

.stat {
  padding: 10px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 11px;
  background: rgba(255,255,255,.08);
}

.stat strong { display: block; font-size: 15px; letter-spacing: -.03em; }
.stat span { display: block; margin-top: 2px; color: rgba(255,255,255,.58); font-size: 8px; }

.beyond {
  margin-top: auto;
  padding: 13px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 13px;
  background: rgba(255,255,255,.08);
}

.beyond strong { display: block; font-size: 10px; }
.beyond p { margin: 5px 0 0; color: rgba(255,255,255,.64); font-size: 9px; line-height: 1.45; }

.main-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: 70px minmax(0, 1fr); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 clamp(22px, 3.5vw, 48px); }
.mobile-brand { display: none; }
.page-title p { margin: 0 0 4px; color: var(--blue); font-size: 9px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.page-title h1 { margin: 0; font-size: 18px; font-weight: 740; letter-spacing: -.035em; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.mobile-study-navigation-button { display: none; }

.subtle-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #586473;
  background: rgba(255,253,250,.78);
  font-size: 10px;
  font-weight: 690;
  cursor: pointer;
}

.content { min-height: 0; padding: 0 clamp(22px, 3.5vw, 48px) clamp(22px, 3.5vw, 38px); }
.view { width: min(920px, 100%); height: 100%; margin: 0 auto; }

.question-card, .setup-card, .result-card, .review-card {
  height: 100%;
  min-height: 0;
  display: grid;
  border: 1px solid rgba(24, 32, 42, .09);
  border-radius: 26px;
  background: rgba(255,253,250,.96);
  box-shadow: 0 22px 65px rgba(42, 37, 55, .09);
  overflow: hidden;
}

.question-card { grid-template-rows: auto minmax(0, 1fr) auto; }
.question-head { padding: 18px clamp(18px, 3vw, 28px) 14px; border-bottom: 1px solid var(--line); }
.question-head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.question-count { color: var(--muted); font-size: 10px; font-weight: 680; }
.question-count strong { color: var(--ink); }
.question-head-tools { display: flex; align-items: center; gap: 7px; }

.answer-mode-button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #66717e;
  background: var(--surface);
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}

.answer-mode-button:hover { border-color: #aeb6e7; }
.answer-mode-button.active { color: var(--blue-dark); border-color: #929de0; background: var(--blue-soft); }

.source-number {
  padding: 6px 9px;
  border-radius: 999px;
  color: #617080;
  background: var(--surface-soft);
  font-size: 9px;
  font-weight: 700;
}

.progress-track { height: 3px; margin-top: 13px; overflow: hidden; border-radius: 999px; background: #e7ded8; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--blue); transition: width .25s ease; }

.question-scroll {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: clamp(20px, 3.2vw, 34px) clamp(18px, 4vw, 46px) 28px;
}

.question-scroll::-webkit-scrollbar { width: 8px; }
.question-scroll::-webkit-scrollbar-thumb { background: #d7dbde; border: 2px solid transparent; background-clip: content-box; border-radius: 999px; }

.image-panel {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 150px;
  max-height: 310px;
  margin-bottom: 23px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fbf7f3;
}

.image-panel img { display: block; max-width: 100%; max-height: 276px; object-fit: contain; }

.image-tools-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 29px;
  padding: 0 9px;
  border: 1px solid rgba(24, 32, 42, .12);
  border-radius: 9px;
  color: #4b5867;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 4px 14px rgba(24, 32, 42, .08);
  font-size: 8px;
  font-weight: 740;
  font-family: inherit;
  cursor: pointer;
}

.image-tools-badge:hover, .expand-image:hover { border-color: #929de0; color: var(--blue-dark); background: white; }

.pencil-icon {
  color: var(--blue-dark);
  font-size: 15px;
  line-height: 1;
  transform: rotate(-12deg);
}

.ruler-icon {
  width: 22px;
  height: 8px;
  display: inline-block;
  border: 1px solid #7b8793;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, transparent 0 4px, #7b8793 4px 5px);
  transform: rotate(6deg);
}

.expand-image {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 7px 10px;
  border: 1px solid rgba(24, 32, 42, .12);
  border-radius: 9px;
  color: #445160;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 4px 14px rgba(24, 32, 42, .08);
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}

.question-kicker { margin: 0 0 9px; color: var(--blue); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.question-text { max-width: 780px; margin: 0; font-size: clamp(18px, 2.15vw, 27px); line-height: 1.28; letter-spacing: -.035em; font-weight: 690; }
.options { display: grid; gap: 9px; margin-top: 24px; }

.option {
  width: 100%;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: #313b47;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color .14s ease, background .14s ease, transform .14s ease;
}

.option:hover { border-color: #cbd2d8; transform: translateY(-1px); }
.option.selected { border-color: #7f8bd8; background: var(--blue-soft); }
.option.correct { border-color: #83c5a4; background: var(--green-soft); }
.option.wrong { border-color: #e3a4a0; background: var(--red-soft); }
.option.locked { cursor: default; transform: none; }
.option.masked { visibility: hidden; pointer-events: none; }

.option-letter {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: #66717e;
  background: white;
  font-size: 10px;
  font-weight: 790;
}

.option.selected .option-letter { color: white; border-color: var(--blue); background: var(--blue); }
.option.correct .option-letter { color: white; border-color: var(--green); background: var(--green); }
.option.wrong .option-letter { color: white; border-color: var(--red); background: var(--red); }
.option-text { font-size: 12px; line-height: 1.45; }
.option-mark { color: transparent; font-size: 13px; font-weight: 800; }
.option.correct .option-mark { color: var(--green); }
.option.wrong .option-mark { color: var(--red); }

.source-notice, .feedback { margin-top: 16px; padding: 13px 14px; border-radius: 12px; font-size: 10px; line-height: 1.5; }
.source-notice { margin-top: 22px; border: 1px solid #ead9ad; color: var(--amber); background: var(--amber-soft); }
.feedback { display: flex; align-items: flex-start; gap: 10px; }
.feedback.good { color: #145f3e; background: var(--green-soft); }
.feedback.bad { color: #953434; background: var(--red-soft); }
.feedback.neutral { color: var(--amber); background: var(--amber-soft); }
.feedback strong { display: block; margin-bottom: 2px; font-size: 11px; }

.question-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(18px, 3vw, 28px);
  border-top: 1px solid var(--line);
  background: rgba(248,242,237,.9);
}

.primary-button, .secondary-button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 11px;
  font-size: 10px;
  font-weight: 750;
  cursor: pointer;
}

.primary-button { color: white; border: 1px solid var(--blue); background: var(--blue); box-shadow: 0 7px 18px rgba(48,65,171,.22); }
.primary-button:hover { border-color: var(--blue-dark); background: var(--blue-dark); }
.primary-button:disabled { color: #a5abb2; border-color: #e2e4e6; background: #eceeed; box-shadow: none; cursor: default; }
.secondary-button { color: #5d6876; border: 1px solid var(--line); background: white; }
.secondary-button:disabled { opacity: .45; cursor: default; }
.shortcut-note { color: var(--quiet); font-size: 8px; }

.setup-card, .result-card { place-items: center; padding: 32px; }
.setup-inner, .result-inner { width: min(560px, 100%); text-align: center; }
.result-inner { width: min(680px, 100%); max-height: 100%; overflow-y: auto; padding: 2px; scrollbar-gutter: stable; }

.setup-mark, .result-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 16px;
  color: var(--blue-dark);
  background: var(--blue-soft);
  font-size: 16px;
  font-weight: 820;
}

.setup-inner h2, .result-inner h2 { margin: 0; font-size: clamp(25px, 4vw, 37px); letter-spacing: -.05em; line-height: 1.05; }
.setup-inner > p, .result-inner > p { max-width: 430px; margin: 13px auto 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.exam-sizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 26px; }

.exam-size {
  padding: 16px 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
  cursor: pointer;
}

.exam-size:hover { border-color: #b6cce7; }
.exam-size.selected { border-color: #7f8bd8; background: var(--blue-soft); }
.exam-size strong { display: block; font-size: 22px; letter-spacing: -.04em; }
.exam-size span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.setup-inner .primary-button { margin-top: 20px; min-width: 150px; }

.exam-clock { display: inline-flex; align-items: center; gap: 7px; color: #4c5968; font-variant-numeric: tabular-nums; font-size: 10px; font-weight: 750; }
.exam-clock::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px rgba(48,65,171,.12); }
.result-score { margin-top: 26px; font-size: clamp(58px, 10vw, 90px); font-weight: 760; letter-spacing: -.07em; line-height: .9; }
.result-score span { color: var(--muted); font-size: .32em; font-weight: 650; letter-spacing: -.03em; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 25px; }
.result-stat { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.result-stat strong { display: block; font-size: 16px; }
.result-stat span { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.result-questions { margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); text-align: left; }
.result-questions-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.result-questions-head strong { font-size: 10px; }
.result-questions-head span { color: var(--muted); font-size: 8px; }

.result-question-list {
  max-height: 190px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  overflow-y: auto;
  padding-right: 4px;
}

.result-question-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
}

.result-question-item strong { font-size: 9px; font-weight: 730; }
.question-status { padding: 4px 6px; border-radius: 999px; font-size: 7px; font-weight: 760; white-space: nowrap; }
.question-status.correct { color: var(--green); background: var(--green-soft); }
.question-status.wrong { color: var(--red); background: var(--red-soft); }
.question-status.unanswered { color: #66717e; background: #eef0f1; }
.question-status.unscored { color: var(--amber); background: var(--amber-soft); }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.save-confirmation { margin: 9px 0 0; color: var(--green); font-size: 9px; font-weight: 680; }
.mobile-nav { display: none; }

.review-card { padding: clamp(20px, 3.5vw, 36px); }
.review-inner { width: min(720px, 100%); height: 100%; min-height: 0; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto auto; margin: 0 auto; }
.review-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.review-heading p { margin: 0 0 6px; color: var(--blue); font-size: 8px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.review-heading h2 { margin: 0; font-size: clamp(25px, 4vw, 36px); letter-spacing: -.05em; line-height: 1.05; }
.review-intro { max-width: 570px; margin: 12px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.review-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 150px)); gap: 8px; margin-top: 18px; }
.review-summary > div { padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.review-summary strong { display: block; font-size: 16px; }
.review-summary span { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; }
.exam-review-list { min-height: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-content: start; gap: 7px; overflow-y: auto; margin-top: 17px; padding: 2px 5px 2px 2px; }
.exam-review-item {
  min-width: 0;
  min-height: 54px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
  text-align: left;
  cursor: pointer;
}
.exam-review-item:hover { border-color: #929de0; background: #f7f7fd; }
.review-number { grid-row: 1 / 3; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; color: #5c6875; background: #eef0f1; font-size: 8px; font-weight: 800; }
.exam-review-item strong { overflow: hidden; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.exam-review-item .review-status { color: var(--green); font-size: 7px; font-weight: 730; }
.exam-review-item.unanswered { border-color: #ead9ad; background: var(--amber-soft); }
.exam-review-item.unanswered .review-number { color: var(--amber); background: #f7e8bd; }
.exam-review-item.unanswered .review-status { color: var(--amber); }
.review-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 17px; }
.review-note { margin: 9px 0 0; color: var(--muted); font-size: 8px; text-align: right; }

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(18, 23, 29, .48);
  backdrop-filter: blur(12px);
}

.dialog-card {
  width: min(520px, 100%);
  max-height: min(720px, calc(100dvh - 36px));
  overflow: hidden;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 22px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 30px 90px rgba(13, 20, 28, .2);
}

.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.dialog-heading p { margin: 0 0 5px; color: var(--blue); font-size: 8px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.dialog-heading h2 { margin: 0; font-size: 22px; letter-spacing: -.04em; }
.dialog-close { width: 34px; height: 34px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: var(--surface-soft); font-size: 18px; cursor: pointer; }
.dialog-description { margin: 12px 0 18px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.field-label { display: block; margin-bottom: 7px; color: #4f5b68; font-size: 9px; font-weight: 740; }
.text-field {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  outline: 0;
  color: var(--ink);
  background: white;
  font-size: 12px;
}
.text-field:focus { border-color: #7f8bd8; box-shadow: 0 0 0 3px rgba(48,65,171,.11); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.study-navigation-card { width: min(510px, 100%); }
.dialog-jump-form { margin-top: 20px; }
.dialog-jump-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.dialog-jump-row .primary-button { min-width: 70px; }
.study-navigation-options { display: grid; gap: 8px; margin-top: 18px; }
.study-navigation-option {
  width: 100%;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  background: var(--surface-soft);
  text-align: left;
  cursor: pointer;
}
.study-navigation-option:hover { border-color: #929de0; background: #f4f4fc; }
.study-navigation-option.active { border-color: #929de0; background: var(--blue-soft); box-shadow: inset 3px 0 0 var(--blue); }
.study-navigation-option > span:first-child { min-width: 0; }
.study-navigation-option strong { display: block; font-size: 10px; }
.study-navigation-option small { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; line-height: 1.35; }
.study-navigation-option > span:last-child { color: var(--blue); font-size: 18px; }
.reset-card { width: min(590px, 100%); }
.reset-options { display: grid; gap: 8px; }
.reset-option {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface-soft);
  text-align: left;
  cursor: pointer;
}
.reset-option:hover { border-color: #929de0; background: #f4f4fc; }
.reset-option strong { display: block; font-size: 10px; }
.reset-option span { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; line-height: 1.45; }
.reset-option.danger { border-color: #efd0cd; background: #fff8f7; }
.reset-option.danger strong { color: var(--red); }

.folder-manager-card { width: min(720px, 100%); display: grid; grid-template-rows: auto auto minmax(0, 1fr); }
.folder-list { min-height: 80px; display: grid; gap: 10px; overflow-y: auto; padding: 2px 4px 2px 2px; }
.folder-empty { display: grid; place-items: center; min-height: 120px; border: 1px dashed var(--line-strong); border-radius: 14px; color: var(--muted); font-size: 10px; text-align: center; }
.folder-card { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.folder-card.active { border-color: #929de0; box-shadow: inset 3px 0 0 var(--blue); }
.folder-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.folder-name { min-width: 0; }
.folder-name strong { display: block; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.folder-name span { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.folder-card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.mini-button, .danger-button {
  min-height: 31px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  font-size: 8px;
  font-weight: 720;
  cursor: pointer;
}
.mini-button:hover { border-color: #aeb6e7; color: var(--blue-dark); }
.mini-button.primary { color: white; border-color: var(--blue); background: var(--blue); }
.mini-button:disabled { opacity: .45; cursor: default; }
.danger-button { color: var(--red); }
.danger-button:hover { border-color: #e3a4a0; background: var(--red-soft); }
.folder-merge { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; margin-top: 11px; }
.folder-merge select { min-width: 0; height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: white; font-size: 9px; }
.folder-details { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.folder-details summary { color: #596574; font-size: 9px; font-weight: 700; cursor: pointer; }
.folder-questions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.folder-question {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 29px;
  padding: 0 5px 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #53606e;
  background: white;
  font-size: 8px;
}
.folder-question button { width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; color: var(--red); background: var(--red-soft); cursor: pointer; }
.folder-question-empty { margin: 0; color: var(--muted); font-size: 9px; }

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(18, 23, 29, .9);
  backdrop-filter: blur(14px);
}

.modal-bar { display: flex; justify-content: space-between; align-items: center; gap: 15px; color: white; }
.modal-bar strong { font-size: 11px; }
.markup-toolbar { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.markup-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 10px;
  color: rgba(255,255,255,.78);
  background: rgba(255,255,255,.08);
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}
.markup-button.active { color: white; border-color: rgba(175,184,244,.9); background: rgba(48,65,171,.76); }
.markup-button:disabled { opacity: .4; cursor: default; }
.markup-button .ruler-icon { border-color: currentColor; background: repeating-linear-gradient(90deg, transparent 0 4px, currentColor 4px 5px); }
.color-control { min-height: 36px; display: inline-flex; align-items: center; gap: 7px; padding: 0 9px; border: 1px solid rgba(255,255,255,.22); border-radius: 10px; color: rgba(255,255,255,.78); background: rgba(255,255,255,.08); font-size: 8px; font-weight: 700; }
.color-control input { width: 19px; height: 19px; padding: 0; overflow: hidden; border: 1px solid rgba(255,255,255,.45); border-radius: 50%; background: transparent; cursor: pointer; }
.color-control input::-webkit-color-swatch-wrapper { padding: 0; }
.color-control input::-webkit-color-swatch { border: 0; border-radius: 50%; }
.modal-close { width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.22); border-radius: 11px; color: white; background: rgba(255,255,255,.1); cursor: pointer; }
.modal-image-wrap { min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 18px; }
.markup-stage { position: relative; width: 0; height: 0; overflow: hidden; border-radius: 8px; background: white; box-shadow: 0 14px 50px rgba(0,0,0,.28); }
.markup-stage img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: contain; user-select: none; -webkit-user-drag: none; }
#drawingCanvas { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.virtual-ruler {
  position: absolute;
  z-index: 3;
  width: min(310px, 58%);
  height: 58px;
  border: 1px solid rgba(52, 62, 72, .55);
  border-radius: 5px;
  background: rgba(244, 196, 66, .55);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  transform-origin: 50% 50%;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.virtual-ruler:active { cursor: grabbing; }
.ruler-measurements { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 14px, rgba(34,43,52,.62) 14px 15px); mask-image: linear-gradient(to bottom, #000 0 40%, transparent 40%); }
.virtual-ruler::after { content: "0    1    2    3    4    5    6    7"; position: absolute; left: 9px; bottom: 7px; color: rgba(35,43,51,.7); font: 7px/1 ui-monospace, monospace; letter-spacing: 6px; white-space: nowrap; overflow: hidden; width: calc(100% - 18px); }
.ruler-rotate-handle { position: absolute; top: 50%; right: -15px; width: 22px; height: 22px; border: 2px solid white; border-radius: 50%; background: var(--blue); box-shadow: 0 2px 8px rgba(0,0,0,.25); transform: translateY(-50%); cursor: ew-resize; }
.markup-hint { margin: 5px 0 0; color: rgba(255,255,255,.68); font-size: 8px; text-align: center; }

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .main-panel { height: 100dvh; grid-template-rows: 58px minmax(0, 1fr) 64px; }
  .topbar { padding: 0 16px; border-bottom: 1px solid rgba(28,37,103,.55); background: linear-gradient(135deg, #3041ab, #28378f); box-shadow: 0 8px 24px rgba(37,51,134,.16); }
  .page-title { display: none; }
  .mobile-brand { display: flex; align-items: center; gap: 8px; }
  .mobile-brand img { width: 30px; height: 30px; }
  .mobile-brand strong { color: white; font-size: 13px; letter-spacing: -.03em; }
  .mobile-study-navigation-button { display: inline-flex; align-items: center; }
  .top-actions { gap: 5px; }
  .top-actions .subtle-button { min-height: 33px; padding-inline: 9px; border-color: rgba(255,255,255,.2); color: white; background: rgba(255,255,255,.1); font-size: 8px; }
  .content { padding: 9px 9px 8px; }
  .view { width: 100%; }
  .question-card, .setup-card, .result-card, .review-card { border-radius: 19px; }
  .question-head { padding: 13px 15px 11px; }
  .question-head-tools { gap: 5px; }
  .answer-mode-button { max-width: 112px; padding-inline: 8px; font-size: 8px; line-height: 1.15; }
  .question-scroll { padding: 18px 15px 22px; scrollbar-gutter: auto; }
  .question-text { font-size: clamp(17px, 5.1vw, 22px); line-height: 1.3; }
  .question-kicker { margin-bottom: 7px; }
  .image-panel { max-height: 230px; min-height: 130px; margin-bottom: 18px; padding: 11px; }
  .image-panel img { max-height: 204px; }
  .image-tools-badge { top: 7px; left: 7px; min-height: 26px; padding-inline: 7px; }
  .image-tools-badge > span:last-child { display: none; }
  .options { gap: 8px; margin-top: 19px; }
  .option { grid-template-columns: 28px minmax(0,1fr) 18px; min-height: 51px; padding: 9px 11px; gap: 10px; }
  .option-text { font-size: 11px; }
  .question-actions { padding: 10px 12px max(10px, env(safe-area-inset-bottom)); }
  .shortcut-note { display: none; }
  .primary-button, .secondary-button { min-height: 39px; padding-inline: 13px; }
  .setup-card, .result-card { padding: 20px; }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    align-items: stretch;
    padding: 7px 9px max(7px, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(24,32,42,.08);
    background: rgba(255,255,255,.82);
    backdrop-filter: blur(18px);
  }

  .mobile-nav button { border: 0; border-radius: 11px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 720; }
  .mobile-nav button.active { color: var(--blue-dark); background: var(--blue-soft); }
  .result-stats { gap: 5px; }
  .result-stat { padding: 10px 5px; }
  .result-question-list { grid-template-columns: 1fr; max-height: 180px; }
  .review-card { padding: 18px 15px; }
  .exam-review-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-summary { grid-template-columns: repeat(2, 1fr); }
  .dialog-card { max-height: calc(100dvh - 20px); padding: 17px; border-radius: 18px; }
  .study-navigation-backdrop { align-items: end; padding: 0; }
  .study-navigation-card { width: 100%; max-height: calc(100dvh - 24px); padding: 20px 17px max(20px, env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; }
  .dialog-jump-row .primary-button { min-width: 62px; }
  .study-navigation-option { min-height: 58px; }
  .folder-card-head { align-items: flex-start; }
  .folder-card-actions { max-width: 180px; }
  .image-modal { padding: max(9px, env(safe-area-inset-top)) max(9px, env(safe-area-inset-right)) max(9px, env(safe-area-inset-bottom)) max(9px, env(safe-area-inset-left)); }
  .modal-bar { align-items: flex-start; }
  .modal-bar > strong { display: none; }
  .markup-toolbar { width: 100%; justify-content: center; gap: 5px; }
  .markup-button { min-height: 34px; padding-inline: 8px; font-size: 8px; }
  .color-control { min-height: 34px; padding-inline: 7px; }
  .color-control span { display: none; }
  .modal-image-wrap { padding: 10px 0; }
  .virtual-ruler { height: 50px; width: min(250px, 62%); }
}

@media (max-width: 430px) {
  .mobile-brand strong { display: none; }
  .folder-card-head { display: grid; }
  .folder-card-actions { max-width: none; justify-content: flex-start; }
  .exam-review-list { grid-template-columns: 1fr; }
  .review-actions { display: grid; grid-template-columns: 1fr; }
  .review-actions .primary-button { grid-row: 1; }
  .review-note { text-align: center; }
  .markup-button { padding-inline: 7px; }
  .markup-button span:not(.ruler-icon) { font-size: 13px; }
  .markup-hint { line-height: 1.35; }
}

@media (max-height: 650px) and (min-width: 761px) {
  .main-panel { grid-template-rows: 54px minmax(0, 1fr); }
  .sidebar { padding-block: 15px; }
  .brand { padding-bottom: 14px; }
  .study-tools { margin-top: 13px; padding-top: 13px; }
  .stats { margin-top: 10px; }
  .beyond { display: none; }
  .question-head { padding-block: 12px 10px; }
  .question-scroll { padding-block: 18px; }
  .image-panel { max-height: 210px; }
  .image-panel img { max-height: 180px; }
  .question-text { font-size: 19px; }
  .options { margin-top: 16px; gap: 7px; }
  .option { min-height: 46px; }
  .question-actions { padding-block: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
