:root {
  --bg: #0b1120; --panel: #151e2e; --panel-2: #1e293b; --line: #2b3648; --text: #f1f5f9; --muted: #94a3b8;
  --accent: #22c55e; --accent-2: #16a34a; --accent-ink: #052e16; --danger: #ef4444; --warn: #f59e0b; --info: #38bdf8;
  --radius: 14px; --tabbar-h: 58px;
  --sa-top: env(safe-area-inset-top, 0px); --sa-bottom: env(safe-area-inset-bottom, 0px);
  --sa-left: env(safe-area-inset-left, 0px); --sa-right: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; }
a { color: var(--info); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.center { justify-content: center; }
body.noscroll { overflow: hidden; }

/* ---------- przyciski ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; min-height: 44px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  text-decoration: none; cursor: pointer; font-weight: 500; user-select: none; -webkit-user-select: none; }
.btn:active { transform: scale(.98); }
.btn:disabled, .btn.disabled { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.danger { border-color: #7f1d1d; color: #fca5a5; background: transparent; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.wide { width: 100%; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0,0,0,.45); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 20px; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.on { background: var(--warn); color: #111; }

.seg { display: inline-flex; border-radius: 12px; background: var(--panel-2); padding: 3px; gap: 2px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 7px 12px; border-radius: 9px; cursor: pointer; white-space: nowrap; min-height: 34px; font-size: 14px; }
.seg button.on { background: var(--text); color: #0b1120; font-weight: 600; }
.seg button b { font-weight: 700; margin-left: 2px; }
.seg.small button { padding: 5px 10px; min-height: 30px; font-size: 13px; }

.chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.chip.ok { background: #14532d; color: #86efac; }
.chip.info { background: #0c4a6e; color: #bae6fd; }
.chip.warn { background: #78350f; color: #fde68a; }
.pill { font-size: 13px; padding: 5px 10px; border-radius: 999px; background: rgba(12,74,110,.85); color: #e0f2fe; cursor: pointer; }
.pill.warn { background: rgba(127,29,29,.9); color: #fee2e2; }

/* ---------- dolny pasek zakładek ---------- */
.tabbar { position: relative; flex: none; z-index: 30; display: flex;
  padding: 4px calc(6px + var(--sa-right)) calc(4px + var(--sa-bottom)) calc(6px + var(--sa-left));
  background: rgba(11,17,32,.92); backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--line); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 0 3px; color: var(--muted);
  text-decoration: none; font-size: 11px; position: relative; min-height: 50px; justify-content: center; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--accent); }
.badge-count { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }
.badge-count.warn { background: var(--warn); color: #111; }

/* ---------- toast ---------- */
.toast { position: absolute; left: 50%; bottom: calc(var(--tabbar-h) + var(--sa-bottom) + 12px); transform: translate(-50%, 20px);
  opacity: 0; pointer-events: none; transition: .2s; z-index: 50; width: min(520px, calc(100% - 20px));
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: #f8fafc; color: #0f172a;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.error { background: #fee2e2; color: #7f1d1d; }
.toast img { width: 36px; height: 48px; object-fit: cover; border-radius: 6px; }
.toast-msg { flex: 1; font-size: 15px; }
.toast-btn { border: 0; background: transparent; color: #15803d; font-weight: 700; padding: 8px 6px; cursor: pointer; white-space: nowrap; }

/* ---------- skaner ---------- */
body.scanner { background: #000; }
.stage { position: relative; flex: 1; min-height: 0; background: #000; overflow: hidden; }
#video, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
#video { object-fit: contain; }
#overlay { pointer-events: none; }
#flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .15s; }
#flash.on { opacity: .85; transition: none; }
.topbar { position: absolute; top: 0; left: 0; right: 0; padding: calc(var(--sa-top) + 8px) calc(12px + var(--sa-right)) 10px calc(12px + var(--sa-left));
  display: flex; align-items: center; gap: 8px; background: linear-gradient(rgba(0,0,0,.7), rgba(0,0,0,0)); z-index: 3; }
.status { flex: 1; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.topbar-actions { display: flex; gap: 8px; }
.append-banner { position: absolute; top: calc(var(--sa-top) + 60px); left: 12px; right: 12px; z-index: 3; display: flex; align-items: center; gap: 10px;
  justify-content: space-between; padding: 8px 8px 8px 14px; border-radius: 12px; background: rgba(12,74,110,.92); font-size: 14px; }
.controls { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px calc(12px + var(--sa-right)) 10px calc(12px + var(--sa-left));
  display: flex; flex-direction: column; gap: 10px; background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.8) 35%); z-index: 3; }
.row.main { justify-content: space-between; }
.row.settings { justify-content: space-between; }
.shutter { --p: 0; width: 76px; height: 76px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; flex: none;
  background: conic-gradient(var(--accent) calc(var(--p) * 360deg), rgba(255,255,255,.35) 0); position: relative; }
.shutter::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: #fff; border: 3px solid #111; }
.shutter:active::after { transform: scale(.92); }
.last-thumb { width: 54px; height: 70px; padding: 0; border-radius: 9px; border: 2px solid rgba(255,255,255,.8); background: #222; overflow: hidden; cursor: pointer; }
.last-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.side-toggles { display: flex; flex-direction: column; gap: 6px; min-width: 54px; align-items: flex-end; }
.mini-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; background: rgba(21,30,46,.85); padding: 6px 10px; border-radius: 999px; cursor: pointer; }
.mini-toggle input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.pages { background: rgba(21,30,46,.94); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.page-strip { display: flex; gap: 8px; overflow-x: auto; min-height: 8px; }
.thumb { position: relative; flex: 0 0 auto; }
.thumb img { width: 50px; height: 66px; object-fit: cover; border-radius: 6px; border: 1px solid #4b5563; display: block; }
.thumb span { position: absolute; left: 3px; bottom: 3px; background: rgba(0,0,0,.7); color: #fff; font-size: 11px; padding: 1px 5px; border-radius: 6px; }
.thumb button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; }
.loading { position: absolute; inset: 0; background: rgba(11,17,32,.97); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px; text-align: center; z-index: 10; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid #374151; border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- strony z listą i formularzami ---------- */
.appbar { position: relative; flex: none; z-index: 20; padding: calc(var(--sa-top) + 10px) calc(16px + var(--sa-right)) 10px calc(16px + var(--sa-left));
  background: rgba(11,17,32,.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px; }
.appbar.compact { flex-direction: row; align-items: center; }
.appbar.compact h1 { flex: 1; font-size: 15px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { color: var(--info); text-decoration: none; font-size: 17px; white-space: nowrap; }
.searchbox { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border-radius: 12px; padding: 0 12px; }
.searchbox svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.searchbox input { flex: 1; border: 0; background: transparent; padding: 11px 0; outline: none; font-size: 16px; min-width: 0; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters .seg { flex: 1 1 100%; }
.filters input[type=month] { background: var(--panel-2); border: 0; border-radius: 12px; padding: 8px 12px; min-height: 40px; font-size: 16px; flex: 1; }
.content { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 12px max(calc(12px + var(--sa-right)), calc((100% - 900px) / 2)) 24px max(calc(12px + var(--sa-left)), calc((100% - 900px) / 2)); }
.narrow-content { display: flex; flex-direction: column; gap: 12px; padding-left: max(12px, calc((100% - 560px) / 2)); padding-right: max(12px, calc((100% - 560px) / 2)); }
.narrow-content > * { flex: none; }
.notice { background: #0c4a6e; color: #e0f2fe; border-radius: 12px; padding: 10px 14px; margin-bottom: 10px; font-size: 14px; }
.notice.warn { background: #78350f; color: #fef3c7; }
.notice a { color: inherit; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

.doc-list { display: flex; flex-direction: column; gap: 8px; }
.doc-list[aria-busy=true] { opacity: .6; }
.doc-card { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: var(--radius); background: var(--panel); color: var(--text); text-decoration: none; }
.doc-card:active { background: var(--panel-2); }
.doc-thumb { width: 48px; height: 64px; border-radius: 8px; background: #0b0f19; overflow: hidden; flex: none; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc-body { flex: 1; min-width: 0; }
.doc-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-chips { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.doc-amount { font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-actions { display: flex; flex-direction: column; gap: 6px; }

/* ---------- szczegóły ---------- */
.detail { padding-bottom: 24px; }
.pages-strip { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x mandatory; }
.page-thumb { position: relative; flex: none; width: 132px; height: 176px; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #0b0f19; cursor: zoom-in; scroll-snap-align: start; }
.page-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.page-thumb span { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.7); color: #fff; font-size: 12px; padding: 1px 7px; border-radius: 8px; }
.page-tools { margin-bottom: 14px; }
.fields fieldset { border: 0; margin: 0 0 14px; padding: 12px; background: var(--panel); border-radius: var(--radius); display: flex; flex-direction: column; gap: 10px; }
.fields legend { float: left; width: 100%; padding: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 2px; }
.field { display: flex; flex-direction: column; gap: 4px; position: relative; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea, .card-box input:not([type=checkbox]), .card-box select {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  font-size: 16px; outline: none; -webkit-appearance: none; appearance: none; }
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--info); }
.field.auto input, .field.auto select { border-color: #1d4ed8; }
.field.auto > span::after { content: " · odczytane"; color: #93c5fd; }
.field.unsure input { border-color: var(--warn); background: rgba(245,158,11,.08); }
.field.unsure > span::after { content: " · sprawdź"; color: #fcd34d; }
.field.invalid input { border-color: var(--danger); }
.field.invalid::after { content: attr(data-msg); font-size: 12px; color: #fca5a5; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 380px) { .grid2 { grid-template-columns: 1fr; } }
.hint { margin: 0; font-size: 13px; color: #93c5fd; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hint.warn { color: #fcd34d; }
.ocr-text { background: var(--panel); border-radius: var(--radius); padding: 12px; margin: 14px 0; }
.ocr-text summary { cursor: pointer; color: var(--muted); }
.ocr-text pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; max-height: 50vh; overflow: auto; background: var(--bg); padding: 10px; border-radius: 8px; }
.danger-zone { margin-top: 10px; justify-content: space-between; }
.actionbar { position: relative; flex: none; z-index: 25; display: flex; gap: 8px;
  padding: 8px calc(12px + var(--sa-right)) 8px calc(12px + var(--sa-left)); background: rgba(11,17,32,.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.confirm-inline { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.viewer { position: fixed; left: 0; right: 0; top: 0; height: var(--app-h, 100dvh); z-index: 60; background: #000; display: flex; flex-direction: column; }
.viewer-top { display: flex; align-items: center; justify-content: space-between; padding: calc(var(--sa-top) + 8px) 12px 8px; }
.viewer-scroll { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom; }
.viewer-scroll img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform .2s; }
.viewer-scroll img.zoomed { max-width: none; max-height: none; width: 250%; }
.viewer-tools { padding: 10px 14px calc(var(--sa-bottom) + 10px); background: var(--panel); display: flex; flex-direction: column; gap: 8px; }
.slider { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.slider span { color: var(--muted); font-size: 12px; }
.slider input { width: 100%; accent-color: var(--accent); }

/* ---------- eksport, ustawienia, logowanie ---------- */
.card-box { background: var(--panel); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card-box h2 { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0; }
.stats div { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.export-buttons { display: grid; grid-template-columns: 1fr; gap: 8px; }
.export-buttons .btn { flex-direction: column; gap: 0; min-height: 56px; }
.export-buttons small { font-weight: 400; font-size: 12px; opacity: .75; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.stale-box { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: rgba(245, 158, 11, .15); border: 1px solid var(--warn); }
.stale-box p { margin: 0 0 8px; }
.changelog { margin-top: 12px; }
.changelog summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
.changelog-entry h3 { font-size: 14px; margin: 12px 0 4px; }
.changelog-entry ul { margin: 0; padding-left: 20px; font-size: 14px; }
.changelog-entry li { margin: 2px 0; }
.switch { display: flex; gap: 10px; align-items: center; font-size: 15px; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.narrow { flex: 1; overflow-y: auto; padding: calc(var(--sa-top) + 48px) max(16px, calc((100% - 420px) / 2)) 32px; }
.narrow h1 { margin-bottom: 16px; }
.error { color: #fca5a5; margin: 0; }
label[for], .card-box label > span { color: var(--muted); font-size: 14px; }
input[type="password"] { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 16px; min-height: 44px; }
/* na skanerze toast u góry, żeby nie zasłaniał spustu i przełączników */
body.scanner .toast { top: calc(var(--sa-top) + 60px); bottom: auto; transform: translate(-50%, -20px); }
body.scanner .toast.show { transform: translate(-50%, 0); }

/* ---------- szkielet aplikacji: zawsze dokładnie wysokość widocznego ekranu ----------
   iOS liczy position:fixed/100vh od pełnej wysokości (pod paskiem Safari i klawiaturą), przez co
   dolne paski wychodziły poza ekran. Teraz body ma wysokość widocznego obszaru (--app-h ustawiane
   w nav.js z visualViewport, w CSS zapas 100dvh), przewija się tylko środkowa część. */
body.page, body.scanner { position: relative; display: flex; flex-direction: column; height: var(--app-h, 100dvh); }
body.page > main { flex: 1; min-height: 0; }
body.kbd .tabbar { display: none; } /* klawiatura otwarta: nie zabieraj miejsca paskiem zakładek */
body.kbd .toast { bottom: 12px; }
.field input, .field select, .field textarea { min-width: 0; }
/* puste pole daty: WebKit pokazuje szarą dzisiejszą datę, co wygląda jak wpisana wartość */
.field.date-empty input { color: transparent; }
.field.date-empty::after { content: "—  nie podano"; position: absolute; left: 13px; bottom: 11px; color: var(--muted); pointer-events: none; font-size: 15px; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }

/* ---------- szybkie usuwanie: przesunięcie karty i tryb zaznaczania ---------- */
.swipe { position: relative; overflow: hidden; border-radius: var(--radius); }
.swipe-actions { position: absolute; inset: 0; display: flex; justify-content: space-between; align-items: stretch; }
.swipe-actions button { border: 0; color: #fff; font-weight: 650; padding: 0 18px; min-width: 96px; cursor: pointer; font-size: 15px; }
.swipe-actions .sw-done { background: var(--accent-2); }
.swipe-actions .sw-del { background: var(--danger); margin-left: auto; }
.swipe .doc-card { position: relative; z-index: 1; touch-action: pan-y; transition: transform .2s; will-change: transform; }
.swipe.dragging .doc-card { transition: none; }
.doc-check { width: 24px; height: 24px; flex: none; accent-color: var(--accent); margin: 0 2px 0 0; }
.del-icon { flex: none; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.del-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.del-icon:active { background: rgba(239,68,68,.15); color: #fca5a5; }
.title-row { display: flex; align-items: center; gap: 10px; }
.title-row h1 { flex: 1; }
.selectbar { flex: none; display: flex; gap: 8px; align-items: center; padding: 8px calc(12px + var(--sa-right)) 8px calc(12px + var(--sa-left));
  background: var(--panel); border-top: 1px solid var(--line); }
.selectbar .count { flex: 1; font-size: 14px; color: var(--muted); }
.list-hint { font-size: 12px; color: var(--muted); text-align: center; margin: 2px 0 8px; }

/* ---------- szybki przegląd (review.html): zdjęcie | pola ---------- */
.review-bar { flex-direction: row; align-items: center; gap: 12px; flex-wrap: wrap; }
.review-bar select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 14px; }
.review-nav { display: flex; align-items: center; gap: 8px; }
.review-nav #pos { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.review-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(380px, 1fr); }
.review-left { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: #070b14; }
.review-imgbar { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.review-imgbar #code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; }
.review-imgs { flex: 1; min-height: 0; overflow: auto; padding: 12px; }
.review-sheet { margin: 0 0 16px; text-align: center; }
.review-sheet figcaption { margin-top: 4px; }
.review-sheet img { display: block; margin: 0 auto; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.5); }
.review-imgs.fit-page .review-sheet { height: 100%; }
.review-imgs.fit-page img { max-width: 100%; max-height: 100%; object-fit: contain; }
.review-imgs.fit-width img { width: 100%; height: auto; }
.review-imgs.zoom img { width: 200%; max-width: none; height: auto; }
.review-right { min-height: 0; overflow-y: auto; padding: 12px 16px 16px; }
.review-form fieldset { padding: 10px 12px; margin-bottom: 10px; gap: 8px; }
.grid-nip { display: grid; grid-template-columns: minmax(140px, 0.6fr) minmax(0, 1.4fr); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(80px, 0.7fr); gap: 8px; }
.review-actions { position: sticky; bottom: -16px; display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 0; background: var(--bg); border-top: 1px solid var(--line); }
.btn.toggle[aria-pressed="true"] { font-weight: 650; }
.btn.danger-toggle[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.warn-toggle[aria-pressed="true"] { background: var(--warn); border-color: var(--warn); color: #111; }
.linklike { background: none; border: 0; padding: 4px 0; color: var(--info); cursor: pointer; text-decoration: underline; }
.kbd-legend { margin: 10px 0 0; line-height: 1.8; }
kbd { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--panel-2); color: var(--text); }
body.review-empty .review-form, body.review-empty .review-actions, body.review-empty .kbd-legend, body.review-empty .review-left { display: none; }
body.review-empty .review-main { grid-template-columns: 1fr; }
@media (max-width: 899px) {
  .review-main { grid-template-columns: 1fr; grid-template-rows: 45% minmax(0, 1fr); }
  .review-left { border-right: 0; border-bottom: 1px solid var(--line); }
  .kbd-legend { display: none; }
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.chip.danger { background: #7f1d1d; color: #fecaca; }
.wide-only { display: none; }
@media (min-width: 900px) and (pointer: fine) { .wide-only { display: inline-flex; } }
@media (min-width: 900px) and (pointer: fine) {
  .review-form .field input, .review-form .field select, .review-form .field textarea { min-height: 36px; padding: 6px 10px; font-size: 15px; }
  .review-form .field textarea { min-height: 52px; }
}
.review-imgs.fit-page .review-sheet:has(figcaption) img { max-height: calc(100% - 24px); }
.btn.rot { font-size: 20px; line-height: 1; padding: 4px 10px; }
.review-actions .btn { white-space: nowrap; }
