:root {
  --brand: #183d4d;
  --brand-2: #2a6f86;
  --bg: #f4f6f7;
  --card: #ffffff;
  --ink: #1b2328;
  --muted: #6b7780;
  --line: #dde3e6;
  --danger: #c0392b;
  --ok: #1e8e5a;
  --warn: #b7791f;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.screen { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { padding: 16px; max-width: 900px; width: 100%; margin: 0 auto; }
.content.center { display: flex; flex-direction: column; justify-content: center; min-height: 80vh; }
h2 { font-size: 16px; margin: 24px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=password] { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; margin-bottom: 12px; }
.hint { color: var(--muted); font-size: 14px; margin: 12px 0 0; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 600; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,.18); }
.badge.mock { background: var(--warn); }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #e8eef1; color: var(--brand); margin-right: 4px; }
.pill.ok { background: #dff3e8; color: var(--ok); }
.pill.warn { background: #fbefd9; color: var(--warn); }
.pill.low { background: #f8e1de; color: var(--danger); }

.btn { border: 0; border-radius: 10px; padding: 14px 18px; font-size: 16px; font-weight: 600; cursor: pointer; min-height: 48px; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: rgba(255,255,255,.15); color: inherit; border: 1px solid var(--line); }
.btn-link { background: none; border: 0; color: #fff; font-size: 16px; padding: 8px 0; cursor: pointer; }
.btn-small { padding: 6px 10px; min-height: 32px; font-size: 14px; border-radius: 8px; background: #e8eef1; color: var(--brand); border: 0; cursor: pointer; font-weight: 600; }

.list .item { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 8px; cursor: pointer; }
.item-right { display: flex; align-items: center; gap: 6px; flex: none; }
.item-del { width: 40px; height: 40px; border: 0; border-radius: 10px; background: none; color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.item-del:hover, .item-del:active { background: #f8e1de; color: var(--danger); }
.list .item .meta { color: var(--muted); font-size: 13px; }

/* Recording */
#screen-record { background: #0b0f19; color: #fff; height: 100dvh; overflow: hidden; position: relative; }
.rec-top { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 10px) 14px 8px; }
.rec-title { flex: 1; font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-badge { display: flex; align-items: center; gap: 7px; background: rgba(255,255,255,.12); padding: 5px 11px; border-radius: 99px; font-variant-numeric: tabular-nums; font-size: 14px; }
.rec-photos { font-size: 14px; background: rgba(255,255,255,.12); padding: 5px 11px; border-radius: 99px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #d92d20; animation: blink 1.2s infinite; }
.rec-dot.paused { animation: none; background: #f79009; }
@keyframes blink { 50% { opacity: .3; } }
.camera { position: relative; flex: 1; min-height: 0; margin: 0 12px; border-radius: 18px; overflow: hidden; background: #1a1f2b; }
.camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .25s; }
.flash.on { opacity: .8; transition: none; }
.no-cam { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; color: #9ca3af; line-height: 1.5; }
.rec-paused { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,.6); padding: 10px 18px; border-radius: 10px; font-weight: 700; }
.toast { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: #fff; color: #111827; border-radius: 99px; padding: 8px 14px; font-size: 13px; font-weight: 600; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.shutter-row { display: flex; justify-content: center; padding: 14px 0 6px; }
.btn-shutter { width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.btn-shutter span { width: 62px; height: 62px; border-radius: 50%; background: #fff; color: #111827; font-weight: 700; font-size: 12px; letter-spacing: .04em; display: flex; align-items: center; justify-content: center; }
.btn-shutter:active span { background: #d1d5db; transform: scale(.94); }
.btn-shutter:disabled { opacity: .4; }
.voice { display: flex; align-items: center; gap: 12px; margin: 6px 12px 0; padding: 10px 12px; background: #1f2937; border-radius: 16px; }
.vbtn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #374151; color: #fff; font-size: 14px; flex: none; cursor: pointer; }
.vbtn.resume { background: #7f56d9; }
.vmid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.vmid small { font-size: 11px; color: #9ca3af; font-weight: 700; letter-spacing: .05em; }
.wave { width: 100%; height: 28px; display: block; }
.vt { font-size: 20px; font-variant-numeric: tabular-nums; }
.stopbtn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: #d92d20; flex: none; cursor: pointer; position: relative; }
.stopbtn::after { content: ""; position: absolute; left: 14px; top: 14px; width: 16px; height: 16px; border-radius: 3px; background: #fff; }
.timeline { padding: 8px 12px calc(env(safe-area-inset-bottom) + 10px); }
.tl-head { font-size: 11px; color: #9ca3af; font-weight: 700; letter-spacing: .05em; padding: 0 2px 6px; }
.tl-scroll { overflow-x: auto; overflow-y: hidden; height: 74px; -webkit-overflow-scrolling: touch; }
.tl-track { position: relative; height: 66px; min-width: 100%; }
.tl-track::before { content: ""; position: absolute; left: 0; right: 0; bottom: 8px; height: 2px; background: #374151; }
.tl-track::after { content: ""; position: absolute; right: 0; top: 0; bottom: 2px; width: 2px; background: #d92d20; }
.th { position: absolute; top: 0; width: 44px; margin-left: -22px; padding: 0; border: 0; background: none; color: #9ca3af; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 9px; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; }
.th img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; border: 2px solid #fff; display: block; }
.th.a { color: #d9ccff; }
.th.a img { border-color: #7f56d9; }
.th::after { content: ""; width: 1px; height: 8px; background: #6b7280; }
.sheet-wrap { position: absolute; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; z-index: 20; }
.sheet { width: 100%; background: #fff; color: #111827; border-radius: 22px 22px 0 0; padding: 20px 18px calc(env(safe-area-inset-bottom) + 24px); }
.sheet h3 { margin: 0 0 10px; font-size: 20px; }
.sheet p { color: #4b5563; font-size: 14px; line-height: 1.45; margin: 10px 0 6px; }
.tags { display: flex; gap: 8px; }
.tag { background: #f4f0ff; color: #6941c6; font-weight: 600; border-radius: 8px; padding: 5px 10px; font-size: 14px; }
.btn-outline { background: #fff; border: 1px solid #d0d5dd; color: #111827; }
#start-error { white-space: pre-line; }
.rec-dot.idle { animation: none; background: #6b7280; }
.rec-cancel { display: none; background: none; border: 0; color: #d9ccff; font-size: 15px; font-weight: 600; padding: 4px 2px; cursor: pointer; }
.begin-row { display: none; margin: 6px 12px 0; text-align: center; }
.begin-row p { margin: 0 0 10px; font-size: 13px; color: #9ca3af; line-height: 1.4; }
.btn-record { background: #d92d20; color: #fff; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px; font-size: 18px; margin-top: 0; }
.btn-record i { width: 14px; height: 14px; border-radius: 50%; background: #fff; }
#screen-record.ready .begin-row { display: block; }
#screen-record.ready .voice { display: none; }
#screen-record.ready .rec-cancel { display: block; }
#screen-record.ready .rec-photos { display: none; }

.progress { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; margin: 12px 0; }
.progress div { height: 100%; width: 0; background: var(--brand-2); transition: width .2s; }

/* Session view */
.player { position: sticky; top: calc(env(safe-area-inset-top) + 60px); z-index: 4; background: var(--brand); padding: 0 16px 10px; }
.player audio { width: 100%; }
.tabs { display: flex; gap: 6px; margin: 8px 0 12px; }
.tab { flex: 1; padding: 10px; border: 1px solid var(--line); background: var(--card); border-radius: 8px; font-weight: 600; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.obs { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.obs h3 { margin: 0 0 4px; font-size: 17px; }
.obs .room { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.obs .photos { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.obs .photos img, .photo-row img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; cursor: zoom-in; }
.quote { border-left: 3px solid var(--brand-2); padding: 6px 10px; background: #f1f6f8; border-radius: 0 8px 8px 0; margin: 8px 0; font-style: italic; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 14px; margin-top: 8px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.photo-row { display: grid; grid-template-columns: 110px 1fr; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.photo-row h4 { margin: 0 0 6px; }
.photo-row .col-title { font-size: 12px; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.sentence { padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; gap: 10px; }
.sentence:hover { background: #eef3f5; }
.sentence .t { color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.sentence.room { font-weight: 600; }
.marker { display: flex; align-items: center; gap: 8px; margin: 6px 0; padding: 4px 8px; background: #fff4e0; border-radius: 6px; font-size: 13px; font-weight: 600; }
.marker img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.warnings { color: var(--warn); font-size: 14px; margin: 8px 0 0; padding-left: 18px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; z-index: 50; }
.lightbox img { max-width: 100%; max-height: 100%; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
