:root {
  color-scheme: light;
  --canvas: #edf2ef;
  --paper: #ffffff;
  --paper-soft: #f6f8f7;
  --ink: #18211f;
  --muted: #68736f;
  --line: #d5ddd9;
  --line-strong: #bcc9c3;
  --output: #e8f0ed;
  --output-line: #c8d7d1;
  --forest: #173b35;
  --forest-deep: #102d28;
  --forest-muted: #93afa6;
  --mint: #45d7a4;
  --mint-dark: #087a5c;
  --amber: #e5ad55;
  --danger: #c93f48;
  --shadow: 0 24px 64px rgba(28, 48, 41, 0.14);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

button,
textarea { font: inherit; }

button { cursor: pointer; }
button, a { touch-action: manipulation; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10;
  padding: 9px 12px;
  border-radius: 6px;
  background: #ffffff;
  color: var(--forest-deep);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }

button:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(69, 215, 164, 0.42);
  outline-offset: 3px;
}

.page-shell {
  width: min(1040px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  margin-bottom: 22px;
}

.brand {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--forest);
  color: var(--mint);
  box-shadow: 0 8px 20px rgba(23, 59, 53, 0.16);
}

.brand-mark svg { width: 22px; height: 22px; stroke-width: 2; }

.brand-copy { display: grid; line-height: 1.12; }
.brand-copy strong { font-size: 18px; font-weight: 760; }
.brand-copy span { color: var(--muted); font-size: 12px; font-weight: 600; }

.privacy-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.62);
  color: #53615c;
  font-size: 12px;
  font-weight: 680;
}

.privacy-state svg { width: 15px; height: 15px; color: var(--mint-dark); }

.authenticator {
  display: grid;
  grid-template-columns: minmax(330px, 0.86fr) minmax(0, 1.14fr);
  min-height: 540px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.code-panel,
.input-panel {
  min-width: 0;
  padding: 34px 36px;
}

.code-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--output-line);
  background: var(--output);
  color: var(--ink);
}

.input-panel {
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--mint-dark);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0;
}

.input-heading .eyebrow { color: var(--mint-dark); }

h1,
h2 {
  margin: 0;
  font-size: 23px;
  font-weight: 740;
  letter-spacing: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--output-line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.52);
  color: #60706a;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8da59d;
}

.status-pill.is-ready { color: #086c52; border-color: rgba(8, 122, 92, 0.28); background: rgba(255, 255, 255, 0.7); }
.status-pill.is-ready .status-dot { background: #20a77f; box-shadow: 0 0 0 4px rgba(32, 167, 127, 0.12); }

.code-stage {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  min-height: 300px;
  padding: 38px 0 28px;
}

.code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}

.token-code {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 20px;
  color: var(--forest-deep);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 72px;
  font-weight: 680;
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.token-code span { display: inline-block; min-width: 3ch; transition: color 180ms ease, transform 180ms ease; }
.token-code.is-updating span { transform: translateY(-2px); color: var(--mint-dark); }

.copy-button,
.icon-button,
.paste-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 7px;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.copy-button {
  flex: none;
  border: 1px solid var(--output-line);
  background: rgba(255, 255, 255, 0.74);
  color: var(--forest);
  box-shadow: 0 5px 14px rgba(34, 67, 58, 0.08);
}

.copy-button:hover:not(:disabled) { border-color: #7eb6a4; background: #ffffff; color: var(--mint-dark); }
.copy-button:active:not(:disabled) { transform: translateY(1px); }
.copy-button:disabled { color: #8b9b95; box-shadow: none; cursor: default; }
.copy-button.is-copied { border-color: #9fd7c3; background: #d8f2e8; color: var(--mint-dark); }
.copy-button svg { width: 19px; height: 19px; stroke-width: 2; }

.timer-block { margin-top: 36px; }

.timer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: #667670;
  font-size: 12px;
}

.timer-meta span { display: inline-flex; align-items: center; gap: 7px; }
.timer-meta svg { width: 15px; height: 15px; }
.timer-meta strong { min-width: 50px; color: var(--forest-deep); font-family: "SFMono-Regular", Consolas, monospace; font-size: 13px; text-align: right; }
.timer-meta strong.is-warning { color: var(--amber); }

progress {
  display: block;
  width: 100%;
  height: 8px;
  overflow: hidden;
  appearance: none;
  border: 0;
  border-radius: 4px;
  background: #cbd8d3;
}

progress::-webkit-progress-bar { background: #cbd8d3; }
progress::-webkit-progress-value { border-radius: 4px; background: #2aaa82; transition: width 220ms linear, background-color 180ms ease; }
progress::-moz-progress-bar { border-radius: 4px; background: #2aaa82; transition: background-color 180ms ease; }
progress.is-warning::-webkit-progress-value { background: var(--amber); }
progress.is-warning::-moz-progress-bar { background: var(--amber); }

.account-meta {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  margin: 0;
  padding-top: 20px;
  border-top: 1px solid var(--output-line);
}

.account-meta[hidden] { display: none; }
.account-meta div { min-width: 0; }
.account-meta div + div { padding-left: 22px; border-left: 1px solid var(--output-line); }
.account-meta dt { margin-bottom: 3px; color: #6f807a; font-size: 11px; }
.account-meta dd { overflow: hidden; margin: 0; color: var(--forest-deep); font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }

.icon-button {
  border: 1px solid var(--line);
  background: var(--paper-soft);
  color: var(--muted);
}

.icon-button:hover { border-color: var(--line-strong); background: #edf3f0; color: var(--ink); }
.icon-button svg { width: 18px; height: 18px; }

.field-group { margin-top: 54px; }

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.field-label-row label { color: var(--ink); font-size: 13px; font-weight: 680; }

.paste-button {
  gap: 7px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--mint-dark);
  font-size: 12px;
  font-weight: 700;
}

.paste-button:hover { border-color: #cde4da; background: #edf8f3; }
.paste-button svg { width: 16px; height: 16px; }

.textarea-shell { position: relative; }

textarea {
  width: 100%;
  min-height: 172px;
  padding: 17px 46px 17px 16px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--paper-soft);
  color: var(--ink);
  outline: none;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.65;
}

textarea::placeholder { color: #99a49f; }
textarea:hover { border-color: #9fb1a8; }
textarea:focus { border-color: var(--mint-dark); background: #ffffff; box-shadow: 0 0 0 3px rgba(8, 122, 92, 0.11); }

.field-icon {
  position: absolute;
  top: 16px;
  right: 15px;
  width: 18px;
  height: 18px;
  color: #87938e;
  pointer-events: none;
}

.message {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.message.error { color: var(--danger); }
.message.success { color: var(--mint-dark); }

.input-status {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.input-status-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: none;
  place-items: center;
  border-radius: 7px;
  background: #e9f6f0;
  color: var(--mint-dark);
}

.input-status-icon svg { width: 17px; height: 17px; }
.input-status > span:last-child { display: grid; line-height: 1.3; }
.input-status small { color: var(--muted); font-size: 10px; }
.input-status strong { color: var(--ink); font-size: 12px; font-weight: 700; }

.page-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding-top: 20px;
  color: #74807b;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
}

@media (max-width: 760px) {
  .page-shell { width: min(100% - 24px, 620px); padding: 14px 0 24px; }
  .topbar { min-height: 44px; margin-bottom: 14px; }
  .brand-mark { width: 38px; height: 38px; }
  .privacy-state { min-height: 32px; }
  .authenticator { grid-template-columns: 1fr; min-height: 0; }
  .code-panel, .input-panel { padding: 26px 22px; }
  .input-panel { min-height: 380px; }
  .code-panel { border-top: 1px solid var(--output-line); border-left: 0; }
  .code-stage { min-height: 245px; padding: 34px 0 22px; }
  .token-code { gap: 12px; font-size: 52px; }
  .code-row { gap: 14px; }
  .timer-block { margin-top: 28px; }
  .field-group { margin-top: 34px; }
  textarea { min-height: 142px; }
}

@media (max-width: 390px) {
  .privacy-state span { display: none; }
  .privacy-state { width: 34px; min-width: 34px; padding: 0; justify-content: center; }
  .status-pill { min-height: 28px; padding: 0 8px; }
  .code-panel, .input-panel { padding-right: 18px; padding-left: 18px; }
  .token-code { font-size: 46px; }
  .copy-button { min-width: 44px; min-height: 44px; }
}

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