:root {
  --bg: #fff4e0;
  --paper: #ffffff;
  --ink: #000000;
  --muted: #4a4a4a;
  --yellow: #ffd23f;
  --pink: #ff90e8;
  --blue: #90c2ff;
  --green: #b8f27c;
  --orange: #ff9f5a;
  --red: #ff5c5c;
  --purple: #c4a1ff;
  --bw: 3px;
  --sh: 5px 5px 0 var(--ink);
  --sh-sm: 3px 3px 0 var(--ink);
  --r: 10px;
  --font: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Archivo Black', 'Arial Black', sans-serif;
  --mono: 'Space Mono', ui-monospace, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(0, 0, 0, 0.13) 1.2px, transparent 1.2px);
  background-size: 18px 18px;
  color: var(--ink);
  font: 500 16px/1.45 var(--font);
}
h1, h2, h3 { font-family: var(--display); font-weight: 400; letter-spacing: -0.02em; margin: 0 0 8px; line-height: 1.1; }
h2 { font-size: 22px; }
h3 { font-size: 18px; display: flex; align-items: center; gap: 10px; }
p { margin: 0 0 10px; }
a { color: var(--ink); font-weight: 700; text-decoration-thickness: 2px; text-underline-offset: 3px; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 24px; }
.row { display: flex; align-items: center; }
.row.gap, .gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.center-row { justify-content: center; }
.stack { display: flex; flex-direction: column; gap: 18px; }

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: square; stroke-linejoin: miter; flex: none; }

/* ---------- surfaces ---------- */
.card {
  background: var(--paper);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--sh);
  padding: 18px;
}

/* ---------- buttons ---------- */
.btn, .ibtn, .chip, .tab, .pill, .seg button {
  font: 700 15px/1 var(--font);
  color: var(--ink);
  border: var(--bw) solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--sh-sm);
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; min-height: 46px; text-decoration: none; }
.btn:hover, .ibtn:hover, .chip:hover, .tab:hover, .pill:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active, .ibtn:active, .chip:active, .tab:active, .pill:active, .seg button:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn:focus-visible, .ibtn:focus-visible, .chip:focus-visible, .tab:focus-visible, .item:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .seg button:focus-visible {
  outline: 3px solid var(--ink); outline-offset: 3px;
}
.btn-yellow { background: var(--yellow); }
.btn-blue { background: var(--blue); }
.btn-pink { background: var(--pink); }
.btn-green { background: var(--green); }
.btn-red { background: var(--red); }
.btn-ghost { box-shadow: none; border-style: dashed; }
.btn-lg { min-height: 54px; font-size: 17px; padding: 14px 20px; }
.btn.small { min-height: 38px; padding: 8px 12px; font-size: 14px; }
.btn.wide { width: 100%; }
.ibtn { width: 42px; height: 42px; display: inline-grid; place-items: center; padding: 0; flex: none; text-decoration: none; }
.ibtn.small { width: 36px; height: 36px; box-shadow: 2px 2px 0 var(--ink); }
.ibtn.small .ic { width: 17px; height: 17px; }
.ibtn.yellow { background: var(--yellow); }

/* ---------- forms ---------- */
label { display: block; font-weight: 700; margin: 14px 0 6px; font-size: 14px; }
input, select, textarea {
  width: 100%;
  font: 500 16px/1.3 var(--font);
  color: var(--ink);
  background: var(--paper);
  border: var(--bw) solid var(--ink);
  border-radius: 8px;
  padding: 12px 13px;
  min-height: 48px;
}
input:focus, select:focus, textarea:focus { outline: none; background: #fffbea; box-shadow: var(--sh-sm); }
textarea { resize: vertical; min-height: 96px; }
input[type='checkbox'] { width: 24px; height: 24px; min-height: 0; padding: 0; accent-color: var(--ink); flex: none; margin: 0; }
input[type='range'] { padding: 0; min-height: 0; border: 0; accent-color: var(--ink); height: 32px; background: transparent; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 12px 0; cursor: pointer; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input { flex: 1; min-width: 0; }
.err { color: #b00000; font-weight: 700; min-height: 0; margin: 8px 0; }
.err:empty { display: none; }
.form .row.end { margin-top: 16px; }

.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button { padding: 10px 14px; min-height: 42px; box-shadow: 2px 2px 0 var(--ink); flex: 1; }
.seg button.on { background: var(--ink); color: var(--paper); box-shadow: 2px 2px 0 var(--yellow); }
.seg.small button { flex: none; padding: 8px 10px; min-height: 36px; font-size: 13px; }
.seg.big button { font-size: 16px; min-height: 48px; }

/* ---------- lock screen ---------- */
.lock-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 16px; }
.lock-card { width: 100%; max-width: 440px; padding: 26px 22px; box-shadow: 8px 8px 0 var(--ink); }
.lock-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; padding: 12px 14px; background: var(--yellow); border: var(--bw) solid var(--ink); border-radius: var(--r); }
.lock-logo h1 { margin: 0; }
.lock-logo p { margin: 0; }
.brand { font-family: var(--display); font-size: 28px; letter-spacing: -0.04em; }
.lock-card .btn-lg { margin-top: 14px; }
.lock-card .btn-ghost { margin-top: 10px; }
.lock-card > p.center { margin: 16px 0 0; }
.foot { margin-top: 18px; }
.warn-box { display: flex; gap: 10px; align-items: flex-start; background: var(--pink); border: var(--bw) solid var(--ink); border-radius: 8px; padding: 12px; margin-top: 14px; font-size: 14px; }
.warn-box .ic { margin-top: 2px; }
.busy { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-top: 10px; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--ink); border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.steps { padding-left: 22px; margin: 8px 0 16px; }
.steps li { margin: 6px 0; }

/* ---------- shell ---------- */
.shell { max-width: 980px; margin: 0 auto; padding: 0 16px 110px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 0 12px; }
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-row .brand { font-size: 24px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; font-size: 13px; border-radius: 999px; box-shadow: 2px 2px 0 var(--ink); }
.pill .ic { width: 16px; height: 16px; }
.pill.ok { background: var(--green); }
.pill.busy { background: var(--yellow); }
.pill.warn { background: var(--orange); }
.pill.bad { background: var(--red); }

.tabs { display: flex; gap: 10px; margin: 6px 0 20px; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px; }
.tab.active { background: var(--yellow); }

@media (max-width: 720px) {
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0;
    background: var(--paper); border-top: var(--bw) solid var(--ink);
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); gap: 6px;
  }
  .tab { flex: 1; flex-direction: column; gap: 4px; padding: 8px 4px; font-size: 12px; box-shadow: none; border-width: 2px; }
  .tab.active { box-shadow: 2px 2px 0 var(--ink); }
  .pill span, .pill { font-size: 12px; }
  .brand-row .brand { font-size: 21px; }
  .card { padding: 15px; }
}

/* ---------- vault ---------- */
.search-row { display: flex; gap: 10px; margin-bottom: 14px; }
.search-box { flex: 1; position: relative; }
.search-box .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search { padding-left: 42px; box-shadow: var(--sh-sm); min-height: 48px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 4px 10px 0; margin-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { padding: 8px 12px; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; font-size: 14px; box-shadow: 2px 2px 0 var(--ink); }
.chip.on { background: var(--ink); color: var(--paper); box-shadow: 2px 2px 0 var(--yellow); }
.count { font-size: 12px; padding: 1px 7px; border-radius: 99px; border: 2px solid currentColor; }
.count.big { font-size: 14px; padding: 2px 10px; border-color: var(--ink); background: var(--paper); }
.count.bad { background: var(--red); }
.count.warn { background: var(--orange); }

.list { display: flex; flex-direction: column; gap: 12px; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--paper); border: var(--bw) solid var(--ink); border-radius: var(--r); box-shadow: var(--sh-sm);
  cursor: pointer; transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.item:hover { transform: translate(-2px, -2px); box-shadow: var(--sh); }
.item:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.list.compact .item { box-shadow: 2px 2px 0 var(--ink); padding: 9px; }
.tile {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border: var(--bw) solid var(--ink); border-radius: 8px; font: 400 21px/1 var(--display);
}
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 8px; align-items: center; }
.item-actions { display: flex; gap: 8px; }
.fav { color: #d18f00; }
.fix { font-weight: 700; font-size: 14px; white-space: nowrap; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; border: 2px solid var(--ink); border-radius: 6px; background: var(--blue); color: var(--ink); }
.empty { text-align: center; padding: 30px 20px; }
.empty .row { margin-top: 14px; }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 24px; overflow-y: auto;
  animation: fade 0.12s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-width: 520px; background: var(--paper); border: var(--bw) solid var(--ink); border-radius: 12px; box-shadow: 9px 9px 0 var(--ink); animation: pop 0.14s ease; }
.sheet.wide { max-width: 860px; }
@keyframes pop { from { transform: translateY(14px); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px 12px 18px; background: var(--yellow); border-bottom: var(--bw) solid var(--ink); border-radius: 9px 9px 0 0; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet-body { padding: 18px; }
@media (max-width: 560px) {
  .overlay { padding: 0; align-items: flex-end; }
  .sheet { border-radius: 14px 14px 0 0; box-shadow: none; border-bottom: 0; max-height: 92vh; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); }
}

.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.detail-head .tile { width: 56px; height: 56px; font-size: 26px; }
.detail-title { font: 400 22px/1.15 var(--display); word-break: break-word; margin-bottom: 4px; }
.field { border: var(--bw) solid var(--ink); border-radius: 8px; padding: 10px 12px; margin: 12px 0; background: #fffdf7; }
.field-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.field-row { display: flex; align-items: center; gap: 10px; }
.field-value { flex: 1; min-width: 0; word-break: break-all; display: flex; align-items: center; gap: 8px; }
.field-value > span:first-child { flex: 1; }
.field-actions { display: flex; gap: 8px; }
.notes { white-space: pre-wrap; word-break: break-word; font-weight: 500; }
.badge { font-size: 11px; padding: 1px 7px; border: 2px solid var(--ink); border-radius: 5px; letter-spacing: 0.02em; text-transform: none; }
.secret { font-size: 15px; }
.totp { flex: 1; }
.totp-code { font-size: 30px; font-weight: 700; letter-spacing: 0.06em; }
.totp-bar { height: 8px; border: 2px solid var(--ink); border-radius: 4px; margin-top: 6px; overflow: hidden; background: var(--paper); }
.totp-fill { height: 100%; background: var(--green); transition: width 1s linear; }
.totp-fill.low { background: var(--red); }
.history { border: var(--bw) solid var(--ink); border-radius: 8px; padding: 10px 12px; margin: 12px 0; }
.history summary { cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: 8px; list-style: none; }
.history summary::-webkit-details-marker { display: none; }
.hist-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 2px dashed #0003; margin-top: 8px; flex-wrap: wrap; }
.detail .row.end { margin-top: 16px; }

/* ---------- meter ---------- */
.meter { margin: 10px 0 4px; }
.meter-bar { height: 14px; border: var(--bw) solid var(--ink); border-radius: 6px; background: var(--paper); overflow: hidden; }
.meter-fill { height: 100%; border-right: var(--bw) solid var(--ink); transition: width 0.2s ease; }
.meter-text { font-size: 13px; margin-top: 5px; }

/* ---------- generator ---------- */
.gen-card { background: var(--paper); }
.gen-out {
  margin: 16px 0 6px; padding: 18px 16px; min-height: 84px;
  font-size: 24px; font-weight: 700; line-height: 1.35; word-break: break-all;
  background: var(--yellow); border: var(--bw) solid var(--ink); border-radius: 8px; box-shadow: inset 4px 4px 0 rgba(0, 0, 0, 0.12);
}
.c-num { color: #0047d6; }
.c-sym { color: #c4004f; }
.gen-card .row { margin-top: 14px; }
.slider { margin: 6px 0 12px; }
.slider-val { font-family: var(--mono); font-size: 18px; border: 2px solid var(--ink); border-radius: 6px; padding: 0 8px; background: var(--yellow); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.recent-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 2px dashed #0003; word-break: break-all; }

/* ---------- health ---------- */
.health-top { display: flex; gap: 20px; align-items: flex-start; }
.score { width: 112px; height: 112px; flex: none; border: var(--bw) solid var(--ink); border-radius: 50%; box-shadow: var(--sh-sm); display: grid; place-content: center; text-align: center; }
.score b { font: 400 40px/1 var(--display); }
.score span { font-size: 12px; font-weight: 700; text-transform: uppercase; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }
.stat { border: 2px solid var(--ink); border-radius: 6px; padding: 3px 9px; font-size: 14px; background: var(--bg); }
@media (max-width: 560px) { .health-top { flex-direction: column; align-items: center; text-align: center; } .stats { justify-content: center; } }

/* ---------- settings ---------- */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.setting select { width: auto; min-width: 170px; }

/* ---------- import ---------- */
.map-table { display: flex; gap: 10px; overflow-x: auto; padding: 2px 4px 10px 0; }
.map-col { min-width: 170px; flex: none; border: var(--bw) solid var(--ink); border-radius: 8px; padding: 8px; background: var(--paper); }
.map-col.off { background: #eee; opacity: 0.75; }
.map-head { font-weight: 700; font-size: 13px; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-col select { min-height: 40px; padding: 6px 8px; font-size: 14px; }
.map-cell { font-size: 12px; padding: 5px 2px; border-top: 2px dashed #0002; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- PIN pad ---------- */
.pin-pad { margin-top: 6px; }
.pin-pad h2 { margin: 6px 0 4px; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 16px 0 6px; }
.pin-dot { width: 20px; height: 20px; border: var(--bw) solid var(--ink); border-radius: 50%; background: var(--paper); transition: background 0.1s ease; }
.pin-dot.on { background: var(--ink); box-shadow: 2px 2px 0 var(--yellow); }
.pin-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 300px; margin: 14px auto 6px; }
.pin-key {
  height: 62px; font: 400 26px/1 var(--display); color: var(--ink); background: var(--paper);
  border: var(--bw) solid var(--ink); border-radius: 12px; box-shadow: var(--sh-sm); cursor: pointer;
  display: grid; place-items: center; -webkit-tap-highlight-color: transparent; transition: transform 0.05s ease, box-shadow 0.05s ease;
}
.pin-key:hover { background: #fffbea; }
.pin-key:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); background: var(--yellow); }
.pin-key.del { background: var(--pink); }
.pin-key:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.pin-pad.busy .pin-keys { opacity: 0.5; pointer-events: none; }
.pin-pad.shake .pin-dots { animation: shake 0.35s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.count.on { background: var(--green); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; z-index: 80; transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); font-weight: 700; padding: 12px 18px; border-radius: 8px;
  border: var(--bw) solid var(--ink); box-shadow: 4px 4px 0 var(--yellow); transition: all 0.18s ease; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { box-shadow: 4px 4px 0 var(--red); }
@media (min-width: 721px) { .toast { bottom: 28px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
