:root {
  --bg: #0d0f13;
  --panel: #151820;
  --panel-2: #1b1f28;
  --panel-3: #232836;
  --border: #272c38;
  --text: #e6e8ee;
  --muted: #8b93a7;
  --accent: #2f7cf6;
  --accent-2: #2563eb;
  --rec: #ef4444;
  --ok: #22c55e;
  --warn: #f59e0b;
  --radius: 10px;
  --topbar: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0 0 2px; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 15px; margin: 0 0 4px; font-weight: 600; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.err { color: #f87171; }
.warn { color: var(--warn); }
.spacer { flex: 1; }
.icon { display: inline-flex; flex: none; }
[hidden] { display: none !important; }

/* ---------- nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  background: var(--panel-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #2b3242; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.primary:hover { background: #1d4fd8; }
.btn.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  background: transparent; color: var(--text);
  border: 0; border-radius: 8px; cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.08); }
.icon-btn.active { background: rgba(47,124,246,.2); color: #7fb0ff; }
.icon-btn.danger:hover { color: #f87171; }
.icon-btn.big { width: 44px; height: 44px; background: var(--accent-2); color: #fff; border-radius: 50%; }
.icon-btn.big:hover { background: #1d4fd8; }
.icon-btn.tiny { width: 22px; height: 22px; vertical-align: middle; }
.icon-btn.tiny svg { width: 14px; height: 14px; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 2px; gap: 2px; }
.seg .icon-btn { width: 34px; height: 30px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  font: inherit; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: #3a4152; }
.chip.active { background: rgba(47,124,246,.18); border-color: var(--accent); color: #fff; }
.chip.small { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.seg .chip.small { border: 0; background: transparent; }
.seg .chip.small.active { background: var(--panel-3); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.s-recording { background: var(--rec); box-shadow: 0 0 0 3px rgba(239,68,68,.2); }
.dot.s-error { background: var(--warn); }
.dot.s-connecting { background: var(--accent); }

/* ---------- đăng nhập ---------- */
.login-page { min-height: 100%; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 0%, #17223a, var(--bg) 60%); }
.login-card {
  width: 100%; max-width: 340px; padding: 32px 28px; text-align: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-card .logo { align-self: center; }
.login-card .logo svg { width: 52px; height: 52px; }
.login-card h1 { margin: 6px 0 0; }
.login-card p { margin: -6px 0 6px; }
.form-error { color: #f87171; min-height: 18px; font-size: 13px; }

input[type=text], input[type=password], input[type=number], input[type=date], select {
  height: 38px; width: 100%; padding: 0 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
select { width: auto; padding-right: 28px; }

/* ---------- khung chính ---------- */
.shell { display: flex; flex-direction: column; min-height: 100%; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  height: var(--topbar); padding: 0 16px;
  background: rgba(13,15,19,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 17px; }
.logo { display: inline-flex; }
.nav { display: flex; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 8px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.05); }
.nav-item.active { color: #fff; background: var(--panel-3); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.rec-status { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px; background: var(--panel-2); color: var(--text); font-size: 13px; font-weight: 500; }
.rec-status .dot { background: var(--muted); }
.rec-status.ok .dot { background: var(--rec); animation: pulse 1.6s infinite; }
.rec-status.warn { color: var(--warn); }
.rec-status.warn .dot { background: var(--warn); }
.rec-status.bad { color: #f87171; }
.rec-status.bad .dot { background: #f87171; }
@keyframes pulse { 50% { opacity: .35; } }

.main { flex: 1; padding: 16px; width: 100%; max-width: 1600px; margin: 0 auto; }
.main.page-live { max-width: none; padding: 10px; display: flex; flex-direction: column; }
.main.page-playback { max-width: none; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.seg.quality { align-items: center; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 60px 20px; color: var(--muted); text-align: center; grid-column: 1 / -1; }
.empty.wide { border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- xem trực tiếp ---------- */
.live-grid {
  --gap: 4px;
  display: grid; gap: var(--gap);
  height: calc(100dvh - var(--topbar) - 76px);
  min-height: 300px;
  background: #000; border-radius: var(--radius); overflow: hidden;
}
.live-grid.l1 { grid-template: 1fr / 1fr; }
.live-grid.l2 { grid-template: 1fr / 1fr 1fr; }
.live-grid.l3 { grid-template: 1fr 1fr / 2fr 1fr; }
.live-grid.l3 > :first-child { grid-row: span 2; }
.live-grid.l4 { grid-template: 1fr 1fr / 1fr 1fr; }
.live-grid.l9 { grid-template: repeat(3, 1fr) / repeat(3, 1fr); }
.page-live:has(.cam-switcher:not(:empty)) .live-grid { height: calc(100dvh - var(--topbar) - 124px); }
.tile { position: relative; background: #050608; overflow: hidden; min-height: 0; user-select: none; }
.tile cam-live { position: absolute; inset: 0; display: block; }
.tile video { object-fit: contain; background: #000; }
.tile.empty-slot { display: grid; place-items: center; color: #3a4152; font-size: 13px; }
.tile-top {
  position: absolute; left: 0; right: 0; top: 0; padding: 8px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: linear-gradient(rgba(0,0,0,.6), transparent); pointer-events: none;
}
.tile-tags { display: flex; align-items: center; gap: 6px; flex: none; }
.q-chip {
  pointer-events: auto; cursor: pointer;
  font: 700 11px/1.45 var(--font); letter-spacing: .3px;
  padding: 2px 7px; border: 0; border-radius: 5px;
  background: rgba(0,0,0,.55); color: #cbd2df; white-space: nowrap;
}
.q-chip:hover:not(:disabled) { background: rgba(0,0,0,.8); color: #fff; }
.q-chip:disabled { cursor: default; }
.tile-name { font-weight: 600; text-shadow: 0 1px 2px #000; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; font-weight: 700; letter-spacing: .3px; padding: 2px 7px; border-radius: 5px; background: rgba(0,0,0,.55); color: #cbd2df; white-space: nowrap; }
.badge.s-recording { background: var(--rec); color: #fff; }
.badge.s-error { background: var(--warn); color: #111; }
.badge.s-connecting { background: var(--accent-2); color: #fff; }
.tile-actions {
  position: absolute; right: 6px; bottom: 6px; display: flex; gap: 2px; padding: 3px;
  background: rgba(10,12,16,.75); border-radius: 10px; opacity: 0; transition: opacity .15s;
}
.tile:hover .tile-actions, .tile:focus-within .tile-actions { opacity: 1; }
.tile-msg { position: absolute; left: 0; right: 0; bottom: 42%; text-align: center; color: #cbd2df; text-shadow: 0 1px 2px #000; pointer-events: none; }
.tile-spinner {
  position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border: 3px solid rgba(255,255,255,.15); border-top-color: #fff; border-radius: 50%;
  animation: spin .9s linear infinite; pointer-events: none;
}
.tile-spinner.static { position: static; margin: 0 auto; }
.tile-spinner.inline { position: static; display: inline-block; width: 14px; height: 14px; margin: 0; border-width: 2px; vertical-align: -2px; }
.tile:has(cam-live[state=playing]) .tile-spinner,
.tile:has(cam-live[state=error]) .tile-spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.cam-switcher { display: flex; gap: 8px; overflow-x: auto; padding-top: 10px; scrollbar-width: none; }
.cam-switcher:empty { display: none; }

/* ---------- xem lại ---------- */
.pb-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.day-nav { display: flex; align-items: center; gap: 4px; }
.date-pick {
  position: relative; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-weight: 500;
}
.date-pick .date-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; height: auto; }
.date-pick .date-input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; cursor: pointer; }
.pb-head .chips { flex: 1; min-width: 0; }
.pb-stage { position: relative; flex: 1; min-height: 240px; background: #000; border-radius: var(--radius); overflow: hidden; }
.pb-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; visibility: hidden; }
.pb-stage video.active { visibility: visible; }
.pb-overlay { position: absolute; inset: 0; z-index: 2; display: none; place-items: center; text-align: center; color: var(--muted); background: rgba(0,0,0,.55); padding: 20px; }
.pb-overlay.show { display: grid; }
.pb-overlay .btn { margin-top: 6px; }
.pb-cam-label { position: absolute; z-index: 1; left: 12px; top: 10px; font-weight: 600; text-shadow: 0 1px 3px #000; pointer-events: none; }
.pb-controls {
  display: flex; align-items: center; gap: 10px 18px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.ctrl-group { display: flex; align-items: center; gap: 4px; }
.ctrl-group.export { margin-left: auto; gap: 6px; }
.pb-clock { display: flex; flex-direction: column; line-height: 1.15; min-width: 92px; }
.pb-clock strong { font-size: 20px; font-variant-numeric: tabular-nums; font-weight: 650; }
.pb-clock span { font-size: 12px; color: var(--muted); }
.rate { height: 34px; }
.range-text { font-size: 13px; font-variant-numeric: tabular-nums; color: #facc15; display: inline-flex; align-items: center; gap: 4px; }
.pb-timeline { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tl-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.tl-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.lg { width: 12px; height: 8px; border-radius: 2px; margin-left: 6px; }
.lg.ok { background: #2f7cf6; }
.lg.rec { background: var(--rec); }
.lg.bad { background: #5b6270; }
.timeline-canvas { display: block; width: 100%; cursor: crosshair; touch-action: pan-y; }

/* ---------- camera ---------- */
.cam-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.cam-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.cam-thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: #050608; color: var(--muted); }
.cam-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-thumb img.broken { visibility: hidden; }
.thumb-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 13px; z-index: 0; }
.cam-thumb img { z-index: 1; }
.cam-thumb .badge { position: absolute; z-index: 2; right: 10px; top: 10px; }
.cam-body { padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.cam-info { font-size: 13px; color: #c3c9d6; min-height: 19px; margin: 0; }
.cam-info.err { color: var(--warn); }
.cam-meta { font-size: 12px; margin: 2px 0 8px; }
.cam-actions { display: flex; align-items: center; gap: 2px; margin-top: auto; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider { width: 38px; height: 22px; border-radius: 999px; background: #3a4152; position: relative; transition: background .2s; }
.switch .slider::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .slider { background: var(--rec); }
.switch input:checked + .slider::after { transform: translateX(16px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- biểu mẫu / hộp thoại ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; color: #c3c9d6; font-weight: 500; }
.field small { font-size: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row2 .field.narrow { max-width: 140px; }
.brand-fields { display: flex; flex-direction: column; gap: 12px; padding: 14px; background: var(--panel-2); border-radius: 10px; }
.checks { display: flex; gap: 20px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.hint { font-size: 13px; color: var(--muted); background: rgba(47,124,246,.08); border: 1px solid rgba(47,124,246,.2); padding: 10px 12px; border-radius: 8px; margin: 0; }
.probe-row { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.probe p { margin: 4px 0; font-size: 13px; display: flex; gap: 6px; align-items: flex-start; }
.modal-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 620px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 0 20px; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); }

/* ---------- nhật ký ---------- */
.filters { display: flex; gap: 8px; }
.log-list { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.log-date { padding: 8px 14px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel-2); border-bottom: 1px solid var(--border); }
.log-row { display: grid; grid-template-columns: 70px 22px 150px 1fr; gap: 10px; align-items: start; padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.log-row:last-child { border-bottom: 0; }
.log-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.log-level { color: var(--accent); }
.log-row.l-warn .log-level { color: var(--warn); }
.log-row.l-error .log-level { color: #f87171; }
.log-row.l-error .log-msg { color: #fca5a5; }
.log-cam { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- cài đặt ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.card.wide { grid-column: 1 / -1; }
.dir-row { display: flex; gap: 8px; margin-bottom: 8px; }
.dir-row input { flex: 1; min-width: 0; font-family: ui-monospace, Consolas, monospace; }
.dir-path { font-family: ui-monospace, Consolas, monospace; font-size: 13px; padding: 8px 12px; margin-bottom: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; word-break: break-all; }
.dir-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.dir-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; background: transparent; color: var(--text); border: 0; border-bottom: 1px solid var(--border); font: inherit; text-align: left; cursor: pointer; }
.dir-item:last-child { border-bottom: 0; }
.dir-item:hover { background: rgba(255,255,255,.05); }
.dir-item .icon { color: #f5c451; }
.dir-item.up { color: var(--muted); }
.dir-item.up .icon { color: var(--muted); }
.dir-empty { padding: 10px 12px; margin: 0; }
.new-dir { margin-top: 14px; }
.card .form { gap: 12px; }
.card .form .btn { align-self: flex-start; }
.card .hint { margin-top: 14px; display: flex; gap: 6px; }
.usage-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: #2a303d; }
.usage-bar span { height: 100%; }
.u-rec { background: var(--accent); }
.u-other { background: #6b7280; }
.u-free { background: #2a303d; }
.usage-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 14px; font-size: 13px; color: #c3c9d6; }
.usage-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-weight: 500; }
.per-cam { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.per-cam-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }

/* ---------- thông báo ---------- */
#toasts { position: fixed; z-index: 100; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px;
  background: #222837; border: 1px solid #343b4c; border-left: 3px solid var(--accent); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); transition: opacity .35s, transform .35s;
}
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--rec); }
.toast.hide { opacity: 0; transform: translateY(8px); }

/* ---------- màn hình vừa: menu chỉ còn biểu tượng ---------- */
@media (min-width: 721px) and (max-width: 1000px) {
  .nav-item { padding: 0 11px; }
  .nav-item > span:not(.icon) { display: none; }
  .rec-status { white-space: nowrap; }
}

/* ---------- điện thoại ---------- */
@media (max-width: 720px) {
  :root { --topbar: 52px; }
  /* backdrop-filter khiến thanh menu "fixed" bám theo thanh trên thay vì đáy màn hình */
  .topbar { gap: 10px; padding: 0 10px; backdrop-filter: none; background: var(--bg); }
  .brand span:last-child { display: none; }
  .nav {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    justify-content: space-around; gap: 0;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    background: rgba(13,15,19,.96); border-top: 1px solid var(--border);
  }
  .nav-item { flex-direction: column; gap: 2px; height: auto; padding: 6px 4px; font-size: 11px; flex: 1; }
  .main { padding: 12px 10px calc(76px + env(safe-area-inset-bottom)); }
  .main.page-live, .main.page-playback { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .hide-mobile { display: none !important; }
  .live-grid, .page-live:has(.cam-switcher:not(:empty)) .live-grid { height: auto; min-height: 0; grid-template: none !important; grid-auto-rows: auto; background: transparent; gap: 8px; }
  .live-grid .tile { aspect-ratio: 16 / 9; border-radius: 8px; grid-row: auto !important; }
  .live-grid.l1 .tile { aspect-ratio: auto; height: calc(100dvh - var(--topbar) - 200px); min-height: 220px; }
  .tile-actions { opacity: 1; }
  .live-grid .tile.empty-slot { display: none; }
  .pb-stage { flex: none; aspect-ratio: 16 / 9; min-height: 0; }
  .pb-controls { gap: 8px; }
  .ctrl-group.export { margin-left: 0; }
  .pb-head { gap: 8px; }
  .pb-head .chips { flex-basis: 100%; }
  .tl-legend { display: none; }
  .log-row { grid-template-columns: 62px 18px 1fr; }
  .log-row .log-cam { grid-column: 3; }
  .log-row .log-msg { grid-column: 1 / -1; }
  .row2 { grid-template-columns: 1fr; }
  .row2 .field.narrow { max-width: none; }
  .settings-grid { grid-template-columns: 1fr; }
  .dir-row { flex-wrap: wrap; }
  .dir-row input { flex-basis: 100%; }
  .page-head h1 { font-size: 20px; }
  #toasts { right: 10px; left: 10px; bottom: calc(70px + env(safe-area-inset-bottom)); max-width: none; }
}
