/* ═══════════════════════════════════════════════════════════════════════════
   CHIKARA Navigator 2.1 — Sovereign Shell
   Single stylesheet · cascade layers
   ═══════════════════════════════════════════════════════════════════════════ */

@layer reset, theme, base, components, shell, views, utilities;

/* ── Reset ──────────────────────────────────────────────────────────────── */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { min-height: 100%; }
  button, input { font: inherit; color: inherit; }
  button { border: 0; background: none; cursor: pointer; }
  img, svg { display: block; max-width: 100%; }
  a { color: inherit; text-decoration: none; }
  :focus { outline: 0; }
  :focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--gold);
    border-radius: 10px;
  }
}

/* ── Theme / materials ──────────────────────────────────────────────────── */
@layer theme {
  :root {
    /* Vellum */
    --vellum: #F4EEDF;
    --vellum-2: #EBE1CE;
    --vellum-3: #DFD0B5;
    --vellum-ink: #1D1917;
    --vellum-muted: #71695E;

    /* Obsidian */
    --obsidian: #0F1010;
    --obsidian-2: #171919;
    --obsidian-3: #242625;
    --obsidian-ink: #F2EDE2;
    --obsidian-muted: #A7A299;

    /* Gold */
    --gold: #C9973A;
    --gold-hi: #F0CF78;
    --gold-deep: #765619;
    --gold-band: linear-gradient(180deg, #E5BE6A 0%, #C9973A 40%, #96702A 100%);

    /* Teal — status / success / connectivity (secondary accent) */
    --teal: #2A7A6E;
    --teal-hi: #3D9B8C;
    --teal-deep: #1A524A;
    --teal-soft: color-mix(in srgb, var(--teal) 16%, transparent);
    --success: var(--teal);
    --online: var(--teal-hi);

    /* Semantic (Vellum default) */
    --surface: var(--vellum);
    --surface-2: var(--vellum-2);
    --surface-3: var(--vellum-3);
    --text: var(--vellum-ink);
    --muted: var(--vellum-muted);
    --line: color-mix(in srgb, var(--text) 12%, transparent);
    --hair: color-mix(in srgb, var(--gold) 28%, transparent);
    --scrim: color-mix(in srgb, #0A0708 48%, transparent);
    --shadow: 0 20px 50px rgba(45, 31, 16, 0.12);

    --radius: 18px;
    --radius-sm: 12px;
    --radius-full: 999px;
    --dock-h: 72px;
    --status-h: calc(48px + env(safe-area-inset-top, 0px));
    --edge: 1.15rem;

    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-ui: 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --dur: 280ms;
  }

  html[data-theme="obsidian"] {
    --surface: var(--obsidian);
    --surface-2: var(--obsidian-2);
    --surface-3: var(--obsidian-3);
    --text: var(--obsidian-ink);
    --muted: var(--obsidian-muted);
    --line: rgba(255, 255, 255, 0.1);
    --hair: rgba(240, 207, 120, 0.28);
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }

  html { color-scheme: light; }
}

/* ── Base ───────────────────────────────────────────────────────────────── */
@layer base {
  @font-face {
    font-family: 'Plus Jakarta Sans';
    src: url('../fonts/plus-jakarta-sans-latin-400-normal.woff2') format('woff2');
    font-weight: 400; font-display: swap;
  }
  @font-face {
    font-family: 'Plus Jakarta Sans';
    src: url('../fonts/plus-jakarta-sans-latin-600-normal.woff2') format('woff2');
    font-weight: 600; font-display: swap;
  }
  @font-face {
    font-family: 'Cormorant Garamond';
    src: url('../fonts/cormorant-garamond-latin-600-normal.woff2') format('woff2');
    font-weight: 600; font-display: swap;
  }
  @font-face {
    font-family: 'JetBrains Mono';
    src: url('../fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2');
    font-weight: 400; font-display: swap;
  }

  html, body {
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
  }
  body {
    min-height: 100dvh;
    overflow-x: hidden;
    padding-top: var(--status-h);
    padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px));
    background-image: radial-gradient(900px 480px at 50% -8%, color-mix(in srgb, var(--gold) 9%, transparent), transparent 70%);
  }

  .sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); border: 0;
  }

  .eyebrow {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--gold);
  }

  .muted { color: var(--muted); font-size: 0.8125rem; }
  .fine-print { font-size: 0.72rem; color: var(--muted); margin-top: 1.5rem; max-width: 42ch; line-height: 1.5; }

  h1, h2 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; }
  h1 { font-size: clamp(1.75rem, 4vw, 2.35rem); letter-spacing: -0.02em; }
  h2 { font-size: 1.25rem; }
}

/* ── Components ─────────────────────────────────────────────────────────── */
@layer components {
  .btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 42px; padding: 0 1.15rem; border-radius: var(--radius-full);
    font-size: 0.8125rem; font-weight: 600; transition: transform 160ms var(--ease-out), filter 160ms;
  }
  .btn:active { transform: scale(0.97); }
  .btn--gold { background: var(--gold-band); color: #1A140C; }
  .btn--gold:hover { filter: brightness(1.06); }
  .btn--ghost { border: 1px solid var(--line); color: var(--text); }
  .btn--ghost:hover { background: var(--surface-2); }
  .btn--sm { min-height: 34px; padding: 0 0.9rem; font-size: 0.75rem; }

  .app-card {
    display: flex; flex-direction: column; align-items: center; gap: 0.55rem;
    padding: 1rem 0.65rem 0.9rem;
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: var(--radius); text-align: center;
    transition: transform 160ms var(--ease-out), background 160ms;
    -webkit-tap-highlight-color: transparent;
  }
  .app-card:active { transform: scale(0.96); }
  .app-card:hover { background: var(--surface-3); }
  .app-card__icon { width: 44px; height: 44px; border-radius: 12px; object-fit: contain; }
  .app-card__name { font-size: 0.8125rem; font-weight: 600; line-height: 1.25; }
  .app-card__tag { font-size: 0.68rem; color: var(--muted); line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

  .app-row {
    display: flex; align-items: center; gap: 0.85rem; width: 100%;
    padding: 0.7rem 0.5rem; border-radius: var(--radius-sm); text-align: left;
    transition: background 160ms;
  }
  .app-row:hover { background: var(--surface-2); }
  .app-row img { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
  .app-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .app-row__body strong { font-size: 0.9rem; }
  .app-row__body span { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .app-row__end { font-size: 0.65rem; letter-spacing: 0.06em; color: var(--muted); flex-shrink: 0; }

  .app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.7rem;
  }

  .featured-row {
    display: flex; gap: 0.75rem; overflow-x: auto; padding-bottom: 0.25rem;
    scroll-snap-type: x mandatory; scrollbar-width: none;
  }
  .featured-row::-webkit-scrollbar { display: none; }
  .featured-row .app-card { flex: 0 0 148px; scroll-snap-align: start; }

  .chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
  .chip {
    padding: 0.45rem 0.85rem; border-radius: var(--radius-full);
    background: var(--surface-2); border: 1px solid var(--line);
    font-size: 0.78rem; font-weight: 500;
  }
  .chip:hover { background: var(--surface-3); }

  .search-bar {
    display: flex; align-items: center; gap: 0.65rem;
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: var(--radius-full); padding: 0.7rem 1rem; margin-bottom: 1.25rem;
  }
  .search-bar input {
    flex: 1; background: transparent; border: none; outline: none;
    font-size: 0.95rem; color: var(--text); min-width: 0;
  }
  .search-bar input::placeholder { color: var(--muted); }
  .search-group-label {
    font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.18em;
    text-transform: uppercase; color: var(--muted); margin: 1rem 0 0.35rem 0.25rem;
  }

  .settings-group { margin-bottom: 1.5rem; }
  .settings-group__label {
    font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.18em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 0.4rem; padding-left: 0.2rem;
  }
  .settings-row {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    width: 100%; padding: 0.9rem 1rem;
    background: var(--surface-2); border: 1px solid var(--line); border-bottom: none;
    text-align: left; transition: background 160ms;
  }
  .settings-row:first-of-type { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
  .settings-row:last-child { border-bottom: 1px solid var(--line); border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
  .settings-row:only-child { border-radius: var(--radius-sm); border-bottom: 1px solid var(--line); }
  .settings-row:hover { background: var(--surface-3); }
  .settings-row__label { font-weight: 500; font-size: 0.9rem; }
  .settings-row__value { font-size: 0.8rem; color: var(--muted); }

  .segmented {
    display: flex; background: var(--surface-2); border: 1px solid var(--line);
    border-radius: var(--radius-full); padding: 3px; gap: 2px;
  }
  .segmented button {
    flex: 1; padding: 0.55rem; border-radius: var(--radius-full);
    font-size: 0.8rem; font-weight: 600; color: var(--muted);
  }
  .segmented button.is-active {
    background: var(--gold-band); color: #1A140C;
  }

  .connect-card {
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1rem; margin-bottom: 0.65rem;
  }
  .connect-card.is-connected { border-color: color-mix(in srgb, var(--gold) 45%, var(--line)); }
  .connect-card__top { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 0.65rem; }
  .connect-card__top strong { display: block; font-size: 0.95rem; }
  .connect-card__top .muted { font-size: 0.75rem; }
  .connect-status { font-size: 0.7rem; font-weight: 600; color: var(--muted); }
  .connect-card.is-connected .connect-status { color: var(--gold); }
  .connect-scopes { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.75rem; }
  .scope {
    font-size: 0.68rem; padding: 0.2rem 0.5rem; border-radius: var(--radius-full);
    background: var(--surface-3); color: var(--muted);
  }
  .scope.is-on { background: color-mix(in srgb, var(--gold) 22%, transparent); color: var(--text); }

  .origin-list { display: flex; flex-direction: column; gap: 0.5rem; }
  .origin-row {
    display: flex; align-items: center; gap: 0.85rem;
    padding: 0.85rem 1rem; background: var(--surface-2);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
  }
  .origin-row.is-muted { opacity: 0.65; }
  .origin-row strong { display: block; font-size: 0.875rem; }
  .origin-badge {
    font-family: var(--font-mono); font-size: 0.58rem; letter-spacing: 0.08em;
    padding: 0.25rem 0.45rem; border-radius: 6px;
    background: var(--surface-3); color: var(--muted); flex-shrink: 0;
  }
  .origin-badge--local { background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--text); }
  .origin-badge--connected { background: color-mix(in srgb, var(--teal) 25%, transparent); color: var(--text); }

  .file-list { display: flex; flex-direction: column; gap: 0.5rem; }
  .file-row {
    position: relative;
    display: flex; align-items: center; gap: 0.85rem;
    padding: 0.85rem 1rem; background: var(--surface-2);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
  }
  .file-row__main { flex: 1; min-width: 0; }
  .file-row__main strong {
    display: block; font-size: 0.875rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .file-row__meta {
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.7rem; color: var(--muted); margin-top: 0.2rem;
  }
  .file-row__end {
    display: flex; flex-direction: column; align-items: flex-end;
    gap: 0.2rem; flex-shrink: 0; margin-right: 1.5rem;
  }
  .file-row__offline {
    font-size: 0.62rem; color: var(--muted);
    padding: 0.15rem 0.4rem; border-radius: 5px; background: var(--surface-3);
  }
  .file-row__offline.is-on {
    color: var(--text); background: color-mix(in srgb, var(--gold) 18%, transparent);
  }
  .file-row__modified { font-size: 0.68rem; color: var(--muted); }
  .file-row__remove {
    position: absolute; top: 0.6rem; right: 0.6rem;
    width: 24px; height: 24px; border-radius: 50%;
    display: grid; place-items: center;
    color: var(--muted); font-size: 0.7rem;
  }
  .file-row__remove:hover { background: var(--surface-3); color: var(--text); }

  .empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); font-size: 0.875rem; }
}

/* ── Shell chrome ───────────────────────────────────────────────────────── */
@layer shell {
  /* Boot */
  #boot {
    position: fixed; inset: 0; z-index: 9000;
    display: grid; place-items: center; background: var(--surface);
    transition: opacity 600ms var(--ease), visibility 600ms;
  }
  #boot.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
  .boot__inner { text-align: center; }
  .boot__mark {
    width: 52px; height: 52px; margin: 0 auto 1.1rem;
    position: relative;
  }
  .boot__mark span, .boot__mark i, .boot__mark b {
    position: absolute; inset: 0; border: 2px solid var(--gold);
    border-radius: 20%; transform: rotate(45deg);
  }
  .boot__mark i { inset: 10px; opacity: 0.7; border-width: 1.5px; }
  .boot__mark b {
    inset: 18px; border: none; background: var(--gold);
    border-radius: 50%; transform: none;
  }
  .boot__word {
    font-family: var(--font-display); font-size: 1.4rem; font-weight: 600;
    letter-spacing: 0.16em;
  }
  .boot__tag {
    font-family: var(--font-mono); font-size: 0.52rem; letter-spacing: 0.28em;
    text-transform: uppercase; color: var(--gold); margin-top: 0.4rem;
  }
  .boot__bar {
    width: 96px; height: 2px; margin: 1.4rem auto 0;
    background: color-mix(in srgb, var(--gold) 18%, transparent);
    border-radius: 2px; overflow: hidden;
  }
  .boot__bar span {
    display: block; height: 100%; width: 0; background: var(--gold);
    animation: bootload 1.2s var(--ease) forwards;
  }
  @keyframes bootload { to { width: 100%; } }

  /* Status bar */
  .statusbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: var(--status-h);
    padding: env(safe-area-inset-top, 0px) var(--edge) 0;
    display: flex; align-items: center; gap: 0.6rem;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(16px) saturate(1.15);
    -webkit-backdrop-filter: blur(16px) saturate(1.15);
    border-bottom: 1px solid var(--line);
  }
  .crest-button {
    width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center; flex-shrink: 0;
  }
  .crest-button img { width: 22px; height: 22px; }
  .crest-button:active { transform: scale(0.92); }
  .statusbar__time {
    font-family: var(--font-mono); font-size: 0.72rem;
    letter-spacing: 0.04em; color: var(--muted); flex-shrink: 0;
  }
  .island {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 0.4rem;
    min-width: 0; font-size: 0.78rem; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .island__dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--gold); flex-shrink: 0;
  }
  .statusbar__right { display: flex; align-items: center; gap: 0.45rem; flex-shrink: 0; }
  .connection {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--online); position: relative;
  }
  .connection.is-offline { background: #C45C5C; }
  .connection i { display: none; }
  .icon-button {
    width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center; position: relative;
  }
  .bell {
    width: 16px; height: 16px; border: 1.5px solid currentColor;
    border-radius: 50% 50% 40% 40%; position: relative;
  }
  .bell::after {
    content: ''; position: absolute; top: -3px; left: 50%; transform: translateX(-50%);
    width: 4px; height: 3px; border: 1.5px solid currentColor; border-bottom: 0;
    border-radius: 4px 4px 0 0;
  }
  #notifyCount {
    position: absolute; top: 2px; right: 2px;
    min-width: 14px; height: 14px; padding: 0 3px;
    background: var(--gold); color: #1A140C;
    font-size: 0.55rem; font-weight: 700; border-radius: 7px;
    display: grid; place-items: center;
  }

  /* Dock */
  .dock {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    height: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px));
    padding: 0 var(--edge) env(safe-area-inset-bottom, 0px);
    display: flex; align-items: flex-start; justify-content: space-around;
    padding-top: 8px;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: blur(18px) saturate(1.15);
    -webkit-backdrop-filter: blur(18px) saturate(1.15);
    border-top: 1px solid var(--line);
  }
  .dock__item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    min-width: 56px; padding: 4px 8px; border-radius: 12px;
    color: var(--muted); transition: color 160ms;
  }
  .dock__item.is-active { color: var(--text); }
  .dock__item small { font-size: 0.62rem; font-weight: 500; }
  .dock-icon {
    width: 24px; height: 24px; border: 1.75px solid currentColor;
    border-radius: 6px; position: relative;
  }
  .dock-home { border-radius: 6px 6px 4px 4px; }
  .dock-home::after {
    content: ''; position: absolute; bottom: -1px; left: 50%; transform: translateX(-50%);
    width: 8px; height: 6px; border: 1.5px solid currentColor; border-top: 0;
  }
  .dock-grid {
    background:
      linear-gradient(currentColor, currentColor) 5px 5px / 5px 5px no-repeat,
      linear-gradient(currentColor, currentColor) 13px 5px / 5px 5px no-repeat,
      linear-gradient(currentColor, currentColor) 5px 13px / 5px 5px no-repeat,
      linear-gradient(currentColor, currentColor) 13px 13px / 5px 5px no-repeat;
    border-color: transparent;
  }
  .dock-search { border-radius: 50%; }
  .dock-search::after {
    content: ''; position: absolute; right: -2px; bottom: -2px;
    width: 7px; height: 1.75px; background: currentColor;
    transform: rotate(45deg); transform-origin: left center;
  }
  .dock-files {
    border-radius: 3px 8px 3px 3px;
  }

  /* ── CHIKARA Halo (floating fast-access nav) ─────────────────────────────
     4-layer structure per CHIKARA Halo Methodology (ref: Bingebox).
     Outer shell = position + breathing glow. Ring = spinning conic-gradient.
     Core = app mark. Petals = built at open-time via getBoundingClientRect. */
  .chikara-halo {
    position: fixed;
    left: 50%; bottom: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px) + 14px);
    top: auto; right: auto;
    transform: translateX(-50%);
    width: var(--halo-size, 75px); height: var(--halo-size, 75px);
    z-index: 350;
    filter:
      drop-shadow(0 4px 16px rgba(0, 0, 0, 0.4))
      drop-shadow(0 0 18px color-mix(in srgb, var(--gold) 30%, transparent));
    animation: haloBreathe 3.6s ease-in-out infinite;
    touch-action: none;
    cursor: grab;
  }
  .chikara-halo:active { cursor: grabbing; }
  .chikara-halo.is-dragging,
  .chikara-halo.menu-open { animation-play-state: paused; }
  @keyframes haloBreathe {
    0%, 100% {
      filter:
        drop-shadow(0 4px 16px rgba(0, 0, 0, 0.4))
        drop-shadow(0 0 12px color-mix(in srgb, var(--gold) 20%, transparent));
    }
    50% {
      filter:
        drop-shadow(0 4px 18px rgba(0, 0, 0, 0.4))
        drop-shadow(0 0 26px color-mix(in srgb, var(--gold) 45%, transparent));
    }
  }

  .halo-ring {
    position: absolute; inset: -2px; border-radius: 50%;
    background: conic-gradient(from 0deg, var(--gold), var(--teal-hi), var(--gold-hi), var(--teal), var(--gold));
    filter: blur(6px); opacity: 0.95;
    animation: haloSpin 3.4s linear infinite;
    pointer-events: none;
  }
  .chikara-halo.menu-open .halo-ring { animation-duration: 0.7s; }
  @keyframes haloSpin { to { transform: rotate(360deg); } }

  .halo-core {
    position: absolute; inset: 3px; border-radius: 50%; overflow: hidden;
    display: grid; place-items: center;
    background: color-mix(in srgb, var(--surface) 88%, var(--gold) 6%);
    border: 1.5px solid rgba(255, 255, 255, 0.28);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
  .halo-core img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .chikara-halo:active .halo-core { transform: scale(0.94); }

  /* Petals + backdrop live outside the shell, built fresh on open */
  .halo-backdrop {
    position: fixed; inset: 0; z-index: 349;
    background: transparent;
    opacity: 0; pointer-events: none;
    transition: opacity 200ms var(--ease);
  }
  .halo-backdrop.is-open { opacity: 1; pointer-events: auto; }

  .halo-petals {
    position: fixed; z-index: 351; pointer-events: none;
  }
  .halo-petals.open { pointer-events: auto; }
  .halo-petal {
    position: absolute; top: 0; left: 0;
    width: var(--petal-size, 60px); height: var(--petal-size, 60px); margin: calc(var(--petal-size, 60px) / -2);
    border-radius: 50%;
    display: grid; place-items: center;
    background:
      linear-gradient(155deg, rgba(255,255,255,0.14), rgba(255,255,255,0.02) 65%),
      color-mix(in srgb, var(--surface) 92%, var(--gold) 8%);
    border: 1px solid var(--hair);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    opacity: 0; transform: translate(0, 0) scale(0.5);
    transition: opacity 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: var(--text);
  }
  .halo-petals.open .halo-petal {
    opacity: 1;
    transform: var(--petal-transform, translate(0,0)) scale(1);
  }
  .halo-petal img { width: calc(var(--petal-size, 60px) * 0.42); height: calc(var(--petal-size, 60px) * 0.42); object-fit: contain; }
  .halo-petal__label {
    position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    margin-top: 5px; font-family: var(--font-ui); font-size: 0.62rem;
    font-weight: 600; color: var(--text); white-space: nowrap;
    padding: 2px 7px; border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    border: 1px solid var(--line);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
    opacity: 0; transition: opacity 200ms var(--ease) 120ms;
  }
  .halo-petals.open .halo-petal__label { opacity: 1; }

  @media (prefers-reduced-motion: reduce) {
    .chikara-halo { animation: none !important; }
    .halo-ring { animation: none !important; opacity: 0.7; }
    .halo-petal { transition-duration: 1ms; }
  }

  /* App main */
  #app {
    min-height: calc(100dvh - var(--status-h) - var(--dock-h));
    outline: none;
  }

  /* Overlay / Control Centre */
  .overlay {
    position: fixed; inset: 0; z-index: 400;
    display: grid; place-items: end center;
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity var(--dur) var(--ease), visibility var(--dur);
  }
  .overlay.is-open { opacity: 1; visibility: visible; pointer-events: auto; }
  .overlay__scrim {
    position: absolute; inset: 0; background: var(--scrim);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  }
  .overlay__panel {
    position: relative; width: min(100%, 420px); max-height: min(88dvh, 680px);
    margin: 0 auto; background: var(--surface);
    border: 1px solid var(--line); border-radius: 24px 24px 0 0;
    padding: 1.25rem 1.15rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%); transition: transform var(--dur) var(--ease-out);
    overflow-y: auto; box-shadow: var(--shadow);
  }
  .overlay.is-open .overlay__panel { transform: none; }

  .control-centre .cc-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 1.25rem;
  }
  .cc-title { font-family: var(--font-display); font-size: 1.5rem; margin-top: 0.15rem; }
  .cc-meta {
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.72rem; color: var(--muted);
  }
  .cc-dot { width: 7px; height: 7px; border-radius: 50%; background: #C45C5C; }
  .cc-dot.is-on { background: #4CAF7A; }
  .cc-time { font-family: var(--font-mono); }
  .cc-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; margin-bottom: 1.1rem;
  }
  .cc-tile {
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: var(--radius-sm); padding: 0.9rem; text-align: left;
  }
  .cc-tile strong { display: block; font-size: 0.9rem; margin-bottom: 0.15rem; }
  .cc-tile span { font-size: 0.7rem; color: var(--muted); }
  .cc-nav {
    display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1.1rem;
  }
  .cc-nav button {
    padding: 0.45rem 0.8rem; border-radius: var(--radius-full);
    background: var(--surface-2); border: 1px solid var(--line);
    font-size: 0.78rem; font-weight: 500;
  }
  .cc-section__label {
    font-family: var(--font-mono); font-size: 0.58rem; letter-spacing: 0.16em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 0.45rem;
  }
  .cc-recent { display: flex; flex-direction: column; gap: 0.25rem; }
  .cc-recent__item {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.5rem; border-radius: 10px; text-align: left; width: 100%;
  }
  .cc-recent__item:hover { background: var(--surface-2); }
  .cc-recent__item img { width: 28px; height: 28px; border-radius: 7px; }
  .cc-recent__item span { font-size: 0.85rem; font-weight: 500; }
  .cc-foot {
    display: flex; justify-content: space-between; margin-top: 1.25rem;
    padding-top: 0.85rem; border-top: 1px solid var(--line);
    font-size: 0.72rem; color: var(--muted);
  }
  .cc-foot button { color: var(--gold); font-weight: 600; }

  /* Toast */
  #toast {
    position: fixed; bottom: calc(var(--dock-h) + 12px + env(safe-area-inset-bottom, 0px));
    left: 50%; transform: translateX(-50%) translateY(12px);
    z-index: 500; max-width: min(92vw, 340px);
    padding: 0.7rem 1.1rem; border-radius: 14px;
    background: var(--surface-2); border: 1px solid var(--line);
    box-shadow: var(--shadow); font-size: 0.8125rem;
    opacity: 0; pointer-events: none;
    transition: opacity 220ms, transform 220ms var(--ease-out);
  }
  #toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: none; } /* a toast over the Halo must never swallow a tap (standards 5.8) */
}

/* ── Views ──────────────────────────────────────────────────────────────── */
@layer views {
  .view {
    padding: 1rem var(--edge) 2rem;
    max-width: 720px; margin: 0 auto;
  }
  .view-header { margin-bottom: 1.5rem; }
  .view-header h1 { margin-top: 0.25rem; }
  .view-header__lead { margin-top: 0.45rem; max-width: 40ch; line-height: 1.5; }

  .view-error {
    display: flex; align-items: center; justify-content: center;
    min-height: 50vh; text-align: center; padding: 2rem var(--edge);
  }
  .view-error__body { max-width: 34ch; }
  .view-error__body h2 {
    font-family: var(--font-display); font-size: 1.35rem; font-weight: 600;
    margin-bottom: 0.5rem;
  }
  .view-error__body p {
    color: var(--muted); font-size: 0.85rem; line-height: 1.55;
    margin-bottom: 1.4rem;
  }
  .view-error__actions {
    display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap;
  }

  .home-kicker {
    display: flex; justify-content: space-between; align-items: baseline;
    font-size: 0.72rem; color: var(--muted); margin-bottom: 1.25rem;
  }
  .home-kicker__date { font-family: var(--font-mono); font-size: 0.68rem; }

  .home-hero { margin-bottom: 2rem; }
  .home-hero__title {
    font-family: var(--font-display); font-size: clamp(2rem, 5vw, 2.75rem);
    font-weight: 600; line-height: 1.08; letter-spacing: -0.025em;
    margin: 0.4rem 0 0.75rem;
  }
  .home-hero__lead {
    font-size: 0.9rem; color: var(--muted); line-height: 1.55;
    max-width: 42ch; margin-bottom: 1.15rem;
  }
  .home-hero__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

  .section { margin-bottom: 1.75rem; }
  .section__head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 0.75rem;
  }
}



/* ── Gold shimmer ─────────────────────────────────────────────────────── */
.gold-shimmer {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #1a1208;
  background: linear-gradient(
    100deg,
    #A77621 0%, #E8C56A 18%, #FFF6D8 34%, #E8C56A 50%,
    #A77621 66%, #C9973A 82%, #E8C56A 100%
  );
  background-size: 280% 100%;
  animation: gold-sweep 8s linear infinite;
}
.gold-shimmer--date {
  font-size: 0.72rem;
  padding: 0.28rem 0.75rem;
  letter-spacing: 0.05em;
}
.gold-shimmer--inline {
  padding: 0;
  border-radius: 0;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}
@keyframes gold-sweep {
  to { background-position: -280% 0; }
}

/* ── Dynamic Island (v1.9 behaviour + Prism aura) ───────────────────── */
.statusbar__center {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
  pointer-events: auto;
}

.dyn-island {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  max-width: min(200px, 48vw);
  min-height: 32px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(20, 12, 8, 0.88);
  color: #FBF5EA;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  overflow: visible;
  white-space: nowrap;
  transition:
    max-width 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    border-radius 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    padding 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
  font-family: var(--font-ui);
}
.dyn-island:hover { transform: scale(1.02); }
.dyn-island:active { transform: scale(0.98); }

/* Prism spectrum aura */
.dyn-island__aura {
  position: absolute;
  inset: -10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #00E676, #FFD600, #FF1744, #00E5FF, var(--teal-hi), #00E676);
  background-size: 220% 100%;
  filter: blur(14px);
  opacity: 0.7;
  z-index: -1;
  animation:
    prism-island-breathe 4.2s ease-in-out infinite,
    prism-island-drift 14s ease-in-out infinite;
  pointer-events: none;
}
.dyn-island__halo {
  position: absolute;
  inset: -14px;
  border-radius: 999px;
  border: 1.5px solid color-mix(in srgb, var(--teal-hi) 40%, transparent);
  z-index: -1;
  animation: prism-island-halo 5s ease-in-out infinite;
  pointer-events: none;
}
.dyn-island.is-dim .dyn-island__aura { opacity: 0.32; animation-duration: 7s, 28s; }
.dyn-island.is-bright .dyn-island__aura { opacity: 0.95; }

.dyn-island__main {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}
.dyn-island__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--teal-hi);
  box-shadow: 0 0 6px color-mix(in srgb, var(--teal-hi) 60%, transparent);
  animation: island-dot-pulse 2.2s ease-in-out infinite;
}
.dyn-island__dot.is-ok {
  background: var(--teal-hi);
}
.dyn-island__dot.is-warn {
  background: var(--gold);
  box-shadow: 0 0 6px color-mix(in srgb, var(--gold) 55%, transparent);
  animation: island-dot-pulse 1.2s ease-in-out infinite;
}
.dyn-island__dot.is-off {
  background: #C45C5C;
  box-shadow: none;
  animation: none;
  opacity: 0.85;
}
.dyn-island__text {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dyn-island__detail {
  display: none;
  margin-top: 0.2rem;
  padding-left: calc(7px + 0.45rem);
  font-size: 0.58rem;
  font-weight: 500;
  color: rgba(251, 245, 234, 0.65);
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dyn-island.is-expanded {
  max-width: min(280px, 72vw);
  border-radius: 16px;
  padding: 8px 14px 10px;
}
.dyn-island.is-expanded .dyn-island__detail {
  display: block;
}

@keyframes prism-island-breathe {
  0%, 100% { opacity: 0.45; transform: scale(0.94); }
  50%      { opacity: 0.9; transform: scale(1.06); }
}
@keyframes prism-island-drift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
@keyframes prism-island-halo {
  0%   { transform: scale(0.88); opacity: 0.55; }
  70%  { transform: scale(1.18); opacity: 0; }
  100% { transform: scale(1.18); opacity: 0; }
}
@keyframes island-dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.65; transform: scale(0.85); }
}

/* Legacy .island flex container (if present) */
.island {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

/* ── Record Crate ─────────────────────────────────────────────────────── */
.crate-stage {
  position: relative;
  overflow-x: clip; /* tiles fanned out past the screen made phones widen the whole page (1.7.3) */
  height: 160px;
  margin: 0 -0.25rem;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
}
.crate-stage.is-dragging { cursor: grabbing; }
.crate-tile {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  will-change: transform, opacity;
}
.crate-tile.is-snap {
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.45s;
}
.crate-face {
  width: 100%;
  height: 100%;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--text) 12%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.75rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.crate-tile.is-focus .crate-face {
  border-color: var(--gold);
  box-shadow: 0 14px 28px color-mix(in srgb, var(--gold) 28%, transparent);
}
.crate-face img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: contain;
}
.crate-face span {
  font-size: 0.68rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── App Detail Sheet (preview-ready) ─────────────────────────────────── */
.detail-sheet .overlay__panel {
  max-height: min(90dvh, 720px);
}
.detail-hero {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-3);
  margin-bottom: 1rem;
  border: 1px solid var(--line);
}
.detail-hero img,
.detail-hero video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.detail-hero__fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
}
.detail-hero__fallback { position: relative; overflow: hidden; }
.detail-hero__fallback img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}
/* Thumbnail art fills the pane: the picture at full pane height, its own edges softened
   into a blurred copy of itself that covers the sides (no new image needed). */
.detail-hero .detail-hero__bg { display: none; }
.detail-hero .detail-hero__fallback.is-thumb .detail-hero__bg {
  display: block; position: absolute; inset: -28px; width: calc(100% + 56px); height: calc(100% + 56px);
  object-fit: cover; filter: blur(24px) saturate(1.1); transform: translateZ(0);
}
.detail-hero__fallback.is-thumb img:not(.detail-hero__bg) {
  position: relative; width: auto; height: 100%; aspect-ratio: 1; object-fit: cover;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}
.detail-hero__fallback.is-vector img:not(.detail-hero__bg) { width: 104px; height: 104px; }
.detail-meta {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}
.detail-meta img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
}
.detail-meta h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 0.15rem;
}
.detail-meta .muted { font-size: 0.78rem; }
.detail-tagline {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gold);
  margin: 0 0 0.5rem;
  line-height: 1.35;
}
.detail-desc {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 1rem;
}
.detail-fit {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.95rem;
  margin-bottom: 1.15rem;
}
.detail-fit__label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.detail-fit__list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.8rem;
  line-height: 1.4;
  padding-left: 1.1rem;
}
.detail-fit__list li { list-style: disc; }
.detail-caps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1.15rem;
}
.detail-caps span {
  font-size: 0.68rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}
.detail-caps span.is-live {
  background: var(--teal-soft);
  border-color: color-mix(in srgb, var(--teal) 35%, transparent);
  color: var(--teal-deep);
}
html[data-theme="obsidian"] .detail-caps span.is-live {
  color: var(--teal-hi);
}
.detail-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Teal connected chips */
.connect-card.is-connected {
  border-color: color-mix(in srgb, var(--teal) 40%, var(--line));
}
.connect-card.is-connected .connect-status {
  color: var(--teal);
}
.scope.is-on {
  background: var(--teal-soft);
  color: var(--text);
}


/* ── Utilities ──────────────────────────────────────────────────────────── */
@layer utilities {
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      transition-duration: 0.01ms !important;
    }
    .gold-shimmer,
    .dyn-island__aura,
    .dyn-island__halo,
    .dyn-island__dot {
      animation: none !important;
    }
    .dyn-island__aura { opacity: 0.55; }
    .gold-shimmer--inline {
      -webkit-text-fill-color: var(--gold);
      color: var(--gold);
      background: none;
    }
  }
  @media (min-width: 720px) {
    .app-grid { grid-template-columns: repeat(auto-fill, minmax(152px, 1fr)); gap: 0.85rem; }
    /* 1.6.0: removed a second centring rule. .view already has max-width 720px and auto margins;
       the extra padding squeezed the content to ~120px on screens wider than 720px. */
  }
}

@layer utilities {
  /* ── Guided Tour (spotlight coach marks) ─────────────────────────────── */
  .tour-overlay {
    position: fixed; inset: 0; z-index: 8000;
    opacity: 0; pointer-events: none;
    transition: opacity 220ms var(--ease);
  }
  .tour-overlay.is-open { opacity: 1; pointer-events: auto; }
  .tour-scrim { position: absolute; inset: 0; }
  .tour-spot {
    position: absolute;
    border-radius: 16px;
    box-shadow: 0 0 0 4000px color-mix(in srgb, #05050A 72%, transparent);
    border: 1.5px solid var(--gold-hi);
    transition: left 260ms var(--ease-out), top 260ms var(--ease-out),
                width 260ms var(--ease-out), height 260ms var(--ease-out);
    pointer-events: none;
  }
  .tour-card {
    position: absolute;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--hair);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem 0.9rem;
    transition: left 260ms var(--ease-out), top 260ms var(--ease-out);
  }
  .tour-card__head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.5rem; margin-bottom: 0.35rem;
  }
  .tour-card__eyebrow {
    font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.16em;
    text-transform: uppercase; color: var(--gold);
  }
  .tour-voice {
    display: grid; place-items: center;
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    background: var(--surface-2); border: 1px solid var(--line);
    color: var(--muted);
    transition: background 160ms var(--ease), color 160ms var(--ease), transform 120ms var(--ease);
  }
  .tour-voice:active { transform: scale(0.92); }
  .tour-voice.is-on {
    background: color-mix(in srgb, var(--gold) 22%, var(--surface-2));
    border-color: var(--gold-hi);
    color: var(--gold);
  }
  .tour-voice__icon {
    width: 15px; height: 15px;
    display: grid; place-items: center;
    position: relative;
  }
  /* Speaker glyph drawn without an external icon asset, per sovereignty
     standard (no third-party icon CDN) — emoji glyph swap on state. */
  .tour-voice__icon::before {
    content: '\1F507'; /* muted speaker */
    font-size: 0.8rem; line-height: 1;
  }
  .tour-voice.is-on .tour-voice__icon::before {
    content: '\1F50A'; /* speaker with sound waves */
  }
  .tour-card__title {
    font-family: var(--font-display); font-size: 1.25rem; font-weight: 600;
    margin-bottom: 0.35rem;
  }
  .tour-card__body {
    font-size: 0.82rem; line-height: 1.45; color: var(--muted);
    margin-bottom: 0.85rem;
  }
  .tour-card__row {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  }
  .tour-card__actions { display: flex; gap: 0.45rem; }
  .tour-skip {
    font-size: 0.75rem; color: var(--muted); font-weight: 500;
    padding: 0.4rem 0.2rem;
  }
  .tour-back, .tour-next {
    padding: 0.45rem 0.9rem; border-radius: var(--radius-full);
    font-size: 0.78rem; font-weight: 600;
  }
  .tour-back { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); }
  .tour-next { background: var(--gold-band); color: #241705; }
  .tour-next:active, .tour-back:active { transform: scale(0.96); }

  @media (prefers-reduced-motion: reduce) {
    .tour-overlay, .tour-spot, .tour-card { transition: none !important; }
  }
}

/* ── Teal state layer ─────────────────────────────────────────────────────
   Role split: gold = identity / structure, teal = STATE ("where you are",
   "connected"). Before this block teal appeared only as two 7-10px dots and
   a faint outline, and the header dot sat at 2.9:1 on Vellum (below the 3:1
   minimum for graphics), so it was effectively invisible.
   Contrast verified against the real surfaces:
     Vellum   → text: teal-deep 7.7:1 · graphics: teal 4.4:1
     Obsidian → text + graphics: teal-hi 5.7:1
   Lives in the last layer so it wins over the shell layer. To tune or
   revert the teal presence, edit or delete this one block. */
@layer utilities {
  :root { --state: var(--teal); --state-text: var(--teal-deep); }
  html[data-theme="obsidian"] { --state: var(--teal-hi); --state-text: var(--teal-hi); }

  /* Dock: the active destination is now teal (text + a small top indicator) */
  .dock__item { position: relative; }
  .dock__item.is-active { color: var(--state-text); }
  .dock__item.is-active::before {
    content: '';
    position: absolute; top: -8px; left: 50%;
    width: 22px; height: 3px; border-radius: 0 0 3px 3px;
    transform: translateX(-50%);
    background: var(--state);
    box-shadow: 0 2px 10px color-mix(in srgb, var(--state) 55%, transparent);
  }

  /* Header connection dot: contrast-safe teal on both themes.
     Offline stays red — re-declared here because a later layer would
     otherwise override the shell layer's .is-offline rule. */
  .connection { background: var(--state); }
  .connection.is-offline { background: #C45C5C; }
}

/* ── 1.5.0 · doors, waitlist ─────────────────────────────────────────── */
.chip-row--scroll {
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  margin-bottom: 1rem; padding-bottom: 0.25rem; -webkit-overflow-scrolling: touch;
}
.chip-row--scroll::-webkit-scrollbar { display: none; }
.chip-row--scroll .chip { flex: 0 0 auto; white-space: nowrap; min-height: 36px; }
.chip.is-active {
  background: var(--surface-3); border-color: var(--gold); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--gold);
}
.section__note { margin: -0.4rem 0 0.75rem; font-size: 0.78rem; }
.app-card { position: relative; }
.app-card.is-soon { opacity: 0.88; border-style: dashed; }
.badge-soon {
  position: absolute; top: 0.4rem; right: 0.4rem;
  font-family: var(--font-mono); font-size: 0.56rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.12rem 0.4rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: var(--surface-1, transparent);
}
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

/* ── 1.6.0 · lion logo in shell, widget board ─────────────────────────── */
@layer utilities {
  /* Boot: the lion medallion inside a slowly turning gold ring (motion is
     removed by the reduced-motion rule above). */
  .boot__mark { width: 84px; height: 84px; margin-bottom: 1.2rem; }
  .boot__mark span {
    inset: -5px; border: 2px solid transparent; border-radius: 50%; transform: none;
    background: conic-gradient(from 0deg, var(--gold), transparent 30%, var(--teal-hi) 55%, transparent 80%, var(--gold)) border-box;
    -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude;
    animation: bootring 2.4s linear infinite;
  }
  .boot__mark img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; box-shadow: 0 8px 24px color-mix(in srgb, var(--gold) 30%, transparent); }
  @keyframes bootring { to { transform: rotate(360deg); } }

  /* Header crest: lion medallion with a fine gold ring */
  .crest-button img {
    width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
    box-shadow: 0 0 0 1.5px var(--gold), 0 2px 8px color-mix(in srgb, var(--gold) 35%, transparent);
  }

  /* Widget board */
  .board-actions { display: inline-flex; gap: 0.4rem; }
  .board { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; }
  .widget { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem 0.9rem 0.95rem; min-width: 0; display: flex; flex-direction: column; gap: 0.55rem; }
  .widget--s { grid-column: span 1; }
  .widget--m { grid-column: span 2; }
  @media (max-width: 340px) { .widget--s { grid-column: span 2; } }
  .board.is-editing .widget { border-style: dashed; border-color: var(--hair); }
  .widget__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem; }
  .widget__head h3 { font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); font-weight: 500; }
  .widget__tools { display: flex; flex-wrap: wrap; gap: 0.3rem; }
  .widget__tools button { min-height: 32px; min-width: 32px; padding: 0 0.55rem; border: 1px solid var(--line); border-radius: 999px; font-size: 0.7rem; font-weight: 600; background: var(--surface); }
  .widget__tools button:disabled { opacity: 0.35; }
  .widget__tools button[data-rm] { color: #A33; }
  .board-empty { padding: 0.5rem 0 0; }
  .w-big { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; line-height: 1.15; }
  .w-big.is-ok { color: var(--state-text); }
  .w-note { font-size: 0.72rem; color: var(--muted); line-height: 1.4; }
  .w-list { list-style: none; display: grid; gap: 0.3rem; font-size: 0.78rem; }
  .w-list li { display: flex; gap: 0.45rem; align-items: baseline; color: var(--muted); }
  .w-list li.is-ok { color: var(--text); }
  .w-list li i { font-style: normal; width: 1em; color: var(--muted); }
  .w-list li.is-ok i { color: var(--state); }
  .w-stats { display: flex; gap: 1.1rem; }
  .w-stats b { display: block; font-family: var(--font-display); font-size: 1.7rem; line-height: 1; }
  .w-stats span { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
  .widget .btn--sm { align-self: flex-start; }
  .w-tasks { list-style: none; display: grid; gap: 0.15rem; }
  .w-tasks li { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; min-height: 40px; }
  .w-tasks label { display: flex; align-items: center; gap: 0.6rem; flex: 1; min-width: 0; font-size: 0.85rem; }
  .w-tasks input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--teal); flex-shrink: 0; }
  .w-tasks li.is-done span { text-decoration: line-through; color: var(--muted); }
  .w-x { width: 36px; height: 36px; font-size: 1.2rem; color: var(--muted); border-radius: 50%; }
  .w-add { display: flex; gap: 0.5rem; }
  .w-add input, .w-notes, .w-conv input { width: 100%; min-height: 40px; padding: 0.45rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 0.85rem; }
  .w-notes { resize: vertical; line-height: 1.5; min-height: 110px; }
  .w-conv { display: grid; grid-template-columns: 1fr 1fr auto 1fr; gap: 0.5rem; align-items: end; }
  .w-conv label { display: grid; gap: 0.25rem; font-size: 0.66rem; color: var(--muted); }
  .w-conv__rate { grid-column: 1 / -1; }
  .w-conv > label:first-child { grid-column: 1 / -1; }
  .w-swap { min-height: 40px; width: 40px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); }
  .gallery { display: grid; gap: 0.6rem; margin-top: 1rem; }
  .gallery__item { text-align: left; padding: 0.8rem 0.9rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); display: grid; gap: 0.2rem; }
  .gallery__item strong { font-size: 0.9rem; }
  .gallery__item span { font-size: 0.75rem; color: var(--muted); line-height: 1.4; }
  .gallery__item:hover { background: var(--surface-3); }
}


/* Halo size stepper in the logo menu (standards 5.2.1): 26 px look, 44 px hit area. */
.halo-size-ctl { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.2rem; }
.halo-size-ctl__label { flex: 1; font-size: 0.85rem; }
.halo-size-ctl button { position: relative; width: 26px; height: 26px; padding: 0; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2, transparent); color: var(--text); font-family: var(--font-mono); font-size: 0.9rem; display: flex; align-items: center; justify-content: center; }
.halo-size-ctl button::after { content: ''; position: absolute; inset: -9px; }
.halo-size-ctl button[disabled] { opacity: .4; }
.halo-size-val { font-family: var(--font-mono); font-size: 0.78rem; min-width: 2.2rem; text-align: center; }


/* ── 1.8.0 Inbox and saved-item search ───────────────────────────────────── */
.dock-inbox { border-radius: 4px 4px 7px 7px; }
.dock-inbox::after { content: ''; position: absolute; left: 5px; right: 5px; top: 9px; height: 1.75px; background: currentColor; box-shadow: 0 5px 0 currentColor; }
.inbox-add { display: grid; gap: .6rem; margin-top: 1rem; }
.inbox-add textarea { width: 100%; min-height: 84px; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: inherit; font-size: .9rem; line-height: 1.5; resize: vertical; }
.inbox-add__row { display: flex; justify-content: space-between; gap: .6rem; align-items: center; }
.inbox-file { cursor: pointer; display: inline-flex; align-items: center; }
.inbox-list { display: grid; gap: .5rem; margin-top: 1rem; }
.inbox-row { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); overflow: hidden; }
.inbox-row__head { width: 100%; display: flex; align-items: center; gap: .65rem; padding: .7rem .8rem; text-align: left; min-height: 56px; }
.inbox-row__main { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.inbox-row__main strong { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-row__main span { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-row__when { font-size: .65rem; color: var(--muted); flex-shrink: 0; text-align: right; }
.inbox-row__body { padding: 0 .8rem .8rem; display: grid; gap: .6rem; }
.inbox-row__body[hidden] { display: none; }
.inbox-text { white-space: pre-wrap; word-break: break-word; font: inherit; font-size: .85rem; line-height: 1.55; margin: 0; max-height: 40vh; overflow: auto; }
.inbox-img { max-width: 100%; max-height: 40vh; border-radius: var(--radius-sm); object-fit: contain; }
.inbox-row__body a { word-break: break-all; color: var(--state-text); }
.inbox-actions { display: flex; flex-wrap: wrap; gap: .5rem; }


/* ── 1.9.0 Customise Home and Lite graphics ─────────────────────────────── */
.cu-list { display: grid; gap: .45rem; margin: .5rem 0 .8rem; }
.cu-row { display: flex; align-items: center; gap: .65rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); min-height: 56px; }
.cu-row.is-off { opacity: .72; }
.cu-row__icon { width: 28px; height: 28px; border-radius: 7px; object-fit: cover; flex-shrink: 0; }
.cu-row__main { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.cu-row__main strong { font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cu-row__main span { font-size: .7rem; color: var(--muted); }
.cu-sep { font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: .5rem 0 .1rem; }
.cu-switch { position: relative; width: 46px; height: 30px; flex-shrink: 0; border-radius: 999px; background: var(--line); border: 1px solid var(--line); transition: background var(--dur, 160ms); }
.cu-switch i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform 160ms; }
.cu-switch[aria-checked="true"] { background: var(--teal); }
.cu-switch[aria-checked="true"] i { transform: translateX(16px); }
.cu-move { display: flex; gap: .25rem; flex-shrink: 0; }
.cu-move button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; display: grid; place-items: center; color: var(--text); }
.cu-move button:disabled { opacity: .3; cursor: default; }
.settings-group .btn[disabled] { opacity: .4; pointer-events: none; }

/* Lite graphics: set by js/core/graphics.js on <html data-gfx="lite">.
   Off: looping glows and floats, the date shimmer, island halo, backdrop blur, grain (gamazine.css).
   Kept: spinners (a real wait), all content, all gestures. */
html[data-gfx="lite"] .gframe::after,
html[data-gfx="lite"] .crate-tile.is-focus .gframe,
html[data-gfx="lite"] #boot .boot__logo,
html[data-gfx="lite"] .chikara-halo,
html[data-gfx="lite"] .halo-ring,
html[data-gfx="lite"] .gold-shimmer,
html[data-gfx="lite"] .dyn-island__aura,
html[data-gfx="lite"] .dyn-island__halo,
html[data-gfx="lite"] .dyn-island__dot,
html[data-gfx="lite"] .boot__mark span { animation: none !important; }
html[data-gfx="lite"] .gframe::after { opacity: 0; }
html[data-gfx="lite"] * { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }

/* ── 1.10.0: scam check panel, file viewer ("Open"), Files Open button ─────── */
.scam { display: grid; gap: .35rem; padding: .7rem .8rem; border-radius: var(--radius-sm); border: 1px solid var(--line); border-left-width: 4px; background: var(--surface-3); font-size: .8rem; line-height: 1.45; }
.scam strong { font-size: .84rem; }
.scam ul { margin: 0; padding-left: 1.1rem; display: grid; gap: .2rem; }
.scam small { font-size: .68rem; color: var(--muted); }
.scam--bad { border-left-color: #B3261E; background: color-mix(in srgb, #B3261E 9%, var(--surface-2)); }
.scam--bad strong { color: #8C1D18; }
.scam--warn { border-left-color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, var(--surface-2)); }
.scam--calm { border-left-color: var(--teal); }
.scam-badge { display: inline-block; margin-right: .35rem; padding: .05rem .35rem; border-radius: 5px; font-size: .58rem; font-weight: 700; letter-spacing: .06em; color: #fff; background: #B3261E; }
.scam-link { margin: 0; font-size: .8rem; word-break: break-all; color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.file-row__open { min-height: 36px; margin-top: .15rem; }
.open-sheet .overlay__panel { display: grid; gap: .75rem; max-height: min(92dvh, 760px); }
.open-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.open-title { min-width: 0; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.open-body { display: grid; gap: .5rem; min-width: 0; }
.open-media { width: 100%; border-radius: var(--radius-sm); background: var(--surface-3); }
.open-media--video { max-height: 52dvh; background: #000; }
.open-media--img { max-height: 52dvh; object-fit: contain; }
.open-pdf { width: 100%; height: 56dvh; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.open-text { white-space: pre-wrap; word-break: break-word; font: inherit; font-size: .82rem; line-height: 1.55; margin: 0; max-height: 52dvh; overflow: auto; padding: .7rem .8rem; border-radius: var(--radius-sm); background: var(--surface-3); }
.open-suggest { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .72rem; color: var(--muted); }
.open-suggest__app { padding: .15rem .55rem; border-radius: var(--radius-full); background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--text); }
.open-sheet .btn--sm, .inbox-actions .btn--sm { min-height: 44px; }
@media (prefers-reduced-motion: reduce) { .open-sheet .overlay__panel { transition: none; } }
