:root {
  color-scheme: light;
  --ink: #1f2923;
  --muted: #637168;
  --paper: #fffdf7;
  --page: #f7f3e8;
  --line: #d8ddd8;
  --green: #2f7651;
  --green-dark: #1f6342;
  --green-soft: #dff3e7;
  --danger: #a33b32;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.55; }

button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
a:focus-visible, summary:focus-visible, #pageProgress:focus-visible {
  outline: 3px solid #245e91;
  outline-offset: 3px;
}

.site-shell { width: min(100%, 880px); margin: 0 auto; padding: 20px 14px 48px; }
.eyebrow { margin: 0 0 10px; color: var(--green-dark); font-weight: 750; letter-spacing: 0.08em; }
.panel { background: var(--paper); border: 1px solid #e6e2d8; border-radius: 20px; padding: clamp(20px, 4vw, 36px); box-shadow: 0 12px 36px rgba(55, 62, 57, 0.08); }
.narrow-panel { width: min(100%, 620px); margin-inline: auto; }
.assessment-panel { padding-inline: clamp(12px, 3vw, 30px); }
.hidden { display: none !important; }
.lead, .field-help, .assessment-hint, .save-status, .progress-copy span { color: var(--muted); }
h1 { margin: 0 0 16px; font-size: clamp(28px, 7vw, 40px); line-height: 1.2; }
h2 { margin-top: 0; }
p { line-height: 1.7; }
label { display: block; margin: 18px 0 7px; font-weight: 700; }
input, textarea, select { width: 100%; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); padding: 12px 14px; }
input { min-height: 48px; }
textarea { resize: vertical; }
.field-help { margin: 6px 0 0; font-size: 14px; }
.privacy-link { text-align: center; }
a, .text-button { color: var(--green-dark); }
.text-button { border: 0; background: transparent; padding: 8px; text-decoration: underline; }
.primary, .secondary { min-height: 48px; border-radius: 12px; padding: 11px 18px; font-weight: 750; }
.primary { border: 2px solid var(--green); background: var(--green); color: #fff; }
.secondary { border: 2px solid var(--line); background: #fff; color: var(--ink); }
.compact { min-height: 40px; padding: 7px 12px; }
.full-width { width: 100%; margin-top: 18px; }
.button-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.message { min-height: 1.5em; margin: 10px 0 0; }
.error { color: var(--danger); }
.consent-row { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; }
.consent-row input { width: 22px; min-height: 22px; margin-top: 4px; flex: 0 0 auto; }
.section-header, .assessment-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-header h1 { margin-bottom: 6px; }
.section-header p { margin: 0; }
.wordlist-list { display: grid; gap: 16px; }
.wordlist-card { border: 2px solid var(--line); border-radius: 16px; padding: 18px; }
.wordlist-card h2 { margin-bottom: 4px; }
.wordlist-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 16px 0; }
.wordlist-stats span { background: #f2f4ef; border-radius: 10px; padding: 10px; }
.instruction-box { border-left: 5px solid var(--green); background: var(--green-soft); border-radius: 12px; padding: 10px 18px; }
.progress-copy { text-align: center; display: grid; gap: 2px; }
.assessment-hint { text-align: center; margin: 18px 0 12px; }

.character-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.character-card {
  min-height: 76px;
  border: 2px solid #d8ddd8;
  border-radius: 12px;
  background: #ffffff;
  color: #1f2923;
  font-size: clamp(34px, 10vw, 48px);
  line-height: 1;
  touch-action: manipulation;
}

.character-card.is-selected {
  border-color: #3d8a61;
  background: #dff3e7;
  color: #1f6342;
}

.save-status { min-height: 26px; text-align: center; padding-top: 8px; }
.page-navigation { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.retry-button { display: block; margin: 0 auto; }
.result-number { font-size: 20px; font-weight: 750; line-height: 1.7; }
.success-copy { border-radius: 12px; background: var(--green-soft); color: var(--green-dark); padding: 14px; font-weight: 750; }
details { margin: 18px 0; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
summary { cursor: pointer; font-weight: 700; }
.result-detail { color: var(--muted); padding-top: 12px; line-height: 1.7; }

.dialog { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 18px; background: rgba(19, 27, 22, 0.58); }
.dialog-card { width: min(100%, 480px); background: #fff; border-radius: 18px; padding: 24px; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25); }
.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; }

.admin-shell { width: min(100%, 1180px); }
.admin-title-row { align-items: flex-start; }
.admin-toolbar, .admin-pagination, .admin-action-grid { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.admin-toolbar { margin: 20px 0 10px; }
.admin-pagination { justify-content: center; margin-top: 18px; }
.admin-table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.admin-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.admin-table th, .admin-table td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.admin-table th { background: #f2f4ef; white-space: nowrap; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-empty { color: var(--muted); font-style: italic; }
.admin-section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.admin-section h2 { margin-bottom: 12px; }
.admin-stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.admin-stat-grid p { margin: 0; padding: 12px; border-radius: 10px; background: #f2f4ef; }
.admin-action-grid { align-items: flex-end; }
.admin-action-grid > button { min-width: 170px; }
.inline-field { width: 150px; }
.inline-field label { margin-top: 0; }
.danger-button { min-height: 48px; border: 2px solid var(--danger); border-radius: 12px; padding: 11px 18px; background: #fff; color: var(--danger); font-weight: 750; }
.admin-record-list { display: grid; gap: 8px; }
.admin-record { line-height: 1.6; padding: 11px 13px; background: #f6f5f0; border-radius: 10px; overflow-wrap: anywhere; }
.admin-wordlist-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin: 14px 0; }
.admin-wordlist-card { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #f6f5f0; line-height: 1.65; }
.back-link { padding-left: 0; }
.credential-list { display: grid; gap: 10px; margin: 18px 0; }
.credential-list div { display: grid; grid-template-columns: 90px 1fr; gap: 10px; padding: 12px; background: var(--green-soft); border-radius: 10px; }
.credential-list dt { font-weight: 750; }
.credential-list dd { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }

@media (min-width: 720px) {
  .site-shell { padding-top: 34px; }
  .character-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .wordlist-stats { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 520px) {
  .stack-mobile { flex-direction: column-reverse; }
  .stack-mobile button { width: 100%; }
  .assessment-header { align-items: flex-start; }
  .admin-stat-grid { grid-template-columns: 1fr; }
  .admin-action-grid { align-items: stretch; }
  .admin-action-grid > button, .inline-field { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
