/*
 * app.css - Access styles: tokens, base, login and personal pages, the panel shell,
 * tables, the drawer, switches, segmented controls, dropdowns and toasts.
 * Visual reference: SubscriptionTracker (white surfaces, gray lines, black primary actions).
 *
 * Layout: mobile up to 480px, tablet 481-1024px, desktop from 1025px. Every page and the
 * drawer take their side padding from --gutter and --drawer-gutter.
 * Motion: state changes use --t-fast or --t-base with --ease; elements that appear and
 * disappear fade with a slight blur and shift (.is-in / .is-out, used by assets/app.js).
 * Hover styles live in the (hover: hover) block so touch screens never keep a stuck hover.
 */

:root {
  color-scheme: light;
  --ink: #171717; --ink-hover: #404040; --text-2: #525252; --text-3: #737373; --text-4: #a3a3a3;
  --line: #e5e5e5; --line-soft: #f5f5f5; --line-strong: #d4d4d4;
  --surface: #fff; --surface-2: #fafafa; --surface-3: #f5f5f5; --surface-4: #efefef;
  --danger: #dc2626; --danger-hover: #b91c1c; --danger-bg: #fef2f2;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --sh-md: 0 4px 6px -1px rgb(0 0 0 / .06), 0 2px 4px -2px rgb(0 0 0 / .06);
  --sh-xl: 0 25px 50px -12px rgb(0 0 0 / .18);
  --ring: 0 0 0 3px rgb(23 23 23 / .12);
  --ring-inset: inset 0 0 0 2px rgb(23 23 23 / .18);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --t-fast: .15s;
  --t-base: .2s;
  --t-drawer: .28s;
  --gutter: 24px;
  --drawer-gutter: 20px;
  --tap: 44px;
}
@media (max-width: 1024px) { :root { --gutter: 20px; } }
@media (max-width: 480px) { :root { --gutter: 16px; --drawer-gutter: 16px; } }

*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--surface); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; overflow-wrap: break-word; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; }
h1, h2, h3 { font-weight: 600; line-height: 1.3; }
.ti { font-size: 18px; line-height: 1; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.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; }

/* Invisible touch area: small controls keep their look and still get a 44px target. */
.btn, .nav button, .dd-btn, .chip button, .segmented button, .switch { position: relative; }
.btn::before, .nav button::before, .dd-btn::before { content: ""; position: absolute; inset: calc((min(100%, var(--tap)) - var(--tap)) / 2) 0; }
.btn.icon::before { inset: calc((min(100%, var(--tap)) - var(--tap)) / 2); }
.segmented button::before { content: ""; position: absolute; inset: calc((min(100%, var(--tap)) - var(--tap)) / 2) 0; }
.chip button::before { content: ""; position: absolute; inset: calc((22px - var(--tap)) / 2); border-radius: 50%; }
.switch::before { content: ""; position: absolute; inset: calc((20px - var(--tap)) / 2) calc((34px - var(--tap)) / 2); }

/* ── Shared controls ─────────────────────────────────────────────────── */
.tile { width: 32px; height: 32px; border-radius: 10px; background: var(--ink); color: #fff; display: grid; place-items: center; flex: none; }
.tile .ti { font-size: 17px; }
.tile.lg { width: 44px; height: 44px; border-radius: 14px; }
.tile.lg .ti { font-size: 22px; }
.tile.sm { width: 24px; height: 24px; border-radius: 7px; }
.tile.sm .ti { font-size: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap; transition: background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast), transform var(--t-fast) var(--ease); }
.btn:focus-visible, .nav button:focus-visible, .segmented button:focus-visible, .dd-btn:focus-visible, .chip button:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:active:not([disabled]), .nav button:active, .segmented button:active, .dd-btn:active, .chip button:active { transform: scale(.98); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ghost { border-color: transparent; color: var(--text-2); }
.btn.danger { color: var(--danger); }
.btn.danger.confirm { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.icon { width: 36px; padding: 0; }
.btn.wide { width: 100%; height: 40px; }
.btn .ti { font-size: 16px; }
.btn-label { display: inline-flex; align-items: center; gap: 6px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn[aria-busy="true"] { opacity: .7; }
.spin { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.field { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fff; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.field:focus { outline: none; border-color: var(--ink); }
.field.error { border-color: var(--danger); }
.field.mono { font-family: var(--mono); font-size: 14px; }
.center-text { text-align: center; }
label.lbl { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }

/* ── Motion helpers ──────────────────────────────────────────────────── */
@keyframes enterUp { from { opacity: 0; transform: translateY(10px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes fadeOut { from { opacity: 1; transform: none; filter: none; } to { opacity: 0; transform: translateY(-4px); filter: blur(2px); } }
.anim { animation: enterUp var(--t-base) ease-out both; }
.is-in { animation: fadeIn var(--t-base) var(--ease) both; }
.is-out { animation: fadeOut var(--t-fast) ease-in both; pointer-events: none; }

/* ── Login, no-access and 404 cards ──────────────────────────────────── */
.center { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 32px; padding: var(--gutter); }
.card { width: 100%; max-width: 22rem; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--sh-md); padding: 32px; display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; background: #fff; }
.card h1 { font-size: 18px; overflow-wrap: anywhere; }
.card .sub { color: var(--text-3); font-size: 14px; margin-top: 4px; text-wrap: pretty; overflow-wrap: anywhere; }
.stack-form { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.login-error { color: var(--danger); font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 6px; animation: fadeIn var(--t-base) var(--ease) both; }
.login-error .ti { font-size: 15px; flex: none; }
.foot { font-size: 13px; color: var(--text-4); text-align: center; }
.foot a { color: var(--text-3); text-decoration: none; display: inline-block; padding: 14px 4px; margin: -14px -4px; border-radius: 6px; transition: color var(--t-fast), box-shadow var(--t-fast); }
.foot a:focus-visible { outline: none; box-shadow: var(--ring); }

/* ── Personal page ───────────────────────────────────────────────────── */
.narrow { max-width: 560px; margin: 0 auto; padding: 48px var(--gutter); }
.narrow-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.narrow-head > div { min-width: 0; }
.narrow-head .btn { flex: none; }
.narrow h1 { font-size: 24px; overflow-wrap: anywhere; }
.section-title { font-size: 13px; font-weight: 500; color: var(--text-3); margin: 32px 0 8px; }
.list { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line-soft); }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row .title { font-weight: 500; overflow-wrap: anywhere; }
.row .meta { font-size: 13px; color: var(--text-3); overflow-wrap: anywhere; }
.row .btn, .row > .ti { flex: none; }
.row.link { text-decoration: none; transition: background-color var(--t-fast), box-shadow var(--t-fast); }
.row.link .ti-arrow-up-right { transition: color var(--t-fast), transform var(--t-fast) var(--ease); }
.row.link:focus-visible { outline: none; box-shadow: var(--ring-inset); }
.row form { display: contents; }
.empty { padding: 16px; font-size: 14px; color: var(--text-3); }
.notice { margin-top: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 14px; color: var(--text-2); animation: fadeIn var(--t-base) var(--ease) both; }

/* ── Panel shell ─────────────────────────────────────────────────────── */
.header { min-height: 64px; border-bottom: 1px solid var(--line); background: #fff; }
.header .in { max-width: 1120px; min-height: 64px; margin: 0 auto; padding: 8px var(--gutter); display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; flex: none; }
.nav { display: flex; gap: 4px; flex: 1 0 auto; }
.nav button { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 10px; color: var(--text-3); font-size: 14px; font-weight: 500; white-space: nowrap; transition: color var(--t-fast), background-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast) var(--ease); }
.nav button[aria-selected="true"] { color: var(--ink); background: var(--surface-3); }
.me { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); min-width: 0; }
.me .name { min-width: 0; text-align: right; line-height: 1.3; overflow-wrap: anywhere; }
.me .btn { flex: none; }
.page { max-width: 1120px; margin: 0 auto; padding: 32px var(--gutter) 64px; transition: opacity var(--t-fast), filter var(--t-fast), transform var(--t-fast) var(--ease); }
.page.is-leaving { opacity: 0; filter: blur(2px); transform: translateY(4px); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head > div { min-width: 0; }
.page-head .btn { flex: none; }
.page-head h1 { font-size: 24px; }
.page-head p { color: var(--text-3); font-size: 14px; margin-top: 2px; }
.filterbar { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; max-width: 100%; padding: 4px 6px 4px 10px; border-radius: 9999px; border: 1px solid var(--line); font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.chip button { width: 22px; height: 22px; flex: none; border-radius: 9999px; display: grid; place-items: center; color: var(--text-3); transition: background-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast) var(--ease); }
.chip .ti { font-size: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: auto; }
.table { border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; transition: opacity var(--t-base); }
.table.is-busy { opacity: .55; }
th { text-align: left; font-weight: 500; font-size: 12px; color: var(--text-3); padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
/* break-word, not anywhere: columns keep whole words and only split a word wider than the column. */
td { padding: 12px 16px; border-top: 1px solid var(--line-soft); vertical-align: middle; overflow-wrap: break-word; }
tr:first-child td { border-top: 0; }
tbody tr.click { cursor: pointer; transition: background-color var(--t-fast), box-shadow var(--t-fast); }
tbody tr.click:focus-visible { outline: none; box-shadow: var(--ring-inset); }
tbody tr.sel { background: var(--surface-3); }
td.empty-row { text-align: center; color: var(--text-3); padding: 32px 16px; cursor: default; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who > span:last-child { min-width: 0; }
.cell-apps .who { flex-wrap: wrap; row-gap: 6px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.icons { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-width: 0; }
.icons .more { font-size: 12px; color: var(--text-3); margin-left: 4px; }
.applist { display: block; flex: 1 1 12rem; min-width: 0; }
.nowrap { white-space: nowrap; }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; font-size: 13px; color: var(--text-3); }

/* ── Drawer ──────────────────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / .18); opacity: 0; pointer-events: none; transition: opacity var(--t-base); z-index: 50; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100%); background: #fff; transform: translateX(100%); visibility: hidden; transition: transform var(--t-drawer) var(--ease), box-shadow var(--t-drawer), visibility 0s var(--t-drawer); z-index: 60; display: flex; flex-direction: column; }
.drawer.on { transform: none; visibility: visible; box-shadow: var(--sh-xl); transition: transform var(--t-drawer) var(--ease), box-shadow var(--t-drawer); }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 14px var(--drawer-gutter); border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 16px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.drawer-head .btn { flex: none; }
.drawer-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px var(--drawer-gutter) 24px; }
.drawer-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 12px var(--drawer-gutter); padding-bottom: max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.drawer-foot .left { margin-right: auto; }
.drawer-head h2, .drawer-body, .drawer-foot { transition: opacity var(--t-fast), filter var(--t-fast), transform var(--t-fast) var(--ease); }
.drawer.is-swapping .drawer-head h2, .drawer.is-swapping .drawer-body, .drawer.is-swapping .drawer-foot { opacity: 0; filter: blur(2px); transform: translateY(4px); }
.form-error { color: var(--danger); font-size: 13px; display: flex; gap: 6px; align-items: flex-start; padding: 10px 12px; background: var(--danger-bg); border-radius: 10px; margin-top: 16px; overflow-wrap: anywhere; }
.form-error .ti { font-size: 16px; margin-top: 1px; flex: none; }
.block { padding: 20px 0; border-top: 1px solid var(--line); }
.block:first-child { border-top: 0; }
.block-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 4px 0; }
.kv .k { color: var(--text-3); flex: none; }
.kv > span:last-child { min-width: 0; text-align: right; overflow-wrap: anywhere; }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; cursor: pointer; }
.switch-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; line-height: 1.3; }
.switch-row small { font-size: 12px; color: var(--text-4); }
.switch-row:has(.switch:disabled) { cursor: default; }

.cat { margin-top: 18px; }
.cat:first-child { margin-top: 0; }
.cat-head { display: flex; align-items: center; gap: 10px; padding: 0 0 8px; margin-bottom: 2px; border-bottom: 1px solid var(--line-soft); }
.cat-head .label { flex: 1; min-width: 0; font-size: 12px; font-weight: 500; color: var(--text-3); }
.cat-head .count { font-size: 12px; color: var(--text-4); font-variant-numeric: tabular-nums; flex: none; }
.app { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; cursor: pointer; }
.app .name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; overflow-wrap: anywhere; }
.app .name small { font-size: 12px; color: var(--text-4); }
.app.stack { flex-wrap: wrap; cursor: default; }
.app.stack .segmented { flex-basis: 100%; margin-top: 6px; }

/* Switch on a native checkbox, same as SubscriptionTracker */
.switch { appearance: none; flex: none; width: 34px; height: 20px; border-radius: 9999px; background: var(--line); cursor: pointer; transition: background-color var(--t-base) var(--ease), box-shadow var(--t-fast), opacity var(--t-fast); margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 9999px; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .2); transition: transform var(--t-base) var(--ease); }
.switch:checked { background: var(--ink); }
.switch:checked::after { transform: translateX(14px); }
.switch:focus-visible { outline: none; box-shadow: var(--ring); }
.switch:disabled { opacity: .5; cursor: default; }

/* Segmented control: icon and text on a gray track */
.segmented { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-3); }
.segmented button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 30px; padding: 0 6px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--text-3); white-space: nowrap; transition: background-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast) var(--ease); }
.segmented button .ti { font-size: 15px; flex: none; }
.segmented button[aria-checked="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .08), inset 0 0 0 1px rgb(0 0 0 / .04); }

/* Dropdown: the list leaves the layout while closed ([hidden]) and fades in and out. */
.dd { position: relative; min-width: 0; }
.dd-btn { display: flex; align-items: center; gap: 8px; width: 100%; min-width: min(190px, 100%); min-height: 36px; padding: 5px 10px 5px 5px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 14px; text-align: left; transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast) var(--ease); }
.dd.block-dd .dd-btn { min-height: 40px; padding-block: 7px; }
.dd-btn .ico { width: 24px; height: 24px; border-radius: 7px; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; flex: none; }
.dd-btn .ico .ti { font-size: 14px; }
.dd-btn .val { flex: 1; min-width: 0; line-height: 1.3; overflow-wrap: anywhere; }
.dd-btn .chev { color: var(--text-4); font-size: 16px; flex: none; transition: transform var(--t-base) var(--ease), color var(--t-fast); }
.dd.open .dd-btn { border-color: var(--ink); }
.dd.open .chev { transform: rotate(180deg); }
.dd-list { position: absolute; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; max-width: min(360px, calc(100vw - 2 * var(--gutter))); max-height: min(320px, 50vh); overflow-y: auto; z-index: 70; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-md); padding: 4px; opacity: 0; transform: translateY(-4px); filter: blur(2px); pointer-events: none; transition: opacity var(--t-fast), transform var(--t-fast) var(--ease), filter var(--t-fast); }
.dd-list[hidden] { display: none; }
.dd.open .dd-list { opacity: 1; transform: none; filter: none; pointer-events: auto; }
.dd-list button { display: flex; align-items: flex-start; gap: 8px; width: 100%; min-height: 34px; padding: 7px 8px; border-radius: 8px; font-size: 14px; line-height: 1.4; color: var(--text-2); text-align: left; overflow-wrap: anywhere; transition: background-color var(--t-fast), color var(--t-fast); }
.dd-list button span { flex: 1; min-width: 0; }
.dd-list button .ti { font-size: 16px; flex: none; margin-top: 2px; color: var(--text-4); transition: color var(--t-fast), opacity var(--t-fast); }
.dd-list button:focus-visible { background: var(--surface-3); color: var(--ink); outline: none; }
.dd-list button .check { color: var(--ink); opacity: 0; }
.dd-list button[aria-selected="true"] .check { opacity: 1; }

.secret { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; transition: border-color var(--t-fast); }
label.secret { cursor: text; }
.secret code { flex: 1; min-width: 0; font-family: var(--mono); font-size: 14px; word-break: break-all; }
.secret input { flex: 1; min-width: 0; align-self: stretch; border: 0; outline: none; font-family: var(--mono); font-size: 14px; background: transparent; }
.secret .btn { flex: none; }
.secret:focus-within { border-color: var(--ink); }
.note { font-size: 13px; color: var(--text-3); margin-top: 8px; }
.message { font-size: 13px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 12px; white-space: pre-line; overflow-wrap: anywhere; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 2 * var(--gutter)); transform: translate(-50%, 12px); filter: blur(2px); background: var(--ink); color: #fff; font-size: 14px; padding: 10px 16px; border-radius: 12px; box-shadow: var(--sh-md); opacity: 0; pointer-events: none; transition: opacity var(--t-base), transform var(--t-base) var(--ease), filter var(--t-base); z-index: 80; display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.toast.on { opacity: 1; transform: translate(-50%, 0); filter: none; }
.toast .ti { font-size: 16px; flex: none; }

/* ── Hover: only on devices that can hover ───────────────────────────── */
@media (hover: hover) {
  .btn:hover { border-color: var(--line-strong); }
  .btn.primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }
  .btn.ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--ink); }
  .btn.ghost.danger:hover { background: var(--danger-bg); color: var(--danger-hover); }
  .btn.danger.confirm:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }
  .field:hover:not(:focus):not(.error) { border-color: var(--line-strong); }
  .secret:hover:not(:focus-within) { border-color: var(--line-strong); }
  .foot a:hover { color: var(--ink); }
  .row.link:hover { background: var(--surface-2); }
  .row.link:hover .ti-arrow-up-right { color: var(--ink); transform: translate(1px, -1px); }
  .nav button:hover { color: var(--ink); }
  .nav button:not([aria-selected="true"]):hover { background: var(--surface-2); }
  .nav button[aria-selected="true"]:hover { background: var(--surface-4); }
  .chip button:hover { background: var(--surface-3); color: var(--ink); }
  tbody tr.click:hover { background: var(--surface-2); }
  tbody tr.sel:hover { background: var(--surface-3); }
  .switch:not(:disabled):hover, .app:hover .switch:not(:disabled), .switch-row:hover .switch:not(:disabled) { background: var(--line-strong); }
  .switch:checked:not(:disabled):hover, .app:hover .switch:checked:not(:disabled), .switch-row:hover .switch:checked:not(:disabled) { background: var(--ink-hover); }
  .segmented button:hover { color: var(--ink); }
  .segmented button:not([aria-checked="true"]):hover { background: rgb(255 255 255 / .55); }
  .dd-btn:hover { border-color: var(--line-strong); }
  .dd-btn:hover .chev { color: var(--text-2); }
  .dd.open .dd-btn:hover { border-color: var(--ink); }
  .dd-list button:hover { background: var(--surface-3); color: var(--ink); }
  .dd-list button:hover .ti { color: var(--ink); }
}

/* ── Tablet and mobile ───────────────────────────────────────────────── */
@media (max-width: 760px) {
  .header .in { flex-wrap: wrap; gap: 8px 16px; padding: 12px var(--gutter) 8px; }
  .brand { flex: 1; }
  .me .name { display: none; }
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; padding-block: 4px; margin-block: -4px; }
  .nav button { padding: 0 10px; flex: none; }
  .page { padding: 24px var(--gutter) 48px; }
  .page-head { flex-wrap: wrap; align-items: flex-start; }
  .filterbar .dd { flex: 1 1 100%; }
  .hide-sm { display: none; }
  td, th { padding: 10px 12px; }
  .narrow { padding: 32px var(--gutter); }
  /* Activity rows stack on phones and small tablets: who and when on top, what happened below. */
  .act thead { display: none; }
  .act tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who when" "what what"; gap: 2px 12px; padding: 10px 12px; border-top: 1px solid var(--line-soft); }
  .act tbody tr:first-child { border-top: 0; }
  .act td { padding: 0; border: 0; }
  .act td:nth-child(1) { grid-area: when; font-size: 12px; }
  .act td:nth-child(2) { grid-area: who; font-weight: 500; min-width: 0; }
  .act td:nth-child(3) { grid-area: what; color: var(--text-2); }
  .act td.empty-row { grid-area: auto; grid-column: 1 / -1; padding: 24px 0; }
}
@media (max-width: 480px) {
  .applist { display: none; }
  .nav { gap: 2px; }
  .nav button { padding: 0 8px; gap: 5px; font-size: 13px; }
  .segmented { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .segmented button { min-height: 36px; }
  .drawer-foot .btn { flex: 1 1 auto; }
  .drawer-foot .left { margin-right: 0; }
  .card { padding: 28px 20px; }
}
@media (max-width: 360px) {
  .nav-long { display: none; }
  .nav button { padding: 0 6px; }
  .secret { gap: 6px; padding-left: 10px; }
}
/* Phones, tablets and any touch screen: 44px fields and list options, and 16px text in
   inputs so iOS does not zoom in on focus. */
@media (max-width: 1024px), (pointer: coarse) {
  .field { height: 44px; font-size: 16px; }
  .secret input { font-size: 16px; }
  .dd-list button { min-height: 44px; padding-block: 12px; }
}

/* Page-to-page navigation inside Access cross-fades where the browser supports it. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: fadeOut var(--t-fast) ease-in both; }
::view-transition-new(root) { animation: fadeIn var(--t-base) var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
}

/* Spacing helpers used by markup the panel builds (the CSP forbids inline styles) */
.lead { margin-bottom: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.field + .switch-row { margin-top: 8px; }
