/* Veil: plain on purpose. Flat colours, 1px lines, small radii, no gradients, glow or blur. */
:root {
  --bg: #f3f2ee; --panel: #fbfaf7; --ink: #1c1c1a; --muted: #66665f; --line: #d9d7cf;
  --accent: #1d5c4a; --accent-ink: #ffffff; --ok: #2b7a4b; --warn: #b36b00; --bad: #b3261e;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --panel: #1b1b19; --ink: #ecebe6; --muted: #9a998f; --line: #2c2c29;
    --accent: #6fbf9f; --accent-ink: #0f1a15; --ok: #5cc48a; --warn: #e0a24a; --bad: #f0807a;
  }
}
:root[data-theme="dark"] {
  --bg: #141413; --panel: #1b1b19; --ink: #ecebe6; --muted: #9a998f; --line: #2c2c29;
  --accent: #6fbf9f; --accent-ink: #0f1a15; --ok: #5cc48a; --warn: #e0a24a; --bad: #f0807a;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
.wrap { max-width: 680px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); font-size: .88rem; }
code { font: .9em ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* ---- landing + legal ---- */
.top { display: flex; align-items: baseline; justify-content: space-between; padding: 22px 0; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 1.2rem; letter-spacing: -.02em; text-decoration: none; color: var(--ink); text-transform: lowercase; }
.mark { display: none; }
.hero { padding: 56px 0 28px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.5rem); line-height: 1.15; letter-spacing: -.025em; margin: 0 0 14px; font-weight: 700; }
.hero p { color: var(--muted); max-width: 520px; margin: 0 0 24px; }
.btn { display: inline-flex; align-items: center; gap: 10px; padding: 11px 18px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-decoration: none; color: var(--ink); font-weight: 600; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 6px 12px; font-size: .9rem; }
.btn.danger { color: var(--bad); }
.fine { color: var(--muted); font-size: .85rem; max-width: 520px; margin: 14px 0 0; }
.fine a { color: inherit; }
.fine.more summary { cursor: pointer; color: var(--accent); list-style: none; }
.fine.more summary::-webkit-details-marker { display: none; }
.err { color: var(--bad); font-weight: 600; margin-top: 12px; }
.invite { display: flex; gap: 10px; flex-wrap: wrap; }
.invite input { padding: 11px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); min-width: 200px; outline: none; }
.invite input:focus, .go input:focus, .row input:focus, .form input:focus { border-color: var(--accent); }
.cards { padding: 12px 0 40px; }
.card { background: none; border: 0; border-top: 1px solid var(--line); padding: 16px 0; }
.card h3 { margin: 0 0 4px; font-size: 1rem; }
.card p { margin: 0; color: var(--muted); font-size: .95rem; max-width: 560px; }
.foot { border-top: 1px solid var(--line); padding: 20px 0 40px; color: var(--muted); font-size: .88rem; display: flex; gap: 18px; flex-wrap: wrap; }
.foot a { color: var(--muted); }
.doc { padding: 24px 0 40px; }
.doc h1 { margin-top: 0; letter-spacing: -.02em; }
.doc h2 { margin-top: 1.8em; font-size: 1.1rem; }
.doc td, .doc th { text-align: left; padding: 6px 12px 6px 0; vertical-align: top; border-bottom: 1px solid var(--line); font-size: .93rem; }
.doc table { border-collapse: collapse; width: 100%; }

/* ---- app ---- */
body.app { display: flex; flex-direction: column; height: 100dvh; }
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.bar .brand { margin-right: 4px; }
.bar .brand .name { display: none; }
@media (min-width: 721px) { .bar .brand .name { display: inline; } }
.go { position: relative; flex: 1; display: flex; min-width: 0; }
.go input { flex: 1; min-width: 0; padding: 9px 40px 9px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg); outline: none; }
.star { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; font-size: 1.1rem; cursor: pointer; color: var(--muted); padding: 4px 8px; }
.star:hover { color: var(--accent); }
.star.on { color: var(--warn); }
.icon { flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: var(--r); width: 36px; height: 36px; cursor: pointer; font-size: 1.05rem; }
.icon:hover { border-color: var(--ink); }
.meter { display: flex; flex-direction: column; gap: 4px; min-width: 96px; font-size: .74rem; color: var(--muted); text-align: right; }
.track { height: 4px; background: var(--line); overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); transition: width .6s, background .3s; }
.fill.warn { background: var(--warn); } .fill.bad { background: var(--bad); }
.stage { position: relative; flex: 1; min-height: 0; }
#view { color-scheme: light; position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; display: none; }
.empty { position: absolute; inset: 0; display: grid; place-items: start center; padding: 14vh 20px 24px; overflow: auto; }
.start { max-width: 600px; width: 100%; }
.logo, .empty h2 { display: none; }
.bigsearch { display: flex; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); margin: 0 0 14px; }
.bigsearch:focus-within { border-color: var(--accent); }
.bigsearch input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 1.05rem; padding: 14px 16px; }
.bigsearch button { align-self: stretch; padding: 0 18px; border: 0; border-left: 1px solid var(--line); background: none; font-size: 1.2rem; cursor: pointer; color: var(--accent); }
.allow { margin: 0 0 28px; }
.allow-top { display: flex; justify-content: space-between; gap: 12px; font-size: .88rem; margin-bottom: 6px; }
.allow-top span { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips + .chips { margin-top: 10px; }
.chip { padding: 7px 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: .92rem; }
.chip:hover { border-color: var(--ink); }
.chip.recent::before { content: "↺ "; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin: 0 0 20px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); cursor: pointer; font-size: .85rem; overflow: hidden; text-align: left; }
.tile:hover { border-color: var(--ink); }
.tile .letter { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; font-weight: 700; color: #fff; }
.tile .t { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loadbar { position: absolute; left: 0; top: 0; height: 2px; width: 0; background: var(--accent); z-index: 4; opacity: 0; transition: width .4s ease, opacity .3s; }
.loadbar.on { opacity: 1; width: 70%; transition: width 6s cubic-bezier(.1,.8,.2,1); }
.loadbar.done { opacity: 0; width: 100%; transition: width .15s, opacity .4s .15s; }
.overlay { position: absolute; inset: 0; display: none; place-items: center; background: var(--bg); text-align: center; padding: 24px; z-index: 5; }
.overlay.show { display: grid; }
.menu { position: absolute; right: 12px; top: 54px; z-index: 10; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 6px; display: none; min-width: 230px; }
.menu.show { display: block; }
.menu button, .menu a { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-decoration: none; color: var(--ink); font-size: .93rem; }
.menu button:hover, .menu a:hover { background: var(--bg); }
.menu .sep { height: 1px; background: var(--line); margin: 6px 0; }
.menu .danger { color: var(--bad); }
.menu .info { padding: 8px 12px; color: var(--muted); font-size: .82rem; }
.menu .info a { display: inline; padding: 0; color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r); font-size: .92rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- bookmarks / history / settings panel ---- */
.panel-wrap { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.4); display: grid; place-items: center; padding: 16px; }
.panel-wrap[hidden] { display: none; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); width: min(620px, 100%); max-height: min(640px, 100%); display: flex; flex-direction: column; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--line); gap: 8px; }
.tabs { display: flex; gap: 2px; }
.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tabs button.on { background: var(--bg); color: var(--ink); }
.panel-body { padding: 14px 16px 18px; overflow: auto; }
.panel-body[hidden] { display: none; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.list .main { flex: 1; min-width: 0; cursor: pointer; }
.list .main b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: .94rem; }
.list .main span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: .8rem; }
.list .when { color: var(--muted); font-size: .76rem; white-space: nowrap; }
.list .del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 4px 8px; }
.list .del:hover { color: var(--bad); }
.row { display: flex; gap: 10px; margin-bottom: 10px; }
.row input { flex: 1; padding: 9px 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg); outline: none; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-weight: 600; font-size: .92rem; }
.field select { padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-weight: 400; }

/* ---- admin ---- */
.adm-wrap { max-width: 900px; }
.adm { max-width: 900px; margin: 0 auto; padding: 0 20px 80px; }
.adm h2 { margin: 28px 0 8px; font-size: 1rem; }
.adm h2.first { margin-top: 0; }
.adm .card { border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-bottom: 12px; background: var(--panel); }
.adm .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.adm .stat { padding: 12px 14px; border-right: 1px solid var(--line); }
.adm .stat:last-child { border-right: 0; }
.adm .stat b { display: block; font-size: 1.4rem; letter-spacing: -.02em; }
.adm .stat span { color: var(--muted); font-size: .82rem; }
.adm .ulist { list-style: none; margin: 0; padding: 0; }
.adm .ulist li { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.adm .ulist li:last-child { border-bottom: 0; }
.adm .ulist .who { flex: 1 1 200px; min-width: 0; }
.adm .ulist small { color: var(--muted); display: block; }
.adm .form { display: flex; gap: 8px; flex-wrap: wrap; }
.adm .form input { flex: 1 1 180px; min-width: 0; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg); outline: none; font-size: 16px; }
.adm pre { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; overflow: auto; font-size: .82rem; max-height: 320px; margin: 10px 0 0; }
.adm .code { font: 700 1.3rem ui-monospace, Consolas, monospace; letter-spacing: .06em; user-select: all; margin-left: 10px; }
.tag { font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); }
.tag.bad { color: var(--bad); border-color: var(--bad); }
.tag.ok { color: var(--ok); border-color: var(--ok); }
.tagpad { margin-left: 6px; }

/* ---- phones: browser controls move to the bottom, within thumb reach ---- */
@media (max-width: 720px) {
  .bar { flex-wrap: wrap; gap: 6px; padding: 10px 12px calc(8px + env(safe-area-inset-bottom)); border-bottom: 0; border-top: 1px solid var(--line); }
  body.app { flex-direction: column-reverse; }
  .bar .brand, .meter, #full { display: none; }
  .go { order: -1; flex: 1 1 100%; }
  .go input { padding: 13px 44px 13px 14px; font-size: 16px; } /* 16px stops iOS zooming in on focus */
  .bar .icon { flex: 1 1 0; width: auto; height: 44px; border-color: transparent; background: none; font-size: 1.25rem; }
  .bar .icon:active { background: var(--bg); }
  .menu { top: auto; bottom: calc(110px + env(safe-area-inset-bottom)); right: 12px; left: 12px; min-width: 0; max-height: 60dvh; overflow: auto; }
  .menu button, .menu a { padding: 13px 12px; font-size: 1rem; }
  .empty { padding-top: 40px; }
  .toast { bottom: calc(130px + env(safe-area-inset-bottom)); }
  .panel-wrap { padding: 0; align-items: end; }
  .panel { width: 100%; max-height: 88dvh; border-radius: var(--r) var(--r) 0 0; border-bottom: 0; }
  .list li { padding: 12px 4px; }
  .hero { padding: 36px 0 20px; }
  .invite { flex-direction: column; align-items: stretch; }
  .invite input, .invite .btn { width: 100%; justify-content: center; }
  .btn { padding: 13px 18px; }
  .adm .ulist .btn { flex: 1 1 100%; justify-content: center; }
  .adm .cols { grid-template-columns: repeat(2, 1fr); }
  .adm .stat { border-bottom: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.adm .hrow { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.adm .hrow:last-child { border-bottom: 0; }
.adm .hrow span { color: var(--muted); }
.adm .badtxt { color: var(--bad); }
.adm .hstate { margin: 0 0 8px; font-weight: 700; }
.adm .hstate.good { color: var(--ok); } .adm .hstate.bad { color: var(--bad); }
.adm h3 { margin: 18px 0 6px; font-size: .92rem; }
.adm .dhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .adm .dhead .btn { margin-left: auto; }
.adm code.big { font-size: 1.05rem; }
.adm .bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; padding-bottom: 16px; }
.adm .bar1 { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; min-width: 0; }
.adm .bar1 i { display: block; width: 100%; background: var(--accent); }
.adm .bar1 span { position: absolute; bottom: -16px; font-size: .66rem; color: var(--muted); }
.adm .form select { padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg); font-size: 16px; }

.banner { background: var(--warn); color: #fff; padding: 8px 14px; font-size: .9rem; text-align: center; }
.banner[hidden] { display: none; }
