:root {
  color-scheme: light;
  font: 100%/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #183227;
  background: #f4f7f4;
  --green: #07543f;
  --green-dark: #123d31;
  --gold: #ba9954;
  --muted: #51645a;
  --line: #dce5df;
  --pale: #eef5ef;
  --error: #942628;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100svh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
a { color: var(--green); text-underline-offset: .19em; }
button, input { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.skip { position: absolute; inset: .5rem auto auto .5rem; z-index: 2; padding: .65rem; background: white; transform: translateY(-175%); }
.skip:focus { transform: none; }
.wrap { width: min(100% - 3rem, 72rem); margin-inline: auto; }
.site-header { color: white; background: var(--green-dark); border-bottom: 3px solid var(--gold); }
.header-inner { min-height: 4rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.brand { font-size: 1.16rem; font-weight: 720; letter-spacing: .08em; color: white; text-decoration: none; }
.brand:hover { text-decoration: underline; }
.site-header .button-outline { color: white; border-color: #71938a; background: transparent; }
.site-header .button-outline:hover { background: #205346; }
main { padding-block: clamp(1.5rem, 4vw, 3rem) 2.5rem; flex: 1; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.85rem, 1.2rem + 2vw, 2.65rem); line-height: 1.2; color: var(--green-dark); }
h2 { font-size: 1.24rem; line-height: 1.35; color: var(--green-dark); }
h3 { font-size: 1.04rem; }
.muted { color: var(--muted); }
.muted:empty, .status:empty, .quiz-state:empty { display: none; }
h1 + .muted, h2 + .muted, h3 + p { margin-top: .45rem; }
.status { margin-block: .75rem; }
.status[data-tone="error"] { color: var(--error); }
.status[data-tone="success"] { color: var(--green); }
.panel { background: white; border: 1px solid var(--line); border-radius: .85rem; padding: clamp(1rem, 2vw, 1.65rem); box-shadow: 0 .35rem 1.5rem #123d310a; }
.login { max-width: 30rem; margin: clamp(1rem, 7vh, 4rem) auto; }
.login form { margin-top: 1.65rem; }
.login button[type="submit"] { min-width: 6.25rem; margin-top: 1.15rem; }
.dashboard-heading, .section-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.dashboard-heading { align-items: flex-end; }
.quiz-panel { display: grid; grid-template-columns: minmax(11rem, .55fr) minmax(0, 1.45fr); gap: 1.35rem; }
.quiz-picker { padding: .85rem; border-radius: .55rem; background: var(--pale); }
.quiz-state { margin-top: .8rem; font-size: .92rem; color: var(--muted); }
.settings-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; margin-block: .65rem .85rem; }
.settings-actions, .dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: .8rem; }
.settings-actions { justify-content: space-between; flex-wrap: wrap; }
label { display: block; margin-bottom: .25rem; font-size: .91rem; font-weight: 690; }
input:not([type="checkbox"]), select { display: block; min-width: 0; width: 100%; min-height: 2.65rem; padding: .47rem .65rem; border: 1px solid #aebfb5; border-radius: .42rem; color: inherit; background: white; }
input[type="file"] { padding: .4rem; }
input[readonly] { background: var(--pale); }
.field-help { margin-top: .2rem; color: var(--muted); font-size: .83rem; }
.toggle { display: inline-flex; align-items: center; margin: 0; gap: .4rem; cursor: pointer; }
.toggle input { accent-color: var(--green); width: 1.05rem; height: 1.05rem; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.63rem; padding: .42rem .88rem; border: 1px solid transparent; border-radius: .42rem; font-weight: 660; font-size: .92rem; cursor: pointer; text-align: center; }
.button:disabled { opacity: .58; cursor: wait; }
.button-primary { background: var(--green); color: white; }
.button-primary:not(:disabled):hover { background: var(--green-dark); }
.button-outline { background: white; color: var(--green); border-color: #93ada0; }
.button-outline:not(:disabled):hover { background: var(--pale); }
.button-danger-outline { background: white; color: var(--error); border-color: #c89292; }
.button-danger-outline:not(:disabled):hover { background: #fff1f0; }
.button-danger { background: var(--error); color: white; }
.button-danger:not(:disabled):hover { background: #741d20; }
.button-quiet { color: var(--green); background: transparent; min-height: 2.4rem; padding: .22rem .48rem; }
.button-quiet:hover { text-decoration: underline; }
.button-quiet-danger { color: var(--error); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; }
#quiz-content .panel { margin-top: 1.1rem; }
.filters { display: grid; grid-template-columns: minmax(0, 21rem) minmax(8rem, 13rem); gap: .7rem; margin-bottom: .85rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: .5rem; }
table { width: 100%; min-width: 31rem; border-collapse: collapse; }
th, td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; overflow-wrap: anywhere; }
th { background: var(--pale); color: var(--green-dark); font-size: .9rem; }
tbody tr:last-child td { border-bottom: 0; }
td { font-size: .93rem; }
td.number, th.number { text-align: right; font-variant-numeric: tabular-nums; }
.identity-column { min-width: 4rem; }
.identity-column:first-child { min-width: 7.4rem; }
.question-column { min-width: 4.5rem; }
.edit-column { width: 7.2rem; text-align: center; white-space: nowrap; }
.lookup-note { margin-bottom: .65rem; }
.lookup-column { min-width: 6rem; }
.empty-cell { color: var(--muted); padding: 1.2rem .7rem; text-align: center; }
.stats-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .65rem; }
.metric { padding: .85rem; background: var(--pale); border-top: 2px solid #a7bfac; border-radius: .45rem; }
.metric dt { color: var(--muted); font-size: .87rem; }
.metric dd { margin: .1rem 0 0; color: var(--green-dark); font-size: clamp(1.24rem, 1rem + 1vw, 1.75rem); font-weight: 720; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.analysis-subtitle { margin: 1.3rem 0 .55rem; }
.score-bands { display: grid; gap: .45rem; margin: .7rem 0 0; padding: 0; list-style: none; }
.score-bands li { display: grid; grid-template-columns: minmax(6rem, max-content) minmax(2rem, 1fr) 4.5rem; align-items: center; gap: .65rem; font-size: .9rem; }
.score-bands meter { display: block; width: 100%; height: .72rem; }
.score-bands meter::-webkit-meter-bar { border: 0; border-radius: .3rem; background: var(--pale); }
.score-bands meter::-webkit-meter-optimum-value { border-radius: .3rem; background: var(--green); }
.score-bands meter::-moz-meter-bar { border-radius: .3rem; background: var(--green); }
.band-count { text-align: right; font-variant-numeric: tabular-nums; }
dialog { width: min(100% - 2rem, 39rem); max-height: calc(100% - 2rem); overflow-y: auto; border: 1px solid var(--line); border-radius: .8rem; padding: clamp(1rem, 4vw, 1.6rem); color: inherit; }
dialog::backdrop { background: #123d3180; }
dialog .muted { margin-block: .4rem .8rem; }
dialog .dialog-actions { margin-top: 1.25rem; }
#import-details { margin-top: .9rem; }
#import-summary { margin-bottom: .65rem; }
footer { border-top: 1px solid var(--line); padding-block: 1.25rem; color: var(--muted); font-size: .9rem; text-align: center; }
footer a { color: inherit; }

@media (max-width: 47rem) {
  .wrap { width: min(100% - 1.5rem,72rem); }
  .quiz-panel { grid-template-columns: 1fr; gap: .85rem; }
  .stats-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}

@media (max-width: 28rem) {
  .dashboard-heading, .section-heading { align-items: flex-start; flex-wrap: wrap; }
  .settings-fields, .filters { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
