/* Palette, panels, option states and layout adapted from the V4 study UI. */
:root {
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color-scheme: light;
  --bg: #f5f7f5;
  --surface: #fff;
  --surface2: #f4f7f5;
  --ink: #21332b;
  --muted: #53695c;
  --border: #dce6df;
  --accent: #18734f;
  --accent-pale: #e9f5ee;
  --on-accent: #fff;
  --shadow: 0 4px 30px rgba(31,64,48,.035);
  --success-bg: #e7f5e9;
  --success: #16653c;
  --error-bg: #fff0ed;
  --error: #af3b2e;
  --pending-bg: #fcf3df;
  --pending: #856214;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111a17;
  --surface: #1b2822;
  --surface2: #24352c;
  --ink: #eef6f0;
  --muted: #a1b6a8;
  --border: #35473c;
  --accent: #78d0a1;
  --accent-pale: #263d30;
  --on-accent: #102016;
  --shadow: none;
  --success-bg: #263f30;
  --success: #9ce0b2;
  --error-bg: #412923;
  --error: #ffab9c;
  --pending-bg: #403722;
  --pending: #f2d295;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--bg); accent-color: var(--accent); }
main { max-width: 1050px; margin: 0 auto; padding: 26px clamp(14px, 3vw, 26px) 48px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.25rem, 3vw, 1.85rem); line-height: 1.35; letter-spacing: -.02em; }
h1 span { color: var(--accent); white-space: nowrap; }
h2 { font-size: clamp(1.16rem, 2.8vw, 1.45rem); line-height: 1.4; }
h3 { font-size: 1rem; }
button, input, select, textarea { color: inherit; font: inherit; }
button, input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  min-height: 44px;
  padding: .5em .75em;
}
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { cursor: default; opacity: .53; }
button.primary {
  color: var(--on-accent);
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 650;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
input[type="checkbox"], input[type="radio"] { margin: 0; width: 18px; height: 18px; flex: none; }
fieldset { margin: 0; min-width: 0; }
legend { padding: 0 3px; }
textarea { resize: vertical; width: 100%; }
label { display: grid; gap: 4px; font-weight: 600; }
label input, label select, label textarea { font-weight: 400; }
.site-header { display: flex; align-items: center; gap: 13px; padding-bottom: 6px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border-radius: 13px;
  color: var(--on-accent);
  background: var(--accent);
  font-size: 1.45rem;
  font-weight: 750;
  flex: none;
}
.header-side { margin-left: auto; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
#account { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.panel, .well {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: clamp(16px, 2.8vw, 24px);
  background: var(--surface);
}
.panel { margin-top: 16px; box-shadow: var(--shadow); }
.well { background: var(--surface2); }
.panel > h2, .toolbar { margin-bottom: 14px; }
.login { max-width: 440px; margin: clamp(25px, 7vh, 72px) auto 0; }
.stack { display: grid; align-content: start; gap: 12px; min-width: 0; }
.row, .toolbar, .inline-control { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.toolbar { justify-content: space-between; }
.inline-control { font-weight: inherit; }
.caption { color: var(--muted); font-size: .9rem; }
.notice { margin-top: 15px; padding: 9px 12px; border-radius: 9px; background: var(--accent-pale); }
.notice:empty, .caption:empty { display: none; }
.notice[data-error="true"] { color: var(--error); background: var(--error-bg); }
.app-tabs { display: flex; gap: 8px; margin-top: 16px; }
.app-tabs [aria-current="page"], .bank-card[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-pale); }
.bank-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 205px), 1fr)); gap: 10px; }
.bank-card { text-align: left; min-height: 70px; overflow-wrap: anywhere; }
.bank-card strong, .bank-card small { display: block; }
.bank-card small { color: var(--muted); }
.search { margin-top: 16px; }
.search input { flex: 1 1 180px; }
.results { display: grid; gap: 7px; margin-top: 12px; }
.results button { text-align: start; overflow-wrap: anywhere; }
.sync-strip, .question-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: .9rem;
}
.sync-strip { border-block: 1px solid var(--border); padding: 9px 0; margin-bottom: 16px; }
.sync-strip[data-state="conflict"], .sync-strip[data-state="error"] { color: var(--pending); }
.question-stem, .option-copy, .answer { white-space: pre-line; overflow-wrap: anywhere; }
.question-stem { margin-top: 10px; }
.stem-image { display: block; max-width: 100%; max-height: 320px; object-fit: contain; border-radius: 8px; margin-top: 10px; }
.options { display: grid; gap: 9px; margin-block: 16px; padding: 0; border: 0; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px 13px;
  min-height: 48px;
  cursor: pointer;
  font-weight: 400;
}
.option input { margin-top: 3px; }
.option:hover, .option:has(input:checked) { background: var(--accent-pale); border-color: var(--accent); }
.option.correct { background: var(--success-bg); color: var(--success); }
.option.wrong { background: var(--error-bg); color: var(--error); }
.answer { padding: 12px; border-radius: 9px; background: var(--surface2); margin-top: 12px; }
.question-tools { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 14px; }
.manage-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 14px; }
.item-row { margin-bottom: 0; padding: 7px 0; border-bottom: 1px solid var(--border); }
.item-row:last-child { border-bottom: 0; }
.item-row > :first-child { min-width: 0; overflow-wrap: anywhere; }
.user-list .item-row { flex-wrap: wrap; }
.check-list { max-height: 270px; overflow: auto; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; }
.check-list label { padding: 5px 0; }
dialog { width: min(440px, calc(100% - 28px)); color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px; }
dialog::backdrop { background: rgb(15 30 22 / 55%); }
@media (max-width: 650px) {
  .site-header { flex-wrap: wrap; }
  .header-side { margin-left: 0; flex: 1 0 100%; }
  .manage-grid { grid-template-columns: minmax(0, 1fr); }
  .login { margin-top: 25px; }
}
