:root {
  color-scheme: light;
  font-family: Inter, system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
  color: #18352d;
  background: #f1f5f2;
  --green: #235c49;
  --green-dark: #163f35;
  --mint: #d8f2bb;
  --soft: #e9f3eb;
  --muted: #526960;
  --line: #d8e4dc;
  --radius: 18px;
  --header-height: 72px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: calc(var(--header-height) + 16px); }
body { margin: 0; min-width: 280px; }
button, input, select { font: inherit; }
h1, h2, h3, p { margin: 0; }
svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
:focus-visible { outline: 3px solid #407b61; outline-offset: 3px; }
.site-header :focus-visible { outline-color: var(--mint); }
.muted { color: var(--muted); }

.site-header {
  position: fixed;
  z-index: 2;
  top: 0;
  inset-inline: 0;
  height: var(--header-height);
  color: white;
  background: var(--green-dark);
  box-shadow: 0 5px 22px #163f351e;
}
.header-inner {
  max-width: 1240px;
  height: 100%;
  margin: auto;
  padding: 0 24px;
  display: flex;
  gap: clamp(12px, 3vw, 44px);
  align-items: center;
}
.brand, .header-actions, .progress-label, .account-name, .dialog-heading {
  display: flex;
  gap: 10px;
  align-items: center;
}
.brand { flex: none; }
.brand-icon, .section-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--mint);
  color: var(--green-dark);
}
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-size: 17px; }
.brand-copy small { color: #c5ded1; font-size: 12px; }
.exam-progress { flex: 1; min-width: 0; max-width: 540px; margin-inline: auto; }
.progress-label { justify-content: space-between; color: #effbf0; font-size: 14px; }
progress { display: block; width: 100%; height: 7px; appearance: none; border: 0; border-radius: 8px; margin-top: 7px; background: #487467; color: var(--mint); }
progress::-webkit-progress-bar { background: #487467; border-radius: 8px; }
progress::-webkit-progress-value { background: var(--mint); border-radius: 8px; }
progress::-moz-progress-bar { background: var(--mint); border-radius: 8px; }

.page { max-width: 1240px; margin: auto; padding: calc(var(--header-height) + 26px) 24px 44px; }
.workspace { display: grid; grid-template-columns: 264px minmax(0, 1fr); align-items: start; gap: 22px; }
.sidebar, #content { display: grid; gap: 14px; }
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 3px 14px #163f3506;
}
.controls { padding: 16px; }
.controls h2 { display: flex; align-items: center; gap: 8px; font-size: 16px; margin-bottom: 14px; }
.controls h2 svg, .account-name svg { color: var(--green); }
.controls form, dialog form, .login form { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; color: #29483d; font-size: 14px; font-weight: 650; min-width: 0; }
.field input, .field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #c9d9cf;
  border-radius: 9px;
  padding: 8px 9px;
  color: #18352d;
  background: #fcfefd;
  font-size: 16px;
  font-weight: 400;
}
.range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.range-hint { font-size: 12px; margin-top: -6px; }
.library { display: grid; gap: 4px; }
.account-name strong { overflow-wrap: anywhere; }
.account-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover:not(:disabled) { filter: brightness(.94); }
.btn:disabled { opacity: .55; cursor: default; }
.primary { background: var(--green); color: white; }
.secondary { background: var(--soft); }
.subtle, .nav-btn { color: var(--green); }
.subtle:hover, .nav-btn:hover, .nav-btn[aria-pressed="true"] { background: var(--soft); }
.nav-btn { justify-content: flex-start; }
.header-secondary { border-color: #729589; color: white; }
.header-secondary:hover { background: #245246; }
.accent { background: var(--mint); }
.icon-btn { width: 42px; padding: 0; }

.overview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  overflow: hidden;
  min-height: 134px;
  padding: 22px 26px;
  margin-bottom: 14px;
  background: linear-gradient(110deg, #e2f2e5, #f0f7e5);
}
.overview h1, .login h1 { font-size: clamp(22px, 3vw, 32px); line-height: 1.2; }
.overview p, .login > p, dialog > p { color: var(--muted); line-height: 1.55; margin-top: 8px; }
.overview-icon { width: 68px; height: 68px; color: #40735c; stroke-width: 1.2; }
.question, .record { padding: 18px 20px; }
.question-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.question-number { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.number {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  min-height: 34px;
  padding: 2px 5px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--green-dark);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.question-title { font-size: 17px; line-height: 1.55; margin-bottom: 12px; overflow-wrap: anywhere; }
.question-meta, .record time { color: var(--muted); font-size: 13px; }
.options { display: grid; gap: 7px; }
.option {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #26443a;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
label.option { cursor: pointer; }
label.option:hover { background: #f4f9f5; }
.option:has(input:checked), .option.selected { border-color: #6ca386; background: #e9f5ec; }
.option input { flex: none; margin: 0; accent-color: var(--green); }
.option-letter { color: var(--green); font-weight: 750; }
.favorite-toggle[aria-pressed="true"] { color: #735017; }
.favorite-toggle[aria-pressed="true"] svg { fill: #f6d78d; }
.question.good { border-inline-start: 4px solid #528765; }
.question.bad { border-inline-start: 4px solid #b25849; }
.result {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 11px;
  padding: 10px;
  border-radius: 9px;
  background: #eef4ef;
  font-size: 14px;
}
.bad .result { background: #faf0ee; }
.edit-answer { margin-top: 4px; }
.record { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.record > div { display: grid; gap: 5px; }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.error { color: #a02424; font-size: 14px; overflow-wrap: anywhere; }
.error:empty { display: none; }
#app-error, .notice { padding: 9px 12px; border-radius: 9px; margin-bottom: 12px; }
#app-error { background: #fbeaea; }
.notice { background: #e4f3e5; color: var(--green-dark); }
.login { width: min(100%, 430px); margin: clamp(10px, 7vh, 90px) auto 0; padding: clamp(20px, 6vw, 34px); }
.login h1 { margin-top: 14px; }
.login form { margin-top: 20px; }

dialog {
  width: min(calc(100% - 24px), 520px);
  max-height: calc(100% - 24px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  box-shadow: 0 14px 54px #142f2960;
}
dialog::backdrop { background: #10291fd0; }
dialog form, .sheet-grid { margin-top: 14px; }
.dialog-heading { justify-content: space-between; }
.dialog-heading h2 { font-size: 21px; }
.sheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 7px;
  max-height: 48vh;
  overflow: auto;
  margin-bottom: 14px;
  padding: 4px;
}
.sheet-grid button { background: #f0f4f1; }
.sheet-grid .answered { background: #d9eddd; border-color: #76a88b; }
.sheet-actions { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

@media (max-width: 800px) {
  .workspace { grid-template-columns: 210px minmax(0, 1fr); gap: 14px; }
  .page, .header-inner { padding-inline: 14px; }
  .question, .record { padding: 14px; }
}

@media (max-width: 640px) {
  :root { --header-height: 62px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar { gap: 8px; }
  .sidebar.exam-active { display: none; }
  .controls { padding: 12px; }
  .controls form { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .controls .range { grid-column: 1 / -1; grid-row: 2; }
  .range-hint { grid-column: 1 / -1; grid-row: 3; }
  #begin { grid-column: 1 / -1; }
  .library { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .nav-btn { justify-content: center; padding-inline: 3px; }
  .nav-btn svg, .account-actions svg { width: 15px; height: 15px; }
  .account { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px; }
  .account-actions { margin-top: 0; }
  .account-actions .btn { padding-inline: 6px; }
  .header-inner { gap: 9px; }
  .exam-active .brand-copy, .submit-icon, .sheet-label { display: none; }
  .header-actions { gap: 5px; }
  .header-actions .btn { padding-inline: 8px; }
  .progress-label { font-size: 12px; gap: 4px; }
  .page { padding-top: calc(var(--header-height) + 12px); }
  .overview { min-height: 100px; padding: 14px; margin-bottom: 10px; }
  .overview-icon { width: 44px; height: 44px; }
}
