/* KMDC Images. Decisions and reasons are in DESIGN.md. */
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 300 800; font-display: swap; src: url(/ui/fonts/onest-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 300 800; font-display: swap; src: url(/ui/fonts/onest-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Onest Fallback'; src: local('Arial'); size-adjust: 103%; ascent-override: 94%; descent-override: 29%; line-gap-override: 0%; }

@view-transition { navigation: auto; }

:root {
  color-scheme: light;
  --ground: #f8f8fb;
  --surface: #ffffff;
  --sunken: #efeff5;
  --ink: #0a2129;
  --muted: #52616a;
  --line: #e2e3ec;
  --line-strong: #82858f;
  --accent: #5a3fc8;
  --accent-hover: #4a32ab;
  --accent-active: #3e2991;
  --accent-text: #4c34b0;
  --accent-subtle: #f0edfb;
  --accent-line: #cfc6f3;
  --danger: #b3261e;
  --danger-subtle: #fcefee;
  --success: #17703f;

  --font: 'Onest', 'Onest Fallback', 'Nirmala UI', 'Kohinoor Devanagari', 'Noto Sans Devanagari', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --r-control: 8px;
  --r-tile: 6px;
  --r-dialog: 14px;
  --shadow: 0 2px 4px rgb(10 33 41 / .06), 0 12px 32px rgb(10 33 41 / .14);
  --fast: 120ms;
  --base: 200ms;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-drawer: cubic-bezier(.32, .72, 0, 1);
  --side: 264px;
  --row: 190px;
  --gap: 10px;
  --dock: 0px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html:has(> .app) { scroll-padding: 190px 0 48px; }
@media (pointer: fine) { html { overscroll-behavior: none; } }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--surface); color: var(--ink); font: 400 16px/1.5 var(--font); font-synthesis: none; -webkit-font-smoothing: antialiased; }
h1, h2, p, ul, fieldset, legend { margin: 0; padding: 0; }
ul { list-style: none; }
fieldset { border: 0; min-width: 0; }
img { display: block; }
button, input, select { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
a { color: var(--accent-text); text-underline-offset: .2em; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.vh { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.skip { position: fixed; z-index: 90; top: 8px; left: 8px; padding: 10px 16px; border-radius: var(--r-control); background: var(--ink); color: #fff; transform: translateY(-200%); }
.skip:focus { transform: none; }
.noscript { position: fixed; inset: auto 16px 16px; padding: 12px 16px; border-radius: var(--r-control); background: var(--ink); color: #fff; }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 500; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.brand img { width: 66px; height: auto; }
.brand:any-link::after { content: ''; width: 2px; height: 1.15em; margin-left: -7px; background: var(--accent); transform: scaleY(0); transition: transform var(--fast) var(--ease-out); }
a:focus-visible { border-radius: 4px; }
.btn:focus-visible, .nav a:focus-visible { border-radius: var(--r-control); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--r-control); font-size: 15px; font-weight: 550; line-height: 1.2; white-space: nowrap; text-decoration: none; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; transition: background-color var(--fast), border-color var(--fast), color var(--fast), transform var(--fast) var(--ease-out); }
.btn:active, .icon-btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-active); }
.btn-primary.is-danger { background: var(--danger); }
.btn-outline { border-color: var(--accent-line); background: var(--surface); color: var(--accent-text); }
.btn-outline:active, .btn-outline[aria-pressed="true"] { background: var(--accent-subtle); border-color: var(--accent); }
.btn-quiet { color: var(--ink); padding: 0 12px; font-weight: 500; }
.btn-quiet .i { color: var(--muted); }
.btn-quiet:active { background: var(--sunken); }
.btn-quiet.is-danger, .btn-outline.is-danger { color: var(--danger); }
.btn-outline.is-danger { border-color: var(--danger); }
.btn-quiet.is-danger .i { color: inherit; }
.lib-tools .btn-outline:not(.is-danger):not([aria-pressed="true"]) { border-color: var(--line-strong); }
.btn-wide { width: 100%; }
.btn-s { min-height: 40px; padding: 0 14px; font-size: 14px; gap: 6px; }
.btn-s .i { width: 18px; height: 18px; }
.btn[aria-disabled="true"], .btn:disabled { opacity: .55; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: var(--r-control); color: var(--ink); touch-action: manipulation; transition: background-color var(--fast), transform var(--fast) var(--ease-out); }
.icon-btn-s { width: 32px; height: 32px; }
.icon-btn:active { background: var(--sunken); }

/* The motion verb is snap: link halves click together, the arrow lifts. */
.i-snap { overflow: visible; }
.i-snap path { transition: transform var(--fast) var(--ease-out); }
.btn .i, .icon-btn .i { transition: transform var(--fast) var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--accent-hover); }
  .btn-primary.is-danger:hover { background: #8f1d17; }
  .btn-outline:hover { background: var(--accent-subtle); border-color: var(--accent); }
  .btn-quiet:hover, .icon-btn:hover { background: var(--sunken); }
  .btn:hover .i:not(.i-snap) { transform: translateY(-2px); }
  .btn:hover .i-lift:not(.i-snap) { transform: translateY(-3px); }
  .addr-open:hover .i:not(.i-snap) { transform: translate(2px, -2px); }
  #signOut:hover .i:not(.i-snap) { transform: translateX(3px); }
  #download:hover .i:not(.i-snap) { transform: translateY(2px); }
  [data-do="rename"]:hover .i:not(.i-snap) { transform: rotate(-9deg); }
  [data-do="trash"]:hover .i:not(.i-snap), [data-do="forever"]:hover .i:not(.i-snap) { transform: rotate(7deg); }
  [data-do="restore"]:hover .i:not(.i-snap) { transform: translateX(-2px); }
  .icon-btn:hover .i { transform: scale(1.14); }
  .brand:any-link:hover::after { transform: none; }
  .btn-show:hover { text-decoration: underline; text-underline-offset: .25em; text-decoration-thickness: 2px; }
  .gate-foot a:hover { color: var(--accent-text); text-decoration-thickness: 2px; }
  .gate-form .btn-primary:hover::after { transform: none; }
  .i-snap .half-a { transform: translate(-2px, 2px); }
  .i-snap .half-b { transform: translate(2px, -2px); }
  .btn:hover .i-snap path, .btn:focus-visible .i-snap path, .btn.is-copied .i-snap path { transform: none; }
}

/* ---------- shell ---------- */
.topbar { display: none; }
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100dvh; }
.side { position: sticky; top: 0; z-index: 30; display: flex; flex-direction: column; gap: 16px; height: 100dvh; padding: 20px 16px max(16px, var(--safe-b)); border-right: 1px solid var(--line); background: var(--ground); overflow-y: auto; overscroll-behavior: contain; }
.side-head { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 8px; }
.side-close { display: none; }
.side nav { flex: 1; }
.nav { display: grid; gap: 2px; }
.nav-title { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 4px; padding-left: 12px; }
.nav-title h2 { font-size: 14px; font-weight: 500; color: var(--muted); }
.nav-end { margin-top: 20px; }
.nav a { position: relative; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px; border-radius: var(--r-control); font-size: 15px; text-align: left; touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: background-color var(--fast), color var(--fast); }
.nav a .i { color: var(--muted); transition: transform var(--fast) var(--ease-out); }
.nav a span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a b { font-size: 14px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav a:active { background: var(--sunken); }
.nav a[aria-current="page"] { background: var(--accent-subtle); color: var(--accent-text); font-weight: 600; }
.nav a[aria-current="page"] .i, .nav a[aria-current="page"] b { color: var(--accent-text); }
.nav-none { padding: 4px 12px; font-size: 14px; color: var(--muted); }
@media (hover: hover) and (pointer: fine) {
  .nav a:hover { background: var(--sunken); }
  .nav a[aria-current="page"]:hover { background: var(--accent-subtle); }
  .nav a:hover .i { transform: translateX(2px); }
}
.side-foot { display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.side-foot .btn { justify-content: flex-start; }
.meter-label { padding: 0 12px; font-size: 14px; color: var(--muted); }
.meter { height: 6px; margin: 0 12px 4px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; background: var(--ink); transform: scaleX(0); transform-origin: left; transition: transform var(--base) var(--ease-out); }
.meter.is-full i { background: var(--danger); }
main { min-width: 0; }

/* ---------- address bar ---------- */
.address { position: sticky; top: 0; z-index: 20; padding: 20px 32px 12px; border-bottom: 1px solid var(--line); background: var(--surface); container: addr / inline-size; }
.addr-top { display: flex; align-items: center; gap: 20px; }
.addr-thumb { display: none; position: relative; width: 76px; height: 76px; flex: none; border-radius: var(--r-tile); overflow: hidden; background: var(--sunken); }
.addr-thumb.has { display: block; }
.addr-thumb::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgb(10 33 41 / .1); pointer-events: none; }
.addr-thumb img { width: 100%; height: 100%; object-fit: cover; }
.addr-thumb.alpha img { object-fit: contain; padding: 6px; }
.addr-main { flex: 1; min-width: 0; container-type: inline-size; }
.addr-line { --n: 40; position: relative; font-size: clamp(1rem, calc(100cqi / (var(--n) * .56)), 1.75rem); line-height: 1.3; letter-spacing: -.022em; font-weight: 500; overflow-wrap: break-word; view-transition-name: address; }
.addr-text { display: block; }
.addr-sel { display: block; }
.is-trashed .addr-path { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--accent); text-decoration-thickness: .09em; }
.addr-tools .btn-primary { margin: 0 4px 0 12px; }
.addr-host { color: var(--muted); font-weight: 400; }
.addr-path { color: var(--ink); font-weight: 600; }
.addr-sel { position: absolute; inset: 0; clip-path: inset(0 100% 0 0); opacity: 0; pointer-events: none; user-select: none; -webkit-user-select: none; transition: opacity var(--base); }
.addr-sel span { background: var(--accent); color: #fff; }
.addr-sel.on { opacity: 1; clip-path: inset(0 0 0 0); transition: clip-path 260ms var(--ease-out); }
@media (min-width: 901px) {
  .addr-line { display: flex; align-items: flex-end; min-height: 2.275rem; }
  .addr-sel { display: flex; align-items: flex-end; }
  .is-loading .address { min-height: 161px; }
}
.addr-meta { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--muted); }
.addr-meta.is-code { color: var(--ink); }
.addr-actions, .addr-acts { display: flex; align-items: center; gap: 8px; flex: none; }
.addr-actions .btn-primary { min-width: 172px; }
.addr-toggle { display: none; }
.addr-more { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 20px; margin-top: 12px; }
.addr-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.addr-tools { display: flex; flex-wrap: wrap; margin-left: -12px; }
.addr-tools .btn { min-height: 40px; font-size: 14px; }
.caret { display: inline-block; width: 2px; height: 1em; margin-left: 2px; vertical-align: -.14em; background: var(--accent); }
.app .caret { display: none; }
.app .is-empty .caret { display: inline-block; }
@media (prefers-reduced-motion: no-preference) { .caret { animation: blink 1.1s steps(1) infinite; } }
@keyframes blink { 50% { opacity: 0; } }

.seg { display: flex; align-items: center; gap: 10px; }
.seg legend { float: left; font-size: 14px; color: var(--muted); }
.seg-row { display: flex; padding: 3px; border-radius: var(--r-control); background: var(--sunken); }
.seg label { position: relative; display: block; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg span { display: grid; place-items: center; min-height: 32px; padding: 0 11px; border-radius: 6px; font-size: 14px; color: var(--muted); white-space: nowrap; transition: background-color var(--fast), color var(--fast); }
.seg input:checked + span { background: var(--surface); color: var(--accent-text); font-weight: 600; box-shadow: 0 1px 2px rgb(10 33 41 / .14); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (hover: hover) and (pointer: fine) { .seg label:hover input:not(:checked) + span { color: var(--ink); } }

/* ---------- library ---------- */
.library { padding: 20px 32px calc(104px + var(--dock)); }
.lib-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 16px; outline: none; scroll-margin-top: 220px; }
.lib-head h1 { font-size: 20px; line-height: 1.3; font-weight: 600; letter-spacing: -.012em; overflow-wrap: anywhere; }
.count { font-size: 14px; color: var(--muted); }
.lib-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.search { position: relative; }
.search .i { position: absolute; left: 11px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input, .select select, .field input, .field select { height: 40px; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface); font-size: 16px; }
.search input { width: 220px; padding: 0 10px 0 36px; }
.search input::placeholder { color: var(--muted); opacity: 1; }
.select select { padding: 0 34px 0 12px; appearance: none; background: var(--surface) url(/ui/icons/chev.svg) no-repeat right 8px center; }
@media (pointer: fine) { .search input, .select select { font-size: 14px; } }

.wall { display: flex; flex-wrap: wrap; gap: 14px var(--gap); }
.wall::after { content: ''; flex: 1000 1 0; height: 0; }
.tile { --ar: 1.5; position: relative; flex: var(--ar) 1 calc(var(--ar) * var(--row)); min-width: 0; max-width: min(100%, calc(var(--ar) * var(--row) * 2)); }
.tile-pick { position: relative; display: block; width: 100%; aspect-ratio: var(--ar); border-radius: var(--r-tile); background: var(--sunken); overflow: hidden; touch-action: manipulation; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.tile-pick img { width: 100%; height: 100%; object-fit: cover; clip-path: inset(0 round 6px); transition: clip-path var(--fast) var(--ease-out), opacity var(--base); }
.tile-pick::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgb(10 33 41 / .08); pointer-events: none; transition: box-shadow var(--fast); }
.tile.alpha .tile-pick { background: repeating-conic-gradient(#e3e4ec 0 25%, #eeeff4 0 50%) 0 0 / 16px 16px; }
.tile.alpha .tile-pick img { object-fit: scale-down; padding: 8%; }
.tile-foot { display: flex; align-items: center; gap: 6px; min-height: 28px; padding: 2px 2px 0; }
.tile-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.tile-tag { flex: none; font-size: 13px; color: var(--muted); }
.tile-copy { position: absolute; right: 14px; bottom: 42px; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px 0 9px; border-radius: var(--r-control); background: var(--surface); color: var(--accent-text); font-size: 14px; font-weight: 600; box-shadow: 0 1px 2px rgb(10 33 41 / .16), 0 4px 12px rgb(10 33 41 / .16); opacity: 0; pointer-events: none; transform: translateY(4px); transition: opacity var(--fast), transform var(--fast) var(--ease-out); }
.tile-check { position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 44px; height: 44px; opacity: 0; cursor: pointer; transition: opacity var(--fast); }
.tile-check span { display: grid; place-items: center; width: 24px; height: 24px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; color: transparent; box-shadow: 0 0 0 1.5px rgb(255 255 255 / .85); transition: border-color var(--fast), color var(--fast), background-color var(--fast); }
.tile-check .i { width: 16px; height: 16px; stroke-width: 2.6; }
.tile.sel .tile-check, .selecting .tile-check { opacity: 1; }
.tile.sel .tile-check span { background: var(--accent); border-color: var(--accent); color: #fff; }
.tile.act .tile-pick::after, .tile.sel .tile-pick::after { box-shadow: inset 0 0 0 3px var(--accent); }
.tile.act .tile-pick img, .tile.sel .tile-pick img { clip-path: inset(7px round 3px); }
.tile.act .tile-pick, .tile.sel .tile-pick { background-color: var(--accent-subtle); }
.tile-pick:focus-visible { outline-offset: 3px; }
.tile-pick:active img { clip-path: inset(7px round 3px); }
@media (hover: hover) and (pointer: fine) {
  .tile:hover .tile-pick img { clip-path: inset(7px round 3px); }
  .tile:not(.act, .sel):hover .tile-pick::after { box-shadow: inset 0 0 0 2px var(--accent-line); }
  .tile:hover .tile-copy, .tile-copy:focus-visible { opacity: 1; pointer-events: auto; transform: none; }
  .tile:hover .tile-check { opacity: 1; }
  .tile:not(.sel) .tile-check:hover span { border-color: var(--accent); color: var(--accent); }
  .selecting .tile:hover .tile-copy { opacity: 0; pointer-events: none; }
  .tile-copy:hover { background: var(--accent); color: #fff; }
}
.tile-copy:active { background: var(--accent-active); color: #fff; }

.tile.up .tile-pick { cursor: default; }
.tile.up .tile-pick img { opacity: .45; }
.tile .bar { position: absolute; left: 10px; right: 10px; bottom: 10px; height: 6px; border-radius: 3px; background: rgb(10 33 41 / .2); overflow: hidden; }
.tile .bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform var(--base) linear; }
.tile.fail { flex: 1 1 300px; max-width: 100%; }
.tile-error { display: flex; flex-direction: column; justify-content: center; gap: 4px; height: 100%; padding: 12px 16px 6px; border-radius: var(--r-tile); background: var(--danger-subtle); box-shadow: inset 0 0 0 1px rgb(179 38 30 / .3); font-size: 14px; }
.tile-error b { display: flex; gap: 8px; color: var(--danger); font-weight: 600; overflow-wrap: anywhere; }
.tile-error div { display: flex; flex-wrap: wrap; gap: 4px; margin-left: -12px; }
.tile-error .btn { min-height: 36px; font-size: 14px; }

.empty { display: grid; justify-items: start; align-content: center; gap: 12px; min-height: min(52vh, 480px); padding: 32px; border: 2px dashed var(--accent-line); border-radius: var(--r-dialog); background: var(--ground); }
.empty.plain { border: 0; background: none; padding: 16px 0; min-height: 0; }
.empty h2 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem); line-height: 1.15; font-weight: 600; letter-spacing: -.022em; text-wrap: balance; }
.empty p { max-width: 56ch; color: var(--muted); }
.empty .btn { margin-top: 8px; }
.more { height: 1px; }

/* ---------- menus, dialogs, toasts, drop ---------- */
.menu { position: fixed; inset: auto; margin: 0; min-width: 200px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); opacity: 0; transform: scale(.96); transform-origin: top right; transition: opacity var(--fast), transform var(--fast) var(--ease-out), overlay var(--fast) allow-discrete, display var(--fast) allow-discrete; }
.menu:popover-open { opacity: 1; transform: none; transition-duration: var(--base); }
@starting-style { .menu:popover-open { opacity: 0; transform: scale(.96); } }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px; border-radius: 6px; font-size: 15px; text-align: left; }
.menu button .i { color: var(--muted); }
.menu button:active { background: var(--sunken); }
@media (hover: hover) and (pointer: fine) { .menu button:hover { background: var(--sunken); } }

.dialog { width: min(100% - 32px, 440px); padding: 24px; border: 0; border-radius: var(--r-dialog); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); overscroll-behavior: contain; opacity: 0; transform: scale(.96); transition: opacity var(--fast), transform var(--fast) var(--ease-out), overlay var(--fast) allow-discrete, display var(--fast) allow-discrete; }
.dialog[open] { opacity: 1; transform: none; transition-duration: var(--base); }
@starting-style { .dialog[open] { opacity: 0; transform: scale(.96); } }
.dialog::backdrop { background: rgb(10 33 41 / .42); }
.dialog form { display: grid; gap: 12px; }
.dialog h2 { text-wrap: balance; font-size: 20px; line-height: 1.3; font-weight: 600; letter-spacing: -.012em; overflow-wrap: anywhere; }
.dialog #dlgText { color: var(--muted); }
.dialog p:empty, .dialog #dlgBody:empty { display: none; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 15px; font-weight: 550; }
.field .hint { font-size: 14px; color: var(--muted); }
.field input, .field select { width: 100%; height: 48px; padding: 0 14px; }
.field input:focus-visible, .field select:focus-visible, .search input:focus-visible, .select select:focus-visible { outline-offset: 0; border-color: var(--accent); }
.field-error { display: flex; gap: 8px; font-size: 14px; color: var(--danger); font-weight: 500; }
.field-error::before { content: '!'; flex: none; display: grid; place-items: center; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; }
.field input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-subtle); }

.toasts { position: fixed; z-index: 60; left: calc(var(--side) + 32px); bottom: calc(24px + var(--safe-b)); display: grid; gap: 8px; justify-items: start; max-width: min(520px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 4px 16px; min-height: 48px; padding: 4px 8px 4px 16px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 15px; box-shadow: var(--shadow); pointer-events: auto; transition: opacity var(--base), transform 300ms var(--ease-out); }
.toast.only { padding-right: 16px; }
@starting-style { .toast { opacity: 0; transform: translateY(16px); } }
.toast.gone { opacity: 0; transform: translateY(8px); transition-duration: var(--base); }
.toast .btn { min-height: 40px; padding: 0 12px; color: #cdc3ff; font-weight: 600; }
.toast .btn:active { background: rgb(255 255 255 / .16); }
.toast .btn:focus-visible { outline-color: #cdc3ff; }
@media (hover: hover) and (pointer: fine) { .toast .btn:hover { background: rgb(255 255 255 / .12); } }

.drop { position: fixed; z-index: 80; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 48px; background: var(--ground); text-align: center; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity var(--fast), visibility var(--fast); }
.drop::before { content: ''; position: absolute; inset: 16px; border: 3px solid var(--accent); border-radius: 18px; transform: scale(1.02); transition: transform var(--base) var(--ease-out); }
.drop.on { opacity: 1; visibility: visible; }
.drop.on::before { transform: none; }
.drop-line { font-size: clamp(2rem, 7.4vw, 7rem); line-height: 1.12; letter-spacing: -.028em; font-weight: 600; white-space: nowrap; }
.app .drop .caret { display: inline-block; width: .055em; min-width: 3px; height: .86em; margin-left: .07em; vertical-align: -.09em; }
.drop-text { font-size: 20px; color: var(--accent-text); font-weight: 600; }

/* ---------- sign in, setup, 404 ---------- */
.gate { display: grid; grid-template-rows: auto 1fr auto; min-height: 100svh; background: var(--ground); padding: calc(24px + var(--safe-t)) clamp(20px, 5vw, 72px) calc(24px + var(--safe-b)); }
.gate main { display: grid; align-content: center; gap: clamp(28px, 5vh, 56px); padding: 40px 0; container-type: inline-size; }
.gate-line { --em: 8.3; font-size: clamp(1.75rem, calc(100cqi / var(--em)), 14rem); line-height: 1.12; letter-spacing: -.028em; font-weight: 600; margin-left: -.05em; white-space: nowrap; view-transition-name: address; }
.gate[data-page="404"] .gate-line { --em: 11.8; }
.gate .addr-host { color: var(--ink); font-weight: 600; }
.gate .caret { width: .055em; min-width: 3px; height: .86em; margin-left: .07em; vertical-align: -.09em; }
.struck { position: relative; display: inline-block; color: var(--muted); font-weight: 600; }
.struck::after { content: ''; position: absolute; left: -.04em; right: -.04em; top: 54%; height: .07em; background: var(--accent); transform-origin: left; }
@media (prefers-reduced-motion: no-preference) { .struck::after { animation: strike 300ms 250ms var(--ease-out) backwards; } }
@keyframes strike { from { transform: scaleX(0); } }
.gate-form { display: grid; justify-items: start; gap: 16px; width: 100%; max-width: 420px; }
.gate-form .field { width: 100%; }
.gate-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.gate-acts .btn { min-height: 48px; padding: 0 20px; font-size: 16px; }
.gate-lead { max-width: 44ch; font-size: 18px; color: var(--muted); text-wrap: pretty; }
.field-row { position: relative; }
.field-row input { padding-right: 84px; }
.btn-show { position: absolute; right: 4px; top: 4px; min-height: 40px; font-size: 14px; color: var(--accent-text); }
.gate-form .btn-primary { min-height: 48px; padding: 0 18px 0 24px; gap: 4px; font-size: 16px; }
.gate-form .btn-primary::after { content: ''; width: 2px; height: 1.15em; background: currentColor; transform: scaleY(0); transition: transform var(--fast) var(--ease-out); }
.gate-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 24px; font-size: 14px; color: var(--muted); }
.gate-foot a { color: var(--ink); display: inline-flex; align-items: center; min-height: 32px; }
.gate-foot p { display: flex; align-items: center; min-height: 32px; overflow-wrap: anywhere; }

/* ---------- middle widths ---------- */
@media (max-width: 1180px) {
  :root { --side: 232px; --row: 170px; }
  .address { padding-inline: 24px; }
  .library { padding-inline: 24px; }
  .toasts { left: calc(var(--side) + 24px); }
  .search input { width: 180px; }
}
@media (min-width: 901px) {
  @container addr (max-width: 1060px) {
    .addr-tools { margin-left: 0; }
    .addr-tools .btn { width: 40px; padding: 0; font-size: 0; gap: 0; }
  }
  @container addr (max-width: 820px) {
    .addr-top { gap: 14px; }
    .addr-thumb { width: 56px; height: 56px; }
    .addr-actions .btn-primary { min-width: 140px; }
    .addr-open { width: 44px; padding: 0; font-size: 0; gap: 0; }
    .seg legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .addr-opts { gap: 8px 10px; }
    .seg span { padding: 0 9px; }
  }
}
@media (max-height: 760px) and (min-width: 901px) {
  .address { padding-top: 14px; padding-bottom: 8px; }
  .addr-thumb { width: 64px; height: 64px; }
}

/* ---------- phone and small tablet: the address bar becomes a dock under the thumb ---------- */
@media (max-width: 900px) {
  html:has(> .app) { scroll-padding: 72px 0 120px; }
  :root { --row: 98px; --gap: 8px; --dock: calc(96px + var(--safe-b)); }
  .topbar { position: sticky; top: 0; z-index: 25; display: flex; align-items: center; gap: 4px; padding: calc(6px + var(--safe-t)) 16px 6px 6px; border-bottom: 1px solid var(--line); background: var(--ground); }
  .topbar .brand { flex: 1; }
  .shell { display: block; min-height: 0; }
  .side { position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(86vw, 320px); height: auto; padding-top: calc(12px + var(--safe-t)); border: 0; box-shadow: var(--shadow); transform: translateX(-104%); visibility: hidden; transition: transform var(--base) var(--ease-drawer), visibility 0s var(--base); }
  .side.open { transform: none; visibility: visible; transition: transform 300ms var(--ease-drawer), visibility 0s; }
  .side-close { display: inline-grid; margin-right: -8px; }
  .nav a { min-height: 48px; }
  .icon-btn-s { width: 44px; height: 44px; }
  .scrim { position: fixed; inset: 0; z-index: 45; background: rgb(10 33 41 / .42); }
  .library { padding: 16px 16px calc(88px + var(--dock)); }
  .lib-head { scroll-margin-top: 72px; }
  .lib-tools { display: contents; }
  .count { flex: 1; }
  .search { flex: 1 1 52%; }
  .search input { width: 100%; height: 44px; }
  .select { flex: 1 1 34%; }
  .select select { width: 100%; height: 44px; }
  .lib-head::after { content: none; }
  .btn-s { min-height: 44px; }

  .address { position: fixed; inset: auto 0 0; top: auto; z-index: 40; padding: 10px 12px calc(10px + var(--safe-b)); border: 0; border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgb(10 33 41 / .1); max-height: 86dvh; overflow-y: auto; overscroll-behavior: contain; }
  .address.is-empty { display: none; }
  .addr-top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 0 10px; }
  .addr-thumb { width: 44px; height: 44px; }
  .addr-line { font-size: 15px; letter-spacing: -.01em; }
  .address[data-open="false"] .addr-line { line-height: 1.25; }
  .address[data-open="false"] .addr-text, .address[data-open="false"] .addr-sel { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .address[data-open="false"] .addr-host, .address[data-open="false"] .addr-id, .address[data-open="false"] .meta-x { display: none; }
  .addr-meta { font-size: 13px; margin: 0; }
  .addr-actions { display: contents; }
  .addr-actions .btn-primary { min-width: 0; min-height: 48px; padding: 0 14px; }
  .addr-open { display: none; }
  .addr-toggle { display: inline-grid; height: 48px; margin-left: -8px; }
  .addr-toggle .i { transition: transform var(--base) var(--ease-out); }
  .address[data-open="true"] .addr-toggle .i { transform: rotate(180deg); }
  .address[data-open="true"] .addr-top { grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 12px 10px; }
  .address[data-open="true"] .addr-toggle { grid-area: 1 / 3; }
  .address[data-open="true"] .addr-acts { grid-column: 1 / -1; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
  .address[data-open="true"] .addr-meta { white-space: normal; }
  .addr-actions .btn-primary { min-width: 0; }
  .addr-more { display: none; }
  .address[data-open="true"] .addr-more { display: grid; justify-content: stretch; gap: 14px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
  .address[data-open="true"] .addr-open { display: inline-flex; min-height: 48px; }
  .addr-opts { display: grid; gap: 12px; }
  .seg { display: block; }
  .seg legend { float: none; margin-bottom: 6px; }
  .seg-row { display: flex; }
  .seg label { flex: 1; }
  .seg span { min-height: 42px; padding: 0 6px; }
  .addr-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0; }
  .addr-tools .btn { min-height: 48px; justify-content: flex-start; background: var(--ground); font-size: 15px; }
  .toasts { left: 16px; right: 16px; bottom: calc(var(--dock) + 8px); max-width: none; justify-items: stretch; }
  .toast { justify-content: space-between; }
  .tile-copy { display: none; }
  .tile { --a: min(var(--ar), 1.85); flex: var(--a) 1 calc(var(--a) * var(--row)); max-width: min(100%, calc(var(--a) * var(--row) * 1.95)); }
  .tile-pick { aspect-ratio: var(--a); }
}
@media (max-width: 420px) {
  .addr-actions .btn-primary .i { display: none; }
  .gate main { align-content: center; padding: 24px 0 72px; }
}
@media (hover: none) { .tile-copy { display: none; } .tile-check { opacity: 0; pointer-events: none; } .selecting .tile-check { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
  .btn, .icon-btn, .btn .i, .icon-btn .i, .btn .i-snap path, .nav a .i, .tile-copy, .menu, .dialog, .toast, .drop::before, .side, .addr-toggle .i { transform: none; transition-property: opacity, background-color, border-color, color; }
  .tile-pick img { transition: none; }
  .btn:active, .icon-btn:active, .btn:hover .i:not(.i-snap), .btn:hover .i-lift:not(.i-snap), .icon-btn:hover .i, .nav a:hover .i, #signOut:hover .i:not(.i-snap), #download:hover .i:not(.i-snap), [data-do]:hover .i:not(.i-snap) { transform: none; }
  .addr-sel.on { transition: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation-duration: 150ms !important; }
}
@media (prefers-reduced-motion: reduce) and (max-width: 900px) {
  .address[data-open="true"] .addr-toggle .i { transform: rotate(180deg); }
  .side:not(.open) { transform: translateX(-104%); }
}
@media (prefers-reduced-motion: no-preference) { ::view-transition-group(*) { animation-duration: 300ms; animation-timing-function: cubic-bezier(.77, 0, .175, 1); } }
@media (forced-colors: active) { .tile.act .tile-pick, .tile.sel .tile-pick { outline: 3px solid Highlight; } .meter i, .tile .bar i { background: Highlight; } }
