/* N-22 (user decision 2026-11-16): the light / dark switch, the system's description beside the logo, and the advanced
   table toolbar (tables.js). Colours come from the theme tokens only (theme.css), so both themes follow. */

/* ---------- Light / dark / the device's ---------- */
.theme-switch { display: inline-flex; flex: none; border: 1px solid var(--dk-border); border-radius: 10px; overflow: hidden; background: var(--dk-surface); }
.theme-switch button { display: grid; place-items: center; inline-size: 36px; block-size: 36px; border: 0; background: transparent; color: var(--dk-muted); cursor: pointer; padding: 0; }
.theme-switch button + button { border-inline-start: 1px solid var(--dk-border); }
.theme-switch button:hover { background: var(--dk-hover); color: var(--dk-text); }
.theme-switch button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-text); }
.theme-switch .icon { inline-size: 18px; block-size: 18px; }
.dk-topbar .theme-switch { block-size: 40px; }
.dk-topbar .theme-switch button { block-size: 38px; }
.auth__top > .lang-switch { margin-inline-start: auto; }
.auth__top { gap: 10px; }
.rp-brand .theme-switch button, .blocked__top .theme-switch button { inline-size: 32px; block-size: 32px; }
.blocked__top { gap: 10px; }

/* ---------- The system's description beside the logo ---------- */
.org-desc { display: block; font-size: 12px; line-height: 1.5; color: var(--dk-muted); font-weight: 400; max-inline-size: 42ch; }
.rp-org .org-desc { margin-block-start: 1px; }
.org-desc--light { color: inherit; opacity: 0.85; margin: 6px 0 0; font-size: 13px; text-align: center; }

/* ---------- The table toolbar ---------- */
.tt { position: relative; margin-block: 12px; }
.tt__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tt__btn { display: inline-flex; align-items: center; gap: 6px; min-block-size: 36px; padding-inline: 12px; border: 1px solid var(--dk-line); border-radius: 10px; background: var(--dk-surface); color: var(--dk-text); font: inherit; font-size: 13px; cursor: pointer; }
.tt__btn:hover { background: var(--dk-hover); }
.tt__btn[aria-expanded="true"] { border-color: var(--brand); color: var(--brand-text); background: var(--brand-soft); }
.tt__btn .icon { inline-size: 16px; block-size: 16px; }
.tt__count { min-inline-size: 18px; block-size: 18px; padding-inline: 5px; border-radius: 999px; background: var(--brand); color: var(--brand-ink); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.tt__chips { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tt__chip { display: inline-flex; align-items: center; gap: 6px; max-inline-size: 100%; padding-block: 3px; padding-inline: 10px 4px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-text); font-size: 12px; }
.tt__chip--sort { background: var(--st-neutral-bg); color: var(--st-neutral); }
.tt__chip .icon { inline-size: 14px; block-size: 14px; flex: none; }
.tt__chip button { display: grid; place-items: center; inline-size: 22px; block-size: 22px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; padding: 0; }
.tt__chip button:hover { background: var(--dk-hover); }
.tt__clear { border: 0; background: none; color: var(--brand-text); font: inherit; font-size: 12px; text-decoration: underline; cursor: pointer; padding: 4px; }
.tt__ignored { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 8px; background: var(--st-warn-bg); color: var(--st-warn-ink); font-size: 12px; }
.tt__ignored .icon { inline-size: 14px; block-size: 14px; }

/* The filter / sort / columns panel (redesigned 2026-11-20): a titled card; each condition reads as one numbered
   sentence (column · comparison · value) on a soft strip, joined to the next by "and" / "then". */
.tt__pop { position: absolute; z-index: 30; inset-block-start: calc(100% + 8px); inset-inline-start: 0; inline-size: min(700px, calc(100vw - 32px)); padding: 16px; border: 1px solid var(--dk-border); border-radius: 18px; background: var(--dk-surface); color: var(--dk-text); box-shadow: var(--dk-pop-shadow); transform-origin: top; animation: tt-pop 0.18s var(--ui-ease, ease) both; }
.tt__pop[data-kind="columns"] { inline-size: min(400px, calc(100vw - 32px)); }
.tt__pop[data-kind="sort"] { inline-size: min(560px, calc(100vw - 32px)); }
@keyframes tt-pop { from { opacity: 0; transform: translateY(-4px) scale(0.985); } }
.tt__head { display: flex; align-items: flex-start; gap: 12px; padding-block-end: 14px; margin-block-end: 14px; border-block-end: 1px dashed var(--dk-border); }
.tt__tile { display: grid; place-items: center; flex: none; inline-size: 38px; block-size: 38px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-text); }
.tt__tile .icon { inline-size: 19px; block-size: 19px; }
.tt__titles { flex: 1; min-inline-size: 0; }
.tt__titles strong { display: block; font-size: 15px; line-height: 1.4; }
.tt__titles .tt__hint { margin: 2px 0 0; }
.tt__x { display: grid; place-items: center; flex: none; inline-size: 32px; block-size: 32px; border: 0; border-radius: 10px; background: transparent; color: var(--dk-faint); cursor: pointer; transition: background-color 0.15s, color 0.15s; }
.tt__x:hover { background: var(--dk-hover); color: var(--dk-text); }
.tt__x .icon { inline-size: 17px; block-size: 17px; }
.tt__hint { margin: 0 0 10px; font-size: 12.5px; line-height: 1.6; color: var(--dk-muted); }
.tt__hint--small { margin: 10px 0 0; font-size: 11.5px; }

.tt__rows { display: grid; gap: 22px; counter-reset: tt-row; }
.tt__row { position: relative; display: grid; grid-template-columns: 26px minmax(0, 1fr) 34px; align-items: center; gap: 10px; padding: 8px; padding-inline-start: 10px; border: 1px solid transparent; border-radius: 14px; background: var(--dk-surface-2); counter-increment: tt-row; transition: border-color 0.15s, background-color 0.15s, opacity 0.16s, transform 0.16s; }
.tt__row:focus-within { border-color: color-mix(in srgb, var(--brand) 35%, transparent); background: color-mix(in srgb, var(--brand-soft) 45%, var(--dk-surface-2)); }
.tt__row.is-new { animation: tt-row-in 0.22s var(--ui-ease, ease) both; }
.tt__row.is-leaving { opacity: 0; transform: scale(0.97); }
@keyframes tt-row-in { from { opacity: 0; transform: translateY(-6px); } }
/* "and" / "then" between two conditions, on the gap */
.tt__row + .tt__row::before { content: attr(data-join); position: absolute; inset-block-start: -19px; inset-inline-start: 12px; padding: 0 9px; border-radius: 999px; background: var(--dk-surface); border: 1px solid var(--dk-border); color: var(--dk-muted); font-size: 11px; font-weight: 600; line-height: 16px; }
.tt__num { display: grid; place-items: center; inline-size: 26px; block-size: 26px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tt__num::before { content: counter(tt-row); }
.tt__cells { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.9fr) minmax(0, 1.25fr); gap: 8px; min-inline-size: 0; }
.tt__row--sort .tt__cells { grid-template-columns: minmax(0, 1fr) auto; }
.tt__value { display: block; min-inline-size: 0; }
.tt__novalue { display: grid; place-items: center; block-size: 40px; border: 1px dashed var(--dk-border); border-radius: 11px; color: var(--dk-faint); }

/* one-frame field, as .control in the kit */
.tt__field { position: relative; display: flex; align-items: center; min-inline-size: 0; block-size: 40px; border: 1px solid var(--dk-line); border-radius: 11px; background: var(--dk-surface); transition: border-color 0.15s, box-shadow 0.15s; }
.tt__field:hover { border-color: var(--dk-line-strong, var(--dk-line)); }
.tt__field:focus-within { border-color: var(--brand); box-shadow: var(--ui-ring, 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent)); }
.tt__field > select, .tt__field > input { flex: 1; min-inline-size: 0; inline-size: 100%; block-size: 100%; padding-inline: 12px; border: 0; outline: 0; border-radius: inherit; background: transparent; color: var(--dk-text); font: inherit; font-size: 13.5px; box-shadow: none; }
.tt__field > input::placeholder { color: var(--dk-faint); }
.tt__field--select > select { -webkit-appearance: none; appearance: none; padding-inline-end: 34px; cursor: pointer; text-overflow: ellipsis; }
.tt__field--select::after { content: ""; position: absolute; inset-inline-end: 12px; inline-size: 12px; block-size: 12px; background: var(--dk-faint); pointer-events: none; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; transition: background-color 0.15s; }
.tt__field--select:focus-within::after { background: var(--brand-text); }
.tt__field--col > select { font-weight: 600; }
.tt__field--op { background: color-mix(in srgb, var(--brand-soft) 55%, var(--dk-surface)); }
.tt__field--op > select { color: var(--brand-text); }
.tt__field--ltr > input { direction: ltr; text-align: end; font-variant-numeric: tabular-nums; }
.tt__field > input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0.55; cursor: pointer; }

/* sort direction as a small segmented control */
.tt__dir { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--dk-surface); border: 1px solid var(--dk-line); }
.tt__dir button { display: inline-flex; align-items: center; gap: 6px; block-size: 32px; padding-inline: 10px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--dk-muted); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; transition: background-color 0.15s, color 0.15s; }
.tt__dir button svg { inline-size: 14px; block-size: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tt__dir button:hover { color: var(--dk-text); }
.tt__dir button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }

.tt__remove { display: grid; place-items: center; inline-size: 34px; block-size: 34px; border: 0; border-radius: 10px; background: transparent; color: var(--dk-faint); cursor: pointer; transition: background-color 0.15s, color 0.15s; }
.tt__remove:hover { background: var(--st-danger-bg, var(--dk-hover)); color: var(--st-danger, var(--dk-text)); }
.tt__remove .icon { inline-size: 17px; block-size: 17px; }

.tt__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-block-start: 16px; }
.tt__grow { flex: 1; }
.tt__add { display: inline-flex; align-items: center; gap: 8px; min-block-size: 36px; padding-inline: 12px 14px; border: 1px dashed color-mix(in srgb, var(--brand) 45%, var(--dk-line)); border-radius: 11px; background: transparent; color: var(--brand-text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background-color 0.15s, border-color 0.15s; }
.tt__add:hover { background: var(--brand-soft); border-style: solid; }
.tt__add .icon { inline-size: 16px; block-size: 16px; }

.tt__cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px; }
.tt__col { display: flex; align-items: center; gap: 8px; min-block-size: 34px; padding-inline: 8px; border-radius: 9px; font-size: 13px; cursor: pointer; }
.tt__col:hover { background: var(--dk-hover); }
.tt__pin { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.tt__pin select { min-block-size: 36px; padding-inline: 8px; border: 1px solid var(--dk-line); border-radius: 10px; background: var(--dk-surface); color: var(--dk-text); font: inherit; }
@media (max-width: 640px) {
  .tt__pop { padding: 14px; }
  .tt__row { grid-template-columns: 26px minmax(0, 1fr) 34px; align-items: start; }
  .tt__cells, .tt__row--sort .tt__cells { grid-template-columns: minmax(0, 1fr); }
  .tt__foot .tt__add { flex: 1 0 100%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { .tt__pop, .tt__row.is-new { animation: none; } }

/* Resizing a column by its header's edge; pinned columns keep the table's surface behind them. */
.tt-th { position: relative; }
.tt-resize { position: absolute; inset-block: 0; inset-inline-end: -3px; inline-size: 7px; cursor: col-resize; z-index: 3; touch-action: none; }
.tt-resize:hover, .tt-resize:active { background: linear-gradient(var(--brand), var(--brand)) center / 2px 100% no-repeat; }
.table.tt-pinned thead th { background: var(--dk-surface-2); }
.dk-main .table.tt-pinned tbody tr:hover > * { background: var(--dk-hover); }
.table-wrap:has(> .tt-pinned) { overflow-x: auto; }
@media print { .tt, .theme-switch { display: none !important; } }

/* =====================================================================
   Scrollbars: slim, rounded, brand-tinted; darker on hover. Chrome/Edge/Safari
   use ::-webkit-scrollbar (rich styling); Firefox gets the standard properties.
   ===================================================================== */
:root { --sb-thumb: color-mix(in srgb, var(--brand) 28%, var(--dk-line-strong)); --sb-thumb-hover: color-mix(in srgb, var(--brand) 70%, var(--dk-line-strong)); }
::-webkit-scrollbar { inline-size: 12px; block-size: 12px; width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background-color: var(--sb-thumb); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; min-block-size: 40px; }
::-webkit-scrollbar-thumb:hover { background-color: var(--sb-thumb-hover); }
::-webkit-scrollbar-thumb:active { background-color: var(--brand); }
::-webkit-scrollbar-corner { background: transparent; }
/* Small scroll areas (sidebar, menus, tables, lists) get a thinner bar. */
:is(.side2, .menu__list, .combo__list, .table-wrap, .tabs, .kit-toc, .settings-nav, .drawer__body, .dialog__body)::-webkit-scrollbar { width: 8px; height: 8px; }
:is(.side2, .menu__list, .combo__list, .table-wrap, .tabs, .kit-toc, .settings-nav, .drawer__body, .dialog__body)::-webkit-scrollbar-thumb { border-width: 2px; }
/* The sidebar's bar only shows while you're over it. */
.side2::-webkit-scrollbar-thumb { background-color: transparent; }
.side2:hover::-webkit-scrollbar-thumb { background-color: var(--sb-thumb); }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--sb-thumb) transparent; }
}