:root {
  color-scheme: light;
  --canvas: #f3f6fa;
  --paper: #fff;
  --navy: #17334d;
  --muted: #586d80;
  --line: #dbe5ed;
  --teal: #087a76;
  --teal-soft: #e4f5f1;
  --red: #a2293f;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--navy);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, p, ul { margin: 0; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #397ec2; outline-offset: 3px; }
button, input { min-height: 44px; border: 1px solid #bccddb; border-radius: 7px; color: var(--navy); background: var(--paper); }
input { width: 100%; padding: 10px 12px; }
button { padding: 8px 15px; font-weight: 600; cursor: pointer; }
button:hover { background: var(--canvas); }
button:disabled { opacity: .6; cursor: default; }
.primary { color: white; border-color: var(--teal); background: var(--teal); }
.primary:hover:not(:disabled) { background: #066764; }
.muted { color: var(--muted); }
.message { font-size: .875rem; }
.message[data-error] { color: var(--red); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.topbar {
  display: flex;
  min-height: 68px;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px max(20px, calc((100% - 980px) / 2));
  background: var(--navy);
}
.back { display: flex; align-items: center; min-height: 44px; color: #ebf4fb; text-decoration: none; }
.back:hover { text-decoration: underline; }
.topbar button { border-color: #68879e; color: #ebf4fb; background: transparent; }
.topbar button:hover { background: #24455e; }
main { width: min(calc(100% - 40px), 980px); margin: 0 auto; padding: 32px 0 48px; }
.page-heading { margin-bottom: 24px; }
h1 { font-size: clamp(1.75rem, 5vw, 2.125rem); line-height: 1.2; }
h2 { font-size: 1.125rem; }
.page-heading p, #gate-help { color: var(--muted); margin-top: 8px; }
.panel { min-width: 0; padding: clamp(16px, 4vw, 26px); border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.vault-gate { max-width: 470px; }
.vault-gate form, .field { display: grid; gap: 8px; }
.vault-gate form { margin-top: 20px; }
.vault-gate label { font-size: .875rem; font-weight: 600; }
.vault-gate .field { margin: 6px 0; }
.vault-gate button { margin-top: 8px; justify-self: start; }

.workspace-tools { display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: flex-end; align-items: center; margin-bottom: 14px; }
.workspace-tools p { flex: 1; }
.workspace-tools p:empty { display: none; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.18fr); align-items: start; gap: 16px; }
.account-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
#account-count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .875rem; }
#list-empty, #code-empty { margin-top: 14px; }
.accounts, .import-preview { display: grid; list-style: none; padding: 0; max-height: 400px; overflow: auto; }
.accounts { margin-top: 12px; }
.accounts li + li { border-top: 1px solid var(--line); }
.accounts button { width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; overflow-wrap: anywhere; }
.accounts button:hover { background: var(--canvas); }
.accounts button[aria-pressed="true"] { color: #125b5c; background: var(--teal-soft); }
.accounts button:focus-visible, #import-preview:focus-visible { outline-offset: -3px; }
.account-name { display: block; font-size: .875rem; overflow-wrap: anywhere; }
.current-panel { border-top: 3px solid #2da294; }
.code-site { display: block; margin-top: 18px; overflow-wrap: anywhere; }
.code-value {
  margin: 16px 0 8px;
  color: #125b5c;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: clamp(1.55rem, 7vw, 3.125rem);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: .11em;
  user-select: all;
}
.code-timing { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; font-variant-numeric: tabular-nums; font-size: .875rem; }
.code-timing progress { width: 100%; height: 9px; accent-color: var(--teal); }
.code-timing span { flex-shrink: 0; }
#copy-status:not(:empty) { margin-top: 10px; }

dialog {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  padding: clamp(16px, 4vw, 26px);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--navy);
  background: var(--paper);
}
dialog::backdrop { background: #1028428a; }
dialog h2 { margin-bottom: 10px; }
.import-actions, .dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.dialog-actions { justify-content: flex-end; margin-top: 20px; }
#camera { display: block; width: 100%; max-height: 250px; object-fit: contain; margin-top: 12px; border-radius: 8px; background: var(--navy); }
#import-status { margin-top: 12px; }
.import-preview { max-height: 195px; margin-top: 12px; border-top: 1px solid var(--line); }
.import-preview li { padding: 8px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }

@media (max-width: 650px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .accounts { max-height: 240px; }
}
