:root {
  color-scheme: light;
  --page: #f3f7f5;
  --white: #fff;
  --ink: #163128;
  --muted: #536a61;
  --green: #13654e;
  --green-dark: #0b503d;
  --line: #d8e3dd;
  --tint: #e7f3ec;
  --warning: #8b320d;
  font: 16px/1.55 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--page); }
[hidden] { display: none !important; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: clamp(1.85rem, 6vw, 2.5rem); line-height: 1.22; letter-spacing: -.04em; overflow-wrap: anywhere; }
h2 { font-size: 1.18rem; line-height: 1.35; overflow-wrap: anywhere; }
h3 { margin-top: .8rem; font-size: 1rem; }
a { color: var(--green); }
a, button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; }
button, .share-controls a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
:focus-visible { outline: 3px solid #178866; outline-offset: 3px; }
.top { background: var(--white); border-bottom: 1px solid var(--line); }
.top-inner { width: min(100% - 2rem, 68rem); min-height: 3.75rem; margin: auto; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 760; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 1.8rem; aspect-ratio: 1; border-radius: .55rem; background: var(--green); color: var(--white); }
nav { display: flex; align-items: center; gap: .85rem; font-size: .9rem; }
nav a { text-decoration: none; color: var(--muted); }
nav a[aria-current] { color: var(--green); font-weight: 750; text-decoration: underline; text-underline-offset: .24em; }

main { margin: 1.55rem auto 4rem; width: min(100% - 2rem, 68rem); }
.narrow { max-width: 31rem; }
.lesson {
  display: grid; gap: .6rem; padding: clamp(1.2rem, 4vw, 1.9rem); margin-bottom: 1rem;
  border-radius: 1.15rem; background: #173c30; color: #fff;
}
.eyebrow { font-weight: 650; font-size: .82rem; color: #c4e4d6; letter-spacing: .09em; }
.lesson-meta, .metadata { overflow-wrap: anywhere; display: grid; gap: .13rem; font-size: .94rem; }
.lesson-meta { color: #e0eee9; }
.metadata { color: var(--muted); }
.card { margin-bottom: 1rem; min-width: 0; padding: clamp(1rem, 3vw, 1.45rem); background: var(--white); border: 1px solid var(--line); border-radius: 1rem; }
.card h2 + p, .page-title p { margin-top: .45rem; }
.subtle { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.split { display: flex; gap: .75rem; justify-content: space-between; align-items: center; }
.split button { flex: none; }
.page-title { margin-bottom: 1.1rem; align-items: end; }
form { display: grid; align-items: start; gap: .78rem; margin-top: 1rem; }
form > button { justify-self: start; }
label { display: grid; gap: .35rem; font-weight: 650; font-size: .9rem; color: var(--ink); }
input, select, textarea {
  width: 100%; min-height: 2.85rem; padding: .58rem .72rem; border-radius: .55rem; border: 1px solid #bfcfc6;
  background: #fff; color: var(--ink); font-size: 1rem; font-weight: 450; 
}
textarea { resize: vertical; }
.primary, .secondary {
  display: inline-flex; min-height: 2.75rem; align-items: center; justify-content: center;
  padding: .55rem .95rem; border: 1px solid transparent; border-radius: .6rem;
  font-weight: 730; font-size: .92rem; text-decoration: none; text-align: center;
}
.primary { color: #fff; background: var(--green); }
.primary:hover { background: var(--green-dark); }
.secondary { color: var(--green-dark); background: #f7faf8; border-color: var(--line); }
.secondary:hover { background: var(--tint); }
.full { width: 100%; }
.link { border: 0; background: transparent; color: var(--green); min-height: 2rem; padding: 0; font-size: .86rem; font-weight: 660; }
.notice { margin-top: .3rem; font-size: .88rem; overflow-wrap: anywhere; }
.notice:empty { display: none; }
.error { color: var(--warning); }
.success { color: var(--green-dark); }
.qr-frame { display: grid; place-items: center; width: max-content; max-width: 100%; margin: 1rem auto .35rem; border: 1px solid var(--line); border-radius: .9rem; overflow: hidden; }
.qr-frame canvas { display: block; width: min(64vw, 14rem); height: auto; image-rendering: pixelated; }
.qr-frame.compact canvas { width: 10rem; max-width: 65vw; }
.qr-caption { text-align: center; }
.details { border-top: 1px solid var(--line); margin: 1rem 0; }
.details div { display: grid; grid-template-columns: 6rem minmax(0, 1fr); gap: .6rem; padding: .58rem 0; border-bottom: 1px solid var(--line); }
.details dt { color: var(--muted); font-size: .9rem; }
.details dd { font-weight: 660; overflow-wrap: anywhere; }
.manual { margin-top: .85rem; padding-top: .65rem; border-top: 1px solid var(--line); }
.manual summary { color: var(--green-dark); font-size: .9rem; cursor: pointer; }
.manual p { margin-top: .42rem; }
.manual code { display: inline-block; max-width: 100%; overflow-wrap: anywhere; margin: .35rem 0; }
.camera-controls, .share-controls { display: flex; justify-content: flex-start; flex-wrap: wrap; gap: .55rem; }
.camera-controls, .share-controls { margin-top: .85rem; }
#camera { display: block; width: 100%; max-height: 55vh; margin-top: .8rem; border-radius: .75rem; background: #12261e; object-fit: contain; }
.result-card { border-color: #a4c9b5; }

.form-grid, .management-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.management-grid { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
.select-wrap { margin: 0 0 .85rem; display: grid; gap: .35rem; }
.dashboard-lesson { margin-bottom: .7rem; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin-bottom: .8rem; }
.metric { display: grid; gap: .15rem; padding: .8rem .9rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--white); }
.metric span { color: var(--muted); font-size: .85rem; }
.metric strong { font-size: 1.75rem; line-height: 1.25; font-variant-numeric: tabular-nums; }
.metric:nth-child(2) { background: var(--tint); border-color: #c5dece; color: var(--green-dark); }
.small-link { display: inline-block; margin-top: .65rem; font-size: .88rem; }
.live { white-space: nowrap; }
.live.success::before { display: inline-block; content: ""; width: .43rem; height: .43rem; margin-right: .33rem; border-radius: 100%; background: #238765; vertical-align: .12em; }
.filters { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: .65rem; margin: 1rem 0 .45rem; }
.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; min-width: 36rem; font-size: .9rem; text-align: left; }
th, td { padding: .58rem .45rem; border-bottom: 1px solid var(--line); }
th { font-weight: 650; color: var(--muted); }
td:nth-child(2), td:nth-child(5) { font-variant-numeric: tabular-nums; white-space: nowrap; }
td:first-child, td:nth-child(3) { max-width: 14rem; overflow-wrap: anywhere; }
.pill { display: inline-block; white-space: nowrap; padding: .16rem .52rem; border-radius: 1rem; background: var(--tint); color: var(--green-dark); font-size: .8rem; }
.pill.pending { background: #eef1ef; color: #4c5e54; }
.pill.other { background: #f8eee2; color: #804916; }
.remove { color: var(--warning); }
.empty { padding: 1.2rem .4rem; text-align: center; }

@media (max-width: 630px) {
  .form-grid, .management-grid { grid-template-columns: 1fr; }
  .management-grid { gap: 0; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 400px) {
  .top-inner, main { width: calc(100% - 1.35rem); }
  nav { gap: .55rem; }
  .page-title .primary { padding-inline: .6rem; }
}
