:root {
  --ink: #17201f;
  --muted: #66716f;
  --paper: #f5f6f2;
  --surface: #ffffff;
  --line: #d8ddda;
  --green: #116149;
  --green-dark: #0b4635;
  --yellow: #e7b84b;
  --red: #a83b32;
  --shadow: 0 18px 55px rgba(25, 40, 35, 0.09);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.topbar {
  height: 64px;
  padding: 0 clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.84);
}
.brand { color: var(--ink); text-decoration: none; font-family: "STZhongsong", serif; font-size: 20px; font-weight: 700; }
.quiet-link, .text-button { color: var(--muted); text-decoration: none; border: 0; background: none; }
.top-links { display: flex; align-items: center; gap: 22px; }
.redeem-layout {
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
  gap: clamp(36px, 8vw, 120px);
  align-items: center;
  padding: 64px clamp(24px, 8vw, 140px);
  background: linear-gradient(110deg, rgba(231,184,75,.15), transparent 38%),
              radial-gradient(circle at 80% 20%, rgba(17,97,73,.1), transparent 30%);
}
.intro h1, .login-panel h1, .page-heading h1 { font-family: "STZhongsong", serif; font-size: clamp(36px, 5vw, 64px); line-height: 1.12; margin: 8px 0 18px; }
.intro p:not(.eyebrow) { max-width: 430px; color: var(--muted); font-size: 17px; line-height: 1.8; }
.announcement { max-width: 500px; margin-top: 28px; padding: 18px 20px; border-left: 4px solid var(--yellow); background: rgba(255,255,255,.78); }
.announcement h2 { margin: 0 0 8px; font-family: "STZhongsong", serif; font-size: 20px; }
.announcement p { margin: 0; color: var(--ink); white-space: pre-wrap; line-height: 1.7; overflow-wrap: anywhere; }
.announcement time { display: block; margin-top: 10px; color: var(--muted); font-size: 12px; }
.eyebrow { margin: 0; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: 0.14em; }
.work-panel, .login-panel {
  width: 100%; max-width: 680px; background: var(--surface); border: 1px solid var(--line);
  border-top: 4px solid var(--yellow); padding: clamp(24px, 5vw, 48px); box-shadow: var(--shadow);
}
.work-panel h2, .section-heading h2 { margin: 0 0 24px; font-family: "STZhongsong", serif; font-size: 26px; }
form { display: grid; gap: 12px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, textarea, select {
  width: 100%; border: 1px solid #c7cfca; border-radius: 4px; background: #fff;
  color: var(--ink); padding: 12px 13px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(17,97,73,.12); }
textarea { resize: vertical; font-family: Consolas, monospace; font-size: 13px; line-height: 1.55; }
button { min-height: 42px; border: 1px solid var(--line); border-radius: 4px; padding: 9px 15px; background: #fff; color: var(--ink); }
button:hover { border-color: #9ba7a1; }
.primary { border-color: var(--green); background: var(--green); color: #fff; font-weight: 700; }
.primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
#redeem-form .primary { margin-top: 8px; }
.unlock-layout .primary { margin-top: 8px; }
.location-readout {
  min-height: 48px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 13px; border: 1px solid var(--line); background: #f8faf8;
  color: var(--muted); font-size: 13px;
}
.location-label { color: var(--ink); font-weight: 700; }
.unlock-result { margin-top: 22px; padding: 20px; border-left: 4px solid var(--green); background: #eef5f1; }
.unlock-result h3 { margin: 7px 0 12px; font-size: 18px; }
.unlock-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ride-controls { margin-top: 26px; padding-top: 24px; border-top: 1px solid var(--line); }
.ride-control-head, .timer-heading {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.ride-control-head-actions { display: flex; align-items: center; gap: 10px; }
.ride-control-head h3, .timer-heading h4 { margin: 0; font-size: 17px; }
.ride-action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.ride-action-grid button { min-width: 0; }
.timer-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.timer-field { max-width: 320px; margin-top: 16px; }
.cycle-summary {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px;
  color: var(--muted); font-size: 13px;
}
.cycle-summary span { padding: 10px 12px; border: 1px solid var(--line); background: #f8faf8; }
.cycle-summary strong { display: block; margin-top: 4px; color: var(--ink); font-size: 14px; }
.timer-countdown {
  min-height: 48px; margin: 14px 0 10px; display: grid; place-items: center;
  background: #f8faf8; border: 1px solid var(--line); font-family: Consolas, monospace;
  font-size: 28px; font-variant-numeric: tabular-nums;
}
.timer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.timer-actions #timer-toggle { grid-column: 1 / -1; }
.timer-actions.with-pause #timer-toggle { grid-column: auto; }
.cycle-log-section { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.cycle-log-section h5 { margin: 0 0 10px; font-size: 14px; }
.cycle-log { max-height: 220px; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.cycle-log li { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; line-height: 1.5; }
.cycle-log li.error { color: var(--red); }
.cycle-log time { display: block; color: var(--muted); font-size: 11px; }
.status { min-height: 22px; margin: 14px 0 0; color: var(--muted); font-size: 14px; }
.status.error { color: var(--red); }
.result { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.result-head h3 { margin: 0 0 12px; font-size: 16px; }
.result-meta { display: grid; justify-items: end; gap: 3px; }
.meta { color: var(--muted); font-size: 12px; }
.copy-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
.lookup-block { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.lookup-block h3 { margin: 0 0 14px; font-family: "STZhongsong", serif; font-size: 19px; }
code { background: #edf0ed; padding: 2px 5px; border-radius: 3px; }
.admin-shell { max-width: 1180px; margin: 0 auto; padding: 56px 24px 90px; }
.login-panel { margin: 8vh auto 0; max-width: 460px; }
.login-panel h1 { font-size: 42px; }
.install-panel { margin-top: 2vh; }
.install-panel form { gap: 14px; }
.install-panel .primary { margin-top: 8px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; }
.page-heading h1 { font-size: 42px; margin-bottom: 0; }
.badge { padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 24px; margin-top: 42px; border-bottom: 1px solid var(--line); }
.tab, .tab-link {
  min-height: 42px; border: 0; border-radius: 0; background: none; color: var(--muted);
  padding: 12px 2px; text-decoration: none; white-space: nowrap;
}
.tab.active { color: var(--green); border-bottom: 3px solid var(--green); font-weight: 800; }
.tab-panel { padding-top: 34px; }
.section-heading { display: flex; justify-content: space-between; }
.section-heading h2 { margin-bottom: 4px; }
.section-heading p { margin: 0; color: var(--muted); }
.inline-form { grid-template-columns: repeat(3, minmax(110px, 1fr)) auto; align-items: end; margin: 26px 0; }
.settings-form { max-width: 620px; margin-top: 26px; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-form label:last-of-type, .settings-form button { grid-column: 1 / -1; }
.identity-form { max-width: 760px; margin-top: 26px; }
.backup-button { margin-top: 26px; }
.generated { max-width: 760px; margin: 24px 0; padding: 20px; background: #eef5f1; border-left: 4px solid var(--green); }
.table-wrap { overflow-x: auto; margin-top: 18px; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 14px; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 12px; }
.state-active { color: var(--green); font-weight: 700; }
.state-disabled { color: var(--red); }
.state-used { color: #8a5a00; font-weight: 700; }
.state-riding { color: #006b55; font-weight: 700; }
.history-heading { margin-top: 48px; }
.order-search-form { max-width: 760px; margin-top: 22px; grid-template-columns: minmax(260px, 1fr) auto auto; align-items: end; }
.compact-button { min-height: 30px; margin-left: 8px; padding: 4px 9px; font-size: 12px; }
.action-buttons { min-width: 152px; white-space: nowrap; vertical-align: middle; }
.action-buttons button { width: 68px; min-width: 68px; min-height: 42px; padding: 9px 12px; white-space: nowrap; }
.action-buttons button + button { margin-left: 8px; }
.action-buttons .compact-button { margin-left: 0; font-size: 14px; }
dialog { width: min(680px, calc(100vw - 32px)); border: 1px solid var(--line); border-top: 4px solid var(--yellow); padding: 24px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(23, 32, 31, .48); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dialog-head h2 { margin: 0; font-family: "STZhongsong", serif; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
#token-dialog .primary { width: 100%; margin-top: 12px; }
.manual-token-shell { max-width: 900px; }
.manual-token-panel { padding-top: 34px; }
.manual-token-form { margin-top: 24px; grid-template-columns: 1fr 1fr; gap: 18px; }
.manual-token-form .wide-field, .manual-token-form button { grid-column: 1 / -1; }
.manual-token-result { max-width: none; }
.manual-token-result .result-meta { justify-items: start; }

@media (max-width: 760px) {
  .redeem-layout { grid-template-columns: 1fr; align-content: start; padding-top: 48px; }
  .intro h1 { font-size: 40px; }
  .inline-form, .settings-form, .order-search-form { grid-template-columns: 1fr; }
  .settings-form label:last-of-type, .settings-form button { grid-column: auto; }
  .page-heading { align-items: start; flex-direction: column; }
  .copy-row { grid-template-columns: 1fr; }
  .top-links { gap: 14px; }
  .cycle-summary { grid-template-columns: 1fr; }
  .tabs { gap: 16px; overflow-x: auto; }
  .manual-token-form { grid-template-columns: 1fr; }
  .manual-token-form .wide-field, .manual-token-form button { grid-column: auto; }
}
