:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #fff;
  --surface-soft: #f8f8fa;
  --text: #1d1d1f;
  --secondary: #6e6e73;
  --muted: #929298;
  --line: #e8e8ed;
  --input-line: #d2d2d7;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --green: #248a3d;
  --red: #c93434;
  --shadow: 0 6px 30px rgba(0, 0, 0, .035), 0 0 0 1px rgba(0, 0, 0, .025);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
:root[data-theme='dark'] { color-scheme: dark; --bg: #101012; --surface: #1c1c1e; --surface-soft: #242426; --text: #f5f5f7; --secondary: #a1a1a6; --muted: #89898f; --line: #333336; --input-line: #49494e; --accent: #2997ff; --accent-hover: #40a9ff; --green: #63d480; --red: #ff827a; --shadow: 0 8px 32px rgba(0, 0, 0, .12), 0 0 0 1px rgba(255, 255, 255, .035); }
* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; color: var(--text); background: var(--bg); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: var(--accent); }
button:disabled { opacity: .55; cursor: not-allowed; }
button, a, input, textarea, select, summary { outline-offset: 4px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent); }
[hidden], .hidden { display: none !important; }
h1, h2, p { margin: 0; }
button { border: 0; }
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 100; border-radius: 12px; padding: 12px 18px; background: var(--surface); }
.skip-link:focus { top: 12px; }
.site-header { background: color-mix(in srgb, var(--bg) 85%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.topbar { max-width: 1120px; margin: auto; min-height: 86px; padding: 0 28px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 26px; }
.brand { display: inline-flex; justify-self: start; align-items: center; gap: 10px; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand-mark { display: block; border-radius: 10px; }
.brand > span { display: inline-flex; align-items: center; font-size: 19px; font-weight: 650; letter-spacing: .5px; }
.brand-divider { width: 1px; height: 15px; background: var(--input-line); margin: 0 13px; }
.brand-caption { font-size: 12px; font-weight: 400; letter-spacing: .4px; color: var(--secondary); }
.page-nav { display: inline-flex; align-items: center; gap: 3px; padding: 4px; border-radius: 13px; background: color-mix(in srgb, var(--secondary) 7%, transparent); }
.page-nav a { min-width: 84px; padding: 9px 15px; border-radius: 10px; color: var(--secondary); text-align: center; text-decoration: none; white-space: nowrap; font-size: 12px; line-height: 18px; transition: color .18s, background .18s, box-shadow .18s; }
.page-nav a:hover { color: var(--text); }
.page-nav a[aria-current='page'] { background: var(--surface); box-shadow: 0 1px 5px rgba(0, 0, 0, .07); color: var(--text); font-weight: 550; }
.header-actions { justify-self: end; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: transparent; color: var(--secondary); transition: background .18s; }
.icon-button:hover { background: var(--line); color: var(--text); }
.icon-button svg { width: 19px; height: 19px; }
.sun-icon, :root[data-theme='dark'] .moon-icon { display: none; }
:root[data-theme='dark'] .sun-icon { display: block; }
.main-content { flex: 1; width: 100%; }
.site-page { padding: 70px 24px 70px; animation: appear .35s ease both; }
.flow-page { padding-top: 64px; }
.form-page { display: none; }
.form-page.active { display: block; animation: appear .32s ease both; }
.page-intro { margin: 0 auto 34px; text-align: center; max-width: 700px; }
.hero-mark { margin-bottom: 25px; }
.hero-mark img { display: block; margin: auto; border-radius: 22px; box-shadow: 0 10px 22px rgba(22, 48, 89, .12); }
.eyebrow { margin-bottom: 16px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 2.2px; line-height: 1.5; }
h1 { font-size: clamp(32px, 4vw, 46px); font-weight: 600; letter-spacing: -1.9px; line-height: 1.25; text-wrap: balance; }
h1:focus { outline: none; }
.home-intro h1 { font-size: clamp(36px, 4.2vw, 50px); }
.page-description { margin-top: 17px; font-size: 15px; line-height: 1.7; letter-spacing: .1px; color: var(--secondary); }
.flow-card, .task-query-form, .status-panel, .queue-card { background: var(--surface); box-shadow: var(--shadow); border-radius: 24px; }
.flow-card { width: min(100%, 510px); margin: 0 auto; padding: 30px; }
.session-card, .review-card { width: min(100%, 590px); }
.field-topline { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.field-topline label, .field-label { font-size: 14px; font-weight: 550; }
.step-caption { color: var(--text); font-size: 10px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.step-caption span { color: var(--muted); margin-left: 3px; }
input, textarea, select { width: 100%; min-width: 0; border: 1px solid var(--input-line); border-radius: 12px; background: var(--surface); color: var(--text); transition: border-color .18s, box-shadow .18s; }
input { min-height: 51px; padding: 13px 15px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.code-input { height: 60px; padding: 16px 18px; font-size: 16px; letter-spacing: 1.5px; }
.code-input::placeholder { font-size: 14px; letter-spacing: .5px; }
textarea { min-height: 185px; padding: 16px; resize: vertical; font-size: 12px; line-height: 1.7; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
textarea:disabled { opacity: .6; }
.primary-button, .ghost-button { min-height: 49px; border-radius: 12px; padding: 13px 20px; font-size: 14px; font-weight: 500; display: inline-flex; justify-content: center; align-items: center; gap: 18px; text-decoration: none; transition: background .18s, transform .18s; }
.primary-button { color: #fff; background: var(--accent); }
.primary-button:hover:not(:disabled) { background: var(--accent-hover); }
.primary-button:active:not(:disabled), .ghost-button:active:not(:disabled) { transform: scale(.985); }
.primary-button b { font-size: 18px; line-height: 1; font-weight: 400; }
.code-card > .primary-button { margin-top: 17px; width: 100%; }
.ghost-button { background: var(--surface-soft); color: var(--secondary); }
.ghost-button:hover { background: var(--line); color: var(--text); }
.field-footnote { margin-top: 19px; color: var(--secondary); font-size: 11px; text-align: center; line-height: 1.7; }
.field-footnote svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 5px; }
.helper-text { margin-top: 11px; color: var(--secondary); font-size: 11px; line-height: 1.7; }
.button-row { display: grid; grid-template-columns: 104px 1fr; gap: 12px; margin-top: 25px; }
.session-guide { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.session-guide summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--secondary); font-size: 12px; cursor: pointer; list-style: none; }
.session-guide summary::-webkit-details-marker { display: none; }
.session-guide[open] summary > span { transform: rotate(45deg); }
.guide-content > p { margin: 17px 0 12px; color: var(--secondary); font-size: 11px; line-height: 1.7; }
.guide-link { display: flex; align-items: center; gap: 11px; padding: 13px 0; color: var(--text); text-decoration: none; }
.guide-link:hover strong { color: var(--accent); }
.guide-link > span:last-child { margin-left: auto; color: var(--accent); }
.guide-number { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 50%; background: var(--surface-soft); color: var(--secondary); font-size: 11px; }
.guide-link strong, .guide-link small { display: block; font-weight: 400; }
.guide-link strong { font-size: 12px; }
.guide-link small { margin-top: 4px; font-size: 10px; color: var(--secondary); }
.summary-grid { display: grid; gap: 18px; }
.summary-grid label > span { display: block; color: var(--secondary); font-size: 11px; margin-bottom: 8px; }
.summary-grid select { padding: 14px; min-height: 50px; font-size: 14px; }
.summary-grid select:disabled, .summary-grid input:read-only { opacity: 1; -webkit-text-fill-color: var(--text); background: var(--surface-soft); color: var(--text); }
.review-box { padding: 7px 0; margin-top: 16px; border-top: 1px solid var(--line); }
.review-box > div { display: flex; justify-content: space-between; align-items: start; gap: 18px; padding-top: 13px; font-size: 11px; line-height: 1.6; }
.review-box span { flex-shrink: 0; color: var(--secondary); }
.review-box strong { text-align: right; font-weight: 400; overflow-wrap: anywhere; }
.query-content { max-width: 680px; margin: auto; display: grid; gap: 18px; }
.task-query-form { padding: 26px; }
.task-query-form > label { display: block; margin-bottom: 12px; font-size: 12px; font-weight: 500; }
.search-row { display: flex; gap: 10px; }
.search-row input { font-size: 12px; }
.search-row .primary-button { flex-shrink: 0; font-size: 12px; gap: 13px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head h2 { font-size: 13px; font-weight: 550; }
.small-button, .text-button { color: var(--accent); background: none; padding: 7px 0 7px 12px; font-size: 11px; border-radius: 6px; }
.small-button:hover, .text-button:hover { text-decoration: underline; }
.small-button span { font-size: 15px; padding-left: 4px; }
.status-panel { padding: 23px 26px; }
.empty-state { min-height: 216px; display: flex; align-items: center; justify-content: center; flex-direction: column; text-align: center; }
.empty-symbol { margin-bottom: 16px; width: 56px; height: 56px; display: grid; place-items: center; background: var(--surface-soft); border-radius: 50%; color: var(--muted); }
.empty-symbol svg { width: 31px; height: 31px; }
.empty-state strong { font-size: 13px; font-weight: 450; }
.empty-state small, .empty-log small { display: block; color: var(--secondary); font-size: 11px; line-height: 1.7; margin-top: 9px; }
.task-card { padding-top: 13px; }
.task-card > div { padding: 14px 0; display: flex; justify-content: space-between; align-items: start; gap: 20px; font-size: 12px; border-bottom: 1px solid var(--line); }
.task-card > div:last-child { border-bottom: 0; }
.task-card > div > span { color: var(--secondary); flex-shrink: 0; }
.task-card strong { font-weight: 450; text-align: right; overflow-wrap: anywhere; line-height: 1.6; }
.task-id { font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; }
.status-value { color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); padding: 2px 10px; border-radius: 6px; }
.status-value[data-status='completed'], .status-value[data-status='success'] { color: var(--green); background: color-mix(in srgb, var(--green) 9%, transparent); }
.status-value[data-status='failed'], .status-value[data-status='error'] { color: var(--red); background: color-mix(in srgb, var(--red) 8%, transparent); }
.log-list { max-height: 330px; overflow: auto; margin-top: 9px; }
.empty-log { min-height: 100px; display: flex; align-items: center; justify-content: center; flex-direction: column; text-align: center; }
.empty-log strong { color: var(--secondary); font-size: 12px; font-weight: 400; }
.log-row { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 11px; line-height: 1.7; }
.log-row:last-child { border-bottom: 0; }
.log-row time { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.log-row > span { overflow-wrap: anywhere; }
.log-row.error { color: var(--red); }
.log-row.success { color: var(--green); }
.log-row.warn { color: #ad7400; }
.page-bottom-action { text-align: center; margin-top: 7px; }
.text-button { font-size: 12px; }
.text-button span { margin-left: 8px; }
.queue-card { max-width: 520px; margin: auto; padding: 25px 30px 23px; }
.queue-metric { display: flex; flex-direction: column; align-items: center; padding: 35px 0 38px; }
.queue-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; color: var(--secondary); }
.pulse-dot { height: 6px; width: 6px; border-radius: 50%; background: var(--green); }
.pulse-dot.muted { background: var(--muted); }
.queue-metric > strong { display: block; margin: 17px 0 5px; font-size: 94px; font-weight: 500; letter-spacing: -5px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.metric-label { color: var(--secondary); font-size: 12px; }
.queue-details { display: grid; gap: 13px; padding: 22px 0; border-top: 1px solid var(--line); }
.queue-details > div { display: flex; justify-content: space-between; gap: 20px; font-size: 11px; }
.queue-details span { color: var(--secondary); }
.queue-details strong { font-weight: 400; font-variant-numeric: tabular-nums; }
.queue-note { padding-top: 18px; border-top: 1px solid var(--line); color: var(--secondary); font-size: 10px; text-align: center; line-height: 1.7; }
.site-footer { width: min(1064px, calc(100% - 56px)); min-height: 66px; margin: 0 auto; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 10px; }
.footer-divider { color: var(--input-line); margin: 0 7px; }
.toast-region { position: fixed; z-index: 20; left: 50%; bottom: 28px; transform: translateX(-50%); display: grid; gap: 10px; width: min(480px, calc(100% - 32px)); pointer-events: none; }
.toast { display: flex; gap: 10px; align-items: center; background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: 0 6px 28px rgba(0, 0, 0, .1); border-radius: 15px; padding: 15px 18px; font-size: 12px; line-height: 1.6; animation: appear .25s ease both; overflow-wrap: anywhere; }
.toast::before { content: '✓'; display: grid; place-items: center; flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%; background: color-mix(in srgb, var(--green) 10%, transparent); color: var(--green); font-size: 11px; }
.toast.error::before { content: '!'; color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); }
.toast.info::before { content: 'i'; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
@keyframes appear { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 700px) {
  .topbar { padding: 0 20px; gap: 12px; min-height: 76px; }
  .brand-caption, .brand-divider { display: none; }
  .brand > span { font-size: 17px; }
  .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
  .brand { gap: 8px; }
  .page-nav a { min-width: auto; padding: 8px 12px; font-size: 11px; }
  .icon-button { width: 31px; height: 31px; }
  .site-page { padding: 54px 20px 54px; }
  .flow-page { padding-top: 49px; }
  h1 { letter-spacing: -1.2px; }
  .page-description { font-size: 13px; margin-top: 14px; }
  .page-intro { margin-bottom: 27px; }
  .hero-mark { margin-bottom: 24px; }
  .hero-mark img { width: 66px; height: 66px; border-radius: 20px; }
  .eyebrow { font-size: 8px; letter-spacing: 1.7px; }
  .flow-card { padding: 25px; border-radius: 22px; }
  .site-footer { width: calc(100% - 40px); min-height: 66px; font-size: 9px; }
  .task-query-form, .status-panel { padding: 22px; border-radius: 21px; }
  .search-row { flex-direction: column; }
  .search-row .primary-button { min-height: 45px; }
  .queue-card { padding: 22px 25px; border-radius: 22px; }
  .queue-metric > strong { font-size: 85px; }
}
@media (max-width: 480px) {
  .topbar { grid-template-columns: 1fr auto; padding-top: 12px; padding-bottom: 12px; gap: 10px; }
  .page-nav { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; }
  .page-nav a { flex: 1; }
  .header-actions { grid-column: 2; grid-row: 1; }
}
@media (max-width: 380px) {
  .topbar { padding: 0 13px; gap: 8px; }
  .brand > span { font-size: 14px; }
  .brand { gap: 6px; }
  .brand-mark { width: 26px; height: 26px; }
  .page-nav a { padding: 8px 10px; font-size: 10px; }
  .site-page { padding-left: 16px; padding-right: 16px; }
  .flow-card { padding: 22px; }
  .button-row { grid-template-columns: 87px 1fr; gap: 9px; }
  .primary-button, .ghost-button { padding-left: 14px; padding-right: 14px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* Current recharge feedback; status and processing records keep their existing layout. */
.current-task-content { max-width: 590px; margin-top: 22px; }
.history-record + .history-record { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 8px; }

/* Keep the existing recharge pulse, scoped to the submit button. */
#submitButton { position: relative; overflow: hidden; isolation: isolate; }
#submitButton > .submit-label, #submitButton > b { position: relative; z-index: 1; }
#submitButton .button-progress { position: absolute; inset: 0; pointer-events: none; }
#submitButton .progress-track { display: block; height: 100%; margin: 0; border-radius: inherit; background: transparent; }
#submitButton .progress-track > span { display: block; width: 35%; height: 100%; border-radius: inherit; background: rgba(255,255,255,.25); animation: recharge-pulse 1.6s ease-in-out infinite; }
#submitButton .progress-track[data-state='completed'] > span, #submitButton .progress-track[data-state='stopped'] > span { width: 100%; animation: none; transform: none; }
#submitButton .progress-track[data-state='completed'] > span { background: rgba(255,255,255,.12); }
#submitButton .progress-track[data-state='stopped'] > span { background: transparent; }
#submitButton[aria-busy='true'] { opacity: 1; cursor: wait; }
@keyframes recharge-pulse { from { transform: translateX(-110%); } to { transform: translateX(390%); } }
@media (prefers-reduced-motion: reduce) { .progress-track[data-state='running'] > span { width: 100%; opacity: .6; animation: none; } }

/* Explicit confirmation is scoped to one stale-token submission. */
.expiry-confirm-dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100svh - 48px); overflow-y: auto; box-sizing: border-box; padding: 28px; border: 1px solid var(--line); border-radius: 24px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.expiry-confirm-dialog::backdrop { background: rgba(0, 0, 0, .32); backdrop-filter: blur(5px); }
.expiry-confirm-dialog h2 { margin: 0 0 16px; font-size: 22px; letter-spacing: -.4px; }
.expiry-confirm-dialog p { color: var(--secondary); font-size: 13px; line-height: 1.8; }
.expiry-confirm-check { display: flex; align-items: flex-start; gap: 10px; margin: 22px 0; font-size: 14px; line-height: 1.7; cursor: pointer; }
.expiry-confirm-check input { flex: 0 0 18px; width: 18px; height: 18px; min-height: 18px; max-height: 18px; padding: 0; margin: 3px 0 0; appearance: auto; accent-color: var(--accent); box-shadow: none; }
.expiry-confirm-dialog .expiry-confirm-note { font-size: 12px; }
.expiry-confirm-actions { display: flex; gap: 12px; margin-top: 24px; }
.expiry-confirm-actions button { flex: 1; min-width: 0; }
