:root {
  --bg: #15161C; --side: #18191F; --surf: #1E1F27; --surf2: #272832; --line: #2C2D37;
  --text: #EFE9DD; --muted: #A9A397; --accent: #B5452B; --ink: #FFF7EC; --off: #3A3B46;
  --danger: #F08A7E; --ok: #7CC2A6; --link: #E58A6F; --pat: 0.18; --fs: 15px;
  --kokowai: #B5452B;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: var(--fs); line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }

/* layout */
.shell { min-height: 100vh; display: flex; }
.side { display: none; }
.main { flex: 1; min-width: 0; padding: calc(env(safe-area-inset-top) + 16px) 16px calc(110px + env(safe-area-inset-bottom)); max-width: 1040px; margin: 0 auto; width: 100%; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { font-size: 21px; font-weight: 700; font-stretch: 115%; letter-spacing: .02em; }
.switcher { border: 1px solid var(--line); background: var(--surf); border-radius: 999px; min-height: 40px; padding: 0 14px; font-weight: 600; font-size: 13px; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #FFF7EC; }
.avatar.btn { width: 42px; height: 42px; border: 1.5px solid var(--accent); cursor: pointer; font-size: 13px; text-decoration: none; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs .niho { position: absolute; left: 0; right: 0; top: -7px; height: 6px; opacity: var(--pat); }
.tabs .row { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); max-width: 620px; margin: 0 auto; }
.tab { min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; }
.tab[aria-current="page"] { color: var(--text); font-weight: 700; }

@media (min-width: 900px) {
  .tabs { display: none; }
  .side { display: flex; flex-direction: column; gap: 22px; width: 248px; flex: none; padding: 28px 16px; background: var(--side); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; }
  .side .nav { display: flex; flex-direction: column; gap: 2px; }
  .side a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; }
  .side a[aria-current="page"] { background: var(--surf2); font-weight: 700; }
  .side a small { color: var(--muted); font-weight: 500; }
  .main { padding: 32px 40px 48px; }
  .topbar { justify-content: flex-end; }
  .topbar .brand, .topbar .switcher { display: none; }
}

/* type */
h1 { font-size: 30px; line-height: 1.15; margin: 0; font-weight: 700; font-stretch: 108%; letter-spacing: -.01em; }
h2 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 28px 4px 10px; font-weight: 700; }
.sub { color: var(--muted); font-weight: 500; }
.lede { color: var(--muted); margin: 4px 0 0; font-size: 13px; letter-spacing: .03em; }
p { margin: 0; }

/* cards */
.card { position: relative; overflow: hidden; background: var(--surf); border: 1px solid var(--line); border-radius: 20px; padding: 18px; }
.card + .card { margin-top: 12px; }
.card .pattern { position: absolute; top: 0; right: 0; width: 170px; height: 100%; opacity: var(--pat); -webkit-mask-image: linear-gradient(to left, #000 30%, transparent); mask-image: linear-gradient(to left, #000 30%, transparent); pointer-events: none; }
.card > * { position: relative; }
.card .pattern { position: absolute; }
.card h3 { margin: 0; font-size: 17px; font-weight: 700; }
.card p { color: var(--muted); margin-top: 4px; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--link); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.grid2 .card + .card { margin-top: 0; }

/* lists */
.list { background: var(--surf); border: 1px solid var(--line); border-radius: 18px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 64px; flex-wrap: wrap; }
.item + .item { border-top: 1px solid var(--line); }
.item .grow { flex: 1 1 160px; min-width: 0; }
.item .name { font-weight: 600; }
.item .meta { font-size: 12px; color: var(--muted); }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 999px; border: 0; background: var(--accent); color: var(--ink); font-weight: 700; cursor: pointer; text-decoration: none; font-size: 14px; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.quiet { background: transparent; color: var(--link); padding: 0 10px; }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
label.f { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input.f, select.f { width: 100%; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 16px; }
select.small { min-height: 38px; font-size: 13px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg); flex-wrap: wrap; }
.seg button { flex: 1 1 auto; min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; padding: 0 12px; cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--surf); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.code { font-weight: 700; letter-spacing: .08em; }
.linkbox { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--bg); border: 1px dashed var(--off); font-size: 13px; word-break: break-all; }

/* palettes */
.pals { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.pal { padding: 6px; border-radius: 16px; border: 1px solid var(--line); background: var(--surf); cursor: pointer; text-align: left; }
.pal[aria-checked="true"] { border: 2.5px solid var(--text); padding: 4.5px; }
.pal .pv { position: relative; display: block; height: 60px; border-radius: 11px; overflow: hidden; }
.pal .pv i { position: absolute; display: block; }
.pal span.n { display: block; font-size: 13px; font-weight: 700; padding: 6px 2px 0; }
.pal span.e { display: block; font-size: 11px; color: var(--muted); padding: 0 2px 2px; }

/* sign in */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth .panel { width: 100%; max-width: 420px; }
.auth .hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; margin-bottom: 26px; }
.auth .hero b { font-size: 34px; font-weight: 700; font-stretch: 115%; letter-spacing: .02em; }
.banner { padding: 12px 14px; border-radius: 14px; background: var(--surf2); font-size: 14px; margin-bottom: 14px; }

#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px); z-index: 20; }
#toast.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* photos */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 4px; }
@media (min-width: 900px) { .thumbs { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; } }
.tile { position: relative; aspect-ratio: 1 / 1; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: var(--surf2); cursor: pointer; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile img:not([src]) { visibility: hidden; }
.badge { position: absolute; bottom: 6px; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: rgba(12,12,16,.72); color: #fff; }
.badge.r { right: 6px; } .badge.l { left: 6px; }
.badge.warn { background: rgba(160,50,30,.9); }
.bar { height: 6px; border-radius: 3px; background: var(--off); overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .2s; }
.drop { position: relative; overflow: hidden; border: 2px dashed var(--off); border-radius: 20px; background: var(--side); padding: 28px 18px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.drop.over { border-color: var(--accent); }
.drop > * { position: relative; }
.drop .pattern { position: absolute; inset: 0; opacity: var(--pat); -webkit-mask-image: radial-gradient(ellipse at center, transparent 40%, #000 100%); mask-image: radial-gradient(ellipse at center, transparent 40%, #000 100%); pointer-events: none; }
.drop .ico { width: 56px; height: 56px; border-radius: 50%; background: var(--surf2); display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.dz-desk { display: none; } .dz-phone { display: inline; }
@media (min-width: 900px) { .dz-desk { display: inline; } .dz-phone { display: none; } }
.qname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-size: 14px; }
.meta.bad { color: var(--danger); } .meta.good { color: var(--ok); }

/* viewer */
.viewer { position: fixed; inset: 0; z-index: 30; background: #0B0B0E; color: #EFE9DD; display: flex; flex-direction: column; }
.viewer .vtop { display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top) + 8px) 8px 8px; }
.viewer .vtitle { font-size: 14px; font-weight: 600; text-align: center; }
.viewer .stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 8px; }
.viewer .stage img, .viewer .stage video { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.viewer .vinfo { padding: 12px 16px calc(env(safe-area-inset-bottom) + 16px); display: flex; flex-direction: column; gap: 10px; }
.viewer .meta { color: #A9A397; }
.viewer .btn.ghost { color: #EFE9DD; border-color: #34353F; }
.iconbtn { width: 44px; height: 44px; border: 0; border-radius: 22px; background: rgba(255,255,255,.08); color: #EFE9DD; display: inline-flex; align-items: center; justify-content: center; font-size: 30px; line-height: 1; cursor: pointer; }
.vprev, .vnext { position: absolute; top: 50%; transform: translateY(-50%); }
.vprev { left: 10px; } .vnext { right: 10px; }
@media (max-width: 600px) { .vprev, .vnext { display: none; } }
