/* ════════════════════════════════════════════════════════════════════
   UI · header, dock, mobile sheet, modal, command palette, assistant,
        guided tour, toast, shared controls
   ════════════════════════════════════════════════════════════════════ */

/* ── Header ────────────────────────────────────────────────────────── */
.header { position: fixed; inset: 0 0 auto 0; z-index: var(--z-header); padding: calc(var(--safe-t) + 12px) var(--gutter) 0; pointer-events: none; }
.header-bar {
  pointer-events: auto; max-width: var(--maxw); margin: 0 auto; min-height: 56px; padding: 6px 8px 6px 12px;
  display: flex; align-items: center; gap: var(--sp-3); border-radius: var(--r-pill);
  background: transparent; border-color: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  transition: background var(--dur-2), border-color var(--dur-2), box-shadow var(--dur-2), backdrop-filter var(--dur-2);
}
.header.is-scrolled .header-bar { background: var(--glass-strong); border-color: var(--border); box-shadow: var(--shadow-1), inset 0 1px 0 var(--hi); -webkit-backdrop-filter: blur(24px) saturate(1.5); backdrop-filter: blur(24px) saturate(1.5); }
.brand { display: inline-flex; align-items: center; gap: .65rem; font-weight: 600; letter-spacing: -.01em; }
.brand-mark { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; font-family: var(--font-display); font-style: italic; font-size: 1.15rem; color: var(--on-accent); background: linear-gradient(135deg, var(--accent), rgb(var(--accent-2-rgb))); }
.brand-name { display: none; }
.avail { display: none; align-items: center; gap: .5rem; padding: .35rem .8rem; border-radius: var(--r-pill); font-size: var(--fs-xs); background: rgba(61, 220, 151, .12); border: 1px solid rgba(61, 220, 151, .35); }
.avail .dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc97; animation: ping 2.4s infinite; }
.avail.is-closed { background: rgba(240, 180, 41, .12); border-color: rgba(240, 180, 41, .4); } .avail.is-closed .dot { background: #f0b429; animation: none; }
[data-theme="light"] .avail { background: rgba(14, 140, 90, .1); border-color: rgba(14, 140, 90, .35); }
@keyframes ping { 70% { box-shadow: 0 0 0 8px rgba(61, 220, 151, 0); } 100% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0); } }
.header-links { display: none; margin-left: auto; gap: .2rem; }
.header-links a { padding: .45rem .8rem; border-radius: var(--r-pill); font-size: var(--fs-sm); color: var(--muted); transition: color var(--dur-1), background var(--dur-1); }
.header-links a:hover, .header-links a[aria-current="true"] { color: var(--text); background: rgba(var(--accent-rgb), .14); }
.header-actions { display: flex; align-items: center; gap: .15rem; margin-left: auto; }
.kbd-hint { display: none; font-family: var(--font-mono); font-size: .7rem; padding: .1rem .4rem; border: 1px solid var(--border-strong); border-radius: 6px; color: var(--muted); margin-left: .35rem; }
.header-cta { display: none; margin-left: .35rem; }
@media (min-width: 560px) { .brand-name { display: inline; } .header-cta { display: inline-flex; } }
@media (min-width: 860px) { .avail { display: inline-flex; } .avail-long { display: none; } }
@media (min-width: 1240px) { .avail-long { display: inline; } }
@media (min-width: 1024px) { .menu-btn { display: none; } .icon-btn[data-action="palette"] { display: inline-flex; gap: .15rem; width: auto; padding: 0 .85rem; border-radius: var(--r-pill); white-space: nowrap; } .kbd-hint { display: inline; } }

/* ── Mobile / tablet sheet ─────────────────────────────────────────── */
.sheet { position: fixed; inset: 0; z-index: calc(var(--z-header) - 1); padding: calc(var(--safe-t) + 78px) var(--gutter) var(--sp-5); background: rgba(8, 12, 24, .5); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); overflow-y: auto; animation: fade var(--dur-2) var(--ease); }
[data-theme="light"] .sheet { background: rgba(245, 244, 240, .55); }
.sheet-inner { display: grid; gap: .25rem; max-width: 520px; margin: 0 auto; padding: .75rem; border-radius: var(--r-lg); }
.sheet-inner a { display: flex; align-items: center; gap: .9rem; padding: .85rem 1rem; border-radius: var(--r-md); font-weight: 500; }
.sheet-inner a:hover, .sheet-inner a[aria-current="true"] { background: rgba(var(--accent-rgb), .14); }
.sheet-tools { display: flex; flex-wrap: wrap; gap: .5rem; padding: .75rem .5rem .25rem; border-top: 1px solid var(--border); margin-top: .5rem; }
@media (min-width: 1024px) { .sheet { display: none !important; } }
@keyframes fade { from { opacity: 0; } }

/* ── Dock (desktop only; never covers content: footer reserves its height) ── */
.dock {
  position: fixed; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); z-index: var(--z-dock);
  display: none; align-items: flex-end; gap: 6px; padding: 8px 10px; border-radius: 22px;
}
@media (min-width: 1024px) { .dock { display: flex; } .footer { padding-bottom: calc(var(--dock-h) + 40px); } }
.dock-item { position: relative; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; color: var(--muted); transform-origin: 50% 100%; transition: transform var(--dur-2) var(--ease), background var(--dur-1), color var(--dur-1); }
.dock-item:hover, .dock-item:focus-visible { color: var(--text); background: rgba(var(--accent-rgb), .16); transform: translateY(-6px) scale(1.22); }
.dock-item[aria-current="true"] { color: var(--accent-ink); }
.dock-item[aria-current="true"]::after { content: ""; position: absolute; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.dock-item .ic { width: 22px; height: 22px; }
.dock-sep { width: 1px; align-self: stretch; margin: 6px 4px; background: var(--border-strong); }
.tip { position: absolute; bottom: calc(100% + 14px); left: 50%; transform: translate(-50%, 4px); padding: .3rem .65rem; border-radius: 8px; font-size: var(--fs-xs); white-space: nowrap; color: var(--text); background: var(--glass-strong); border: 1px solid var(--border); opacity: 0; pointer-events: none; transition: opacity var(--dur-1), transform var(--dur-1); }
.dock-item:hover .tip, .dock-item:focus-visible .tip { opacity: 1; transform: translate(-50%, 0); }
html[data-motion="off"] .dock-item:hover, html[data-motion="off"] .dock-item:focus-visible { transform: none; }

/* ── Shared controls ───────────────────────────────────────────────── */
.chip-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { padding: .45rem .95rem; min-height: 38px; border-radius: var(--r-pill); font-size: var(--fs-sm); color: var(--muted); border: 1px solid var(--border); background: transparent; transition: all var(--dur-1); }
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.is-on, .chip[aria-pressed="true"] { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--glass); }
.seg button { padding: .4rem .9rem; min-height: 36px; border-radius: var(--r-pill); font-size: var(--fs-sm); color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.field-inline { display: flex; align-items: center; gap: .6rem; padding: 0 1rem; min-height: 44px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--glass); color: var(--muted); min-width: min(260px, 100%); }
.field-inline input { flex: 1; min-width: 0; border: 0; background: transparent; outline: 0; color: var(--text); padding: .6rem 0; }
.field-inline:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .25); }
.field-inline input::-webkit-search-cancel-button { filter: grayscale(1); }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.tags li { padding: .2rem .65rem; border-radius: var(--r-pill); font-family: var(--font-mono); font-size: var(--fs-xs); background: rgba(var(--accent-rgb), .12); color: var(--accent-ink); }
.mini-link { display: inline-flex; align-items: center; gap: .35rem; font-size: var(--fs-sm); color: var(--accent-ink); font-weight: 550; padding: .3rem 0; }
.mini-link .ic { width: 15px; height: 15px; }
.mini-link:hover { text-decoration: underline; text-underline-offset: 3px; }
kbd { font-family: var(--font-mono); font-size: .72rem; padding: .1rem .45rem; border: 1px solid var(--border-strong); border-radius: 6px; color: var(--muted); }

/* ── Modal (case study, settings, compare, playground, tour intro) ──── */
.modal { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center; padding: max(var(--sp-4), var(--safe-t)) var(--sp-4) max(var(--sp-4), var(--safe-b)); }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 8, 18, .6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade var(--dur-2) var(--ease); }
[data-theme="light"] .modal-backdrop { background: rgba(30, 36, 60, .35); }
.modal-card { position: relative; width: min(780px, 100%); max-height: min(88vh, 900px); overflow: auto; overscroll-behavior: contain; border-radius: var(--r-xl); padding: clamp(1.25rem, 3vw, 2.2rem); box-shadow: var(--shadow-2), inset 0 1px 0 var(--hi); animation: rise var(--dur-3) var(--ease); }
.modal-card.wide { width: min(1180px, 100%); }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.985); } }
.modal-x { position: absolute; top: 12px; right: 12px; z-index: 2; }
.modal-body h2 { font-size: var(--fs-h2); line-height: 1.05; font-weight: 500; letter-spacing: -.02em; padding-right: 3rem; font-size: clamp(1.8rem, 1.3rem + 2vw, 2.8rem); }
.modal-body h3.mono { font-size: var(--fs-xs); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 1.6rem 0 .45rem; font-weight: 500; }
.modal-body p, .modal-body li { color: var(--muted); }
.modal-body ul.bul { list-style: disc; padding-left: 1.2rem; display: grid; gap: .3rem; }
.modal-img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: var(--r-md); margin: 1.2rem 0; background: var(--bg-2); }
.modal-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.6rem; }
.related { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.related button { text-align: left; padding: .8rem 1rem; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--glass); transition: border-color var(--dur-1), transform var(--dur-2) var(--ease); }
.related button:hover { border-color: var(--accent); transform: translateY(-2px); }
.related strong { display: block; color: var(--text); font-weight: 600; }
.related span { font-size: var(--fs-xs); color: var(--muted); }

/* settings rows */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .9rem 0; border-bottom: 1px solid var(--border); }
.set-row > label, .set-row > span.lbl { font-weight: 500; color: var(--text); }
.set-row small { display: block; color: var(--muted); font-size: var(--fs-xs); font-weight: 400; }
.swatches { display: flex; gap: .55rem; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; box-shadow: inset 0 0 0 2px var(--bg); }
.swatches button[aria-pressed="true"] { border-color: var(--text); }

/* compare table */
.cmp-wrap { overflow-x: auto; margin-top: 1.2rem; border: 1px solid var(--border); border-radius: var(--r-md); }
.cmp-table { width: 100%; border-collapse: collapse; min-width: 560px; font-size: var(--fs-sm); }
.cmp-table th, .cmp-table td { padding: .85rem 1rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.cmp-table thead th { font-weight: 600; color: var(--text); background: rgba(var(--accent-rgb), .08); }
.cmp-table tbody th { width: 150px; font-family: var(--font-mono); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 500; }
.cmp-table td { color: var(--text); }
.shared { color: var(--accent-ink); font-weight: 600; }

/* ── Command palette ───────────────────────────────────────────────── */
.palette { place-items: start center; padding-top: min(14vh, 120px); }
.palette .modal-card { width: min(640px, 100%); padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.pal-input { display: flex; align-items: center; gap: .75rem; padding: 0 1.1rem; border-bottom: 1px solid var(--border); color: var(--muted); }
.pal-input input { flex: 1; min-width: 0; height: 58px; border: 0; background: transparent; outline: 0; color: var(--text); font-size: 1.02rem; }
#pal-list { overflow: auto; max-height: min(52vh, 420px); padding: .5rem; }
.pal-group { padding: .7rem .8rem .3rem; font-size: var(--fs-xs); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-family: var(--font-mono); }
.pal-item { display: flex; align-items: center; gap: .85rem; padding: .7rem .8rem; border-radius: var(--r-sm); cursor: pointer; }
.pal-item .ic { color: var(--muted); }
.pal-item small { margin-left: auto; color: var(--muted); font-size: var(--fs-xs); }
.pal-item[aria-selected="true"] { background: rgba(var(--accent-rgb), .18); } .pal-item[aria-selected="true"] .ic { color: var(--accent-ink); }
.pal-empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.pal-foot { display: flex; gap: 1.2rem; padding: .65rem 1.1rem; border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--muted); }
@media (max-width: 560px) { .pal-foot { display: none; } .palette { padding-top: 12vh; } }

/* ── Assistant ─────────────────────────────────────────────────────── */
.assistant { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + var(--safe-b)); z-index: var(--z-assistant); display: flex; flex-direction: column; align-items: flex-end; gap: .75rem; }
@media (min-width: 1024px) { .assistant { bottom: calc(24px + var(--safe-b)); } }
.as-fab { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; color: var(--accent-ink); transition: transform var(--dur-2) var(--ease); }
.as-fab:hover { transform: translateY(-3px) scale(1.05); }
.as-panel { width: min(380px, calc(100vw - 32px)); max-height: min(560px, calc(100vh - 140px)); display: flex; flex-direction: column; border-radius: var(--r-lg); overflow: hidden; animation: rise var(--dur-3) var(--ease); }
.as-panel header { display: flex; align-items: center; justify-content: space-between; padding: .75rem .75rem .5rem 1.1rem; }
.as-panel header strong { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; }
.as-mode { padding: 0 1.1rem .6rem; font-size: var(--fs-xs); color: var(--muted); }
.as-log { flex: 1; overflow-y: auto; padding: .5rem 1.1rem; display: flex; flex-direction: column; gap: .6rem; min-height: 180px; }
.msg { max-width: 88%; padding: .65rem .9rem; border-radius: 16px; font-size: var(--fs-sm); line-height: 1.5; overflow-wrap: anywhere; }
.msg.bot { align-self: flex-start; background: rgba(var(--accent-rgb), .12); border-bottom-left-radius: 4px; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.msg-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; }
.msg-actions button { padding: .3rem .7rem; border-radius: var(--r-pill); font-size: var(--fs-xs); border: 1px solid var(--border-strong); color: var(--accent-ink); }
.msg-actions button:hover { background: rgba(var(--accent-rgb), .15); }
.as-quick { display: flex; flex-wrap: wrap; gap: .4rem; padding: .25rem 1.1rem .6rem; }
.as-quick button { padding: .3rem .75rem; border-radius: var(--r-pill); font-size: var(--fs-xs); border: 1px solid var(--border); color: var(--muted); }
.as-quick button:hover { color: var(--text); border-color: var(--accent); }
.as-form { display: flex; gap: .5rem; padding: .6rem .75rem .75rem; border-top: 1px solid var(--border); }
.as-form input { flex: 1; min-width: 0; padding: .65rem 1rem; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--glass); outline: 0; }
.as-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .25); }
.dots span { display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; } .dots span:nth-child(2) { animation-delay: .15s; } .dots span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .25; } }
@media (max-width: 1023px) { .assistant { bottom: calc(16px + var(--safe-b)); } }

/* ── Guided tour ───────────────────────────────────────────────────── */
.tour { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: var(--z-tour); width: min(520px, calc(100% - 28px)); padding: 1rem 1.2rem; border-radius: var(--r-lg); animation: rise var(--dur-3) var(--ease); }
@media (min-width: 1024px) { .tour { bottom: calc(var(--dock-h) + 48px); } }
.tour .k { font-size: var(--fs-xs); letter-spacing: .1em; text-transform: uppercase; color: var(--accent-ink); }
.tour p { margin: .35rem 0 .9rem; color: var(--muted); font-size: var(--fs-sm); }
.tour .row { display: flex; gap: .5rem; flex-wrap: wrap; }
.tour-target { outline: 2px solid rgba(var(--accent-rgb), .55); outline-offset: -2px; transition: outline-color var(--dur-3); }
.path-grid { display: grid; gap: .6rem; margin-top: 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.path-grid button { text-align: left; padding: 1rem 1.1rem; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--glass); transition: border-color var(--dur-1), transform var(--dur-2) var(--ease); }
.path-grid button:hover { border-color: var(--accent); transform: translateY(-2px); }
.path-grid strong { display: block; color: var(--text); } .path-grid span { color: var(--muted); font-size: var(--fs-sm); }

/* ── Toast ─────────────────────────────────────────────────────────── */
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 12px); z-index: var(--z-toast); padding: .65rem 1.1rem; border-radius: var(--r-pill); font-size: var(--fs-sm); color: var(--text); background: var(--glass-strong); border: 1px solid var(--border-strong); box-shadow: var(--shadow-1); opacity: 0; pointer-events: none; transition: opacity var(--dur-2), transform var(--dur-2) var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Terminal easter egg ───────────────────────────────────────────── */
.term { font-family: var(--font-mono); font-size: var(--fs-sm); }
.term-log { max-height: 46vh; overflow: auto; display: grid; gap: .2rem; color: var(--muted); white-space: pre-wrap; padding-bottom: .5rem; }
.term-log .cmd { color: var(--text); } .term-log .ok { color: var(--accent-ink); }
.term-in { display: flex; gap: .6rem; align-items: center; border-top: 1px solid var(--border); padding-top: .8rem; }
.term-in span { color: var(--accent-ink); }
.term-in input { flex: 1; border: 0; background: transparent; outline: 0; color: var(--text); font-family: inherit; }
