/* Components. Every color, size, font, radius and shadow comes from theme.css (var(--...)).
   No inline styles anywhere: the CSP (default-src 'self') blocks them. */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; font-family: var(--font-sans); font-size: var(--text-md); line-height: var(--leading); color: var(--text); background: var(--bg); }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
b, strong { font-weight: var(--weight-bold); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }
[hidden] { display: none !important; }

/* ---------- icons: CSS masks, so JS-built rows need no SVG nodes (currentColor) ---------- */
.i { display: inline-block; width: 20px; height: 20px; flex: none; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.i-sm { width: 16px; height: 16px; }
.i-lg { width: 22px; height: 22px; }
.i-logo { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8h16l-1.5 10.5a2 2 0 0 1-2 1.5h-9a2 2 0 0 1-2-1.5z'/%3E%3Cpath d='M3 8c0-1.9 4-3.5 9-3.5s9 1.6 9 3.5'/%3E%3Cpath d='M12 11v5'/%3E%3Cpath d='m9.5 13.5 2.5 2.5 2.5-2.5'/%3E%3C/svg%3E"); }
.i-upload { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 15V4'/%3E%3Cpath d='m7 9 5-5 5 5'/%3E%3Cpath d='M4 15v3a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-3'/%3E%3C/svg%3E"); }
.i-key { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8' cy='15' r='4'/%3E%3Cpath d='m10.8 12.2 9.2-9.2'/%3E%3Cpath d='m17 6 3 3'/%3E%3Cpath d='m14.5 8.5 2 2'/%3E%3C/svg%3E"); }
.i-help { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M9.6 9.4a2.5 2.5 0 1 1 3.4 2.4c-.6.3-1 .8-1 1.5v.4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E"); }
.i-shield { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 5 6v5c0 4.4 3 8 7 10 4-2 7-5.6 7-10V6z'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E"); }
.i-logout { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 4h4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-4'/%3E%3Cpath d='m9 16-4-4 4-4'/%3E%3Cpath d='M5 12h10'/%3E%3C/svg%3E"); }
.i-copy { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='11' height='11' rx='2'/%3E%3Cpath d='M5 15V6a2 2 0 0 1 2-2h8'/%3E%3C/svg%3E"); }
.i-file { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3C/svg%3E"); }
.i-check { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8.5 12 2.5 2.5 4.5-5'/%3E%3C/svg%3E"); }
.i-alert { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 4.3 2.6 17.5A2 2 0 0 0 4.3 20.5h15.4a2 2 0 0 0 1.7-3L13.7 4.3a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9.5v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E"); }
.i-info { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5'/%3E%3Cpath d='M12 8h.01'/%3E%3C/svg%3E"); }
.i-x { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 6l12 12'/%3E%3Cpath d='M18 6 6 18'/%3E%3C/svg%3E"); }
.i-plus { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5v14'/%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E"); }
.i-link { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1'/%3E%3Cpath d='M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1'/%3E%3C/svg%3E"); }
.i-lock { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='11' width='14' height='10' rx='2'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E"); }
.i-terminal { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='16' rx='2'/%3E%3Cpath d='m7 9 3 3-3 3'/%3E%3Cpath d='M13 15h4'/%3E%3C/svg%3E"); }
.i-sun { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2.5v2M12 19.5v2M4.6 4.6l1.4 1.4M18 18l1.4 1.4M2.5 12h2M19.5 12h2M4.6 19.4 6 18M18 6l1.4-1.4'/%3E%3C/svg%3E"); }
.i-moon { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 14.5A8 8 0 1 1 9.5 4a6.5 6.5 0 0 0 10.5 10.5z'/%3E%3C/svg%3E"); }
.i-monitor { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='12' rx='2'/%3E%3Cpath d='M8 20h8'/%3E%3Cpath d='M12 16v4'/%3E%3C/svg%3E"); }
.error, .secret .warn { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 4.3 2.6 17.5A2 2 0 0 0 4.3 20.5h15.4a2 2 0 0 0 1.7-3L13.7 4.3a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9.5v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E"); }
.ok { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8.5 12 2.5 2.5 4.5-5'/%3E%3C/svg%3E"); }

/* ---------- top bar (desktop) + tab bar (mobile) ---------- */
.topbar { height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-in { max-width: var(--content-w); height: 100%; margin: 0 auto; padding: 0 var(--space-6); display: flex; align-items: center; gap: var(--space-8); }
.brand { display: inline-flex; align-items: center; gap: var(--space-3); font-weight: var(--weight-bold); color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--text); color: var(--bg); display: grid; place-items: center; }
.tabs { display: flex; gap: var(--space-1); }
.tab { flex: none; white-space: nowrap; height: 40px; padding: 0 var(--space-4); border-radius: var(--radius-sm); display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-muted); }
.tab:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.tab[aria-current=page] { background: var(--surface-sunken); color: var(--text); }
.who { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); color: var(--text-muted); min-width: 0; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14rem; }
.avatar { width: 32px; height: 32px; flex: none; border-radius: var(--radius-full); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: var(--weight-bold); text-transform: uppercase; }
.topbar .error { margin: 0 var(--space-6); }
.tabbar { display: none; }

/* theme picker (auto / light / dark), built by theme.js */
.theme-picker { display: inline-flex; gap: 2px; padding: 2px; background: var(--surface-sunken); border-radius: var(--radius-sm); }
.theme-picker button { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--text-muted); }
.theme-picker button:hover { background: var(--surface-2); color: var(--text); }
.theme-picker button[aria-pressed=true] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.auth-top { position: absolute; top: var(--space-4); right: var(--space-4); }
body { position: relative; }

/* ---------- page ---------- */
.page { max-width: var(--content-w); margin: 0 auto; padding: var(--space-10) var(--space-6) var(--space-12); display: flex; flex-direction: column; gap: var(--space-6); }
.page.mid { max-width: var(--content-w-mid); }
.page-head { display: flex; flex-direction: column; gap: var(--space-2); }
.title { font-size: var(--text-2xl); line-height: var(--leading-tight); font-weight: var(--weight-bold); letter-spacing: -0.01em; }
.lead { color: var(--text-muted); max-width: 64ch; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.upload-grid { display: grid; grid-template-columns: 440px minmax(0, 1fr); gap: var(--space-6); align-items: start; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.card-title, h2.card-title { font-size: var(--text-lg); line-height: var(--leading-tight); font-weight: var(--weight-bold); }

/* ---------- forms ---------- */
form { margin: 0; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
label, .label, legend { font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--text); padding: 0; }
input[type=text], input[type=password], input[type=number], input[type=url], input:not([type]), select { width: 100%; height: var(--control-h); padding: 0 var(--space-3); font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
input[readonly] { background: var(--surface-2); }
input::placeholder { color: var(--text-faint); }
input.mono, .secret input { font-family: var(--font-mono); font-size: var(--text-sm); }
input[aria-invalid=true] { border-color: var(--bad-fg); }
.hint { font-size: var(--text-sm); color: var(--text-muted); }
.hint.bad { color: var(--bad-fg); }
.row { display: flex; gap: var(--space-2); align-items: center; }
.row input { flex: 1; min-width: 0; }
.inline { display: flex; gap: var(--space-3); align-items: flex-end; flex-wrap: wrap; }
.inline > .field { flex: 1 1 12rem; }
.inline > .field.narrow { flex: 0 1 14rem; }

/* drop zone (the whole zone is the <label> of the file input) */
.drop { border: 1.5px dashed var(--border-strong); border-radius: var(--radius-md); background: var(--surface-2); padding: var(--space-8) var(--space-4); display: flex; flex-direction: column; align-items: center; gap: var(--space-2); text-align: center; font-weight: var(--weight-regular); font-size: var(--text-md); cursor: pointer; transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease); }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop:focus-within { border-color: var(--accent); box-shadow: var(--focus-ring); }
.drop-icon { width: 48px; height: 48px; border-radius: var(--radius-full); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.drop .link { color: var(--accent); }
.file-chip { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
.file-chip .item-main { flex: 1; }

/* segmented control: radios built from the #ttl <select> */
.seg { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: var(--space-1); padding: var(--space-1); background: var(--surface-sunken); border-radius: var(--radius-md); }
.seg-i { margin: 0; cursor: pointer; font-weight: var(--weight-medium); }
.seg-i span { height: 36px; border-radius: var(--radius-sm); display: grid; place-items: center; font-size: var(--text-sm); color: var(--text-muted); white-space: nowrap; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.seg-i:hover span { color: var(--text); }
.seg-i input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg-i input:focus-visible + span { box-shadow: var(--focus-ring); }

progress { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 6px; border: 0; border-radius: var(--radius-full); background: var(--surface-sunken); overflow: hidden; color: var(--accent); }
progress::-webkit-progress-bar { background: var(--surface-sunken); }
progress::-webkit-progress-value { background: var(--accent); border-radius: var(--radius-full); transition: width var(--dur) var(--ease); }
progress::-moz-progress-bar { background: var(--accent); border-radius: var(--radius-full); }

/* ---------- buttons ---------- */
button, .btn { height: var(--control-h); padding: 0 var(--space-5); border-radius: var(--radius-sm); border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); font: inherit; font-weight: var(--weight-bold); white-space: nowrap; background: var(--accent); color: var(--on-accent); cursor: pointer; text-decoration: none; transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease); }
button:hover, .btn:hover { background: var(--accent-hover); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: wait; transform: none; }
button.block, .btn.block { width: 100%; }
button.secondary, .btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
button.secondary:hover, .btn.secondary:hover { background: var(--surface-2); }
button.ghost, .btn.ghost { background: transparent; color: var(--text-muted); font-weight: var(--weight-medium); }
button.ghost:hover, .btn.ghost:hover { background: var(--surface-2); color: var(--text); }
button.danger, .btn.danger { background: var(--surface); color: var(--bad-fg); border-color: var(--bad-border); }
button.danger:hover, .btn.danger:hover { background: var(--bad-bg); }
button.small, .btn.small { height: var(--control-h-sm); padding: 0 var(--space-3); font-size: var(--text-sm); }
button.icon { width: var(--control-h); padding: 0; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ---------- feedback ---------- */
.error, .ok { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1px solid; font-size: var(--text-sm); }
.error::before, .ok::before { content: ""; width: 18px; height: 18px; margin-top: 2px; flex: none; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.error { color: var(--bad-fg); background: var(--bad-bg); border-color: var(--bad-border); }
.ok { color: var(--ok-fg); background: var(--ok-bg); border-color: var(--ok-border); }
.secret { border: 1.5px solid var(--secret-border); background: var(--warn-bg); border-radius: var(--radius-md); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.secret .warn { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--weight-bold); color: var(--warn-fg); }
.secret .warn::before { content: ""; width: 20px; height: 20px; flex: none; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.result { border: 1px solid var(--ok-border); background: var(--ok-bg); border-radius: var(--radius-md); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.result-title { display: flex; align-items: center; gap: var(--space-2); font-weight: var(--weight-bold); color: var(--ok-fg); }
.note { display: flex; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--surface-2); font-size: var(--text-sm); color: var(--text-muted); }
.note .i { margin-top: 2px; }

/* ---------- badges ---------- */
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 1px 10px; line-height: 1.4; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-medium); border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); }
.badge.on::before, .badge.off::before, .badge.bad::before, .badge.wait::before { content: ""; width: 6px; height: 6px; flex: none; border-radius: var(--radius-full); background: currentColor; }
.badge.on { color: var(--ok-fg); background: var(--ok-bg); border-color: var(--ok-border); }
.badge.bad { color: var(--bad-fg); background: var(--bad-bg); border-color: var(--bad-border); }
.badge.wait { color: var(--warn-fg); background: var(--warn-bg); border-color: var(--warn-border); }
.badge.admin { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-border); }

/* ---------- lists (history, keys, admin) ---------- */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list > li { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; column-gap: var(--space-4); row-gap: var(--space-1); padding: var(--space-4) 0; border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; padding-top: 0; }
.list > li:last-child { padding-bottom: 0; }
.file-ic { width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--surface-sunken); color: var(--text-muted); display: grid; place-items: center; }
.item-main { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.name { font-weight: var(--weight-bold); overflow-wrap: anywhere; }
.name .hint { font-weight: var(--weight-regular); }
.meta { font-size: var(--text-sm); color: var(--text-muted); overflow-wrap: anywhere; }
.mono { font-family: var(--font-mono); }
li.dim .name { color: var(--text-muted); }
.empty { color: var(--text-muted); }

/* admin: one row per user / key on desktop (name | badges | meta | actions) */
.list.table > li { grid-template-columns: minmax(8rem, 1fr) minmax(0, 1.4fr) 13.5rem auto; column-gap: var(--space-4); }
.list.table.keys-table > li { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.2fr) auto; }
.list.table .actions { justify-content: flex-end; }

/* ---------- help ---------- */
ol.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-4); }
ol.steps li { counter-increment: step; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--space-3); align-items: start; }
ol.steps li::before { content: counter(step); width: 28px; height: 28px; border-radius: var(--radius-full); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: var(--text-sm); font-weight: var(--weight-bold); }
code { font-family: var(--font-mono); font-size: .875em; background: var(--surface-sunken); padding: 1px 6px; border-radius: 4px; overflow-wrap: anywhere; }
textarea.prompt, .pre { display: block; width: 100%; margin: 0; font: var(--text-xs) / 1.6 var(--font-mono); color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4); white-space: pre; overflow: auto; }
textarea.prompt { resize: vertical; min-height: 18rem; }
textarea.prompt:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.pre.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- login / invite ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-6); padding: var(--space-6) var(--space-4); }
.auth .card { width: 100%; max-width: var(--content-w-narrow); }
.auth .title { font-size: var(--text-xl); }

/* ---------- landing ---------- */
.l-sec { max-width: var(--content-w); margin: 0 auto; padding: var(--space-12) var(--space-6); display: flex; flex-direction: column; gap: var(--space-8); }
.l-hero { display: grid; grid-template-columns: minmax(0, 1fr) 480px; gap: var(--space-12); align-items: center; }
.l-hero-text { display: flex; flex-direction: column; gap: var(--space-5); }
.eyebrow { font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--accent); }
.display { font-size: 3rem; line-height: 1.15; font-weight: var(--weight-bold); letter-spacing: -0.02em; }
.h2 { font-size: var(--text-2xl); line-height: var(--leading-tight); font-weight: var(--weight-bold); letter-spacing: -0.01em; }
.lead-lg { font-size: var(--text-lg); color: var(--text-muted); max-width: 40ch; }
.l-visual { box-shadow: var(--shadow-md); pointer-events: none; user-select: none; }
.l-visual .row > span.input { flex: 1; min-width: 0; height: var(--control-h); padding: 0 var(--space-3); display: flex; align-items: center; overflow: hidden; white-space: nowrap; font-family: var(--font-mono); font-size: var(--text-sm); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.l-visual .seg-i span { cursor: default; }
.l-visual .seg-i.on span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-6); }
.fact { display: flex; flex-direction: column; gap: var(--space-2); }
.fact h3 { font-size: var(--text-md); font-weight: var(--weight-bold); }
.fact-ic { width: 40px; height: 40px; flex: none; border-radius: var(--radius-md); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.card-title-row { display: flex; align-items: center; gap: var(--space-3); }
.band { background: var(--text); color: var(--bg); border-radius: var(--radius-lg); padding: var(--space-10) var(--space-8); display: flex; align-items: center; justify-content: space-between; gap: var(--space-6); }
.band .btn { background: var(--bg); color: var(--text); }
.band .btn:hover { background: var(--surface-2); }
.band .hint { color: var(--border-strong); }
.foot { border-top: 1px solid var(--border); }
.foot-in { max-width: var(--content-w); margin: 0 auto; padding: var(--space-6); display: flex; justify-content: space-between; gap: var(--space-4); font-size: var(--text-sm); color: var(--text-faint); }
.l-feature { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--space-10); align-items: start; padding: var(--space-10); border: 1px solid var(--accent-border); border-radius: var(--radius-lg); background: linear-gradient(160deg, var(--accent-soft), var(--surface) 55%); box-shadow: var(--shadow-md); }
.l-feature-text { display: flex; flex-direction: column; gap: var(--space-5); }
.l-feature .eyebrow { display: inline-flex; align-items: center; gap: var(--space-2); }
.l-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.l-points li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--space-3); align-items: start; color: var(--text-muted); }
.l-pt-ic { width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.l-points b { color: var(--text); }
.l-install { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.l-code { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.l-code-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: var(--control-h-sm); }
.l-code-head .label { font-size: var(--text-sm); font-weight: var(--weight-bold); }
.l-code .pre { background: var(--surface); }
.l-asks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.l-asks li { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface); font-size: var(--text-sm); }
.l-bar-actions { margin-left: auto; display: flex; gap: var(--space-2); align-items: center; }

/* ---------- admin settings ---------- */
.settings { display: flex; flex-direction: column; gap: var(--space-4); }
.section-head { display: flex; flex-direction: column; gap: var(--space-1); padding-top: var(--space-4); }
.section-title { font-size: var(--text-xl); line-height: var(--leading-tight); font-weight: var(--weight-bold); }
.settings form { display: flex; flex-direction: column; gap: var(--space-4); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-5); }
.with-unit { display: flex; align-items: center; gap: var(--space-2); }
.with-unit input { flex: 1 1 auto; min-width: 0; }
.unit { flex: none; min-width: 4.5rem; font-size: var(--text-sm); color: var(--text-muted); }
.field-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: var(--control-h-sm); }
.field-foot button { flex: none; }
input[type=number] { font-variant-numeric: tabular-nums; }

/* ---------- file request form (/u/<token>) + agent approval (/approve/<code>) ---------- */
.auth .req-card { max-width: var(--content-w-mid); }
.req-message { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border); }
.req-message-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.req-facts { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-5); }
.req-facts > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.req-facts dt { font-size: var(--text-sm); color: var(--text-muted); }
.req-facts dd { margin: 0; font-weight: var(--weight-medium); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.req-files > li { grid-template-columns: 40px minmax(0, 1fr) auto; }
.req-files progress { margin-top: var(--space-1); }
.req-files > li.req-ok .meta { color: var(--ok-fg); }
.req-files > li.req-bad .meta { color: var(--bad-fg); }
.req-actions button { flex: 1 1 10rem; }

/* ---------- tablet ---------- */
@media (max-width: 1100px) {
  .topbar-in { gap: var(--space-4); }
  .who-name, .who .avatar, .who .badge { display: none; }
  .who .logout-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .who .logout { width: var(--control-h-sm); padding: 0; }
}
@media (max-width: 1000px) {
  .upload-grid, .l-hero, .l-feature { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list.table > li, .list.table.keys-table > li { grid-template-columns: minmax(0, 1fr) auto; }
  .list.table > li > .badges, .list.table > li > .meta { grid-column: 1; }
  .list.table > li > .actions { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
}

/* ---------- phone: menu moves to a bottom tab bar ---------- */
@media (max-width: 860px) {
  body.has-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .topbar { height: 56px; }
  .topbar-in { padding: 0 var(--space-2) 0 var(--space-4); gap: var(--space-3); }
  .tabs, .who-name, .who .badge, .who .avatar { display: none; }
  .who .logout-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .who .logout { width: var(--control-h); padding: 0; }
  .who { gap: var(--space-1); }
  .theme-picker button { width: 40px; height: 40px; }
  .tabbar { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); }
  .m-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: var(--weight-medium); color: var(--text-faint); }
  .m-tab:hover { text-decoration: none; color: var(--text); }
  .m-tab[aria-current=page] { color: var(--accent); }

  .page { padding: var(--space-5) var(--space-4) var(--space-8); gap: var(--space-4); }
  .title { font-size: var(--text-xl); }
  .card { padding: var(--space-4); border-radius: var(--radius-md); }
  .inline > .field, .inline > .field.narrow { flex-basis: 100%; }
  .inline > button { width: 100%; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .settings .actions button { flex: 1 1 auto; }

  .list > li { grid-template-columns: 40px minmax(0, 1fr); align-items: start; }
  .list > li > .actions { grid-column: 1 / -1; padding-top: var(--space-2); }
  .list > li > .actions button { flex: 1 1 auto; }
  .list.table > li, .list.table.keys-table > li { grid-template-columns: minmax(0, 1fr); }
  .list.table > li > .badges, .list.table > li > .meta, .list.table > li > .actions { grid-column: 1; grid-row: auto; }
  .list.table .actions { justify-content: flex-start; }
  .history-list > li > .actions button { width: 100%; }
  .req-facts { grid-template-columns: minmax(0, 1fr); }
  .req-files > li > .actions { grid-column: 1 / -1; }

  .l-sec { padding: var(--space-8) var(--space-4); gap: var(--space-6); }
  .display { font-size: 2.125rem; }
  .h2 { font-size: var(--text-xl); }
  .grid-2, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .l-hero-text .btn { width: 100%; }
  .band { flex-direction: column; align-items: stretch; padding: var(--space-6); }
  .l-feature { padding: var(--space-5); gap: var(--space-6); }
  .foot-in { flex-direction: column; padding: var(--space-5) var(--space-4); }
  .l-bar-actions .ghost { display: none; }
}

/* ---------- small phone: the top bar keeps only the logo (name stays for screen readers) ---------- */
@media (max-width: 420px) {
  .topbar .brand > span:not(.brand-mark) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
