/* Base components of the cabinet. Ported from design/prototype-v2/assets/app.css (v2.1).
   Rules: radius 0, no shadows, 1px lines, no icons except the brand square and the status dot,
   no animations, no chips / tiles / segments / caps labels. Tokens live in tokens.css. */

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: var(--fs-base)/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-underline-offset: 3px; }
code, pre, .mono, input, select, button, textarea, table { font-family: var(--mono); }
code { font-size: 12.5px; background: var(--soft); padding: 1px 5px; }
h1 { font: 500 var(--fs-h1)/1.3 var(--sans); letter-spacing: -0.01em; margin: 0; }
h2 { font: 500 var(--fs-h2)/1.4 var(--sans); margin: 0 0 4px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.bad { color: var(--bad); }
.small { font-size: var(--fs-small); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 1px solid var(--line-strong); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; } /* the border already shows focus */
#app:focus, .main:focus, h1:focus { outline: none; }
.skip { position: absolute; left: 16px; top: -100px; z-index: 30; background: var(--fg); color: var(--bg); padding: 8px 12px; font: 12.5px var(--mono); text-decoration: none; }
.skip:focus { top: 12px; }
.nw { white-space: nowrap; }

/* ---------- shell (ux-v3 SPEC §2.1, §3, §4.6) ----------
   Desktop: sidebar column (brand, server list, menu) + <main>; the footer of the sidebar (language, «Выйти») comes
   after <main> in the DOM (tab order: menu -> content -> footer) and is put back into the left column by the grid.
   Phone (<= 900): the sidebar is a 52 px top bar (brand + server button), the menu is the bottom bar nav.mbar with
   «Ещё» (a plain list above the bar). <main> and the router's inert copy (.stale) share the same grid cell. */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; min-height: 100vh; min-height: 100dvh;
  background: linear-gradient(var(--line), var(--line)) calc(var(--side-w) - 1px) 0 / 1px 100% no-repeat; }
.shell > .main { grid-column: 2; grid-row: 1 / span 2; }
.side { grid-column: 1; grid-row: 1; align-self: start; position: sticky; top: 0; max-height: calc(100vh - 88px); max-height: calc(100dvh - 88px); overflow-y: auto;
  padding: 22px 14px 12px; margin-right: 1px; display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.brand { font: 500 14px var(--mono); padding: 0 10px 22px; display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand i { width: 10px; height: 10px; background: var(--accent); display: inline-block; flex: none; }

/* server list: open (<= 5 servers, desktop) or a button that unfolds the same list (phone, 6+ servers) */
.switch { position: relative; padding: 0 0 14px; min-width: 0; }
.switch .sw-cur { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 34px; border: 1px solid var(--line); background: none; padding: 6px 10px;
  font: 12.5px/1.4 var(--mono); color: var(--fg); text-align: left; }
.switch .sw-cur:hover, .switch .sw-cur[aria-expanded="true"] { border-color: var(--field); background: none; }
.switch .sw-cur .nm { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch .sw-cur::after { content: '\25BE'; color: var(--muted); padding-left: 6px; flex: none; }
.switch .sw-cur[aria-expanded="true"]::after { content: '\25B4'; }
.switch .sw-list { list-style: none; margin: 6px 0 0; padding: 0; display: none; }
.switch .sw-cur[aria-expanded="true"] + .sw-list { display: block; }
.switch .sw-list a { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 10px; font: 13px/1.35 var(--mono); color: var(--muted); text-decoration: none; }
.switch .sw-list a:hover { color: var(--fg); }
.switch .sw-list li.sw-on > a { color: var(--fg); background: var(--soft); }
.switch .sw-list a .nm { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch .sw-list a .q { flex: none; font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.switch .sw-list li.sw-on > a .q { color: var(--muted); }                     /* --faint is below AA on --soft */
.switch .sw-list a.pend { flex-wrap: wrap; row-gap: 0; }
.switch .sw-list a.pend .q { flex-basis: 100%; padding-left: 14px; }          /* «ждёт подключения» on its own line */
.sw-dot { width: 6px; height: 6px; flex: none; background: var(--accent); }
.sw-dot.off { background: var(--faint); }
.sw-dot.pend { background: none; box-shadow: inset 0 0 0 1px var(--faint); }
/* «+ Добавить сервер»: always the last line; at the quota the same words as quiet text with the reason under them */
.switch .sw-list li.sw-add > a { color: var(--muted); }
.switch .sw-add .sw-off { display: block; padding: 6px 10px 0; font: 12.5px/1.45 var(--mono); color: var(--faint); opacity: .6; cursor: default; }   /* disabled (WCAG 1.4.3 exempts inactive controls) */
.switch .sw-add .sw-hint { display: block; padding: 0 10px 6px; font: 11.5px/1.45 var(--mono); color: var(--faint); }
@media (min-width: 901px) {
  .switch.open .sw-cur { display: none; }
  .switch.open .sw-list { display: block; margin: 0; }
}

/* menu: two groups split by a line; signals are text only (a count at «Журнал», a word at «Telegram») */
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; padding: 4px 10px; text-decoration: none; font: 13px var(--mono); color: var(--muted); }
.nav a:hover { color: var(--fg); }
.nav a.on { color: var(--fg); background: var(--soft); }
.nav a .cnt { color: var(--fg); font-size: 12px; font-variant-numeric: tabular-nums; }
.nav a .st { color: var(--faint); font-size: 11.5px; white-space: nowrap; }
.nav a.on .st { color: var(--muted); }
.nav .sep { height: 1px; background: var(--line); margin: 10px 10px; }
.switch + .nav { border-top: 1px solid var(--line); padding-top: 10px; }

/* sidebar footer: language + «Выйти», after <main> in the DOM, sticky at the bottom of the left column */
.side-foot { grid-column: 1; grid-row: 2; align-self: end; position: sticky; bottom: 0; margin-right: 1px; background: var(--bg);
  padding: 12px 24px 22px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
/* «Выйти» is a text link everywhere: sidebar, login, invite, 404 */
.out { font: 12px var(--mono); color: var(--muted); background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; text-align: left; cursor: pointer; }
.out:hover { color: var(--fg); background: none; }
.lang { font: 12px var(--mono); color: var(--faint); display: flex; gap: 10px; }
.lang button { font: inherit; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; }
.lang button:hover { color: var(--fg); background: none; }
.lang button.on { color: var(--fg); text-decoration: underline; text-underline-offset: 4px; }
/* in the cabinet the language switch is one quiet line, no underline */
.side-foot .lang button { color: var(--faint); }
.side-foot .lang button.on { color: var(--muted); text-decoration: none; }
.side-foot .lang button:hover { color: var(--fg); }

/* phone bottom bar and the «Ещё» list (desktop: not shown) */
.mbar { display: none; }

.main { padding: var(--page-top) var(--page-x) 80px; width: 100%; min-width: 0; }
/* safety net: a page without a .pg primitive (player card page, 404) keeps the v2 width instead of stretching to 2560 */
.main:not(:has(> .pg)) { max-width: calc(1040px + 2 * var(--page-x)); }
.main.narrow:not(:has(> .pg)) { max-width: calc(820px + 2 * var(--page-x)); }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: var(--after-head); }
.head .sub { font: var(--fs-cap)/1.7 var(--mono); color: var(--muted); margin-top: 6px; }

/* ---------- page primitives (SPEC §4.2; js/core/layout.js builds them) ----------
   < 1400: one column, the panel above the list (.m-top), after the form (.m-after) or not at all (.m-hide).
   >= 1400: the panel is a second column; >= 2200: the whole block is at most --w-max, centred. */
.pg { max-width: var(--w-max); width: 100%; min-width: 0; }
@media (min-width: 2200px) { .pg { margin-inline: auto; } }
.pg-la, .pg-sa { display: grid; grid-template-columns: minmax(0, 1fr); }
.pg-h { order: 0; min-width: 0; }
.aside.m-top { order: 1; }
.pg-b { order: 2; min-width: 0; }
.aside.m-after { order: 3; }
.aside { min-width: 0; }
.aside.m-hide { display: none; }
.aside.m-top { margin: 0 0 24px; }
.aside.m-after { margin: 40px 0 0; }
.aside-in { min-width: 0; }
@media (min-width: 1400px) {
  .pg-la { grid-template: "head head" auto "body aside" 1fr / minmax(0, 1fr) var(--w-aside); column-gap: var(--gap-aside); }
  .pg-sa { grid-template: "head head" auto "body aside" 1fr / minmax(0, var(--w-settings)) minmax(var(--w-aside), 1fr); column-gap: var(--gap-aside); }
  .pg-la > .pg-h, .pg-sa > .pg-h { grid-area: head; }
  .pg-la > .pg-b, .pg-sa > .pg-b { grid-area: body; }
  .pg-la > .aside, .pg-sa > .aside { grid-area: aside; display: block; margin: 0; border-left: 1px solid var(--line); padding-left: 24px; }
  .aside-in { position: sticky; top: 28px; max-height: calc(100vh - 56px); max-height: calc(100dvh - 56px); overflow: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
  .pg-sa .aside-in { max-width: 720px; }
}
@media (min-width: 1900px) {
  .pg-sa { grid-template-columns: minmax(0, var(--w-form-wide)) minmax(460px, 1fr); }
}
/* settings: table of contents + sections */
.pg-toc { display: grid; grid-template-columns: minmax(0, 1fr); }
.pg-toc > .toc { display: none; }
.pg-toc > .pg-h, .pg-toc > .pg-b { min-width: 0; }
@media (min-width: 1280px) {
  /* the h1 keeps the shared left edge (a full-width head row); the TOC and the sections start under it */
  .pg-toc { grid-template: "head head" auto "toc body" 1fr / 180px minmax(0, var(--w-settings)); column-gap: 48px; }
  .pg-toc > .toc { grid-area: toc; display: block; }
  .pg-toc > .pg-h { grid-area: head; }
  .pg-toc > .pg-b { grid-area: body; }
}
@media (min-width: 1900px) {
  .pg-toc { grid-template-columns: 180px minmax(0, 1fr); }
  .pg-toc > .pg-b.two, .pg-toc .two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 48px; align-items: start; }
}
.pg-read { max-width: var(--w-read); }
.toc .toc-in { position: sticky; top: 28px; font: 12.5px/1.5 var(--mono); }
.toc a { display: block; padding: 5px 0 5px 12px; color: var(--muted); text-decoration: none; border-left: 1px solid var(--line); }
.toc a:hover { color: var(--fg); }
.toc a.on { color: var(--fg); border-left-color: var(--fg); }

/* panel blocks: a heading and 3-6 lines of text and links (never a dashboard) */
.ax { margin-bottom: 28px; }
.ax:last-child { margin-bottom: 0; }
.ax h2 { margin-bottom: 8px; }
.ax .l { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; min-height: 28px; padding: 4px 0; font: 12.5px/1.5 var(--mono); color: var(--muted); text-decoration: none; }
.ax .l .v { color: var(--fg); text-align: right; min-width: 0; overflow-wrap: anywhere; }
.ax a.l { color: var(--fg-2); }
.ax a.l:hover { color: var(--fg); }
.ax a.l .v { color: var(--muted); }
.ax a.l:hover .v { color: var(--fg); }
.ax .l .go { color: var(--muted); flex: none; }
.pg-sa .ax .l { max-width: 460px; }          /* the form panel grows at 1920+: a value stays near its label */
.aside.busy .aside-in { opacity: .45; transition: opacity 0s linear .12s; }   /* old content while the next one loads (I4) */

/* selected row of a list with a panel */
.sel, .sel > summary { background: var(--soft); box-shadow: inset 2px 0 0 var(--fg); }
.sel .t, .sel > summary .t { color: var(--muted); }

/* object tabs inside a module */
.tabs { display: flex; gap: 0 24px; border-bottom: 1px solid var(--line); font: 13px var(--mono); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 10px 0 11px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.tabs a:hover { color: var(--fg); }
.tabs a.on, .tabs a[aria-current="page"] { color: var(--fg); box-shadow: inset 0 -1px 0 var(--fg); }
.tabs a .n { color: var(--fg); margin-left: 6px; font-variant-numeric: tabular-nums; }

/* pause presets: «Пауза: 30 мин · 2 ч · сутки» */
.pause { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0 2px; font: 12.5px var(--mono); color: var(--muted); }
.pause > .muted { margin-right: 6px; }
.pause .link { min-height: 28px; padding: 0 2px; }
.pause .sep::before { content: '\00a0\00b7\00a0'; color: var(--faint); }

/* sections, read-only, danger, confirm */
details.msec > summary { list-style: none; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
details.msec > summary::-webkit-details-marker { display: none; }
details.msec > summary h2 { margin: 0; }
details.msec > summary .sum { font: 12.5px var(--mono); color: var(--muted); }
details.msec + details.msec { margin-top: 36px; }
details.msec > summary + * { margin-top: 8px; }
.ro { font: 12px var(--mono); color: var(--muted); margin: 0 0 14px; }
select:disabled { opacity: .55; cursor: default; }
.danger { margin-top: 44px; }
.danger > h2 { padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.confirm { background: var(--soft); padding: 10px 12px; font: 12.5px var(--mono); color: var(--fg); display: flex; gap: 10px 14px; align-items: center; flex-wrap: wrap; }
.confirm .sp { flex: 1; }
.confirm button { padding: 5px 12px; }
.step .n { font: 13px var(--mono); color: var(--muted); }

/* settings sections (lifted from access.css: bridge, team and settings use them) */
.set { margin-top: 48px; }
.set:first-child { margin-top: 0; }
.set h2 { margin-bottom: 4px; }
.set .lead { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; max-width: 620px; }
.set .rules { margin-top: 4px; }
.set .rule { grid-template-columns: minmax(0, 1fr) auto; min-height: 56px; }
.set .rule .act { display: flex; justify-content: flex-end; }
.set .row { display: flex; gap: 12px 16px; align-items: center; flex-wrap: wrap; margin-top: 16px; font: 12.5px var(--mono); }
.set .row .ask { color: var(--fg); }
.set .inv { max-width: 620px; }
.set .hint { font: 12px/1.7 var(--mono); color: var(--muted); margin-top: 8px; }
.set .cfg { max-width: 620px; }
.set .cfg label { margin-top: 20px; }
.set .cfg .code { margin-top: 0; }
.set .err:empty { min-height: 0; margin: 0; }

/* bare layout: login, invite code, join, 404 */
.bare { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.bare .box { width: 100%; max-width: 360px; }
.bare .brand { padding: 0 0 28px; font-size: 15px; }
.bare h1 { margin-bottom: 8px; }
.bare .lead { color: var(--muted); font-size: 13.5px; margin: 0 0 8px; }
.bare form .primary, .bare form button[type=submit] { width: 100%; margin-top: 18px; padding: 10px; }
.bare .alt { margin-top: 28px; font: 12px var(--mono); color: var(--muted); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.bare .alt a { color: var(--muted); }
.tg { min-height: 40px; margin-top: 8px; }

/* ---------- controls ---------- */
button, .btn { font: 12.5px var(--mono); background: transparent; color: var(--fg); border: 1px solid var(--line-strong); padding: 7px 14px; cursor: pointer; border-radius: 0; text-decoration: none; display: inline-block; line-height: 1.5; }
button:hover, .btn:hover { background: var(--soft); }
button:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: default; }
button:disabled:hover { background: transparent; }
.primary { background: var(--fg); color: var(--bg); }
.primary:hover { background: var(--fg); opacity: .88; }
.primary:disabled:hover { background: var(--fg); }
.ghost { border-color: var(--line); color: var(--fg-2); }
.ghost:hover { border-color: var(--line-strong); color: var(--fg); }
.link { border: 0; padding: 0; background: none; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { background: none; color: var(--fg); }
input, select, textarea { font-size: 13px; color: var(--fg); background: var(--bg); border: 1px solid var(--field); padding: 8px 10px; border-radius: 0; outline: none; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--line-strong); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; line-height: 1.5; }
select { width: auto; appearance: none; padding-right: 28px; cursor: pointer;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a8a8a'/%3E%3C/svg%3E") no-repeat right 10px center; }
label { display: block; font: 12px var(--mono); color: var(--muted); margin: 16px 0 6px; }
.err { color: var(--bad); font: 12px var(--mono); margin-top: 12px; min-height: 18px; }

/* text switches instead of segmented controls */
.links { font: 12.5px var(--mono); color: var(--faint); display: flex; gap: 6px 16px; flex-wrap: wrap; }
.links a, .links button { color: var(--muted); text-decoration: none; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.links a:hover, .links button:hover { color: var(--fg); background: none; }
.links .on { color: var(--fg); text-decoration: underline; text-underline-offset: 5px; }

/* status */
.dot { display: inline-block; width: 7px; height: 7px; background: var(--accent); margin-right: 8px; vertical-align: 1px; }
.dot.bad { background: var(--bad); }
.dot.off { background: var(--faint); }
.status { font: 12.5px var(--mono); color: var(--muted); margin-top: 8px; }
.status .st { color: var(--fg); }
.status .st.bad { color: var(--bad); }
.todo { font: 13px var(--mono); margin-top: 20px; }
.todo a { color: var(--fg); }
.todo .calm { color: var(--muted); }
.today { font: 12.5px var(--mono); color: var(--muted); margin-top: 6px; }
.today a { color: var(--muted); }
.today a:hover { color: var(--fg); }
.saved { font: 12px var(--mono); color: var(--muted); padding-top: 6px; }

/* ---------- feed rows (Server) ---------- */
.sect { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 40px 0 10px; }
.feed { border-top: 1px solid var(--line); font: var(--fs-row)/1.5 var(--mono); }
.msg { display: grid; grid-template-columns: 48px 140px minmax(0, 1fr) auto; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: baseline; text-decoration: none; }
.msg .t { color: var(--faint); font-variant-numeric: tabular-nums; }
.msg.open .t, .it[open] > summary .t { color: var(--muted); }   /* on --soft --faint drops below 4.5:1 */
.msg .n { color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .x { min-width: 0; overflow-wrap: anywhere; }
.msg .m { color: var(--muted); font-size: 12px; white-space: nowrap; }
a.msg:hover { background: var(--soft); }
.msg.hid .x { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.msg.sys .x { color: var(--muted); }
.foot { font: 12px var(--mono); color: var(--faint); padding: 16px 0; }
.foot a { color: var(--muted); }

/* ---------- journal entries ---------- */
.day { font: 12px var(--mono); color: var(--faint); padding: 28px 0 8px; border-bottom: 1px solid var(--line); }
.day:first-child { padding-top: 0; }
.log { font: var(--fs-row)/1.5 var(--mono); }
.it > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 48px 140px minmax(0, 1fr) auto; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.it > summary::-webkit-details-marker { display: none; }
.it > summary:hover { background: var(--soft); }
.it .t { color: var(--faint); font-variant-numeric: tabular-nums; }
.it .n { color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.it .x { min-width: 0; overflow-wrap: anywhere; }
.it .m { color: var(--muted); font-size: 12px; white-space: nowrap; text-align: right; }
.it[open] > summary { border-bottom-color: transparent; background: var(--soft); }
.it.fp .x { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.ctx { background: var(--soft); border-bottom: 1px solid var(--line); padding: 2px 16px 16px 220px; }
.ctx .l { padding: 2px 0; color: var(--muted); overflow-wrap: anywhere; }
.ctx .l b { font-weight: 400; color: var(--muted); margin-right: 10px; }
.ctx .l.me { color: var(--fg); }
.ctx .l.me b { color: var(--fg-2); }
.ctx .meta { margin-top: 14px; display: flex; gap: 10px 16px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.ctx .meta .sp { flex: 1; }
.ctx .meta button { padding: 5px 12px; }
.ctx .meta a { color: var(--muted); }

/* ---------- rules ---------- */
.rules { border-top: 1px solid var(--line); }
.rule { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 20px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.rule .nm { font: 13.5px var(--mono); }
.rule .ds { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.rule select { width: 100%; }
.more { border-bottom: 1px solid var(--line); }
.more > summary { list-style: none; cursor: pointer; padding: 14px 0; font: 13px var(--mono); color: var(--muted); }
.more > summary:hover { color: var(--fg); }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::after { content: '\00a0↓'; color: var(--faint); }
.more[open] > summary::after { content: '\00a0↑'; }
.more > .rule:first-of-type { border-top: 1px solid var(--line); }
.more .rule:last-child { border-bottom: 0; }
.probe { margin-top: 56px; max-width: 560px; }
.probe textarea { font-size: 13.5px; }
.probe .row { display: flex; gap: 16px; align-items: baseline; margin-top: 10px; flex-wrap: wrap; font: 12.5px var(--mono); color: var(--muted); }
.probe .row b { font-weight: 400; color: var(--fg); }

/* ---------- connect ---------- */
.steps { border-top: 1px solid var(--line); max-width: 680px; }
.step { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 8px; padding: 26px 0; border-bottom: 1px solid var(--line); }
.step .no { font: 13px var(--mono); color: var(--faint); padding-top: 1px; }
.step p { color: var(--muted); margin: 0 0 14px; font-size: 13.5px; }
.step .ver { font: 12px var(--mono); color: var(--faint); margin-left: 12px; }
.code { display: flex; align-items: stretch; border: 1px solid var(--line); background: var(--soft); margin-top: 10px; }
.code pre { margin: 0; flex: 1; min-width: 0; padding: 12px 14px; font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.code button { border: 0; border-left: 1px solid var(--line); color: var(--muted); padding: 0 14px; flex: none; }
.wait { font: 13px var(--mono); color: var(--muted); }
.check { margin: 14px 0 0; padding: 0 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.8; }

/* ---------- admin ---------- */
.big { display: flex; gap: 64px; flex-wrap: wrap; margin-bottom: 40px; }
.big .k { font: 12.5px var(--mono); color: var(--muted); }
.big .v { font: 500 var(--fs-big)/1.2 var(--mono); margin-top: 6px; font-variant-numeric: tabular-nums; }
.big .d { font: 12.5px var(--mono); color: var(--muted); margin-top: 4px; }
.tbl { width: 100%; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
th { font-weight: 400; color: var(--muted); font-size: 12px; }
th.sort { cursor: pointer; }
th.sort:hover { color: var(--fg); }
td.r, th.r { text-align: right; }
td.nm { white-space: normal; overflow-wrap: anywhere; }
tr.row { cursor: pointer; }
tr.row:hover td { background: var(--soft); }
tr.row.open td { background: var(--soft); border-bottom-color: transparent; }
tr.card > td { background: var(--soft); padding: 0 16px 18px; }
tr.card .ip { font-size: 12px; color: var(--muted); padding: 2px 0 10px; }
tr.card table { font-size: 12.5px; }
tr.card th, tr.card td { padding: 6px 12px; }
tr.grp td { color: var(--muted); font-size: 12px; padding-top: 22px; }
tr.fold td { color: var(--muted); cursor: pointer; }
tr.fold:hover td { color: var(--fg); }
tr.off td { color: var(--muted); }
tfoot td { border-bottom: 0; border-top: 1px solid var(--fg-2); }
.note { font: 12px/1.7 var(--mono); color: var(--faint); margin-top: 16px; }

/* ---------- states: loading, empty, error, 404 ----------
   No skeletons, no spinners, no toasts for loading (owner's decision 30.09). While a screen or its data is on the way:
   - .nprog: a 2 px line in the accent colour at the top of the window (core/progress.js), only after 120 ms;
   - the old content stays on screen, inert (core/router.js): the last copy of the same screen as is (.stale), the
     previous screen dimmed (.stale-dim), never an empty main area. */
.nprog { position: fixed; top: 0; left: 0; z-index: 60; height: 2px; width: 0; background: var(--accent); opacity: 0; pointer-events: none; }
.nprog.on { opacity: 1; }
.nprog.grow { width: 80%; transition: width 6s cubic-bezier(.08, .7, .2, 1); }
.nprog.done { width: 100%; opacity: 0; transition: width .12s linear, opacity .18s linear .06s; }
@media (prefers-reduced-motion: reduce) {
  .nprog.on, .nprog.grow { width: 100%; transition: none; }
  .nprog.done { transition: none; }
}
.main[hidden] { display: none; }
.stale { pointer-events: none; user-select: none; }
.stale.stale-dim { opacity: .45; }
.empty { font: 13px var(--mono); color: var(--muted); padding: 28px 0; }
.empty .act { margin-top: 14px; }
.failed { font: 13px var(--mono); color: var(--bad); padding: 28px 0; }
.failed button { margin-left: 12px; }
.nf { font: 13px var(--mono); color: var(--muted); }
.nf .code404 { font: 12.5px var(--mono); color: var(--faint); margin-bottom: 8px; }
.stub { font: 12.5px/1.7 var(--mono); color: var(--faint); border-top: 1px solid var(--line); padding-top: 16px; margin-top: 40px; }

/* ---------- toast ----------
   One quiet line at the bottom, used for errors and "undo". No shadow, no animation, no colours
   except --bad for errors. Pages prefer inline states; the toast is for things with no place on screen. */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; max-width: min(560px, calc(100vw - 32px));
  background: var(--soft); border: 1px solid var(--line); color: var(--fg); font: 12.5px/1.5 var(--mono); padding: 10px 14px;
  display: flex; gap: 16px; align-items: baseline; }
.toast.error .tx { color: var(--bad); }
.toast button { padding: 0; border: 0; background: none; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.toast button:hover { color: var(--fg); background: none; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  :root { --page-top: 24px; --page-x: 16px; }
  /* top bar: brand + server button (52 px, sticky); the menu moves to the bottom bar */
  .shell { display: block; background: none; }
  .side { position: sticky; top: 0; z-index: 10; height: 52px; max-height: none; overflow: visible; margin: 0; flex-direction: row; align-items: center;
    justify-content: space-between; gap: 12px; padding: 0 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .brand { padding: 0; min-height: var(--tap); flex: none; }
  .side .nav, .side-foot { display: none; }
  .switch { position: static; padding: 0; min-width: 0; max-width: 60%; }
  .switch .sw-cur { border: 0; padding: 0; min-height: 44px; gap: 8px; font-size: 13px; }
  .switch .sw-cur:hover, .switch .sw-cur[aria-expanded="true"] { border: 0; }
  .switch .sw-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 11; margin: 0; padding: 4px 16px 10px; background: var(--bg); border-top: 1px solid var(--fg-2); border-bottom: 1px solid var(--fg-2); }
  .switch .sw-list a { min-height: 44px; padding: 4px 0; font-size: 14px; }
  .switch .sw-list li.sw-on > a { background: none; color: var(--fg); }
  .switch .sw-add .sw-off, .switch .sw-add .sw-hint { padding-left: 0; padding-right: 0; }
  .out, .lang button { min-height: var(--tap); }
  .lang button { min-width: 32px; display: inline-flex; align-items: center; justify-content: center; }
  .main { padding: var(--page-top) var(--page-x) calc(var(--mbar-h) + env(safe-area-inset-bottom) + 16px); }
  .toast { bottom: calc(var(--mbar-h) + env(safe-area-inset-bottom) + 12px); }
  /* bottom bar: five text cells (the fifth is «Ещё», or the name of the section that lives there) */
  .mbar { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 12;
    min-height: var(--mbar-h); padding-bottom: env(safe-area-inset-bottom); background: var(--bg); border-top: 1px solid var(--line); }
  .mbar > a, .mbar > button.more { min-height: var(--mbar-h); display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 2px;
    font: 12px var(--mono); color: var(--muted); text-decoration: none; white-space: nowrap; background: none; border: 0; min-width: 0; }
  .mbar > a .lb, .mbar > button.more .lb { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .mbar > a:hover, .mbar > button.more:hover { color: var(--fg); background: none; }
  .mbar > a.on, .mbar > button.more.on { color: var(--fg); box-shadow: inset 0 1px 0 var(--fg); }
  .mbar > a .cnt { color: var(--fg); flex: none; }
  .mbar > a:focus-visible, .mbar > button.more:focus-visible { outline-offset: -3px; }
  .mbar > button.more[aria-expanded="true"] { color: var(--fg); }
  /* the open sheet dims the page above it (a plain layer, no blur); a tap on it closes the sheet */
  .more-bd { position: fixed; left: 0; right: 0; top: 0; bottom: calc(var(--mbar-h) + env(safe-area-inset-bottom)); z-index: -1; background: rgba(0, 0, 0, .5); }
  .more-bd[hidden] { display: none; }
  .more-sheet { position: absolute; left: 0; right: 0; bottom: 100%; max-height: calc(100dvh - 52px - var(--mbar-h)); overflow-y: auto;
    padding: 4px 16px 8px; background: var(--bg); border-top: 1px solid var(--fg-2); }   /* the sheet's edge over the content: a line, no shadow */
  .more-sheet a, .more-sheet .out { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 48px; padding: 0;
    border-bottom: 1px solid var(--line); font: 14px var(--mono); color: var(--fg-2); text-decoration: none; }
  .more-sheet a.on { color: var(--fg); }
  .more-sheet a:hover { color: var(--fg); }
  .more-sheet .out { border-bottom: 0; text-decoration: none; }
  .more-sheet .sep { height: 12px; }
  .more-lang { display: flex; align-items: center; gap: 8px; min-height: 48px; border-bottom: 1px solid var(--line); font: 14px var(--mono); }
  .more-lang .k { color: var(--muted); margin-right: 8px; }
  .more-lang button { min-width: 44px; min-height: 44px; padding: 0 6px; border: 0; background: none; font: 14px var(--mono); color: var(--muted); }
  .more-lang button:hover { color: var(--fg); background: none; }
  .more-lang button.on { color: var(--fg); text-decoration: underline; text-underline-offset: 5px; }
  .ax .l { min-height: 36px; }
  .pause .link { min-height: var(--tap); }
  .tabs a { min-height: 40px; }
  /* one scrolling line fades out at the right (SPEC §4.6), so a cut word reads as «more this way»; the spacer lets
     the last item scroll clear of the fade */
  .tabs, .jr-flt { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); }
  .tabs::after { content: ''; flex: 0 0 8px; }            /* + the 24 px gap = 32 */
  .jr-flt::after { content: ''; flex: 0 0 14px; }         /* + the 18 px gap = 32 */
  details.msec { border-bottom: 1px solid var(--line); }
  details.msec + details.msec { margin-top: 0; }
  details.msec > summary { min-height: 48px; padding: 12px 0; cursor: pointer; }
  details.msec > summary h2 { font-size: 15px; }
  /* a setting row with a select: name and select on one line, the description under both (SPEC §4.6) */
  .rule:has(> div:first-child + select:last-child) { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .rule:has(> div:first-child + select:last-child) > div:first-child { display: contents; }
  .rule:has(> div:first-child + select:last-child) .nm { grid-column: 1; grid-row: 1; align-self: center; }
  .rule:has(> div:first-child + select:last-child) > div:first-child > :not(.nm) { grid-column: 1 / -1; }
  /* one width for every select of a form, so their left edges line up (the longest value, «Режим ИИ», fits) */
  .rule:has(> div:first-child + select:last-child) > select { grid-column: 2; grid-row: 1; width: 188px; max-width: 52vw; }
  /* …unless its longest value does not fit 188 px: then name / select (full width) / description, one per line */
  .rule:has(> div:first-child + select.sel-w:last-child) { grid-template-columns: minmax(0, 1fr); }
  .rule:has(> div:first-child + select.sel-w:last-child) > select { grid-column: 1; grid-row: 2; width: 100%; max-width: none; }
  .head { margin-bottom: 24px; }
  .sect { margin-top: 32px; }
  button, .btn { min-height: var(--tap); }
  input, textarea { min-height: var(--tap); }
  .link, .links a, .links button { min-height: var(--tap); display: inline-flex; align-items: center; }
  /* stand-alone links (not inside a sentence) get a 36px tap target (DESIGN_V2 rule 12) */
  .todo a, .foot a, .foot .link, .nf a, .foot-link a, .jr-more a, .note a, .empty .act a { display: inline-flex; align-items: center; min-height: var(--tap); }
  details > summary { min-height: var(--tap); display: flex; align-items: center; }
  .it > summary { display: grid; }
  .msg { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; }
  .msg .n { grid-column: 1; grid-row: 1; }
  .msg .t { grid-column: 2; grid-row: 1; font-size: 12px; text-align: right; }
  .msg .x { grid-column: 1 / 3; }
  .msg .m { grid-column: 1 / 3; white-space: normal; }
  .it > summary { grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 0; }
  .it .n { grid-column: 1; grid-row: 1; }
  .it .t { grid-column: 2; grid-row: 1; font-size: 12px; text-align: right; }
  .it .x { grid-column: 1 / 3; }
  .it .m { grid-column: 1 / 3; text-align: left; white-space: normal; }
  .ctx { padding: 4px 12px 16px; }
  .ctx .meta .sp { display: none; }
  .ctx .meta button { padding: 9px 14px; }
  .rule { grid-template-columns: minmax(0, 1fr) 168px; gap: 12px; }
  .rule select { font-size: 12.5px; padding-left: 9px; padding-right: 22px; background-position: right 8px center; min-height: var(--tap); }
  .big { gap: 32px; }
  .big .v { font-size: 24px; }
  .hide-m { display: none; }
  .skel .r { grid-template-columns: minmax(0, 1fr) 40px; }
  .skel .r i:nth-child(1) { display: none; }
}
/* iOS Safari zooms into any field with a font below 16px and leaves the page wider than the screen.
   Never disable zoom through the viewport; make touch-screen fields 16px instead. */
@media (max-width: 900px) and (pointer: coarse) {
  input, select, textarea, .rule select, .probe textarea { font-size: 16px; }
}
.nf h1 { color: var(--fg); }

/* phone: an address with #anchor (rules#mode, settings#data) scrolls its target below the sticky 52 px top bar */
@media (max-width: 900px) {
  #main [id] { scroll-margin-top: 68px; }
}
