:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #172523;
  background: #eef2f0;
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
body:has(dialog[open]) { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, p { margin: 0; }
h1, h2 { color: #183d38; font-size: 25px; letter-spacing: -.5px; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 32px; color: #f4f7f4; background: #183d38; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 36px; height: 32px; display: grid; place-items: center; background: #b6d86a; color: #17332f; font-size: 12px; font-weight: 800; border-radius: 4px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small { margin-top: 2px; color: #b7cbc5; font-size: 12px; }
main { max-width: 1160px; margin: 0 auto; padding: 0 28px 56px; }
.page-nav { display: flex; gap: 32px; border-bottom: 1px solid #cbd5d1; }
.page-nav a { padding: 23px 0 18px; border-bottom: 3px solid transparent; color: #61746c; text-decoration: none; font-size: 14px; }
.page-nav a[aria-current] { border-color: #267467; color: #183d38; font-weight: 700; }
input, select, textarea { min-height: 42px; padding: 9px 12px; color: #172523; background: #fff; border: 1px solid #bfcac6; border-radius: 5px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid #e4ad4e; outline-offset: 2px; }
.button { min-height: 40px; padding: 0 18px; border: 1px solid transparent; border-radius: 5px; font-weight: 600; white-space: nowrap; }
button:disabled { opacity: .5; cursor: default; }
.primary { color: #fff; background: #267467; }
.primary:hover:not(:disabled) { background: #1d6258; }
.secondary { color: #263e39; background: #fff; border-color: #b6c5bf; }
.secondary:hover:not(:disabled) { background: #e8efec; }
.topbar-button { color: #e4ede8; background: transparent; border-color: #66837a; font-size: 13px; }
.topbar-button:hover { background: #284d44; }
.notice { min-height: 20px; margin: 16px 0; color: #3f5f57; font-size: 13px; }
.error { color: #a04438; }
.form-notice { min-height: 18px; margin-top: 12px; font-size: 13px; }
.muted, .section-heading p { color: #61746c; font-size: 14px; line-height: 1.65; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.section-heading p { margin-top: 7px; }
.settings-panel { background: #fff; border: 1px solid #d1dbd6; border-radius: 10px; overflow: hidden; }
.daily-limit { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: 36px; background: #e3eee8; border-left: 5px solid #267467; }
.daily-limit label { font-size: 20px; font-weight: 700; color: #183d38; }
.daily-limit p { margin-top: 10px; color: #526c60; font-size: 13px; line-height: 1.6; }
.limit-input { display: flex; align-items: baseline; gap: 12px; white-space: nowrap; }
.limit-input input { width: 160px; padding: 4px 8px; font: 600 52px/1.2 "Bahnschrift", "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; color: #183d38; border-color: #b5cbbd; text-align: center; }
.limit-input span { color: #526c60; font-size: 14px; }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; padding: 36px; }
.settings-grid label, .question-form label { display: grid; gap: 10px; color: #3e514c; font-size: 14px; }
.settings-grid small { color: #73817c; font-size: 12px; line-height: 1.5; }
.input-with-unit { display: flex; align-items: center; gap: 10px; }
.input-with-unit input { width: 100%; min-width: 0; font-size: 19px; }
.input-with-unit > span { flex-shrink: 0; color: #73817c; font-size: 12px; }
.settings-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 36px; border-top: 1px solid #e2e9e5; }
.settings-footer p { color: #61746c; font-size: 13px; }
.count { display: inline-grid; min-width: 30px; height: 26px; place-items: center; margin-left: 6px; padding: 0 8px; color: #285d52; background: #dceae3; border-radius: 14px; font-size: 13px; vertical-align: 3px; font-variant-numeric: tabular-nums; }
.filters { display: flex; gap: 10px; }
.filters select { min-width: 140px; }
.table-wrap { background: #fff; border: 1px solid #d1dbd6; border-radius: 8px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 15px 18px; color: #61746c; background: #f5f8f6; font-size: 12px; font-weight: 600; }
td { padding: 16px 18px; border-top: 1px solid #e2e9e5; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
th:first-child, td:first-child { width: 110px; }
th:last-child, td:last-child { width: 90px; text-align: right; }
td:nth-child(3) { color: #39675b; width: 200px; }
.empty { padding: 40px; color: #71817c; text-align: center; }
.delete-button { padding: 5px 9px; color: #984b3f; background: transparent; border: 1px solid #d9b2aa; border-radius: 4px; font-size: 12px; }
.delete-button:hover { background: #f9e9e5; }
.loading { margin: 64px auto; text-align: center; color: #61746c; }
.login-view { max-width: 500px; padding-top: 64px; }
.login-card { padding: 36px; background: #fff; border: 1px solid #d1dbd6; border-top: 4px solid #267467; border-radius: 8px; }
.login-eyebrow { display: block; margin-bottom: 16px; color: #267467; font-size: 12px; font-weight: 700; }
.login-card h1 { font-size: 24px; margin-bottom: 10px; }
.login-card form { display: grid; margin-top: 28px; }
.login-card label { margin: 16px 0 8px; font-size: 13px; color: #3e514c; }
.login-card label:first-child { margin-top: 0; }
.login-card .button { margin-top: 12px; width: 100%; }
dialog { width: min(620px, calc(100% - 32px)); max-height: calc(100dvh - 40px); padding: 28px; border: 1px solid #c3cfca; border-radius: 10px; box-shadow: 0 24px 90px #0c282e33; overflow-y: auto; }
dialog::backdrop { background: #102c296b; backdrop-filter: blur(3px); }
.form-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.form-heading h2 { font-size: 21px; margin-bottom: 5px; }
.icon-button { flex-shrink: 0; width: 32px; height: 32px; color: #4c615b; background: transparent; border: 1px solid #c3cfca; border-radius: 4px; font-size: 21px; line-height: 1; }
.form-meta { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-top: 16px; }
.options-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; margin-top: 20px; }
.options-fields label { grid-template-columns: 18px minmax(0, 1fr); align-items: center; color: #267467; font-weight: 700; }
.options-fields input { width: 100%; min-width: 0; font-weight: 400; }
.correct-answer { width: 160px; margin-top: 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 20px; border-top: 1px solid #e2e9e5; }
.ai-dialog { width: min(780px, calc(100% - 32px)); }
.ai-fields { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 16px; }
.ai-fields label { display: grid; gap: 10px; color: #3e514c; font-size: 14px; }
.ai-fields input { width: 100%; min-width: 0; }
.ai-generation-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; }
.ai-generation-actions .muted { font-size: 12px; }
.ai-preview { margin-top: 24px; border-top: 1px solid #d1dbd6; }
.ai-preview-heading { margin: 22px 0 18px; }
.ai-preview-heading h3 { margin: 0 0 8px; color: #183d38; font: 600 23px "STKaiti", "KaiTi", serif; }
.ai-preview-heading .muted { font-size: 12px; }
.ai-question-list { display: grid; gap: 14px; }
.ai-question { padding: 18px; border: 1px solid #d1dbd6; border-radius: 6px; }
.ai-question-heading { display: flex; align-items: flex-start; gap: 10px; color: #183d38; font-size: 14px; font-weight: 600; line-height: 1.7; cursor: pointer; overflow-wrap: anywhere; }
.ai-question-heading input { flex-shrink: 0; width: 17px; height: 17px; min-height: 0; margin: 4px 0 0; accent-color: #267467; }
.ai-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin: 14px 0 0 27px; padding: 0; list-style: none; }
.ai-options li { padding: 8px 10px; color: #61746c; background: #f5f8f6; border-radius: 4px; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.ai-options .correct { color: #185e4d; background: #e3eee8; }
.ai-options .correct span { display: block; font-size: 11px; font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 760px) {
  .topbar { padding: 0 16px; }
  main { padding: 0 16px 32px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .daily-limit { align-items: flex-start; flex-direction: column; padding: 24px; }
  .settings-grid { grid-template-columns: 1fr; gap: 24px; padding: 24px; }
  .settings-footer { align-items: flex-start; flex-direction: column; padding: 20px 24px; }
  .settings-footer .button { width: 100%; }
  .filters { width: 100%; }
  .filters select { flex: 1; min-width: 0; }
  table { min-width: 620px; }
  .login-view { padding-top: 32px; }
  .login-card { padding: 24px; }
  dialog { padding: 20px; }
  .form-meta, .options-fields { grid-template-columns: 1fr; }
  .ai-generation-actions { align-items: stretch; flex-direction: column; }
  .ai-options { grid-template-columns: 1fr; }
  .ai-question { padding: 14px; }
}
@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: appear .16s ease-out; }
  @keyframes appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
}
