/* Defence Radar workspace. Component/layout rules; the single colour and type system is in live.css.
   Inspired by Tabler's clear app framing and Carbon's data hierarchy, implemented in native CSS.
   Breakpoints: 1100 desktop rail, 760 stacked content, 480 compact telemetry. */
:root { --font-head: var(--font-sans); --rail-w: 210px; --bar-h: 0px; --mx-top: 54px;
  --reticle: #087568; --reticle-tint: 5%;
  /* the map is a plotting-room instrument in both themes: a dark sphere, muted land, one signal colour per dot */
  --globe-deep: #02060a; --globe-sea: #04111a; --globe-sea-hi: #071d27;
  --globe-land: #0a1d27; --globe-land-hi: #102d39; --globe-edge: #284a59;
  --globe-grid: rgb(112 190 205 / .11); --globe-atmo: #57dfcc;
  --globe-star: #cfeeff; --globe-label: #9ebdc6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --reticle: #70dac3; --reticle-tint: 5%; } }
:root[data-theme="dark"] { --reticle: #70dac3; --reticle-tint: 5%; }
body { background: var(--bg); }
.shell { min-height: 100dvh; }
.frame { margin-left: var(--rail-w); min-width: 0; }
main, main.wide { max-width: 1600px; padding: 28px 32px 48px; margin: 0 auto; }
html { scroll-padding-top: 20px; }
html:has(.mx-top) { scroll-padding-top: 130px; }

/* Seven working destinations, with one stable active indicator. */
.cmd-rail { position: fixed; inset: 0 auto 0 0; z-index: var(--z-nav); width: var(--rail-w); display: flex; flex-direction: column;
  padding: 28px 16px 20px; background: var(--surface); border-right: 1px solid var(--line); }
.cmd-mark { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; padding: 0 4px; }
.cmd-mark svg { flex: none; color: var(--accent); }
.cmd-mark > span { font-size: 14px; font-weight: 600; letter-spacing: -.03em; }
.cmd-mark small { display: block; margin-top: 3px; font-size: 11px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.nav-label, .page-eyebrow, .panel-label, .phase-label { font: 500 12px/1.4 var(--font-sans); letter-spacing: 0; text-transform: none; color: var(--muted); }
.nav-label { margin: 40px 12px 12px; }
.cmd-rail .nav { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 6px; }
.cmd-rail .nav a { display: flex; gap: 12px; min-height: 44px; padding: 10px 14px; border: 1px solid transparent; border-radius: 7px;
  font-size: 13px; color: var(--muted); transition: background-color var(--fast), color var(--fast); }
.cmd-rail .nav a:hover { color: var(--ink); background: var(--surface-2); }
.cmd-rail .nav a[aria-current="page"] { background: var(--tint-accent); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 23%, transparent); font-weight: 600; }
.nav-ico { flex: none; width: 19px; height: 19px; }
.rail-foot { margin-top: auto; padding: 20px 12px 0; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.local-label { display: flex; gap: 7px; align-items: center; font-size: 11px; color: var(--ink-2); }
.local-label::before { content: ''; width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--accent); }
.rail-foot p { margin: 16px 0; line-height: 1.7; }
.rail-foot a { display: inline-flex; gap: 12px; min-height: 32px; align-items: center; color: var(--ink-2); text-decoration: none; }
.phase-label { display: block; margin-top: 18px; font-size: 11px; font-weight: 400; }

/* Values are page snapshots, explicitly labelled 'As of', not simulated telemetry. */
.status-bar { border-bottom: 1px solid var(--line); background: var(--surface); padding: 0 32px; }
.sb-name { display: none; }
.sb-tele { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 1.35fr 1.4fr; margin: 0; }
.sb-item { display: flex; flex-direction: column-reverse; justify-content: center; gap: 4px; padding: 9px 20px; border-right: 1px solid var(--line); }
.sb-item:first-child { padding-left: 0; }
.sb-item:last-child { border: 0; padding-right: 0; }
.sb-item dt { color: var(--muted); font: 500 12px/1.4 var(--font-sans); letter-spacing: 0; text-transform: none; }
.sb-item dd { margin: 0; color: var(--ink); font-size: 16px; font-weight: 600; line-height: 1.2; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sb-item:nth-child(-n+2) dd::before { content: ''; display: inline-block; width: 6px; height: 6px; margin: 0 9px 4px 0; border-radius: 50%; background: var(--ok); }
.sb-item.sb-warn dd::before { background: var(--warn); }
.sb-item.sb-hot dd::before { background: var(--war); }
.sb-hot dd { color: var(--war); }
.sb-utc { color: var(--muted); font-size: 11px; font-weight: 400; letter-spacing: 0; margin-left: 4px; }

.page-head { margin: 0 0 26px; }
.page-eyebrow { display: flex; gap: 10px; font-size: 11px; margin: 0 0 18px; }
.page-eyebrow > span { opacity: .5; }
.page-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.page-title { font: 600 clamp(26px, 2.3vw, 34px)/1.2 var(--font-sans); letter-spacing: -.045em; }
.lede { max-width: 78ch; font-size: 13px; line-height: 1.65; color: var(--muted); margin-top: 10px; }
.page-head .utc-switch { flex: none; min-height: 36px; gap: 8px; font-size: 11px; margin: 0; }
h2 { letter-spacing: -.025em; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 15px; }
.section-head a { font-size: 11px; text-decoration: none; min-height: 30px; display: inline-flex; align-items: center; gap: 7px; }
.btn { border-color: var(--line-strong); padding: 8px 12px; font-size: 12px; line-height: 1.3; font-weight: 600; }
.btn.small { min-height: 30px; padding: 5px 8px; }
.btn.primary { box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
input, select, textarea { min-width: 0; max-width: 100%; border-color: var(--line-strong); padding: 8px 10px; }
input[type="checkbox"] { padding: 0; flex: none; }
summary { min-height: 36px; }
.key > summary { font-size: 12px; font-weight: 600; }
.note { margin: 12px 0; padding: 12px 16px; font-size: 12px; }
.note.warn { border-left: 3px dotted var(--warn); }
.note.bad { border-left: 3px dashed var(--war); }
.panel, .side-card, .health-sum, .rq, .sect, .log { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 2px 4px rgb(0 0 0 / .025); }
.empty-state { border-style: solid; border-color: var(--line); padding: 28px; gap: 10px; font-size: 13px; }
.empty-state strong { font-size: 17px; letter-spacing: -.025em; }
.empty-state > span { max-width: 50ch; color: var(--muted); line-height: 1.7; }

/* Live: incoming signals lead, delivery preferences support. */
.ready { display: block; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); margin-bottom: 24px; }
.ready > .check-conn { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border: 0; box-shadow: none; background: transparent; }
.check-conn .check-body { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.check-conn h3 { font-size: 12px; margin: 0; }
.check-conn p { margin: 0; font-size: 11px; max-width: none; color: var(--muted); }
.conn { padding: 0; min-height: 24px; border: 0; font-size: 11px; }
.conn .radar { display: none; }
.conn-down { background: transparent; border: 1px dashed var(--ink); padding: 2px 6px; }
.mark { width: 19px; height: 19px; flex: none; }
.live-grid { grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; }
.live-grid > #history { grid-column: 1; grid-row: 1; }
.live-grid > .newest-part { grid-column: 1; grid-row: 2; margin-top: 0; }
.live-side { grid-column: 2; grid-row: 1 / span 2; gap: 18px; }
#history .empty-state { justify-items: center; text-align: center; min-height: 340px; align-content: center; padding: 26px; background: var(--surface); }
.quiet-radar { color: var(--accent); fill: none; stroke: currentcolor; stroke-width: .7; }
.quiet-radar > circle, .quiet-radar > path { opacity: .18; }
.quiet-radar .radar-sector { fill: var(--accent); opacity: .07; stroke: none; }
.quiet-radar .radar-line { opacity: .65; stroke-width: 1.5; }
.quiet-radar .radar-center { fill: var(--accent); opacity: 1; }
#history .empty-state .panel-label { color: var(--accent); font-size: 11px; margin-top: -5px; }
#history .empty-state .btn { margin-top: 8px; }
.ready-delivery { margin: 0; padding: 18px; }
.ready-delivery h2, .side-card h2 { font-size: 13px; margin: 0 0 16px; letter-spacing: -.015em; }
.ready-delivery .check { grid-template-columns: minmax(0,1fr); padding: 16px 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; box-shadow: none; background: transparent; }
.ready-delivery .check:last-child { padding-bottom: 0; }
.ready-delivery .mark { display: none; }
.ready-delivery h3 { color: var(--muted); font: 500 11px/1.4 var(--font-sans); margin-bottom: 10px; }
.ready-delivery .check p { color: var(--muted); font-size: 11px; line-height: 1.7; margin-top: 10px; }
.ready-delivery .btn { min-height: 36px; font-size: 11px; }
.side-card { padding: 18px; }
.side-card .legend { display: block; font-size: 11px; }
.side-card .legend dt { margin-top: 16px; font-size: 11px; }
.side-card .legend dd { margin: 6px 0 0; line-height: 1.75; color: var(--muted); }
.side-card.key { padding: 10px 18px; }
.newest-part .part-lede { font-size: 11px; color: var(--muted); margin: -5px 0 14px; }
.newest-part .newest { padding: 0; border-radius: var(--radius-lg); }
.newest li { padding: 17px 20px; gap: 9px; box-shadow: none; border-left: 2px solid var(--line-strong); }
.newest li[data-tier="mainstream"] { border-left-color: var(--blue); box-shadow: none; }
.newest li:first-child { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.newest li:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.newest-part .n-title { font-size: 13px; line-height: 1.6; }
.newest-part .newest .byline { font-size: 11px; gap: 8px; }
.side-more { font-size: 11px; margin-top: 12px; }
.toasts { z-index: var(--z-toast); }
.alert { padding: 18px; }

/* Matrix: topics and source buckets remain distinct from the story stream. */
.mx-top { --mx-top: 54px; top: 0; height: 54px; margin: 0 0 12px; padding: 0; display: flex; align-items: center; background: var(--bg); }
.tabs.sections { flex-wrap: nowrap; overflow-x: auto; gap: 4px; padding: 4px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; width: max-content; max-width: 100%; }
.tabs.sections a { flex: none; white-space: nowrap; min-height: 34px; border: 0; padding: 8px 12px; font-size: 11px; border-radius: 5px; }
.tabs.sections a[aria-current="page"] { background: var(--tint-accent); color: var(--accent); }
.tabs.sections a[aria-current="page"] .count { color: inherit; }
.tabs.sections a[aria-current="page"] .dot { box-shadow: none; }
.board { grid-template-columns: 220px minmax(0, 1fr); gap: 26px; --mx-top: 54px; }
.rail { top: 66px; padding-right: 10px; max-height: calc(100dvh - 90px); }
.rail-h { font: 500 12px/1.4 var(--font-sans); letter-spacing: 0; text-transform: none; margin-bottom: 16px; }
.rb { font-size: 12px; min-height: 36px; }
.chip { font-size: 11px; min-height: 27px; border-radius: 5px; padding: 4px 7px; }
.chip.zero { border-color: var(--line); }
.stream { max-width: none; }
.showing { font-size: 11px; }
.mh { top: 54px; font-size: 16px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.mc { gap: 14px; }
.event { padding: 20px; gap: 12px; }
.event .ptitle { font-size: 16px; line-height: 1.5; letter-spacing: -.02em; }
.event .pbody { font-size: 13px; line-height: 1.75; }
.ev-head { font-size: 11px; }
.event .byline { font-size: 11px; }
.lane { scroll-margin-top: 64px; }

/* target lock: a calm pointer/focus tint and a fine edge, never an alert-level outline. */
.event:hover, .event:focus-within, .newest li:hover, .newest li:focus-within { background-color: color-mix(in srgb, var(--reticle) var(--reticle-tint), var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--reticle) 25%, transparent); }
.tbl tbody tr:not(.grp):hover, .tbl tbody tr:not(.grp):focus-within { background: color-mix(in srgb, var(--reticle) var(--reticle-tint), var(--surface)); }
@media (forced-colors: active) { .event:focus-within, .newest li:focus-within { outline: 2px solid Highlight; } }

/* Source management and health share one readable ledger. */
.scroll { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
/* a scroll box is the containing block for what is positioned inside it: the screen-reader-only text (.sr is position: absolute) in far-right
   table cells otherwise escapes the box and makes the whole page scroll sideways (Audit: +433px at 390px wide) */
.scroll { position: relative; }
.tbl { min-width: 820px; }
.tbl th { font: 500 12px/1.4 var(--font-sans); letter-spacing: 0; text-transform: none; padding: 12px 14px; background: var(--surface-2); color: var(--muted); }
.tbl td { padding: 14px; font-size: 12px; }
.tbl.sources td { padding-top: 17px; padding-bottom: 17px; }
.tbl.sources .who strong { font-size: 13px; }
.tbl.sources .who-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 7px; font-size: 11px; }
.tbl.sources .topic { max-width: 23rem; font-size: 11px; }
.tbl.sources td.act { font-weight: 600; font-variant-numeric: tabular-nums; }
.tbl.sources th.num { text-align: right; }
.feed-state, .ago-cell { white-space: nowrap; }
.feed-kind, .rev-age { color: var(--muted); font-size: 11px; margin-left: 5px; }
.state-red, .state-auto-disabled { background: var(--war); color: var(--war-ink); border-color: var(--war); }
.tbl tr.grp th { font: 600 12px/1.5 var(--font-sans); text-transform: none; letter-spacing: 0; padding: 14px; }
.filters { gap: 12px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.filters label { flex: 1 1 140px; min-width: 0; gap: 6px; font-size: 11px; }
.filters label.check { flex: 1 1 190px; padding: 0; border: 0; background: transparent; box-shadow: none; }
.grid { gap: 12px; }
.grid label { gap: 6px; }
.table-note { color: var(--muted); font-size: 11px; margin: 10px 0; }
.jump { gap: 6px; margin-bottom: 16px; }
.jump a { border-color: var(--line); padding: 8px 12px; font-size: 12px; }
.top-add { margin: 0 0 12px; }
.top-add > summary { display: inline-flex; gap: 9px; min-height: 38px; padding: 8px 13px; list-style: none; background: var(--accent); color: var(--accent-ink); border-radius: var(--radius); font-size: 12px; }
.top-add > summary::-webkit-details-marker { display: none; }
.top-add > summary::before { content: '+'; font-size: 18px; font-weight: 400; }
.top-add[open] > summary::before { content: '\00d7' / 'Close'; }
.manage-body { max-height: min(440px, 65dvh); overflow-y: auto; max-width: calc(100vw - 48px); padding: 40px 16px 16px; }
.manage-feeds { display: grid; gap: 6px; max-width: 100%; font-size: 11px; }
.manage-feeds .loc { font-size: 11px; }
.manage[open] > summary::after { content: '\00d7' / 'Close'; position: absolute; top: calc(100% + 10px); right: 10px; z-index: 3; display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.bulk { border-color: var(--line); gap: 12px; padding: 16px; }
.bulk label { gap: 6px; }
.log li { grid-template-columns: minmax(140px,1fr) minmax(120px,.8fr) minmax(100px,1fr) 60px; padding: 14px; }
.health-sum .fb-head { padding: 18px; }
/* Health: the feeds split by state as one bar. Count on each segment, a different fill per state (not colour alone), a legend with the same fills */
.sum-chart { padding: 0 18px 20px; }
.sum-bar { display: flex; gap: 3px; height: 36px; }
.seg { flex: var(--n) 1 0; min-width: 40px; display: grid; place-items: center; border-radius: 4px; }
.seg b { padding: 3px 9px; border-radius: 3px; background: var(--bg); color: var(--ink); font: 700 14px/1 var(--font-sans); font-variant-numeric: tabular-nums; }
.seg-ok { background: var(--ok); }
.seg-red { background: var(--war); }
.seg-auto-disabled { background: repeating-linear-gradient(135deg, var(--war) 0 5px, color-mix(in srgb, var(--war) 45%, var(--bg)) 5px 10px); }
.seg-no-data { background: var(--line-strong); }
.seg-disabled { background: transparent; border: 2px dashed var(--off); }
.sum-keys { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 16px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--ink-2); }
.sum-keys li { display: inline-flex; align-items: center; gap: 8px; }
.sum-keys strong { color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }
.sum-keys li.zero { color: var(--muted); }
.sum-keys li.zero strong { color: var(--muted); font-weight: 400; }
.sum-keys .sw { flex: none; width: 18px; height: 18px; min-width: 0; border-radius: 3px; }
.feeds-h { font-size: 16px; }
.rq { padding: 28px; max-width: 860px; margin-top: 20px; }
.rq h2 { font-size: 23px; line-height: 1.5; margin: 16px 0; }
.rq .pbody.big { font-size: 16px; line-height: 1.85; }
.rq .keys { display: flex; gap: 12px; margin: 24px 0 16px; }
.rq .btn.key { min-height: 44px; gap: 12px; padding: 10px 16px; }
.rq kbd { background: var(--surface-2); padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px; }
.review-summary { display: flex; flex-wrap: wrap; gap: 12px 24px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.replay-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; margin-top: 20px; }
.replay-panel { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.replay-panel h2 { margin-top: 0; }
.replay-stats { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.replay-stats dt { color: var(--muted); font-size: 11px; }
.replay-stats dd { margin: 4px 0; font-size: 22px; font-variant-numeric: tabular-nums; }
.replay-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.audit-value { max-width: 36ch; }
.audit-json { display: block; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; padding: 10px; background: var(--sunken); }

/* Map remains the real, offline vector map; controls use the same surfaces. */
body:has(.map-full) { display: block; height: auto; overflow: hidden; }
body:has(.map-full) .frame { height: 100dvh; display: flex; flex-direction: column; }
body:has(.map-full) .frame > main.map-full { flex: 1; min-height: 0; max-width: none; width: 100%; padding: 0; }
.map-float { background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); backdrop-filter: none; }
.map-side { width: 320px; top: 18px; left: 18px; bottom: 78px; }
.side-head { padding: 14px; }
.side-title { font-size: 13px; font-weight: 600; }
.side-body { padding: 16px; }
.map-find { top: 18px; }
.map-find input { font-size: 12px; }
.map-zoom { top: 18px; }
.map-chips .chip { border-radius: 5px; }
.map-chips .chip[aria-current="true"] { color: var(--accent-ink); background: var(--accent); }
.map-bar { font-size: 11px; }

@media (max-width: 1300px) and (min-width: 1101px) {
  :root { --rail-w: 188px; }
  .cmd-rail { padding-left: 10px; padding-right: 10px; }
  main, main.wide { padding-left: 24px; padding-right: 24px; }
  .status-bar { padding: 0 24px; }
  .sb-item { padding: 8px 14px; }
  .sb-item dd { font-size: 15px; }
  .sb-utc { display: block; margin: 4px 0 0; }
  .live-grid { grid-template-columns: minmax(0, 1fr) 270px; gap: 20px; }
}
@media (max-width: 1100px) {
  :root { --rail-w: 0px; }
  .cmd-rail { position: static; width: auto; padding: 0 24px; flex-direction: row; align-items: center; gap: 22px; border: 0; border-bottom: 1px solid var(--line); }
  .cmd-mark { padding: 18px 0; }
  .cmd-mark small { display: none; }
  .cmd-mark > span { white-space: nowrap; }
  .nav-label, .rail-foot { display: none; }
  .cmd-rail .nav { flex-direction: row; flex: 1; overflow-x: auto; gap: 2px; }
  .cmd-rail .nav a { flex: none; min-height: 40px; padding: 8px 10px; gap: 7px; font-size: 12px; }
  .nav-ico { width: 16px; height: 16px; }
  .status-bar { padding: 0 24px; }
  .sb-item { padding: 8px 16px; }
  .sb-item dd { font-size: 16px; }
  body:has(.map-full) .shell { height: 100dvh; display: flex; flex-direction: column; }
  body:has(.map-full) .frame { height: auto; flex: 1; min-height: 0; }
}
@media (max-width: 760px) {
  .cmd-rail { display: block; padding: 0 16px; }
  .cmd-mark { padding: 15px 0 12px; }
  .cmd-mark svg { width: 25px; height: 25px; }
  .cmd-mark small { display: block; font-size: 11px; }
  .cmd-rail .nav { padding-bottom: 10px; gap: 3px; scrollbar-width: thin; }
  .cmd-rail .nav a { padding: 9px 12px; min-height: 40px; }
  .status-bar { padding: 0 16px; }
  .sb-tele { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .sb-item { padding: 13px 15px; gap: 6px; }
  .sb-item:nth-child(3) { border: 0; }
  .sb-item:nth-child(n+4) { flex-direction: row; align-items: baseline; justify-content: flex-start; gap: 8px; grid-column: span 1; border: 0; padding: 11px 0; border-top: 1px solid var(--line); }
  .sb-item:nth-child(4) { grid-column: span 1; }
  .sb-item:nth-child(5) { grid-column: span 2; justify-content: flex-end; }
  .sb-item:nth-child(n+4) dd { font-size: 11px; letter-spacing: 0; }
  .sb-item:nth-child(n+4) dt { font-size: 11px; }
  .sb-item dt { font-size: 11px; }
  .sb-utc { font-size: 11px; }
  main, main.wide { padding: 24px 18px 36px; }
  .page-heading-row { flex-wrap: wrap; gap: 8px 16px; }
  .page-head { margin-bottom: 20px; }
  .page-eyebrow { margin-bottom: 12px; }
  .page-title { font-size: 28px; }
  .page-head .utc-switch { min-height: 32px; font-size: 11px; }
  .lede { font-size: 12px; }
  .ready > .check-conn { padding: 13px; }
  .check-conn .check-body { gap: 5px 12px; }
  .check-conn p { flex-basis: 100%; line-height: 1.7; }
  .live-grid { grid-template-columns: minmax(0,1fr); gap: 24px; }
  .live-grid > #history, .live-grid > .newest-part, .live-side { grid-column: 1; grid-row: auto; }
  #history .empty-state { min-height: 300px; padding: 22px; }
  .quiet-radar { width: 120px; height: 120px; }
  .live-side { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
  .live-side > details { grid-column: 1 / -1; }
  .board { grid-template-columns: minmax(0,1fr); gap: 20px; }
  .rail { position: static; max-height: 260px; border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: var(--surface); }
  .mx-top { margin: 0; }
  .mh { top: 54px; }
  .filters { padding: 14px; }
  .filters label { flex-basis: calc(50% - 12px); }
  .log li { grid-template-columns: minmax(0,1fr); }
  .rq { padding: 20px; }
  .rq h2 { font-size: 19px; }
  .rq .keys { flex-wrap: wrap; }
  .replay-grid { grid-template-columns: minmax(0,1fr); }
  .map-side { top: 72px; width: min(300px,calc(100% - 84px)); bottom: 126px; left: 12px; }
  .map-find { left: 12px; right: 12px; top: 12px; width: auto; transform: none; }
  .map-zoom { top: 72px; right: 12px; }
  .map-chips { left: 12px; right: 12px; bottom: 76px; width: auto; transform: none; overflow-x: auto; flex-wrap: nowrap; justify-content: flex-start; max-width: none; }
  .map-chips .chip { flex: none; }
  .map-bar { left: 12px; right: 12px; bottom: 12px; padding: 10px; }
  .map-bar .map-legend, .map-coords { display: none; }
}
@media (max-width: 480px) {
  .sb-item:nth-child(n+4) { gap: 5px; }
  .sb-item:nth-child(4) dt { display: none; }
  .sb-item:nth-child(4) dd::before { content: 'Intake '; color: var(--muted); font-weight: 400; }
  .sb-utc { display: none; }
  .live-side { grid-template-columns: minmax(0,1fr); }
  .filters label { flex-basis: 100%; }
  .page-heading-row { align-items: flex-start; }
  .page-head .utc-switch { flex-basis: 100%; }
  .newest li { padding: 16px; }
  .section-head .panel-label { font-size: 11px; }
  .map-side { bottom: 140px; }
}
@media (max-height: 720px) { .rail-foot p { display: none; } }
@media (pointer: coarse) { .btn, .btn.small, .cmd-rail .nav a, summary, .chip, select { min-height: 44px; } }
@media print { .cmd-rail, .status-bar, .utc-switch, .toasts { display: none; } .frame { margin: 0; } main, main.wide { max-width: none; padding: 0; } }

/* the tier rail is hidden at the user's request; its markup stays (tests lock it) and ?tier= in the address still filters */
nav.map-chips.map-float, p.map-strip.map-float { display: none; }

/* ---------- Map: the interface floats over the map. Layer rail left, status strip top, controls right, time window bottom.
   Proportions follow a layout the user liked (40px rail buttons with count badges, 32px round controls, a segmented switch, a direction
   pad, one status strip); the colours, icons and data are ours. ---------- */
:root { --ease-out: cubic-bezier(.16, 1, .3, 1); }
.map-float { background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }

.map-chips { left: 12px; top: 12px; right: auto; bottom: auto; width: 54px; margin: 0; padding: 6px; display: flex; flex-direction: column;
  align-items: center; gap: 4px; transform: none; overflow: visible; }
.map-chips .chip { position: relative; display: grid; place-items: center; flex: none; width: 40px; height: 40px; min-height: 40px; padding: 0; border: 1px solid transparent;
  border-radius: 8px; font-size: 0; color: var(--muted); background: transparent;
  transition: background-color .5s var(--ease-out), color .5s var(--ease-out), border-color .5s var(--ease-out); }
.map-chips .chip:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, transparent); }
.map-chips .chip[aria-current="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.map-chips .chip.zero { opacity: .55; }
.map-chips .chip .n { position: absolute; top: -3px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; opacity: 1;
  background: var(--accent); color: var(--accent-ink); font: 700 10px/16px var(--font-sans); text-align: center; font-variant-numeric: tabular-nums; }
.map-chips .chip.zero .n { display: none; }

.map-strip { position: absolute; top: 12px; left: 12px; margin: 0; display: flex; align-items: center; gap: 0 6px; height: 40px; padding: 0 16px; white-space: nowrap; }
.map-strip .k { color: var(--muted); font: 500 11px/1.2 var(--font-sans); letter-spacing: 0; text-transform: none; }
.map-strip b { margin-right: 12px; color: var(--ink); font: 600 13px/1 var(--font-sans); font-variant-numeric: tabular-nums; }
.map-strip b:last-child { margin-right: 0; }
.map-strip .zulu { color: var(--accent); }

.map-find { top: 12px; left: 12px; transform: none; width: 340px; height: 40px; }
.map-side { left: 12px; top: 64px; bottom: 112px; width: 320px; }

.map-zoom { top: 12px; right: 12px; width: 46px; padding: 6px; gap: 6px; justify-items: center; }
.map-zoom .btn { width: 32px; min-width: 32px; height: 32px; min-height: 32px; padding: 0; justify-content: center; border-radius: 50%; font-size: 16px; line-height: 1; }
.map-zoom .zoom-read { font: 600 10px/1 var(--font-sans); color: var(--muted); }

.map-zoom { display: none; }  /* the slider and readout stay in the page for the script; + and - live in the pad */
.map-pad { position: absolute; right: 12px; bottom: 64px; display: flex; align-items: center; gap: 14px; padding: 14px 22px 14px 16px; border-radius: 16px;
  background: color-mix(in srgb, var(--bg) 55%, transparent); }
.pad-zoom { display: grid; gap: 14px; }
.pad-div { align-self: stretch; width: 1px; margin: 6px 0; background: var(--line); }
.pad-dir { display: grid; grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(3, 34px); }
.pad-dir .up { grid-area: 1 / 2; } .pad-dir .left { grid-area: 2 / 1; } .pad-dir .right { grid-area: 2 / 3; } .pad-dir .down { grid-area: 3 / 2; }
.pad-b { display: grid; place-items: center; width: 40px; height: 34px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted);
  font: 300 22px/1 var(--font-sans); cursor: pointer; transition: color .3s var(--ease-out), background-color .3s var(--ease-out); }
.pad-b:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.pad-b:active { transform: scale(.92); }
.pad-reset { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.pad-reset:focus-visible { width: auto; height: auto; margin: 0; padding: 6px 10px; clip-path: none; right: 12px; bottom: calc(100% + 6px); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; }
.map-coords { right: 236px; bottom: 64px; }

.map-window { position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%); display: flex; gap: 2px; padding: 4px; }
.map-window a { display: inline-flex; align-items: center; height: 28px; padding: 0 14px; border: 1px solid transparent; border-radius: 7px; color: var(--ink-2);
  font: 600 12px/1 var(--font-sans); text-decoration: none; transition: background-color .5s var(--ease-out), color .5s var(--ease-out), border-color .5s var(--ease-out); }
.map-window a:hover { color: var(--ink); }
.map-window a[aria-current="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 12px 0; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.facts div { padding: 10px 12px; background: var(--surface); }
.facts dt { color: var(--muted); font: 500 11px/1.2 var(--font-sans); letter-spacing: 0; text-transform: none; }
.facts dd { margin: 6px 0 0; color: var(--ink); font: 600 16px/1.1 var(--font-sans); font-variant-numeric: tabular-nums; white-space: nowrap; }

@keyframes map-pulse { 0%, 100% { opacity: .22; } 50% { opacity: .5; } }
.pin .halo { animation: map-pulse 2s ease-in-out infinite; }

@media (max-width: 900px) { .map-strip { display: none; } .map-find { left: 12px; right: 70px; width: auto; } }
@media (max-width: 760px) {
  .map-side { left: 12px; right: 12px; width: auto; top: 64px; bottom: 120px; }
  .map-coords { display: none; }
  .map-window { bottom: 60px; }
}

/* ---------- Map: the view bar (3D / 2D, Map / Sat) with its scale, bottom left; the globe canvas ---------- */
.globe { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.globe[hidden] { display: none; }
.map-modes { position: absolute; left: 12px; bottom: 64px; display: flex; align-items: center; gap: 12px; padding: 6px 10px; border-radius: 14px; }
.map-modes[hidden] { display: none; }
.seg-group { display: flex; gap: 6px; }
.seg-sep { width: 1px; height: 24px; background: var(--line); }
.seg-b { display: inline-flex; align-items: center; gap: 7px; height: 27px; padding: 0 12px; border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--muted); font: 500 12px/1 var(--font-sans); letter-spacing: 0; text-transform: none; cursor: pointer;
  transition: background-color .5s var(--ease-out), color .5s var(--ease-out), border-color .5s var(--ease-out); }
.seg-b:hover { color: var(--ink); }
.seg-b[aria-pressed="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.map-scale { position: absolute; left: 14px; top: calc(100% + 8px); display: flex; align-items: center; gap: 8px; pointer-events: none; }
.scale-bar { display: block; height: 6px; width: 120px; border: 1px solid var(--muted); border-top: 0; }
.scale-km { color: var(--muted); font: 500 11px/1 var(--font-sans); letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.map-side { bottom: 142px; }

/* ---------- Map: OSIRIS-style plotting room ----------
   The globe is the primary view. Both the canvas and the flat fallback use one dark
   palette, so switching 3D/2D does not change the instrument's mood. The dots keep
   the page's own meaning: amber place, blue sea or strait, coral border. */
.map-stage { background: var(--globe-deep); }
.map-view { background: var(--globe-deep); }
.globe { background: var(--globe-deep); }
.map .sea { fill: var(--globe-deep); }
.map .grat line { stroke: var(--globe-grid); }
.map .ctry path { fill: var(--globe-land); stroke: var(--globe-edge); stroke-width: .55; }
.map .ctry.has path { fill: color-mix(in srgb, var(--globe-land), var(--globe-sea-hi) 55%); }
.map .ctry:hover path { fill: var(--globe-land-hi); }
.map .ctry.sel path { fill: var(--globe-land-hi); stroke: var(--globe-atmo); stroke-width: 1.1; }
/* a pin is a small signal lamp: soft halo, bright core, and the same colour language as the legend */
/* the map keeps the brighter plotting-room lamp colours, independent of the warmer page chrome */
.map-stage { --map-place: #e9b45a; --map-water: #8ab4f0; --map-border: #f0807b; }
.map-stage .pin { color: var(--map-place); }
.map-stage .pin-water { color: var(--map-water); }
.map-stage .pin-border { color: var(--map-border); }
.map-stage .key-dot { background: var(--map-place); box-shadow: 0 0 0 4px color-mix(in srgb, var(--map-place) 22%, transparent); }
.map-stage .key-dot.water { background: var(--map-water); box-shadow: 0 0 0 4px color-mix(in srgb, var(--map-water) 22%, transparent); }
.map-stage .key-dot.border { background: var(--map-border); box-shadow: 0 0 0 4px color-mix(in srgb, var(--map-border) 22%, transparent); }
.map-stage .key-box { border-color: var(--map-place); }
.map .pin .halo { opacity: .22; }
.map .pin:hover .halo, .map .pin.sel .halo { opacity: .44; }
.map .pin .dot { stroke: color-mix(in srgb, var(--globe-deep) 70%, transparent); stroke-width: .7; filter: drop-shadow(0 0 1.2px currentColor); }
.map .pin.sel .dot { stroke: #fff; stroke-width: 1.2; }
/* country, state and city names on the flat map: grow a little with zoom, placed only where they fit */
.map .place-label { fill: var(--globe-label); font-family: var(--font-sans); font-weight: 600; letter-spacing: .06em;
  opacity: .85; paint-order: stroke; stroke: var(--globe-deep); stroke-width: .22em; stroke-linejoin: round; pointer-events: none; user-select: none; }
.map .place-label.state { fill: #dff3f5; opacity: .95; font-weight: 600; }
.map .place-label.city { fill: #bfdde3; letter-spacing: 0; opacity: .9; }
.map .place-label.city.capital { font-weight: 600; }
.map .place-label.sel { fill: var(--globe-atmo); opacity: 1; font-weight: 700; }
.map .pin.sel .pin-label { display: inline; }
/* state and province borders, drawn over the country fill and under the names */
.map .state-borders { pointer-events: none; }
.map .state-border { fill: none; stroke: color-mix(in srgb, var(--globe-edge) 82%, transparent); stroke-width: .8px;
  stroke-linejoin: round; opacity: .55; vector-effect: non-scaling-stroke; }
.map .pin-label rect { fill: rgb(4 10 14 / .84); stroke: currentcolor; stroke-width: .45; opacity: 1; }
.map .pin-name { fill: #e8f8fa; }
.map .map-float { background: color-mix(in srgb, var(--surface) 90%, transparent); }
.map-bar { color: var(--ink-2); }
.map-modes .seg-b[aria-pressed="true"] { color: var(--globe-atmo); border-color: color-mix(in srgb, var(--globe-atmo) 50%, transparent); background: color-mix(in srgb, var(--globe-atmo) 14%, transparent); }
.map .map-side, .map .map-find, .map .map-pad, .map .map-window, .map .map-modes, .map .map-bar { border-color: color-mix(in srgb, var(--globe-edge) 65%, transparent); }

/* smaller windows: a narrower panel and a smaller pad leave the map visible */
@media (min-width: 761px) and (max-width: 1100px), (min-width: 761px) and (max-height: 700px) {
  .map-side { width: 264px; }
  .map-pad { transform: scale(.72); transform-origin: right bottom; right: 8px; }
}

/* satellite layer on the flat map: the NASA image replaces the dark sea and land fills; outlines stay for picking */
.sat-img { display: none; pointer-events: none; }
.map.sat .sat-img { display: inline; }
.map.sat .sea, .map.sat .grat { display: none; }
.map.sat .ctry path { fill: transparent; stroke: rgb(255 255 255 / .5); }
.map.sat .ctry.has path { fill: rgb(255 255 255 / .03); }
.map.sat .ctry:hover path { fill: rgb(255 255 255 / .12); }
.map.sat .ctry.sel path { fill: rgb(87 223 204 / .16); stroke: var(--globe-atmo); }
.map.sat .place-label { fill: #fff; opacity: 1; stroke: rgb(0 0 0 / .85); }
.map.sat .place-label.sel { fill: var(--globe-atmo); }

/* Media screen: photos and videos from Telegram */
.media-views { margin: 0 0 var(--space-4, 16px); }
.media-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.media-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.media-card.kept { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.media-view { background: var(--bg); aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden; }
.media-view img, .media-view video { width: 100%; height: 100%; object-fit: contain; display: block; }
.media-none { display: grid; gap: 4px; padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }
.media-meta { display: grid; gap: 6px; padding: 12px 14px 14px; }
.media-meta p { margin: 0; }
.media-src { font-size: 13px; }
.media-cap { font-size: 13px; color: var(--ink-2, var(--ink)); overflow-wrap: anywhere; }
.media-links { display: flex; align-items: center; gap: 12px; font-size: 12px; }
.media-actions { display: flex; gap: 8px; margin-top: 4px; }
.media-actions form { margin: 0; }
.media-chan { font-size: 12px; color: var(--muted); margin-left: 6px; }
.media-when { font-size: 12px; }
.media-cap summary { cursor: pointer; }
.media-near { font-size: 12px; border-left: 2px solid var(--line-strong, var(--line)); padding-left: 8px; }

/* Telegram screen: channel list on the left, messages like the app on the right */
.tg { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 20px; align-items: start; }
.tg-side { display: grid; gap: 12px; position: sticky; top: calc(var(--bar-h, 0px) + 8px); max-height: calc(100dvh - var(--bar-h, 0px) - 24px); overflow: auto; }
.tg-add form { display: grid; gap: 8px; margin-top: 10px; }
.tg-add label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.tg-search input, .tg-add input, .tg-edit input { width: 100%; }
.tg-labels { display: flex; flex-wrap: wrap; gap: 6px; }
.tg-channels { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.tg-channels a { display: flex; gap: 10px; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: inherit; }
.tg-channels a:hover, .tg-channels .on a { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.tg-ava { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: color-mix(in srgb, var(--accent) 22%, var(--surface)); color: var(--accent); }
.tg-chan { display: grid; gap: 2px; min-width: 0; font-size: 13px; }
.tg-chan strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tg-empty { padding: 8px 10px; }
.tg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.tg-head h2 { margin: 0; font-size: 18px; }
.tg-head p { margin: 2px 0 0; font-size: 12px; }
.tg-edit { display: flex; gap: 8px; align-items: center; }
.tg-edit input { min-width: 220px; }
.tg-older { text-align: center; margin: 8px 0; }
.tg-day { text-align: center; margin: 18px 0 10px; }
.tg-day span { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 12px; background: var(--surface-2, var(--surface)); color: var(--muted); }
.tg-msg { max-width: 680px; margin: 0 0 10px; padding: 10px 14px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; }
.tg-msg.gone { opacity: .6; border-style: dashed; }
.tg-from { margin: 0 0 6px; font-size: 13px; }
.tg-text { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; }
.tg-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 4px 12px; margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.tg-media { display: grid; gap: 6px; margin: 2px 0; }
.tg-media.n2, .tg-media.n4 { grid-template-columns: 1fr 1fr; }
.tg-media.n3 { grid-template-columns: 1fr 1fr 1fr; }
.tg-media figure { margin: 0; display: grid; gap: 4px; }
.tg-media img, .tg-media video { width: 100%; max-height: 420px; object-fit: contain; background: var(--bg); border-radius: 8px; display: block; }
.tg-media figcaption { display: flex; gap: 6px; }
.tg-media figcaption form { margin: 0; }
@media (max-width: 900px) { .tg { grid-template-columns: 1fr; } .tg-side { position: static; max-height: none; } }
.tg-backfill { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 8px; font-size: 12px; }
.tg-backfill label { display: flex; align-items: center; gap: 6px; }
.tg-del { margin: 0; }
.tg-seen { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 10px; padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 8%, var(--surface)); font-size: 13px; }
.tg-seen form { margin: 0; }
.tg-badge { display: inline-block; min-width: 20px; padding: 1px 6px; margin-left: 6px; border-radius: 999px; background: var(--accent); color: var(--bg); font-size: 11px; font-weight: 700; text-align: center; }
.tg-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.tg-when { flex: none; font-size: 11px; }
.tg-prev { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.tg-row .tg-badge { flex: none; margin-left: 0; }
.tg-newbar { display: flex; align-items: center; gap: 12px; margin: 16px 0 10px; color: var(--accent); font-size: 12px; font-weight: 600; scroll-margin-top: calc(var(--bar-h, 0px) + 12px); }
.tg-newbar::before, .tg-newbar::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--accent) 45%, transparent); }
.tg-msg.is-new { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.tg-jump { position: sticky; bottom: 18px; float: right; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line-strong, var(--line)); color: var(--ink); box-shadow: 0 2px 10px rgb(0 0 0 / .35); }
.tg-jump:hover { color: var(--accent); }
#first-new, #end { scroll-margin-top: calc(var(--bar-h, 0px) + 12px); }
.tg-media audio, .media-view audio { width: 100%; }
.video-tag { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.tg-settings form { display: grid; gap: 8px; margin-top: 10px; }
.tg-settings label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.tg-settings p { font-size: 12px; margin: 8px 0 0; }
.tg-range { border-top: 1px solid var(--line); padding-top: 10px; }
.tg-confirm { max-width: 560px; display: grid; gap: 12px; }
.tg-confirm ul { margin: 0; padding-left: 18px; }
.tg-confirm form { display: flex; gap: 10px; }
.tg-msg { scroll-margin-top: calc(var(--bar-h, 0px) + 12px); }
.tg-msg { transition: opacity .15s ease; }
.tg-msg.busy { opacity: .55; pointer-events: none; }
.tg-error { margin: 0 0 8px; }
/* the title block of the Telegram page is kept for screen readers and hidden: the chat needs the room */
.tg-page > .page-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); margin: 0; padding: 0; }
.tg-page { padding-top: var(--space-4, 16px); }
/* the channel name, labels and controls stay in view while the messages scroll under them */
.tg-top { position: sticky; top: var(--bar-h, 0px); z-index: 6; background: var(--bg); padding: 6px 0 4px; }
.tg-top .tg-head { margin-bottom: 6px; }
.tg-top .tg-backfill, .tg-top .tg-seen { margin-bottom: 0; }
.tg-msg, .tg-newbar, #first-new, #end { scroll-margin-top: calc(var(--bar-h, 0px) + 150px); }

/* Labelling: two posts side by side */
.pair-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 16px 0; }
@media (max-width: 760px) { .pair-grid { grid-template-columns: 1fr; } }

/* Telegram comments, loaded on request */
.tg-comments { margin: 8px 0; padding: 8px 12px; border-left: 2px solid var(--line-strong, var(--line)); }
.tg-comments summary { cursor: pointer; font-weight: 500; }
.tg-comments ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.tg-comments-ask { margin: 6px 0; }

/* =====================================================================
   Telegram app (redesign)
   Scoped to .tg-page so the rest of the console keeps its own palette.
   ===================================================================== */
.tg-page {
  --tg-bg: #0e1621; --tg-side: #17212b; --tg-head: #17212b; --tg-bubble: #182533;
  --tg-bubble-2: #202b36; --tg-hover: #202b36; --tg-active: #2b5278; --tg-text: #f1f5f8;
  --tg-muted: #7d8e9f; --tg-accent: #64b5ef; --tg-green: #4fae4e; --tg-line: #0b1219;
  --tg-pill: rgb(255 255 255 / .08); --tg-shadow: 0 8px 30px rgb(0 0 0 / .35);
}
.tg-page > .page-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); margin: 0; padding: 0; }
.tg-page { padding-top: 10px; }
.tg-page .tg {
  display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 0;
  align-items: stretch;
  height: min(880px, calc(100dvh - 160px)); min-height: 480px;
  overflow: hidden; border: 1px solid var(--tg-line); border-radius: 12px;
  background: var(--tg-bg); box-shadow: var(--tg-shadow);
}
.tg-page .tg-side {
  position: relative; top: auto; max-height: none; overflow: visible;
  display: flex; flex-direction: column; min-height: 0; gap: 0;
  background: var(--tg-side); border-right: 1px solid var(--tg-line);
}
.tg-page .tg-side-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 56px; padding: 0 12px; flex: none; }
.tg-page .tg-side-title { display: inline-flex; align-items: center; gap: 10px; color: var(--tg-text); font-size: 16px; }
.tg-page .tg-plane { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--tg-accent); color: #0e1621; }
.tg-page .tg-plane svg { width: 19px; height: 19px; }
.tg-page .tg-side-actions { display: inline-flex; align-items: center; gap: 4px; }
.tg-page .tg-icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--tg-muted); cursor: pointer; list-style: none; }
.tg-page .tg-icon-btn::-webkit-details-marker { display: none; }
.tg-page .tg-icon-btn:hover, .tg-page .tg-pop[open] > .tg-icon-btn { color: var(--tg-text); background: var(--tg-hover); }
.tg-page .tg-pop { position: relative; }
.tg-page .tg-pop-body {
  position: absolute; top: 44px; right: 0; z-index: 40; width: 320px; padding: 14px;
  background: #1c2733; color: var(--tg-text); border: 1px solid #2a3948; border-radius: 10px; box-shadow: var(--tg-shadow);
}
.tg-page .tg-settings .tg-pop-body { width: 340px; }
.tg-page .tg-pop-body h3 { margin: 0 0 10px; font-size: 13px; color: var(--tg-text); }
.tg-page .tg-pop-body h3:not(:first-child) { margin-top: 16px; }
.tg-page .tg-form { display: grid; gap: 9px; margin: 0; }
.tg-page .tg-form label { display: grid; gap: 5px; font-size: 11px; color: var(--tg-muted); }
.tg-page .tg-form input, .tg-page .tg-form select { width: 100%; min-height: 34px; padding: 6px 9px; border: 1px solid #2d3d4d; border-radius: 7px; background: #242f3d; color: var(--tg-text); font-size: 12px; }
.tg-page .tg-form input:focus, .tg-page .tg-form select:focus { outline: 2px solid var(--tg-accent); outline-offset: 1px; }
.tg-page .tg-pop-link { display: inline-block; margin-top: 14px; color: var(--tg-accent); font-size: 12px; }
.tg-page .tg-hint { margin: 8px 0 0; font-size: 11px; line-height: 1.5; color: var(--tg-muted); }
.tg-page .tg-search {
  position: relative; display: flex; align-items: center; gap: 8px; margin: 0 10px 6px;
  padding: 0 10px; min-height: 40px; border-radius: 9px; background: #242f3d; color: var(--tg-muted); flex: none;
}
.tg-page .tg-search-ico { flex: none; opacity: .8; }
.tg-page .tg-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--tg-text); font-size: 13px; padding: 8px 0; }
.tg-page .tg-search input::placeholder { color: var(--tg-muted); }
.tg-page .tg-search input:focus-visible { outline: 0; }
.tg-page .tg-search:focus-within { outline: 2px solid var(--tg-accent); outline-offset: 0; }
.tg-page .tg-search-clear { color: var(--tg-muted); text-decoration: none; font-size: 18px; line-height: 1; padding: 2px 4px; }
.tg-page .tg-folders { display: flex; flex-wrap: nowrap; gap: 6px; margin: 0 10px 6px; padding: 0 0 4px; overflow-x: auto; flex: none; scrollbar-width: none; }
.tg-page .tg-folders::-webkit-scrollbar { display: none; }
.tg-page .tg-folders .chip { flex: none; min-height: 28px; padding: 4px 10px; border: 0; border-radius: 14px; background: #202b36; color: var(--tg-muted); font-size: 11px; font-weight: 600; }
.tg-page .tg-folders .chip:hover { color: var(--tg-text); }
.tg-page .tg-folders .chip[aria-current="true"] { background: var(--tg-active); color: #fff; }
.tg-page .tg-folders .chip .n { color: inherit; opacity: .7; }
.tg-page .tg-channels { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 2px 6px 10px; display: block; scrollbar-width: thin; }
.tg-page .tg-channels li { margin: 0; }
.tg-page .tg-channels a { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; color: var(--tg-text); text-decoration: none; }
.tg-page .tg-channels a:hover { background: var(--tg-hover); }
.tg-page .tg-channels li.on a { background: var(--tg-active); }
.tg-page .tg-channels li.on .tg-prev, .tg-page .tg-channels li.on .tg-when, .tg-page .tg-channels li.on .muted { color: rgb(255 255 255 / .72); }
.tg-page .tg-ava { flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; color: #fff; font-size: 18px; font-weight: 700; background: #3d7eb8; }
.tg-page .tg-ava-0 { background: linear-gradient(135deg, #e17076, #c75c62); }
.tg-page .tg-ava-1 { background: linear-gradient(135deg, #7bc862, #4fae4e); }
.tg-page .tg-ava-2 { background: linear-gradient(135deg, #65aadd, #3d7eb8); }
.tg-page .tg-ava-3 { background: linear-gradient(135deg, #ee7aae, #d65a8e); }
.tg-page .tg-ava-4 { background: linear-gradient(135deg, #faa774, #e58b52); }
.tg-page .tg-ava-5 { background: linear-gradient(135deg, #a695e7, #8574d4); }
.tg-page .tg-ava-big { width: 40px; height: 40px; font-size: 15px; }
.tg-page .tg-chan { display: grid; gap: 1px; min-width: 0; flex: 1; font-size: 13px; }
.tg-page .tg-chan strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.tg-page .tg-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.tg-page .tg-when { flex: none; color: var(--tg-muted); font-size: 10px; font-weight: 400; }
.tg-page .tg-prev { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tg-muted); font-size: 12px; }
.tg-page .tg-tags { display: none; }
.tg-page .tg-stopped { font-size: 10px; font-weight: 400; }
.tg-page .tg-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--tg-green); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.tg-page .tg-empty { padding: 14px 10px; font-size: 12px; }
.tg-page .tg-feed { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; background: var(--tg-bg); }
.tg-page .tg-top { position: sticky; top: 0; z-index: 6; flex: none; background: var(--tg-head); border-bottom: 1px solid var(--tg-line); padding: 0 16px; }
.tg-page .tg-head { display: flex; align-items: center; gap: 11px; min-height: 58px; margin: 0; padding: 8px 0; border: 0; flex-wrap: nowrap; }
.tg-page .tg-head h2 { margin: 0; font-size: 15px; line-height: 1.3; letter-spacing: 0; color: var(--tg-text); }
.tg-page .tg-head p { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: 2px 0 0; font-size: 11px; }
.tg-page .tg-head p a { color: var(--tg-accent); text-decoration: none; }
.tg-page .tg-title { min-width: 0; flex: 1; }
.tg-page .tg-back { display: none; align-items: center; justify-content: center; width: 34px; height: 34px; border: 0; border-radius: 50%; color: var(--tg-muted); text-decoration: none; }
.tg-page .tg-back:hover { background: var(--tg-hover); color: var(--tg-text); }
.tg-page .tg-chat-menu { flex: none; }
.tg-page .tg-chat-menu .tg-pop-body { right: 0; }
.tg-page .tg-seen { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: nowrap; margin: 0; padding: 7px 0; border-top: 1px solid var(--tg-line); font-size: 12px; color: var(--tg-muted); }
.tg-page .tg-seen > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-page .tg-seen strong { color: var(--tg-text); }
.tg-page .tg-seen form { margin: 0; }
.tg-page .tg-backfill { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 10px; margin: 0; padding: 7px 0 9px; border-top: 1px solid var(--tg-line); font-size: 11px; color: var(--tg-muted); }
.tg-page .tg-backfill label { display: inline-flex; align-items: center; gap: 6px; }
.tg-page .tg-backfill input { min-height: 30px; padding: 4px 7px; border: 1px solid #2d3d4d; border-radius: 6px; background: #242f3d; color: var(--tg-text); font-size: 11px; }
.tg-page .tg-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px clamp(14px, 5vw, 72px) 12px; background: radial-gradient(circle at 20% 10%, rgb(100 181 239 / .035), transparent 35%), radial-gradient(circle at 80% 70%, rgb(79 174 78 / .025), transparent 30%), var(--tg-bg); scrollbar-width: thin; scroll-behavior: smooth; }
.tg-page .tg-day { text-align: center; margin: 14px 0 12px; }
.tg-page .tg-day span { display: inline-block; padding: 4px 10px; border-radius: 11px; background: rgb(0 0 0 / .22); color: #aeb9c4; font-size: 11px; font-weight: 500; }
.tg-page .tg-newbar { display: flex; align-items: center; gap: 12px; margin: 14px 0 12px; color: var(--tg-accent); font-size: 11px; font-weight: 600; }
.tg-page .tg-newbar::before, .tg-page .tg-newbar::after { content: ""; flex: 1; height: 1px; background: rgb(100 181 239 / .35); }
.tg-page .tg-older { text-align: center; margin: 4px 0 14px; }
.tg-page .tg-msg { position: relative; max-width: min(78%, 680px); margin: 0 0 8px; padding: 7px 10px 6px; background: var(--tg-bubble); color: var(--tg-text); border: 0; border-radius: 12px 12px 12px 4px; box-shadow: 0 1px 1px rgb(0 0 0 / .16); }
.tg-page .tg-msg::after { content: ""; position: absolute; left: -5px; bottom: 0; width: 10px; height: 12px; background: var(--tg-bubble); clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.tg-page .tg-msg.is-new { box-shadow: inset 2px 0 0 var(--tg-accent), 0 1px 1px rgb(0 0 0 / .16); }
.tg-page .tg-msg.gone { opacity: .58; background: #151d26; }
.tg-page .tg-msg.gone::after { background: #151d26; }
.tg-page .tg-msg.busy { opacity: .55; pointer-events: none; }
.tg-page .tg-from { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin: 0 0 3px; color: var(--tg-accent); font-size: 12px; }
.tg-page .tg-from a { color: var(--tg-accent); text-decoration: none; }
.tg-page .tg-from .tag { font-size: 9px; }
.tg-page .tg-text { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.45; color: var(--tg-text); }
.tg-page .tg-text.muted { color: var(--tg-muted); }
.tg-page .tg-media { display: grid; gap: 4px; margin: 4px 0 2px; }
.tg-page .tg-media.n2, .tg-page .tg-media.n4 { grid-template-columns: 1fr 1fr; }
.tg-page .tg-media.n3 { grid-template-columns: 1fr 1fr 1fr; }
.tg-page .tg-media figure { margin: 0; display: grid; gap: 3px; }
.tg-page .tg-media img, .tg-page .tg-media video { width: 100%; max-height: 380px; object-fit: cover; border-radius: 8px; background: #0b1219; display: block; }
.tg-page .tg-media audio { width: 100%; }
.tg-page .tg-media figcaption { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; font-size: 10px; color: var(--tg-muted); }
.tg-page .tg-media figcaption form { margin: 0; }
.tg-page .tg-media-actions .btn { min-height: 22px; padding: 2px 6px; font-size: 10px; }
.tg-page .tg-foot { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; color: var(--tg-muted); font-size: 10px; }
.tg-page .tg-msg-flags { display: inline-flex; gap: 4px; margin-right: auto; }
.tg-page .tg-foot .tag { height: 17px; padding: 0 5px; font-size: 9px; }
.tg-page .tg-open { color: var(--tg-accent); text-decoration: none; font-size: 10px; }
.tg-page .tg-open:hover { text-decoration: underline; }
.tg-page .tg-more { position: relative; margin: 0; }
.tg-page .tg-more-btn { display: grid; place-items: center; width: 22px; height: 18px; border: 0; border-radius: 4px; background: transparent; color: var(--tg-muted); cursor: pointer; list-style: none; font-size: 16px; line-height: 1; }
.tg-page .tg-more-btn::-webkit-details-marker { display: none; }
.tg-page .tg-more-btn:hover { background: rgb(255 255 255 / .08); color: var(--tg-text); }
.tg-page .tg-more-body { position: absolute; right: 0; bottom: 22px; z-index: 12; display: grid; gap: 5px; min-width: 150px; padding: 7px; background: #1c2733; border: 1px solid #2a3948; border-radius: 8px; box-shadow: var(--tg-shadow); }
.tg-page .tg-more-body form { margin: 0; display: grid; }
.tg-page .tg-more-body .btn { justify-content: center; }
.tg-page .tg-msg time { color: var(--tg-muted); font-variant-numeric: tabular-nums; }
.tg-page .tg-comments { margin: 6px 0 2px; padding: 6px 8px; border-left: 2px solid var(--tg-accent); border-radius: 0 7px 7px 0; background: rgb(0 0 0 / .16); }
.tg-page .tg-comments summary { cursor: pointer; font-size: 11px; color: var(--tg-accent); }
.tg-page .tg-comments ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; font-size: 12px; color: var(--tg-text); }
.tg-page .tg-comments-ask { margin: 4px 0 0; }
.tg-page .tg-comments-ask .btn { border: 0; padding: 2px 0; background: transparent; color: var(--tg-accent); font-size: 10px; }
.tg-page .tg-comments-wait { font-size: 10px; }
.tg-page .tg-jump { position: absolute; right: 22px; bottom: 74px; z-index: 8; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--tg-accent); color: #0e1621; box-shadow: 0 4px 14px rgb(0 0 0 / .35); }
.tg-page .tg-jump:hover { background: #7ccaff; color: #0e1621; }
.tg-page .tg-compose { flex: none; display: flex; align-items: center; gap: 9px; min-height: 56px; padding: 8px 16px; background: var(--tg-head); border-top: 1px solid var(--tg-line); }
.tg-page .tg-compose-clip { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--tg-muted); }
.tg-page .tg-compose-field { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 6px 12px; border-radius: 17px; background: #242f3d; color: var(--tg-text); font-size: 11px; }
.tg-page .tg-compose-field .muted { color: var(--tg-muted); font-size: 9px; }
.tg-page .tg-compose-open { color: var(--tg-accent); font-size: 11px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.tg-page .tg-page .btn, .tg-page .btn { border-color: #2d3d4d; background: #242f3d; color: var(--tg-text); min-height: 28px; font-size: 11px; }
.tg-page .btn:hover { background: #2b3a4a; border-color: #3a4b5d; }
.tg-page .btn.danger { background: #3a2229; border-color: #5b343e; color: #ff9aa7; }
.tg-page .btn.btn.primary { background: var(--tg-accent); border-color: var(--tg-accent); color: #10161d; font-weight: 600; min-height: 34px; font-size: 12px; }
.tg-page .btn.btn.primary:hover { background: color-mix(in srgb, var(--tg-accent) 82%, #fff); border-color: transparent; }
.tg-page .tag { background: rgb(255 255 255 / .06); border-color: transparent; color: #aeb9c4; }
.tg-page .tag.bad { color: #ff9aa7; border-color: rgb(255 154 167 / .35); }
.tg-page .video-tag { color: var(--tg-accent); border-color: rgb(100 181 239 / .35); }
.tg-page .note { background: #1c2733; border-color: #2a3948; color: var(--tg-text); }
.tg-page .empty-state { border-color: #2a3948; background: #151f29; color: var(--tg-muted); }
.tg-page .empty-state strong { color: var(--tg-text); }
.tg-page .empty-state code { background: #0b1219; color: var(--tg-accent); }
.tg-page .muted { color: var(--tg-muted); }
.tg-page .tg-error { margin: 0 0 7px; font-size: 11px; }

@media (max-width: 900px) {
  .tg-page .tg { grid-template-columns: 1fr; height: calc(100dvh - 130px); min-height: 480px; border-radius: 8px; }
  .tg-page .tg-feed { display: none; }
  .tg-page .tg-chat-open .tg-side { display: none; }
  .tg-page .tg-chat-open .tg-feed { display: flex; }
  .tg-page .tg-back { display: inline-flex; }
  .tg-page .tg-pop-body { position: fixed; top: 70px; left: 12px; right: 12px; width: auto; max-height: calc(100dvh - 92px); overflow: auto; }
  .tg-page .tg-msg { max-width: 88%; }
  .tg-page .tg-scroll { padding: 12px 12px 8px; }
  .tg-page .tg-jump { right: 14px; bottom: 70px; }
  .tg-page .tg-compose { padding: 7px 10px; }
}
@media (max-width: 600px) {
  .tg-page { padding-top: 0; }
  .tg-page .tg { height: calc(100dvh - 120px); min-height: 420px; border: 0; border-radius: 0; }
  .tg-page .tg-ava { width: 46px; height: 46px; font-size: 16px; }
  .tg-page .tg-compose-open { display: none; }
}

/* backfill lives in the channel menu, not as a bar over the chat */
.tg-page .tg-pop .tg-backfill { display: grid; gap: 8px; margin: 14px 0 0; padding: 0; border: 0; }
.tg-page .tg-pop .tg-backfill .tg-hint { margin: 0; }
.tg-page .tg-pop .tg-backfill label { display: grid; gap: 5px; font-size: 11px; color: var(--tg-muted); }
.tg-page .tg-pop .tg-backfill input { width: 100%; }

.tg-page { padding-bottom: 0; }
main.tg-page { padding-bottom: 0; }

/* The Telegram section fills the content area; it is not a card. */
main.tg-page { max-width: none; padding: 0; }
.tg-page .tg { width: 100%; height: calc(100dvh - 120px); min-height: 0; border: 0; border-radius: 0; box-shadow: none; }

/* Add/settings are real dialogs over the section, not menus that collide with the pane border. */
.tg-page .tg-add[open]::before, .tg-page .tg-settings[open]::before {
  content: ""; position: fixed; inset: 0; z-index: 58; background: rgb(0 0 0 / .48);
}
.tg-page .tg-add[open] .tg-pop-body, .tg-page .tg-settings[open] .tg-pop-body {
  position: fixed; top: 50%; left: 50%; right: auto; transform: translate(-50%, -50%);
  z-index: 59; width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto;
  padding: 20px; border-radius: 12px;
}
.tg-page .tg-pop-close {
  position: absolute; top: 8px; right: 8px; display: grid; place-items: center;
  width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent;
  color: var(--tg-muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.tg-page .tg-pop-close:hover { background: var(--tg-hover); color: var(--tg-text); }

.tg-page .tg-empty-chat { flex: 1; display: grid; place-items: center; background: var(--tg-bg); }
.tg-page .tg-empty-chat-pill { padding: 9px 16px; border-radius: 16px; background: rgb(0 0 0 / .22); color: var(--tg-muted); font-size: 12px; }

/* Media tiles: every multi-file message uses the same-sized boxes, like Telegram albums. */
.tg-page .tg-media { gap: 4px; }
.tg-page .tg-media.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tg-page .tg-media.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tg-page .tg-media.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tg-page .tg-media-box { position: relative; aspect-ratio: 1 / 1; overflow: hidden; border-radius: 8px; background: #0b1219; }
.tg-page .tg-media.n1 .tg-media-box { aspect-ratio: auto; }
.tg-page .tg-media-box.is-audio { aspect-ratio: auto; padding: 6px; }
.tg-page .tg-media-box img, .tg-page .tg-media-box video {
  display: block; width: 100%; height: 100%; max-height: none; object-fit: cover; border-radius: 0; background: #0b1219;
}
.tg-page .tg-media.n1 .tg-media-box img {
  width: auto; height: auto; max-width: 100%; max-height: 420px; object-fit: contain; margin: 0 auto;
}
.tg-page .tg-media.n1 .tg-media-box video { width: 100%; height: auto; max-height: 420px; object-fit: contain; }
.tg-page .tg-media-box > a { display: block; width: 100%; height: 100%; text-align: center; }
.tg-page .tg-media-box audio { width: 100%; }
.tg-page .tg-media-box .media-none { height: 100%; place-content: center; padding: 8px; }

.tg-page .tg-msg.has-media { max-width: min(88%, 720px); }
.tg-page .tg-play { position: absolute; inset: 0; display: grid; place-items: center; border: 0; padding: 0; background: rgb(0 0 0 / .18); color: #fff; cursor: pointer; }
.tg-page .tg-play:hover { background: rgb(0 0 0 / .3); }
.tg-page .tg-play svg { filter: drop-shadow(0 2px 5px rgb(0 0 0 / .45)); }

/* Telegram album sizing: one large tile and smaller companions, not three huge squares. */
.tg-page .tg-media { width: min(100%, 430px); }
.tg-page .tg-media figure { display: flex; flex-direction: column; min-width: 0; }
.tg-page .tg-media.n2, .tg-page .tg-media.n4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tg-page .tg-media.n3 { grid-template-columns: 2fr 1fr; grid-template-rows: auto auto; }
.tg-page .tg-media.n3 figure:nth-child(1) { grid-row: span 2; }
.tg-page .tg-media.n3 figure:nth-child(1) .tg-media-box { flex: 1; aspect-ratio: auto; min-height: 150px; }
.tg-page .tg-media.n3 figure:nth-child(n+2) .tg-media-box { aspect-ratio: 1 / 1; }
.tg-page .tg-msg { width: fit-content; }

/* Three-file albums follow Telegram's tall layout: one large tile, two stacked beside it. */
.tg-page .tg-media.n3 { aspect-ratio: 3 / 4; grid-template-rows: 1fr 1fr; }
.tg-page .tg-media.n3 figure { min-height: 0; }
.tg-page .tg-media.n3 .tg-media-box { flex: 1; aspect-ratio: auto; min-height: 0; }

/* A media message takes the media's width; long captions wrap inside it instead of
   leaving a big empty slab beside a small video. */
.tg-page .tg-msg.has-media { max-width: min(92%, 460px); width: fit-content; }

/* Keep text messages close to Telegram's reading width instead of stretching across the pane. */
.tg-page .tg-msg { max-width: min(78%, 520px); }
.tg-page .tg-msg .tg-text { line-height: 1.38; }

/* ---------------------------------------------------------------------------
   Telegram in the desk palette.
   The Telegram app layout, bubbles and media stay exactly as they are; only
   the colour is brought onto the same warm ink ramp and rust accent as the
   rest of the workspace. No blue chrome, no glow, no gradients on surfaces.
   --------------------------------------------------------------------------- */
.tg-page {
  --tg-bg: #14120f; --tg-side: #1a1713; --tg-head: #1a1713; --tg-bubble: #211d18;
  --tg-bubble-2: #29241d; --tg-hover: #26211b; --tg-active: #3b2a20; --tg-text: #f1ede2;
  --tg-muted: #a0988a; --tg-accent: #dd9d82; --tg-green: #8fae7a; --tg-line: #0c0b09;
  --tg-pill: rgb(241 237 226 / .07); --tg-shadow: 0 8px 30px rgb(0 0 0 / .45);
}
.tg-page .tg-scroll { background: var(--tg-bg); }
.tg-page .tg-pop-body { background: #221e19; border-color: #3a342a; }
.tg-page .tg-form input, .tg-page .tg-form select { border-color: #3d372d; background: #28231c; }
.tg-page .tg-search { background: #28231c; }
.tg-page .tg-folders .chip { background: #28231c; }
.tg-page .tg-folders .chip[aria-current="true"] { background: var(--tg-active); color: var(--tg-text); }
.tg-page .tg-ava { background: #8a5a43; }
.tg-page .tg-ava-0 { background: linear-gradient(135deg, #b8654d, #8e4634); }
.tg-page .tg-ava-1 { background: linear-gradient(135deg, #8fae7a, #627a50); }
.tg-page .tg-ava-2 { background: linear-gradient(135deg, #7c93a8, #5b7286); }
.tg-page .tg-ava-3 { background: linear-gradient(135deg, #b87d86, #8e5a63); }
.tg-page .tg-ava-4 { background: linear-gradient(135deg, #c19a5e, #96733e); }
.tg-page .tg-ava-5 { background: linear-gradient(135deg, #a3a06e, #7c7a4b); }
.tg-page .tg-backfill input { border-color: #3d372d; background: #28231c; }
.tg-page .tg-msg.gone { background: #1a1713; }
.tg-page .tg-msg.gone::after { background: #1a1713; }
.tg-page .tg-more-body { background: #221e19; border-color: #3a342a; }
.tg-page .tg-more-btn:hover { background: var(--tg-pill); color: var(--tg-text); }
.tg-page .btn, .tg-page .tg-page .btn { border-color: #3d372d; background: #28231c; color: var(--tg-text); }
.tg-page .btn:hover { background: #332b23; border-color: #4a4134; }
.tg-page .btn.danger { background: #2c1714; border-color: #5b3430; color: #e89284; }
.tg-page .tag { background: rgb(241 237 226 / .06); color: #b5ad9e; }
.tg-page .tag.bad { color: #e89284; border-color: rgb(232 146 132 / .35); }
.tg-page .note { background: #221e19; border-color: #3a342a; }
.tg-page .empty-state { border-color: #3a342a; background: #1a1713; }
.tg-page .empty-state code { background: #0f0d0a; }
.tg-page .tg-day span { color: var(--tg-muted); }
.tg-page .tg-compose-field { background: #28231c; }
.tg-page .tg-empty-chat-pill { background: rgb(0 0 0 / .25); }
.tg-page .tg-jump { color: #14120f; }
.tg-page .tg-jump:hover { background: #eab39c; color: #14120f; }
.tg-page .tg-channels li.on .tg-prev, .tg-page .tg-channels li.on .tg-when,
.tg-page .tg-channels li.on .muted { color: rgb(241 237 226 / .72); }
.tg-page .tg-play { background: rgb(0 0 0 / .22); }
.tg-page .tg-play:hover { background: rgb(0 0 0 / .32); }

/* ---------- Map on phones. Owner's report 2026-11-20: the panel covered the globe, the bottom controls (arrow pad,
   3D/2D switch, time window, summary) sat on top of each other, and then the stacked controls hid half the globe.
   Now three slim rows along the top: search; time window and zoom; view switch and the panel button. The summary
   alone along the bottom. The panel starts closed (map.js) and opens as a sheet over the lower part. Dragging moves
   the globe, so the arrow pad is left out; icons in the view switch are dropped for room.
   Rules start at main.map-full so they win over desk.css (loaded later), whose .desk .map-side sets a width. ---------- */
@media (max-width: 760px) {
  main.map-full .map-find { top: 10px; left: 10px; right: 10px; width: auto; }
  main.map-full .map-window { top: 58px; bottom: auto; left: 10px; transform: none; padding: 2px; }
  main.map-full .map-window a { height: 28px; padding: 0 10px; }
  main.map-full .map-pad { top: 58px; bottom: auto; right: 10px; gap: 0; padding: 2px; border-radius: 10px; transform: none; }
  main.map-full .pad-dir, main.map-full .pad-div { display: none; }
  main.map-full .pad-zoom { grid-auto-flow: column; gap: 2px; }
  main.map-full .pad-b { width: 36px; height: 28px; font-size: 20px; }
  main.map-full .map-modes { top: 98px; bottom: auto; left: 10px; right: auto; gap: 4px; padding: 2px 4px; border-radius: 10px; }
  main.map-full .seg-group { gap: 2px; }
  main.map-full .seg-b { height: 28px; padding: 0 10px; }
  main.map-full .seg-b svg { display: none; }
  main.map-full .seg-sep { height: 18px; }
  main.map-full .map-scale { display: none; }
  main.map-full .map-bar { left: 10px; right: 10px; bottom: 10px; padding: 6px 10px; gap: 2px 8px; border-radius: 10px; }
  main.map-full .map-bar .map-key { display: none; }
  main.map-full .map-bar .sum-line, main.map-full .map-bar .sum-line strong { font-size: 12px; }
  main.map-full .map-side { top: auto; left: 10px; right: 10px; bottom: 10px; width: auto; max-height: 58%; z-index: 2; background: var(--surface); }
  main.map-full .map-side .side-head { align-items: center; padding: 6px 8px 6px 14px; }
  main.map-full .map-side .side-title { margin: 0; }
  main.map-full .map-side.shut { top: 98px; bottom: auto; left: auto; right: 10px; max-height: none; border-radius: 10px; }
  main.map-full .map-side.shut .side-head { padding: 2px; border: 0; }
  main.map-full .map-side.shut .side-title { display: none; }
  main.map-full .map-side.shut #side-toggle { height: 28px; min-height: 28px; }
  main.map-full .map-side .panel-h, main.map-full .map-side .feeds-h { font-size: 18px; }
  main.map-full .map-side .panel-sub { font-size: 13px; }
}

/* Owner's report 2026-11-20: big empty gaps in the map panel. The general heading margin (30px above) does not
   belong inside the panel; every width. */
main.map-full .map-side .panel-h { margin: 0 0 6px; }
main.map-full .map-side #lists-h { margin: 0 0 8px; }
main.map-full .map-side .map-lists { margin-top: 10px; padding-top: 10px; }
@media (max-width: 760px) { main.map-full .map-side .side-body { padding: 12px 14px; } }
