:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1b1f27;
  --muted: #5f6878;
  --line: #dde2ea;
  --brand: #1a73e8;
  --brand-ink: #ffffff;
  --ok: #137333;
  --err: #c5221f;
  --field: #f7f9fc;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101319;
    --card: #1a1e27;
    --text: #e9edf3;
    --muted: #9aa4b5;
    --line: #2c3340;
    --brand: #8ab4f8;
    --brand-ink: #0b1b33;
    --ok: #81c995;
    --err: #f28b82;
    --field: #141821;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(16px + env(safe-area-inset-top)) 16px 8px;
  max-width: 560px; margin: 0 auto;
}
.logo {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  background: var(--brand); color: #fbbc04;
  display: grid; place-items: center; font-size: 26px;
}
h1 { font-size: 20px; margin: 0; }
.top p { margin: 0; color: var(--muted); font-size: 14px; }
main { max-width: 560px; margin: 0 auto; padding: 8px 16px 32px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
h2 { font-size: 17px; margin: 0 0 10px; }
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
textarea, input[type=text] {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--field); color: var(--text); font: inherit; resize: vertical;
}
textarea:focus, input:focus, .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.row { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.row.between { justify-content: space-between; margin-top: 0; }
.row.between h2 { margin: 0; }
.grow { flex: 1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  min-height: 46px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: 14px; }
.btn.block { display: flex; width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:active:not(:disabled) { transform: scale(.98); }
.status { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.status.err { color: var(--err); }
.status.ok { color: var(--ok); }
.result { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.res-name { font-weight: 700; font-size: 17px; margin: 0 0 8px; overflow-wrap: anywhere; }
.note { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.qr { margin-top: 14px; display: grid; gap: 10px; justify-items: center; }
.qr canvas { width: min(260px, 100%); height: auto; border-radius: 10px; background: #fff; }
.muted { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.steps { margin: 12px 0 0; padding-left: 20px; color: var(--muted); font-size: 14px; }
.steps li + li { margin-top: 4px; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.hist li:first-child { border-top: 0; }
.hist .info { flex: 1; min-width: 0; background: none; border: 0; padding: 0; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.hist .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist .l { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#histEmpty { margin: 8px 0 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #202124; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px;
  max-width: calc(100% - 32px); box-shadow: 0 4px 16px rgba(0,0,0,.3); z-index: 10;
}
[hidden] { display: none !important; }
