/* Layout: one-column phone app. Sticky header with search + tag filter, scrolling list, floating add button, bottom sheet editor. */
:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --ink: #17212c;
  --muted: #5d6b7a;
  --line: #d5dce3;
  --accent: #2f5bd3;
  --accent-ink: #ffffff;
  --tag: #b8560f;
  --tag-soft: #fbeadb;
  --value-soft: #e7ecf3;
  --hit: #ffe27a;
  --danger: #b3261e;
  --display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: ui-monospace, Menlo, monospace;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10161d; --surface: #19222c; --ink: #e8edf2; --muted: #93a2b2; --line: #2b3744;
    --accent: #7c9cff; --accent-ink: #0c1320; --tag: #f0a15c; --tag-soft: #3a2a1c;
    --value-soft: #243140; --hit: #6b5a12; --danger: #ff8a80; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #10161d; --surface: #19222c; --ink: #e8edf2; --muted: #93a2b2; --line: #2b3744;
  --accent: #7c9cff; --accent-ink: #0c1320; --tag: #f0a15c; --tag-soft: #3a2a1c;
  --value-soft: #243140; --hit: #6b5a12; --danger: #ff8a80; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--body); -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }

header { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 14px 16px 10px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font: 700 22px/1.1 var(--display); margin: 0; letter-spacing: -0.01em; }
.count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 6px 10px; font-size: 13px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--value-soft); border-radius: 12px; padding: 3px; }
.tabs button { border: 0; background: transparent; border-radius: 9px; padding: 8px; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }

.search { display: flex; gap: 8px; }
.search input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 11px 12px; font-family: var(--mono); font-size: 15px; }
.mode { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 0 12px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.random-bar { display: flex; gap: 8px; align-items: center; }
.random-bar .seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.random-bar .seg button { border: 0; background: transparent; padding: 10px 14px; font-variant-numeric: tabular-nums; }
.random-bar .seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.primary { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 12px; padding: 11px 16px; font-weight: 600; }
.random-bar .primary { flex: 1; }

.tagbar { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tagbar::-webkit-scrollbar { display: none; }
.tagbar:empty { display: none; }
.tagchip { flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--tag); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 500; }
.tagchip[aria-pressed="true"] { background: var(--tag); border-color: var(--tag); color: var(--surface); }
.tagchip .n { opacity: .7; margin-left: 4px; font-variant-numeric: tabular-nums; }

main { flex: 1; padding: 12px 16px 110px; display: grid; gap: 10px; align-content: start; }
.status { font-size: 13px; color: var(--muted); }
.status.warn { color: var(--danger); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; text-align: left; width: 100%; }
.card .k { font: 600 17px/1.25 var(--display); overflow-wrap: anywhere; display: flex; justify-content: space-between; gap: 8px; }
.card .score { font: 500 12px var(--mono); color: var(--muted); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.v { font: 13px/1.3 var(--mono); background: var(--value-soft); border-radius: 6px; padding: 3px 7px; overflow-wrap: anywhere; }
.v.hit { background: var(--hit); }
.t { font-size: 12px; font-weight: 600; color: var(--tag); background: var(--tag-soft); border-radius: 999px; padding: 2px 9px; }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; display: grid; gap: 12px; justify-items: center; }
.empty strong { font: 600 18px var(--display); color: var(--ink); }

.fab { position: fixed; right: max(16px, calc(50% - 264px)); bottom: 20px; z-index: 6; width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 30px; line-height: 1; box-shadow: 0 6px 18px rgb(0 0 0 / .25); }

.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / .4); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.scrim[hidden] { display: none; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; max-height: 92%; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 18px 16px 24px; display: grid; gap: 14px; }
.sheet h2 { margin: 0; font: 700 20px var(--display); }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
.field input.plain, textarea { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px; width: 100%; }
textarea { font-family: var(--mono); font-size: 12px; min-height: 140px; }
.chipinput { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 7px; min-height: 46px; }
.chipinput:focus-within { border-color: var(--accent); }
.chipinput input { flex: 1; min-width: 110px; border: 0; background: transparent; padding: 4px; outline: none; font-family: var(--mono); }
.chipinput .x { border: 0; background: transparent; padding: 0 0 0 5px; color: inherit; opacity: .6; font-size: 14px; }
.chipinput .v, .chipinput .t { display: inline-flex; align-items: center; }
.suggest { display: flex; flex-wrap: wrap; gap: 5px; }
.suggest button { border: 1px dashed var(--line); background: transparent; color: var(--tag); border-radius: 999px; padding: 2px 9px; font-size: 12px; }
.err { color: var(--danger); font-size: 13px; min-height: 1em; }
.row { display: flex; gap: 8px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.row .right { display: flex; gap: 8px; margin-left: auto; }
.ghost { border: 1px solid var(--line); background: transparent; border-radius: 12px; padding: 10px 14px; }
.danger { border: 1px solid var(--danger); color: var(--danger); background: transparent; border-radius: 12px; padding: 10px 14px; }
.danger.solid { background: var(--danger); color: var(--surface); }
.menu-list { display: grid; gap: 8px; }
.hdr-btns { display: flex; gap: 6px; }
.file-label { cursor: pointer; }
.login { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: grid; place-items: center; padding: 16px; }
.login[hidden] { display: none; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 24px 20px; display: grid; gap: 14px; }
.login-card .primary { justify-self: stretch; }
.icon-btn.lock { font-weight: 600; }
.icon-btn.lock.open { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.v.locked { color: var(--muted); font-style: italic; letter-spacing: .04em; }
.gate { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 16px; display: grid; gap: 10px; justify-items: start; }
.gate strong { font: 600 18px var(--display); }
.gate p { margin: 0; color: var(--muted); }
.menu-list .ghost { text-align: left; }
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: up .18s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: .6; } }
}
