/* ----------------------------------------------------------------- fonts */

/* Inter, self-hosted: 130 KB for the latin subsets, one variable file covering
   400-700. No CDN, so the wall keeps its type with the network unplugged. */
@font-face {
  font-family: 'InterVariable';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/inter-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: 'InterVariable';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/inter-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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ==========================================================================
   Xars — the front door (shelf, gate, not-found)

   Layout only. Colour, type, glass and motion come from app.css's :root
   tokens — nothing here invents a value that the board would disagree with.
   app.css is written for a full-bleed canvas (body { overflow: hidden }), so
   everything that makes this a scrolling document is scoped to .shell, which
   only the shelf has.
   ========================================================================== */

:root {
  /* The reading column. One number, used by the masthead, the shelf and the
     foot, so all three line up. 1040px is a two-to-three card shelf on a
     laptop and never a full-bleed smear on a wide monitor. */
  --col: 1040px;
  --gutter: 26px;
  --tap: 44px;          /* the smallest target a thumb may have on a phone */
}

/* ------------------------------------------------------- document scrolling */

html:has(.shell), body:has(.shell) { height: auto; min-height: 100%; overflow: visible; }
body:has(.shell) { overflow-x: hidden; overflow-y: auto; }

.shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; position: relative; }

/* Black with the wall's fine dot field, so the shelf and the board are visibly
   the same material. Static: one paint, no compositor work. */
/* `[hidden]` is a bare `display: none` in the UA sheet, so any rule that sets a
   display beats it — app.css lost a whole control to `.row { display: flex }`
   exactly this way, and the studio chips did the same trick here. Anything the
   shelf hides by attribute is hidden, whatever else it is. */
[hidden] { display: none !important; }

.shell::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(circle at 50% -10%, rgba(255, 255, 255, .045), transparent 60%),
    radial-gradient(circle, var(--dot) 1.05px, transparent 1.5px),
    linear-gradient(180deg, var(--wall-1), var(--wall-4));
  background-size: 100% 100%, var(--dot-size) var(--dot-size), 100% 100%;
  background-repeat: no-repeat, repeat, no-repeat;
}
.shell::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: var(--grain); opacity: var(--grain-opacity); mix-blend-mode: var(--grain-blend);
}
.shell > * { position: relative; z-index: 1; }

/* ---------------------------------------------------------------- masthead */

.masthead {
  height: 64px; padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--wall-1) 82%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  position: sticky; top: 0; z-index: 20;
}
.masthead__inner {
  max-width: var(--col); margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 12px;
}
.masthead__mark {
  width: 28px; height: 28px; border-radius: 10px; flex: none;
  background: linear-gradient(150deg, var(--rose), var(--amber));
  color: #fff; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  box-shadow: var(--shadow-1);
}
.masthead__title { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.masthead__sub {
  color: var(--ink-3); font-size: 12.5px; font-style: italic;
  font-family: var(--font-display);
  border-left: 1px solid var(--line); padding-left: 14px; margin-left: 4px;
}
.masthead__spacer { flex: 1; }

/* -------------------------------------------------------------------- page */

.wrap { width: 100%; max-width: var(--col); margin: 0 auto; padding: 34px var(--gutter) 56px; }

.intro { margin-bottom: 22px; }
.intro h1 { font-size: 30px; font-weight: 600; letter-spacing: -.015em; margin: 0 0 8px; }
.intro p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.7; max-width: 68ch; }

/* -------------------------------------------------------------------- bar */

.bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bar__field { position: relative; flex: 1 1 240px; min-width: 200px; }
.bar__field svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.bar__field .input { padding-left: 36px; height: 38px; border-radius: var(--r-pill); }
.input--lg { height: 38px; border-radius: var(--r-pill); }
.btn--lg { height: 38px; padding: 0 18px; }

/* A button that only a phone shows: the top row keeps search, "New page" and the
   studio key, and everything else moves behind this. display:none keeps it out
   of the tab order on a desktop, where it is not needed. */
.only-phone { display: none; }

/* ---------------------------------------------------------- tools row */

.tools {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 14px 0 18px; padding: 10px 12px;
  border: 1px solid var(--line-soft); border-radius: var(--r-lg);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.5); backdrop-filter: blur(var(--glass-blur)) saturate(1.5);
}
.tools__group { display: flex; align-items: center; gap: 8px; }
.tools__label { font-family: var(--font-display); font-style: italic; font-size: 12px; color: var(--ink-3); }
.tools__spacer { flex: 1; }
#sort { width: auto; min-width: 168px; border-radius: var(--r-pill); }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 13px; border-radius: var(--r-pill);
  border: 1px solid var(--line); color: var(--ink-2); font-size: 12.5px;
  background: var(--glass-bg);
  transition: color .16s var(--ease), background .16s var(--ease), border-color .16s var(--ease);
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip[aria-pressed="true"] { color: var(--ink); border-color: var(--accent); background: var(--accent-soft); }
.chip__n {
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.chip[aria-pressed="true"] .chip__n { color: var(--accent-hi); }
.chip svg { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ bulk */

.bulk {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  width: 100%; padding-top: 10px; margin-top: 2px;
  border-top: 1px solid var(--line-soft);
}
.bulk[hidden] { display: none; }
.bulk__count { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* The checkbox and its 44px tap area. The visible box is 18px; the label is the
   target, so a thumb never has to hit the box itself. */
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: var(--tap); padding-right: 4px; }
.check input {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; flex: none; margin: 0;
  border: 1.5px solid var(--line-strong); border-radius: 6px;
  background: var(--glass-bg); cursor: pointer;
  display: grid; place-items: center;
}
.check input:checked, .check input:indeterminate { background: var(--accent); border-color: var(--accent); }
.check input:checked::after {
  content: ''; width: 9px; height: 5px; margin-top: -2px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(-45deg);
}
.check input:indeterminate::after { content: ''; width: 9px; height: 2px; background: #fff; border-radius: 1px; }
.check input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.check span { font-size: 12.5px; color: var(--ink-2); }

/* ------------------------------------------------------------------ alert */

/* A refusal from the server has to sit where the person who caused it is
   looking. The board throws toasts; the shelf keeps one message until it is
   answered or dismissed, because the next thing they read is the error. */
.alert {
  display: none; align-items: flex-start; gap: 10px;
  margin: 0 0 16px; padding: 11px 13px;
  border: 1px solid color-mix(in srgb, var(--danger) 44%, transparent);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--ink); font-size: 12.5px; line-height: 1.6;
}
.alert.is-on { display: flex; }
.alert svg { width: 16px; height: 16px; color: var(--danger); flex: none; margin-top: 1px; }
.alert__text { flex: 1; word-break: break-word; }
.alert__x { color: var(--ink-3); display: inline-flex; padding: 6px; margin: -6px -6px -6px 0; }
.alert__x:hover { color: var(--ink); }
.alert__x svg { width: 14px; height: 14px; color: currentColor; }

/* ------------------------------------------------------------------ cards */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 18px; align-items: start; }

.card {
  display: flex; flex-direction: column; text-align: left;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.5); backdrop-filter: blur(var(--glass-blur)) saturate(1.5);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-xl); overflow: hidden;
  box-shadow: var(--shadow-1);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--line); }
.card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-2); }
.card.is-open { transform: none; }

.card__top { position: relative; }
.card__check { position: absolute; top: 4px; left: 4px; z-index: 2; min-height: 40px; }
.card__check span { display: none; }
.card__check input {
  width: 20px; height: 20px;
  background: color-mix(in srgb, var(--wall-1) 62%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

/* The whole of the card that opens the page is one link: a real anchor, so it
   tabs, middle-clicks and previews like one. Everything else on the card is a
   button beside it, never inside it. */
.card__link { display: block; color: inherit; text-decoration: none; }
.card__link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.card__thumb {
  aspect-ratio: 16 / 10; background: var(--surface-2);
  display: grid; place-items: center; overflow: hidden; position: relative;
}
.card__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card__thumb--empty { color: var(--ink-3); }
.card__thumb--empty svg { width: 30px; height: 30px; }
.card__thumb--blank { background: var(--surface-2); color: var(--accent); }
.card__thumb--blank svg { width: 26px; height: 26px; opacity: .6; }
.card__body { padding: 13px 15px 10px; }
.card__name {
  font-family: var(--font-display); font-weight: 600; font-size: 15.5px;
  margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card__link:hover .card__name { color: var(--accent-hi); }
.card__meta { display: flex; align-items: center; gap: 7px; color: var(--ink-3); font-size: 11.5px; flex-wrap: wrap; }
.card__meta .slug { font-family: var(--font-mono); }
.card__badge {
  position: absolute; top: 10px; right: 10px;
  background: rgba(10, 10, 12, .74); color: #fff; font-size: 10.5px;
  padding: 4px 9px; border-radius: 999px; display: flex; align-items: center; gap: 4px;
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.card__badge svg { width: 11px; height: 11px; }
.card__badge--lock { color: var(--amber); }
.card__badge--soft { color: var(--ink-2); }

/* facts: count, weight, when — everything the list already knows, so a shelf of
   twenty pages costs no requests at all. */
.card__facts {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  padding: 0 15px 6px; color: var(--ink-2); font-size: 11.5px;
}
.card__facts b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.card__facts .sepdot { color: var(--ink-3); opacity: .6; }

/* The shareable link, always in reach: one tap on the button beside it. */
.card__linkline { display: flex; align-items: center; gap: 6px; padding: 0 15px 10px; }
.card__linkline code {
  flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--r-sm);
  padding: 5px 8px;
}
.card__actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 0 15px 14px; margin-top: auto; }
.card__actions .grow { flex: 1; }

/* -------------------------------------------------------- the detail panel */

.detail { border-top: 1px solid var(--line-soft); background: color-mix(in srgb, var(--wall-4) 55%, transparent); padding: 12px 15px 14px; }
.detail[hidden] { display: none; }
.detail__row { display: flex; gap: 10px; padding: 4px 0; font-size: 12px; align-items: baseline; }
.detail__k { color: var(--ink-3); flex: none; min-width: 92px; font-family: var(--font-display); font-style: italic; }
.detail__v { color: var(--ink-2); word-break: break-word; min-width: 0; }
.detail__v--mono { font-family: var(--font-mono); font-size: 11px; }
.detail__v .link { font-family: var(--font-mono); font-size: 11px; color: var(--ink); user-select: all; }
.detail__foot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.detail__stats { margin-top: 6px; }
.detail__stats .gate__err { margin-top: 4px; }

.pillrow { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ sessions */

.sess { display: flex; flex-direction: column; }
.sess__row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 2px; border-bottom: 1px solid var(--line-soft);
}
.sess__row:last-child { border-bottom: 0; }
.sess__main { min-width: 0; flex: 1; }
.sess__role { font-size: 12.5px; color: var(--ink); display: flex; align-items: center; gap: 7px; }
.sess__role .tag {
  font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px;
}
.sess__meta { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.sess__id { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); opacity: .7; }

/* --------------------------------------------------------------- dialog bits */

/* app.css's scrim is a warm brown left over from the paper theme; on the one
   black theme it reads as a colour cast. The shelf only. */
.dialog { background: rgba(6, 6, 8, .58); }
.dialog__card--wide { width: min(660px, calc(100vw - 32px)); }
.dialog__body .hint + .hint { margin-top: 8px; }
.dialog__list { margin: 10px 0 0; padding: 0; list-style: none; font-size: 12px; color: var(--ink-2); max-height: 34vh; overflow: auto; }
.dialog__list li { padding: 3px 0; }
.dialog__list .more { color: var(--ink-3); font-style: italic; }
#dlgErr { margin-top: 10px; }
.dialog__foot .btn--danger { border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent); }

/* ------------------------------------------------------------------- foot */

.foot { border-top: 1px solid var(--line-soft); padding: 20px var(--gutter); color: var(--ink-3); font-size: 12px; }
.foot__inner { max-width: var(--col); margin: 0 auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ------------------------------------------------------------ empty states */

.empty-state { text-align: center; padding: 64px 22px; color: var(--ink-3); }
.empty-state[hidden] { display: none; }
.empty-state strong { display: block; font-family: var(--font-display); font-size: 19px; color: var(--ink-2); margin-bottom: 8px; }
.empty-state span { font-size: 13px; }

/* ------------------------------------------------------- unlock / panelbox */

.panelbox {
  background: var(--glass-bg-2); border: 1px solid var(--line-soft);
  border-radius: var(--r-xl); padding: 24px; max-width: 480px; box-shadow: var(--shadow-2);
  -webkit-backdrop-filter: blur(18px) saturate(1.6); backdrop-filter: blur(18px) saturate(1.6);
  margin-bottom: 20px;
}
.panelbox h2 { margin: 0 0 8px; font-size: 19px; }
.panelbox p { margin: 0 0 16px; color: var(--ink-2); font-size: 13.5px; line-height: 1.7; }
.panelbox .field { margin-bottom: 12px; }
#lockPanel[hidden] { display: none; }

/* gate + not found (unchanged: those pages share this sheet) */
.gate {
  min-height: 100vh; display: grid; place-items: center; padding: 26px;
  background:
    radial-gradient(900px 420px at 50% -8%, var(--accent-soft), transparent 72%),
    var(--bg);
  position: relative;
}
.gate::before {
  content: ''; position: fixed; inset: 0; pointer-events: none;
  background-image: var(--grain); opacity: var(--grain-opacity); mix-blend-mode: var(--grain-blend);
}
.gate__card {
  position: relative; width: 410px; max-width: 100%;
  background: var(--glass-bg-2); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-pop);
  padding: 30px 28px;
}
.gate__badge {
  width: 40px; height: 40px; border-radius: 14px;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; margin-bottom: 18px;
}
.gate__badge svg { width: 20px; height: 20px; }
.gate__title { font-size: 21px; font-weight: 600; margin: 0 0 6px; }
.gate__sub { color: var(--ink-2); font-size: 13.5px; margin: 0 0 22px; line-height: 1.7; }
.gate__err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-top: 10px; }
.gate__foot { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line-soft); color: var(--ink-3); font-size: 12px; line-height: 1.6; }

/* ------------------------------------------------------------------ toasts */

/* app.css parks the board's toasts 62px up, clear of the tool rail. The shelf
   has no rail, so they come back down to the corner. */
.toasts { bottom: calc(18px + env(safe-area-inset-bottom)); }

/* ------------------------------------------------------------- focus rings */

/* The board is pointer-first, so app.css only styles focus on inputs. The shelf
   is navigated by keyboard as much as by mouse: every control says where it is. */
.btn:focus-visible, .chip:focus-visible, .card__link:focus-visible,
.card__actions .btn:focus-visible, .detail__foot .btn:focus-visible,
.alert__x:focus-visible, .sess__row .btn:focus-visible, .select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
#pageHeading:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 6px; }

/* ============================================================ small screens */

/* ------------------------------------------------ tablet: two cards, tighter */
@media (max-width: 860px) {
  :root { --gutter: 18px; }
  .masthead__sub { display: none; }
  .wrap { padding-top: 26px; }
  .intro h1 { font-size: 25px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
}

/* --------------------------------------------------------- one column proper */
@media (max-width: 700px) {
  .cards { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------- phone
   Three things change: the top row keeps only what a thumb needs (search,
   New page, the studio key — everything else behind "Filter"); a card's
   actions live behind its Details expander instead of always on screen; and
   every tappable thing is at least --tap tall. */
@media (max-width: 560px) {
  :root { --gutter: 14px; }

  .masthead { height: 56px; }
  .masthead__title { font-size: 15px; }
  .wrap { padding: 20px 14px 40px; }
  .intro h1 { font-size: 22px; }
  .intro p { font-size: 13px; }

  .bar { gap: 8px; }
  .bar__field { flex: 1 1 100%; }
  .bar .btn--lg { flex: 1 1 auto; justify-content: center; }
  .only-phone { display: inline-flex; }

  /* the tools row folds away until asked for */
  .tools { display: none; margin: 12px 0 16px; }
  .tools.is-open { display: flex; }
  .tools__spacer { display: none; }
  .tools__group { flex-wrap: wrap; }
  #sort { min-width: 0; flex: 1; }

  .chip { height: 40px; }
  .check { min-height: 46px; }
  .check span { font-size: 13px; }

  /* every button is a thumb target */
  .btn { height: var(--tap); }
  .btn--sm { height: var(--tap); padding: 0 14px; font-size: 13px; }
  .btn--icon { width: var(--tap); height: var(--tap); }
  .card__actions .btn, .detail__foot .btn { flex: 1 1 auto; justify-content: center; }
  #sort, .chip { height: var(--tap); }

  /* A card's actions only appear once the card is opened — except the button
     that opens them. Hiding the whole row hid the only way in, which left a
     phone with no Rename, Passwords, Archive or Trash at all. */
  .card__actions { padding: 0 14px 12px; }
  .card__actions .btn:not([data-details]) { display: none; }
  .card.is-open .card__actions .btn { display: inline-flex; }
  .card__actions .card__check { min-height: var(--tap); }
  .alert__x { padding: 14px; margin: -14px -14px -14px 2px; }
  .card__body { padding: 12px 14px 8px; }
  .card__facts, .card__linkline { padding-left: 14px; padding-right: 14px; }
  .card__linkline code { font-size: 11px; }
  .card__check { min-height: 46px; padding-right: 8px; top: 2px; left: 2px; }

  .empty-state { padding: 52px 16px; }
  .panelbox { padding: 18px; }
}

@media (max-width: 380px) {
  .card__name { font-size: 15px; }
  .intro h1 { font-size: 20px; }
}

/* Phone: anything a finger has to hit gets a 44px box, even when the mark drawn
   inside it stays small. The card checkboxes and row actions measured 20px at
   390x844, which is a miss-tap rather than a control. */
@media (max-width: 560px) {
  input[type="checkbox"], #cards button, #cards a[href] { min-height: 44px; }
  input[type="checkbox"] { min-width: 44px; }
  /* the walking hint sat flush against the first card */
  [class*="hint"] { margin-block-end: 14px; }
}
