:root {
  color-scheme: dark;
  --bg: #07101f;
  --bg-2: #0a1733;
  --panel: rgba(14, 27, 51, .92);
  --panel-solid: #0e1b33;
  --line: rgba(255, 255, 255, .09);
  --line-gold: rgba(214, 169, 79, .32);
  --text: #f4f0e8;
  --muted: #9aa8bd;
  --faint: #6b7890;
  --gold: #d6a94f;
  --gold-2: #a9792c;
  --ok: #7ee0b2;
  --warn: #f6c453;
  --danger: #ff9d90;
  --blue: #7fb2ff;
  --radius: 16px;
  --tap: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: -apple-system, "Segoe UI", system-ui, Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  color: var(--text);
  background: radial-gradient(circle at 15% 0%, rgba(30, 99, 214, .20), transparent 40%),
              radial-gradient(circle at 90% 5%, rgba(214, 169, 79, .14), transparent 32%),
              linear-gradient(170deg, #050b16, var(--bg-2) 55%, var(--bg));
  background-attachment: fixed;
  font-size: 15px; line-height: 1.45;
  overscroll-behavior-y: contain;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold); }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.app { min-height: 100%; display: flex; flex-direction: column; padding-top: var(--safe-t); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  background: rgba(7, 16, 31, .72); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--gold-2), var(--gold)); display: grid; place-items: center; color: #0e0b06; font-weight: 900; font-size: 12px; flex-shrink: 0; }
.brand-title { font-weight: 850; letter-spacing: .02em; font-size: 14px; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; border: 1px solid var(--line); background: rgba(255,255,255,.04); white-space: nowrap; }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync[data-tone="ok"]::before { background: var(--ok); }
.sync[data-tone="warn"]::before { background: var(--warn); }
.sync[data-tone="off"]::before { background: var(--danger); }
.sync[data-tone="busy"]::before { background: var(--blue); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.lang select { appearance: none; -webkit-appearance: none; padding: 6px 9px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--text); font-size: 11px; font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

main { flex: 1; width: min(560px, 100%); margin: 0 auto; padding: 14px 14px calc(84px + var(--safe-b)); }
.screen { animation: rise .22s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen { animation: none; } }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + var(--safe-b));
  background: rgba(7, 16, 31, .86); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 700; border-radius: 12px; min-height: var(--tap); position: relative; }
.tab svg { width: 22px; height: 22px; }
.tab.is-active { color: var(--gold); background: rgba(214, 169, 79, .10); }
.tab .badge { position: absolute; top: 4px; right: 18%; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--warn); color: #1a1200; font-size: 10px; font-weight: 900; display: grid; place-items: center; }

/* ── Cards & type ──────────────────────────────────────────────────────── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card--gold { border-color: var(--line-gold); }
h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
h2 { margin: 0 0 10px; font-size: 12px; color: var(--gold); text-transform: uppercase; letter-spacing: .08em; }
.muted { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.eyebrow { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
label { display: block; font-size: 11px; font-weight: 800; color: var(--muted); margin: 0 0 6px; text-transform: uppercase; letter-spacing: .05em; }
.field { margin-bottom: 14px; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 12px 14px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14); background: #101f3a; color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(214,169,79,.18); }
select option { background: #101f3a; color: var(--text); }
textarea { min-height: 112px; resize: vertical; line-height: 1.5; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: var(--tap); padding: 12px 16px; border-radius: 12px; border: 1px solid transparent; font-weight: 850; letter-spacing: .01em; transition: transform .08s ease, filter .15s ease; }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: default; }
.btn--primary { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #0e0b06; }
.btn--secondary { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.14); color: var(--text); }
.btn--ghost { background: none; border-color: transparent; color: var(--muted); }
.btn--danger { background: rgba(255,157,144,.10); border-color: rgba(255,157,144,.3); color: var(--danger); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.status { margin-top: 10px; font-size: 13px; min-height: 1.2em; color: var(--muted); }
.status.is-error { color: var(--danger); }
.status.is-ok { color: var(--ok); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip { padding: 8px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.04); font-size: 12px; font-weight: 700; color: var(--muted); min-height: 36px; }
.chip.is-on { border-color: var(--gold); color: var(--gold); background: rgba(214,169,79,.10); }

/* ── Photos ────────────────────────────────────────────────────────────── */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #0b1730; border: 1px solid var(--line); }
.photo img, .photo video { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo button { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 15px; line-height: 1; }
.photo .size { position: absolute; left: 6px; bottom: 6px; font-size: 10px; padding: 2px 6px; border-radius: 6px; background: rgba(0,0,0,.55); }
.capture { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.capture input { display: none; }

/* ── Lists ─────────────────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { display: block; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; transition: border-color .15s; }
.item:active { border-color: var(--line-gold); }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.item-title { font-weight: 800; font-size: 15px; line-height: 1.3; }
.item-code { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--gold); letter-spacing: .04em; }
.item-meta { color: var(--muted); font-size: 12.5px; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.tag { font-size: 10.5px; font-weight: 800; padding: 3px 8px; border-radius: 6px; background: rgba(127,178,255,.12); color: var(--blue); white-space: nowrap; }
.tag--ok { background: rgba(126,224,178,.12); color: var(--ok); }
.tag--warn { background: rgba(246,196,83,.14); color: var(--warn); }
.tag--danger { background: rgba(255,157,144,.14); color: var(--danger); }
.progress { height: 6px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); }
.progress--works i { background: linear-gradient(90deg, #3a7bd5, var(--blue)); }
.day { margin: 14px 0 8px; font-size: 12px; color: var(--faint); text-transform: capitalize; font-weight: 800; }
.thumbs { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); flex-shrink: 0; background: #0b1730; }
.proof { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--faint); margin-top: 8px; word-break: break-all; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }
.search { position: sticky; top: 62px; z-index: 10; padding: 4px 0 10px; background: linear-gradient(var(--bg-2), transparent); }

/* ── Sheet (project detail) ────────────────────────────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(3,8,16,.6); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 86vh; overflow-y: auto; background: var(--panel-solid); border-radius: 20px 20px 0 0; border-top: 1px solid var(--line-gold); padding: 10px 16px calc(20px + var(--safe-b)); animation: up .22s ease both; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 42px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.2); margin: 0 auto 12px; }
.range { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; margin-bottom: 10px; }
.range input[type="range"] { min-height: 0; padding: 0; background: none; border: 0; accent-color: var(--gold); }
.range output { font-variant-numeric: tabular-nums; font-weight: 800; min-width: 44px; text-align: right; }

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%); z-index: 50; padding: 10px 16px; border-radius: 12px; background: rgba(18,34,26,.96); color: #dfeede; border: 1px solid rgba(126,224,178,.4); font-size: 13px; font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,.45); max-width: min(92vw, 480px); text-align: center; }
.toast.is-error { background: rgba(48,18,16,.96); color: #ffd9d3; border-color: rgba(255,157,144,.45); }

/* ── Account / install ─────────────────────────────────────────────────── */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv span { color: var(--faint); }
.kv strong { font-weight: 700; word-break: break-all; }
.install-steps { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.install-steps li { margin: 4px 0; }
.version { text-align: center; color: var(--faint); font-size: 11px; margin-top: 18px; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login { max-width: 420px; margin: 8vh auto 0; }
.login .brand-mark { width: 48px; height: 48px; border-radius: 14px; font-size: 16px; margin-bottom: 14px; }
.login h1 { font-size: 24px; }
.login .note { font-size: 12px; color: var(--faint); margin-top: 14px; line-height: 1.5; }

/* ── Onboarding ────────────────────────────────────────────────────────── */
.onboarding { max-width: 460px; margin: 4vh auto 0; }
.onb-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; gap: 12px; margin: 0 -14px 16px; padding: 0 14px; }
.onb-track::-webkit-scrollbar { display: none; }
.onb-slide { flex: 0 0 100%; scroll-snap-align: center; background: var(--panel); border: 1px solid var(--line-gold); border-radius: 20px; padding: 26px 20px 22px; min-height: 300px; }
.onb-art { font-size: 44px; line-height: 1; margin-bottom: 18px; width: 76px; height: 76px; display: grid; place-items: center; border-radius: 22px; background: rgba(214,169,79,.10); border: 1px solid var(--line-gold); }
.onb-slide h1 { font-size: 21px; margin-bottom: 8px; }
.onb-dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; }
.onb-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.18); transition: background .2s, width .2s; }
.onb-dots i.is-on { background: var(--gold); width: 22px; border-radius: 4px; }
