/* NOXXE NFC Tools — mobile-first, light/dark, no framework. */

@font-face {
  font-family: "Inter Tight";
  src: url("/fonts/inter-tight.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Archivo";
  src: url("/fonts/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --font-sans: "Inter Tight", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Archivo", var(--font-sans);
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --radius-s: 10px;
  --radius-m: 14px;
  --radius-l: 20px;
  --tap: 48px;
  --tabbar-h: 68px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* Light: NOXXE paper */
  --bg: #f1eee7;
  --surface: #f8f6f1;
  --surface-2: #eae6dd;
  --line: #d5cfc3;
  --text: #1b2533;
  --text-2: #526176;
  --ink: #02081c;
  --accent: #0272ac;
  --accent-hover: #03608f;
  --accent-soft: rgba(6, 182, 252, .14);
  --on-accent: #ffffff;
  --signal: #06b6fc;
  --star: #c98a00;
  --success: #157a3b;
  --success-soft: rgba(21, 122, 59, .12);
  --warn: #8a5300;
  --warn-soft: rgba(201, 138, 0, .14);
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, .1);
  --shadow: 0 1px 2px rgba(2, 8, 28, .06), 0 8px 24px rgba(2, 8, 28, .06);
  --tap-bg: #02081c;
  --tap-icon: #06b6fc;
  --tap-text: #f8f6f1;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #02081c;
    --surface: #061331;
    --surface-2: #0b1d45;
    --line: #17305f;
    --text: #e4ecf8;
    --text-2: #9fb3cc;
    --ink: #f8f6f1;
    --accent: #06b6fc;
    --accent-hover: #6ad3fd;
    --accent-soft: rgba(6, 182, 252, .16);
    --on-accent: #02081c;
    --star: #ffce3d;
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, .12);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, .12);
    --danger: #ff8a7a;
    --danger-soft: rgba(255, 138, 122, .12);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .3);
    --tap-bg: #06b6fc;
    --tap-icon: #02081c;
    --tap-text: #02081c;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #02081c;
  --surface: #061331;
  --surface-2: #0b1d45;
  --line: #17305f;
  --text: #e4ecf8;
  --text-2: #9fb3cc;
  --ink: #f8f6f1;
  --accent: #06b6fc;
  --accent-hover: #6ad3fd;
  --accent-soft: rgba(6, 182, 252, .16);
  --on-accent: #02081c;
  --star: #ffce3d;
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, .12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .12);
  --danger: #ff8a7a;
  --danger-soft: rgba(255, 138, 122, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .3);
  --tap-bg: #06b6fc;
  --tap-icon: #02081c;
  --tap-text: #02081c;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--font-display); color: var(--ink); margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--accent); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 6px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.icon .fill { fill: currentColor; stroke: none; }
.mono { font-family: var(--font-mono); font-size: .86em; }

/* ---------- Shell ---------- */
.app { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand-mark rect { fill: var(--ink); }
.brand-mark path { fill: none; stroke: var(--signal); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-family: var(--font-display); font-weight: 800; letter-spacing: .14em; font-size: 15px; }
.brand-text span { font-size: 12px; color: var(--text-2); letter-spacing: .02em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text);
  transition: background .2s var(--ease), transform .1s;
}
.icon-btn:active { transform: scale(.96); }
.api-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap;
}
.api-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.api-chip[data-ok="true"] { color: var(--success); background: var(--success-soft); }
.api-chip[data-ok="false"] { color: var(--warn); background: var(--warn-soft); }

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 6px 6px env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: 0; border-radius: 14px; text-decoration: none; color: var(--text-2);
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tab .icon { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.content {
  width: 100%; max-width: 640px; margin: 0 auto;
  padding: 20px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
}
.panel { display: flex; flex-direction: column; gap: 16px; animation: panel-in .28s var(--ease); }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.panel-title { font-size: clamp(24px, 6.4vw, 30px); font-weight: 750; line-height: 1.1; }
.panel-title-row { display: flex; align-items: center; gap: 10px; }
.panel-lead { color: var(--text-2); font-size: 15px; margin-top: -6px; }
.section-title { font-size: 17px; font-weight: 700; }
.hint { color: var(--text-2); font-size: 13.5px; }
.eyebrow { display: block; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }

/* ---------- Form controls ---------- */
.field-label { display: block; font-size: 13px; font-weight: 650; color: var(--text-2); margin-bottom: 6px; }
.input, .input-shell textarea {
  width: 100%; min-height: var(--tap);
  padding: 12px 14px; border-radius: var(--radius-m);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.input:focus, .input-shell textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--text-2) 75%, transparent); }
.input-shell { position: relative; }
.input-shell textarea {
  display: block; resize: vertical; min-height: 104px; max-height: 260px;
  padding-bottom: 52px; font-size: 15px; word-break: break-all;
}
.input-tools { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 8px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2);
  font-size: 13.5px; font-weight: 600; color: var(--text);
}
.chip-btn .icon { width: 16px; height: 16px; }
.converter { display: flex; flex-direction: column; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: var(--radius-m);
  border: 1px solid transparent; font-weight: 650; font-size: 15.5px; text-decoration: none;
  transition: background .2s var(--ease), border-color .2s var(--ease), transform .1s, opacity .2s;
  user-select: none; text-align: center;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; min-height: 54px; font-size: 16.5px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-small { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn-danger-text { color: var(--danger); }
.btn .spinner {
  display: none; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
.btn[aria-busy="true"] .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- Notices ---------- */
.notice {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px; border-radius: var(--radius-m);
  background: var(--surface); border: 1px solid var(--line); font-size: 14.5px;
}
.notice-title { display: flex; align-items: flex-start; gap: 8px; font-weight: 700; color: var(--ink); }
.notice-title .icon { margin-top: 1px; }
.notice-error { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: var(--danger-soft); }
.notice-error .notice-title { color: var(--danger); }
.notice-warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: var(--warn-soft); }
.notice-warn .notice-title { color: var(--warn); }
.notice-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.notice small { color: var(--text-2); }

/* ---------- Result ---------- */
.result {
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px; border-radius: var(--radius-l);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  animation: panel-in .3s var(--ease);
}
.result-head { display: flex; align-items: center; gap: 12px; }
.result-icon {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border-radius: 12px; background: var(--warn-soft); color: var(--star);
}
.result-icon .icon { fill: currentColor; }
.result-heading { flex: 1; min-width: 0; }
.result-name { font-size: 19px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.badge { flex: none; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; }
.badge[data-level="high"] { background: var(--success-soft); color: var(--success); }
.badge[data-level="medium"] { background: var(--warn-soft); color: var(--warn); }
.kv { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border-radius: var(--radius-s); background: var(--surface-2); }
.kv-key { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.kv-value { overflow-wrap: anywhere; word-break: break-all; font-size: 14px; }
.link-out { color: var(--accent); text-decoration: none; }
.warnings { margin: 0; padding: 10px 12px 10px 30px; border-radius: var(--radius-s); background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.action-grid .btn { padding: 0 10px; font-size: 14.5px; }

.qr-block { display: flex; align-items: center; gap: 16px; padding: 12px; border-radius: var(--radius-m); border: 1px dashed var(--line); }
.qr-frame {
  width: 128px; height: 128px; flex: none; padding: 8px; border-radius: 12px; background: #fff;
  display: grid; place-items: center;
}
.qr-frame svg { width: 100%; height: 100%; display: block; }
.qr-frame-lg { width: min(72vw, 300px); height: min(72vw, 300px); margin: 0 auto; }
.qr-actions { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.qr-caption { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }
.qr-actions .btn { min-height: 42px; font-size: 14px; }

/* ---------- Candidates ---------- */
.candidates { display: flex; flex-direction: column; gap: 10px; }
.candidate-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.candidate {
  display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: var(--radius-m);
  background: var(--surface); border: 1px solid var(--line);
}
.candidate-id { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); word-break: break-all; }
.candidate-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- Writer ---------- */
.writer { display: flex; flex-direction: column; gap: 10px; }
.toggles { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.toggle {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 60px;
  border-radius: var(--radius-m); background: var(--surface); border: 1px solid var(--line); cursor: pointer;
}
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-ui {
  position: relative; width: 44px; height: 26px; flex: none; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); transition: background .2s var(--ease);
}
.toggle-ui::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--text-2); transition: transform .22s var(--ease), background .2s;
}
.toggle input:checked + .toggle-ui { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-ui::after { transform: translateX(18px); background: var(--on-accent); }
.toggle-danger input:checked + .toggle-ui { background: var(--danger); border-color: var(--danger); }
.toggle input:focus-visible + .toggle-ui { outline: 2px solid var(--signal); outline-offset: 2px; }
.toggle input:disabled ~ * { opacity: .5; }
.toggle-text { display: flex; flex-direction: column; min-width: 0; }
.toggle-text strong { font-size: 15px; }
.toggle-text small { color: var(--text-2); font-size: 13px; line-height: 1.35; }

.tap-zone { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 12px 0 4px; }
.tap-target {
  position: relative; width: min(58vw, 220px); aspect-ratio: 1; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 0; background: var(--tap-bg); color: var(--tap-icon);
  box-shadow: 0 0 0 8px var(--accent-soft), var(--shadow);
  transition: transform .15s var(--ease), background .3s var(--ease), color .3s;
}
.tap-target:active { transform: scale(.97); }
.tap-target:disabled { opacity: .5; cursor: not-allowed; }
.tap-icon { width: 54px; height: 54px; stroke-width: 1.6; }
.tap-label { font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--tap-text); }
.tap-rings { position: absolute; inset: 0; pointer-events: none; }
.tap-rings i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; }
.tap-zone[data-state="waiting"] .tap-rings i { animation: ring 2.1s var(--ease) infinite; }
.tap-zone[data-state="waiting"] .tap-rings i:nth-child(2) { animation-delay: .7s; }
.tap-zone[data-state="waiting"] .tap-rings i:nth-child(3) { animation-delay: 1.4s; }
@keyframes ring { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(1.55); opacity: 0; } }
.tap-zone[data-state="success"] .tap-target { background: var(--success); color: #fff; }
.tap-zone[data-state="success"] .tap-label { color: #fff; }
.tap-zone[data-state="error"] .tap-target { background: var(--danger); color: #fff; }
.tap-zone[data-state="error"] .tap-label { color: #fff; }
.tap-status { text-align: center; color: var(--text-2); font-size: 15px; max-width: 34ch; min-height: 3em; }
.tap-zone[data-state="success"] .tap-status { color: var(--success); font-weight: 600; }
.tap-zone[data-state="error"] .tap-status { color: var(--danger); font-weight: 600; }

.counter {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-m);
  background: var(--surface); border: 1px solid var(--line);
}
.counter-value { font-family: var(--font-display); font-size: 30px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 2ch; }
.counter-label { flex: 1; color: var(--text-2); font-size: 14px; line-height: 1.3; }

/* ---------- Manage ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tool {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px 12px; min-height: 124px;
  border-radius: var(--radius-m); background: var(--surface); border: 1px solid var(--line); text-align: left; color: var(--text);
  transition: border-color .2s var(--ease), transform .1s;
}
.tool:active { transform: scale(.98); }
.tool .icon { width: 26px; height: 26px; color: var(--accent); margin-bottom: auto; }
.tool strong { font-size: 15px; line-height: 1.2; }
.tool small { color: var(--text-2); font-size: 12.5px; line-height: 1.3; }
.tool-danger .icon { color: var(--danger); }
.tool:disabled { opacity: .5; cursor: not-allowed; }
.op-status {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius-m);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
}
.op-text { flex: 1; font-weight: 600; font-size: 14.5px; }
.op-pulse { width: 14px; height: 14px; flex: none; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.op-status[data-state="success"] { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 40%, var(--line)); }
.op-status[data-state="success"] .op-pulse { background: var(--success); animation: none; }
.op-status[data-state="error"] { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.op-status[data-state="error"] .op-pulse { background: var(--danger); animation: none; }
@keyframes pulse { 0%, 100% { transform: scale(.8); opacity: .6; } 50% { transform: scale(1.15); opacity: 1; } }
.read-result { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: var(--radius-l); background: var(--surface); border: 1px solid var(--line); }
.record-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.record { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: var(--radius-s); background: var(--surface-2); }
.record-type { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.record-data { overflow-wrap: anywhere; word-break: break-all; font-size: 14px; }
.record-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- History ---------- */
.count-pill { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.search-shell {
  display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: var(--radius-m);
  background: var(--surface); border: 1px solid var(--line);
}
.search-shell .icon { color: var(--text-2); }
.input-bare { border: 0; background: transparent; padding-left: 0; box-shadow: none !important; }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history-item { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: var(--radius-m); background: var(--surface); border: 1px solid var(--line); }
.history-top { display: flex; align-items: flex-start; gap: 10px; }
.history-name { flex: 1; min-width: 0; font-weight: 700; font-size: 15.5px; color: var(--ink); overflow-wrap: anywhere; }
.history-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--text-2); }
.history-id { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); word-break: break-all; }
.history-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.history-actions .btn { min-height: 40px; padding: 0 6px; font-size: 13px; gap: 5px; }
.history-actions .icon { width: 17px; height: 17px; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 16px; text-align: center; color: var(--text-2); font-size: 14.5px; }
.empty .icon { width: 32px; height: 32px; opacity: .6; }
.history-tools { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Dialogs & toasts ---------- */
.dialog {
  width: min(92vw, 420px); padding: 0; border: 1px solid var(--line); border-radius: var(--radius-l);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(2, 8, 28, .55); backdrop-filter: blur(2px); }
.dialog[open] { animation: panel-in .22s var(--ease); }
.dialog-body { display: flex; flex-direction: column; gap: 14px; padding: 20px; margin: 0; }
.dialog-title { font-size: 19px; }
.dialog-text { color: var(--text-2); font-size: 15px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
#confirm-dialog[data-danger="true"] #confirm-ok { background: var(--danger); color: #fff; }

.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(92vw, 420px); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border-radius: var(--radius-m);
  background: var(--ink); color: var(--bg); font-size: 14.5px; font-weight: 600; box-shadow: var(--shadow);
  animation: toast-in .25s var(--ease);
}
.toast .icon { color: var(--signal); }
.toast[data-kind="error"] .icon { color: var(--danger); }
.toast.leaving { animation: toast-out .2s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- Small phones (320px) ---------- */
@media (max-width: 359px) {
  .content { padding-left: 12px; padding-right: 12px; }
  .brand-text span { display: none; }
  .tab { font-size: 10.5px; }
  .tool-grid { grid-template-columns: 1fr; }
  .tool { min-height: 0; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .tool .icon { margin-bottom: 0; }
  .tool small { flex-basis: 100%; }
  .qr-block { flex-direction: column; align-items: stretch; }
  .qr-frame { margin: 0 auto; }
  .history-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .action-grid .btn { font-size: 13.5px; }
}

/* ---------- Desktop: side rail ---------- */
@media (min-width: 960px) {
  .app { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; padding-left: 24px; padding-right: 24px; }
  .tabbar {
    position: sticky; top: 72px; inset: auto; align-self: start;
    display: flex; flex-direction: column; gap: 4px; height: auto; padding: 20px 12px;
    background: transparent; border: 0; backdrop-filter: none;
  }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 14px; font-size: 15px; }
  .content { padding: 32px 24px 64px; margin: 0; max-width: 680px; }
  .toasts { bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
