/* svc-mobremote styles. Owner: ui. Dark theme only (SPEC §8). 8 px grid, glass bars, 150–200 ms transitions. */

/* ---------------------------------------------------------------------------------------------------- tokens */
:root {
  --bg: #0b0d10; --bar: rgba(20, 22, 26, .86); --fg: #e7e9ee; --accent: #4da3ff; --warn: #ffb020; --err: #ff5a5f;
  --ok: #3ccf8e;
  --fg-2: rgba(231, 233, 238, .70); --fg-3: rgba(231, 233, 238, .58); --fg-4: rgba(231, 233, 238, .28);
  --s1: #111419; --s2: #171b21; --s3: #1f242c; --s4: #2a303a;
  --line: rgba(255, 255, 255, .07); --line-2: rgba(255, 255, 255, .12); --line-3: rgba(255, 255, 255, .18);
  --accent-soft: rgba(77, 163, 255, .14); --accent-line: rgba(77, 163, 255, .55); --accent-ink: #06121f;
  --warn-soft: rgba(255, 176, 32, .14); --err-soft: rgba(255, 90, 95, .14); --ok-soft: rgba(60, 207, 142, .14);
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px;
  --t-fast: 150ms; --t: 200ms; --ease: cubic-bezier(.2, .8, .2, 1); --ease-out: cubic-bezier(.16, 1, .3, 1);
  --shadow: 0 8px 32px rgba(0, 0, 0, .45), 0 1px 0 rgba(255, 255, 255, .04) inset;
  --blur: blur(14px) saturate(150%);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR",
    "Noto Sans CJK KR", Roboto, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, monospace;
  --kb: 0px; --vvh: 100vh;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --top-h: 52px; --keybar-h: 52px; --toolbar-h: 60px; --rail-w: 112px;
  color-scheme: dark;
}

/* ---------------------------------------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; background: var(--bg); color: var(--fg);
  font: 400 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; word-break: keep-all; overflow-wrap: break-word; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .45; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.ic { display: block; flex: none; }
.ic .fill { fill: currentColor; stroke: none; opacity: .9; }
.mono { font-family: var(--mono); }
.muted { color: var(--fg-3); }
.copy-buffer { position: fixed; left: -9999px; top: 0; opacity: 0; }

#kbd { position: fixed; left: 0; top: 0; width: 2px; height: 2px; opacity: 0; pointer-events: none; resize: none; border: 0;
  padding: 0; font-size: 16px; color: transparent; background: transparent; caret-color: transparent; }

#app, #app button, #sheets button, #toasts { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

/* ---------------------------------------------------------------------------------------------------- app grid (portrait) */
#app { position: fixed; left: 0; right: 0; top: 0; height: calc(100% - var(--kb)); display: grid;
  grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top" "stage" "bottom"; background: var(--bg); overflow: hidden; }

/* top bar */
#topbar { grid-area: top; position: relative; z-index: 20; display: flex; align-items: center; gap: 8px;
  min-height: calc(var(--top-h) + var(--sat));
  padding: calc(var(--sat) + 8px) calc(var(--sar) + 8px) 8px calc(var(--sal) + 8px);
  background: linear-gradient(to bottom, rgba(11, 13, 16, .96), rgba(11, 13, 16, .86)); border-bottom: 1px solid var(--line); }
#badges { position: absolute; left: calc(var(--sal) + 8px); right: calc(var(--sar) + 120px); top: calc(100% + 8px); display: flex; flex-wrap: wrap;
  gap: 6px; align-items: center; pointer-events: none; }
#badges > * { pointer-events: auto; }
#pill { margin-right: auto; }
#btn-sound, #btn-find, #btn-menu, .icon-btn { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 999px;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--line); color: var(--fg);
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), border-color var(--t-fast); }
.icon-btn.sm { width: 32px; height: 32px; }
/* 44 px touch targets (SPEC §8) without growing the visuals or the top bar: invisible hit-area extension */
#btn-sound, #btn-find, #btn-menu, .icon-btn { position: relative; }
#btn-sound::after, #btn-find::after, #btn-menu::after, .icon-btn::after { content: ""; position: absolute; inset: -2px; border-radius: inherit; }
.icon-btn.sm::after { inset: -6px; }
#btn-sound.pressed, #btn-find.pressed, #btn-menu.pressed, .icon-btn.pressed { background: rgba(255, 255, 255, .12); transform: scale(.94); }
.icon-btn.spin .ic { animation: spin .6s linear infinite; }
/* speaker button (only with pref audio "on"): accent while sound plays; the badges make room for the third button */
#btn-sound.on { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.has-sound #badges { right: calc(var(--sar) + 168px); }

/* status pill */
#pill { flex: 0 1 auto; min-width: 0; height: 36px; display: inline-flex; align-items: center; gap: 8px; padding: 0 14px 0 12px;
  border-radius: 999px; background: rgba(255, 255, 255, .05); border: 1px solid var(--line); color: var(--fg);
  font-size: 13px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast); }
#pill.pressed, #pill[aria-expanded="true"] { background: rgba(255, 255, 255, .10); border-color: var(--line-2); }
.p-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--fg-4); box-shadow: 0 0 0 3px rgba(255, 255, 255, .05);
  transition: background var(--t) var(--ease), box-shadow var(--t); }
#pill[data-level="good"] .p-dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
#pill[data-level="warn"] .p-dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
#pill[data-level="bad"] .p-dot { background: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
#pill[data-level="wait"] .p-dot { background: var(--accent); animation: pulse 1.2s var(--ease) infinite; }
.p-host { font-weight: 700; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; max-width: 96px; }
.p-stats { display: inline-flex; align-items: center; gap: 6px; color: var(--fg-2); font-weight: 600; }
.p-v small { font-size: 10.5px; font-weight: 600; color: var(--fg-3); margin-left: 1px; }
.p-sep { color: var(--fg-4); }
.p-kw { display: inline-flex; align-items: center; gap: 5px; }
.p-bar { position: relative; width: 22px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .10); overflow: hidden; }
.p-bar i { position: absolute; inset: 0; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); border-radius: 2px;
  transition: transform 400ms var(--ease), background var(--t); }
.p-bar.hot i { background: var(--warn); }
.p-state { color: var(--fg-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

/* badges */
.chip { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 650; background: rgba(20, 22, 26, .88); box-shadow: 0 4px 12px rgba(0, 0, 0, .35); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--line-2); color: var(--fg);
  animation: chip-in var(--t) var(--ease-out); white-space: nowrap; }
.chip.once { border-color: var(--accent-line); color: var(--accent); background: rgba(16, 32, 52, .92); }
.chip.lock, .chip.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.warn { background: rgba(48, 36, 12, .92); border-color: rgba(255, 176, 32, .5); color: var(--warn); }
.chip.err { background: rgba(52, 18, 20, .92); border-color: rgba(255, 90, 95, .55); color: var(--err); }
button.chip.pressed { transform: scale(.95); }

/* ---------------------------------------------------------------------------------------------------- stage */
#stage { grid-area: stage; position: relative; overflow: hidden; background: #050607; touch-action: none; user-select: none;
  -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; contain: strict; }
#stage::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px); background-size: 16px 16px; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; pointer-events: none;
  transition: filter 300ms var(--ease); }
#world canvas, #world video { display: block; }
#ripples { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#cursor { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 5; }
.state-picker #cursor, .state-login #cursor, .state-boot #cursor, .state-connecting #cursor, .state-reconnecting #cursor,
.state-failed #cursor, .state-idle-hidden #cursor { opacity: 0; }
.view-only #cursor { opacity: .35; }

#minimap { position: absolute; top: 8px; right: 8px; width: 96px; height: 60px; z-index: 6; border-radius: var(--r-sm);
  background: rgba(10, 12, 15, .62); border: 1px solid var(--line-2); box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); overflow: hidden; touch-action: none; }
#minimap::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(255, 255, 255, .08) 0 6%, transparent 6%) ; }
#minimap-view { position: absolute; left: 0; top: 0; border: 1.5px solid var(--accent); border-radius: 3px;
  background: rgba(77, 163, 255, .16); box-shadow: 0 0 0 1px rgba(0, 0, 0, .4); }
.no-minimap #minimap, .state-picker #minimap, .state-login #minimap, .state-connecting #minimap, .state-boot #minimap,
.state-reconnecting #minimap, .state-failed #minimap, .state-idle-hidden #minimap { display: none; }
/* landscape + keyboard leaves ~100 px of stage: the 60 px minimap would cover most of it */
.landscape.kb-open #minimap, .landscape.compose-open #minimap { display: none; }

/* reconnecting freeze + tap overlay */
.state-reconnecting #world, .state-failed #world, .state-idle-hidden #world { filter: brightness(.5) saturate(.6); }
#freeze, #tap-overlay { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; padding: 24px;
  animation: fade-in var(--t) var(--ease); }
#freeze { background: radial-gradient(ellipse at center, rgba(5, 6, 8, .35), rgba(5, 6, 8, .75)); }
.state-connecting #freeze { background: radial-gradient(ellipse at 50% 40%, #12161c, #07080a 70%); }
/* "탭하여 전체화면" chip in #badges (visual-2; #tap-overlay is no longer used). Hidden while typing: the stage is short */
.kb-open .fs-chip, .compose-open .fs-chip { display: none; }
.fs-chip { height: 32px; padding: 0 12px 0 10px; gap: 6px; }
.fs-chip.compact { width: 32px; padding: 0; justify-content: center; }
.fs-chip.compact span { display: none; }
.ov-card { width: min(320px, 100%); display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  padding: 24px 20px 20px; border-radius: var(--r-xl); background: rgba(20, 22, 26, .82); border: 1px solid var(--line-2);
  box-shadow: var(--shadow); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.ov-ic { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.ov-ic.err { background: var(--err-soft); color: var(--err); }
.ov-ic.warn { background: var(--warn-soft); color: var(--warn); }
.ov-title { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.ov-sub { margin: -4px 0 0; color: var(--fg-2); font-size: 13px; }
.ov-detail { margin: 0; max-width: 100%; font: 11.5px/1.4 var(--mono); color: var(--fg-3); overflow-wrap: anywhere;
  max-height: 4.2em; overflow: hidden; }
.ov-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 4px; }
.ov-progress { width: 100%; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.ov-progress i { display: block; height: 100%; width: 40%; background: var(--accent); border-radius: 2px; animation: indeterminate 1.4s var(--ease) infinite; }
.tap-big { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 32px; border-radius: var(--r-xl);
  border: 1px solid var(--line-2); background: rgba(20, 22, 26, .8); color: var(--fg); font-size: 15px; font-weight: 700;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.tap-big .ic { color: var(--accent); }

/* idle (no session) stage art */
.stage-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--fg-4); pointer-events: none; }

/* ---------------------------------------------------------------------------------------------------- bottom stack */
#bottom { grid-area: bottom; position: relative; z-index: 20; display: flex; flex-direction: column;
  background: var(--bar); border-top: 1px solid var(--line); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  padding-left: var(--sal); padding-right: var(--sar); }
.state-picker #bottom, .state-login #bottom, .state-boot #bottom { visibility: hidden; }
/* no live stream: dim + disable only the controls that send input (visual-11). kbd / compose / close / paste / palette,
   the compose bar and the local view tools (zoom, pan, view, fullscreen) stay usable. */
:is(.state-connecting, .state-reconnecting, .state-failed, .state-idle-hidden)
  :is(#keybar, #rail-left, #rail-right) .k:is([data-kind="mod"], [data-kind="key"], [data-kind="chord"], [data-kind="hold"], [data-kind="switcher"]),
:is(.state-connecting, .state-reconnecting, .state-failed, .state-idle-hidden)
  .tool:is([data-tool="left"], [data-tool="right"], [data-tool="drag"]) {
  opacity: .4; filter: saturate(.4); pointer-events: none; transition: opacity var(--t) var(--ease);
}

/* key bar */
/* key bar = scroller + pinned end slot (visual-4/5): pinned keys (close / kbd+compose) never cover a scrolled key */
#keybar { display: flex; align-items: stretch; height: var(--keybar-h); overflow: hidden; }
.kb-scroll { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 4px 8px; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; overscroll-behavior-x: contain; touch-action: pan-x;
  mask-image: linear-gradient(to right, transparent 0, #000 8px, #000 calc(100% - 16px), transparent); }
.kb-scroll::-webkit-scrollbar { display: none; }
.kb-end { flex: none; display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 6px; border-left: 1px solid var(--line); }
.kb-end[hidden] { display: none; }
.kb-end .k[data-id="close"] { background: var(--s4); }
/* the main typing entry point reads as primary */
.kb-end .k[data-id="kbd"] { color: var(--accent); border-color: var(--accent-line); }
.k { flex: none; min-width: 40px; height: 44px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--s3); color: var(--fg);
  font-size: 14px; font-weight: 650; letter-spacing: -.01em;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 1px 2px rgba(0, 0, 0, .35);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease); }
.k .kt { font-size: 13.5px; font-weight: 650; }
.k .ic.mod { stroke-width: 1.6; }
.k.pressed { background: var(--s4); transform: translateY(1px) scale(.97); }
.k[data-kind="mod"] { width: 44px; padding: 0; }
.k[data-sticky="once"] { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }
.k[data-sticky="lock"] { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.k[aria-pressed="true"][data-kind="action"], .k[aria-pressed="true"][data-kind="switcher"] { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.k.holding { background: conic-gradient(from -90deg, rgba(255, 90, 95, .32) var(--hp, 0%), var(--s3) 0); animation: hold-fill var(--hold-ms, 600ms) linear forwards; }
.ksep { flex: none; width: 1px; height: 22px; margin: 0 2px; background: var(--line-2); }
.chord { display: inline-flex; align-items: center; gap: 1px; }
.chord .kt { font-weight: 650; }

/* composing bubble (direct mode, Gboard composition) */
.compose-bubble { position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 6px 12px; border-radius: 999px; background: rgba(28, 31, 37, .94); border: 1px solid var(--accent-line); color: var(--fg);
  font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }

/* direct-input strip */
#kbstrip { padding: 0 8px 6px; }
.strip-btn { width: 100%; height: 32px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .04); border: 1px dashed var(--line-2); color: var(--fg-2); font-size: 12.5px; font-weight: 600; }
.strip-btn span { flex: 1; text-align: left; }
.strip-btn.pressed { background: rgba(255, 255, 255, .08); }

/* compose bar */
#composebar { display: flex; align-items: flex-end; gap: 8px; padding: 2px 8px 8px; animation: rise var(--t) var(--ease-out); }
#compose { flex: 1; min-height: 40px; max-height: 112px; resize: none; padding: 9px 16px; border-radius: 20px; border: 1px solid var(--line-2);
  background: var(--s2); color: var(--fg); font-size: 16px; line-height: 1.4; user-select: text; -webkit-user-select: text;
  transition: border-color var(--t-fast); }
#compose:focus-visible { outline: none; }
#compose:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
#compose::placeholder { color: var(--fg-3); }
#compose-send { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); transition: transform var(--t-fast) var(--ease), opacity var(--t-fast); }
#compose-send.pressed { transform: scale(.92); }
#compose-send .ic { stroke-width: 2; }

/* toolbar */
#toolbar { position: relative; padding: 0 4px calc(var(--sab) + 4px); transition: height var(--t) var(--ease); }
.tb-handle { position: absolute; left: 50%; top: -1px; transform: translateX(-50%); width: 64px; height: 14px; border: 0; background: none;
  display: grid; place-items: center; padding: 0; z-index: 1; }
.tb-grip { width: 32px; height: 4px; border-radius: 2px; background: var(--line-3); }
.tb-row { display: flex; height: var(--toolbar-h); align-items: stretch; padding-top: 6px; }
#toolbar.collapsed .tb-row { display: none; }
#toolbar.collapsed { height: calc(16px + var(--sab)); }
/* collapsed: the whole strip is the (≥ 24 px) handle; expanded keeps the small handle so it covers no tool */
#toolbar.collapsed .tb-handle { left: 0; right: 0; width: auto; transform: none; top: -8px; height: calc(24px + var(--sab)); }
.tool { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 0; background: none;
  color: var(--fg-2); border-radius: var(--r-md); transition: color var(--t-fast), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.tool.tb { flex: 1 1 0; min-width: 0; padding: 4px 2px; }
.tool .cap { font-size: 10.5px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
  font-variant-numeric: tabular-nums; }
.tool.pressed { background: rgba(255, 255, 255, .07); transform: scale(.96); color: var(--fg); }
.tool.held { background: var(--accent-soft); color: var(--accent); }
.tool[aria-pressed="true"] { color: var(--accent); }
.tool[aria-pressed="true"]::after { content: ""; position: absolute; top: 2px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
.tool.tb[aria-pressed="true"]::after { top: auto; bottom: 0; }

/* keyboard open (portrait): toolbar hidden, bottom = key bar (+ compose or strip) */
.kb-open #toolbar { display: none; }
.kb-open #bottom { padding-bottom: 0; }

/* ---------------------------------------------------------------------------------------------------- landscape */
#rail-left, #rail-right { display: none; }
.landscape #app { grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "stage" "bottom"; }
.landscape #topbar { position: absolute; left: 0; right: 0; top: 0; z-index: 25; min-height: 0; background: none; border: 0; pointer-events: none;
  padding: calc(var(--sat) + 8px) calc(var(--sar) + 8px) 0 calc(var(--sal) + 8px); }
.landscape #topbar > * { pointer-events: auto; }
.landscape #topbar > #badges { pointer-events: none; }
.landscape #pill { width: var(--rail-w); height: auto; min-height: 44px; display: grid; grid-template-columns: 8px 1fr; align-items: start; column-gap: 8px; padding: 8px 10px;
  border-radius: var(--r-lg); background: var(--bar); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); font-size: 12px; }
.landscape .p-host { display: none; }
.landscape .p-stats { flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.35; }
.landscape .p-dot { margin-top: 5px; }
.landscape .p-state { white-space: normal; font-size: 11.5px; line-height: 1.3; }
.landscape .p-sep { display: none; }
.landscape .p-bar { width: 16px; }
.landscape #badges { left: calc(var(--sal) + var(--rail-w) + 16px); right: calc(var(--sar) + var(--rail-w) + 16px); top: calc(var(--sat) + 8px); justify-content: center; }
.landscape #btn-find, .landscape #btn-menu { width: 48px; height: 44px; border-radius: var(--r-md); background: var(--bar);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.landscape #bottom { display: none; }
.landscape.kb-open #bottom, .landscape.compose-open #bottom { display: flex; }
.landscape #toolbar { display: none; }

.landscape #rail-left, .landscape #rail-right { display: flex; position: absolute; z-index: 18; top: calc(var(--sat) + 60px); bottom: calc(var(--sab) + 8px);
  width: var(--rail-w); flex-direction: column; justify-content: center; gap: 8px; pointer-events: none; }
.landscape #rail-left { left: calc(var(--sal) + 8px); }
.landscape #rail-right { right: calc(var(--sar) + 8px); }
.landscape.left-handed #rail-left { left: auto; right: calc(var(--sar) + 8px); }
.landscape.left-handed #rail-right { right: auto; left: calc(var(--sal) + 8px); }
.landscape.kb-open #rail-left, .landscape.kb-open #rail-right, .landscape.compose-open #rail-left, .landscape.compose-open #rail-right { display: none; }
.rail-panel { pointer-events: auto; display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: var(--r-lg);
  background: var(--bar); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); transition: transform var(--t) var(--ease), opacity var(--t); }
.rail-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.k.rail, .tool.rail { width: auto; min-width: 0; height: 44px; padding: 0; gap: 1px; }
.tool.rail { background: var(--s3); border: 1px solid var(--line); color: var(--fg); border-radius: 10px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 1px 2px rgba(0, 0, 0, .35); }
.tool.rail[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); }
.tool.rail[aria-pressed="true"]::after { display: none; }
.rail-toggle { pointer-events: auto; align-self: flex-end; width: 44px; height: 36px; border-radius: var(--r-md); display: grid; place-items: center;
  background: var(--bar); border: 1px solid var(--line); color: var(--fg-2); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.left-handed .rail-toggle { align-self: flex-start; }
.rail-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.rails-hidden .rail-panel { opacity: 0; pointer-events: none; transform: translateX(-24px); }
.rails-hidden #rail-right .rail-panel { transform: translateX(24px); }
.landscape #minimap { right: calc(var(--rail-w) + 16px + var(--sar)); top: calc(var(--sat) + 8px); }
.landscape.rails-hidden #minimap { right: 8px; }
.landscape.left-handed #minimap { right: auto; left: calc(var(--rail-w) + 16px + var(--sal)); }

/* ---------------------------------------------------------------------------------------------------- HUD */
#hud { position: absolute; z-index: 30; left: calc(var(--sal) + 8px); top: calc(var(--sat) + var(--top-h) + 4px);
  width: min(380px, calc(100vw - 16px - var(--sal) - var(--sar))); max-height: calc(100% - var(--top-h) - var(--sat) - 16px); overflow: auto;
  padding: 12px 14px 14px; border-radius: var(--r-lg); background: #101216; border: 1px solid var(--line-2);
  box-shadow: var(--shadow); /* opaque: the tap-to-fullscreen card ghosted through the old .97 glass */
  animation: drop-in var(--t) var(--ease-out); font-variant-numeric: tabular-nums; }
/* narrow portrait: span the stage so the top-right minimap does not peek out beside the panel */
.portrait #hud { width: min(440px, calc(100vw - 16px - var(--sal) - var(--sar))); }
.landscape #hud { top: calc(var(--sat) + 60px); left: calc(var(--sal) + var(--rail-w) + 16px); max-height: calc(100% - 68px - var(--sat)); }
.hud-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.hud-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; color: var(--fg-2); }
.hud-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 12px; }
.hud-grid dt { color: var(--fg-3); white-space: nowrap; }
.hud-grid dd { margin: 0; text-align: right; color: var(--fg); font-weight: 550; overflow-wrap: anywhere; }
.hud-sub { margin: 12px 0 4px; font-size: 11px; font-weight: 700; color: var(--fg-3); text-transform: uppercase; letter-spacing: .04em; }
.hud-log { margin: 0; padding: 8px 10px; border-radius: var(--r-sm); background: rgba(0, 0, 0, .35); border: 1px solid var(--line);
  font: 10.5px/1.45 var(--mono); color: var(--fg-2); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 96px; overflow: auto; user-select: text; }
.hud-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }

/* ---------------------------------------------------------------------------------------------------- toasts */
#toasts { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); top: calc(var(--sat) + var(--top-h) + 8px);
  width: min(420px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.landscape #toasts { top: calc(var(--sat) + 8px); width: min(420px, calc(100vw - 2 * var(--rail-w) - 48px)); }
/* landscape + keyboard leaves ~250 px of stage: show only the newest toast (newest is prepended) */
.landscape.kb-open #toasts > .toast:not(:first-child) { display: none; }
/* …and keep it compact; toasts without a button let touches through to the stage */
.landscape.kb-open .toast, .landscape.compose-open .toast { min-height: 32px; padding: 4px 8px; font-size: 12px; }
.landscape.kb-open .toast:not(:has(.toast-act)), .landscape.compose-open .toast:not(:has(.toast-act)) { pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 8px 8px 12px; border-radius: var(--r-md);
  background: rgba(28, 31, 37, .94); border: 1px solid var(--line-2); box-shadow: var(--shadow); color: var(--fg); font-size: 13px; font-weight: 550;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  opacity: 0; transform: translateY(-8px) scale(.98); transition: opacity var(--t) var(--ease), transform var(--t) var(--ease-out); }
.toast.in { opacity: 1; transform: none; }
.toast.out { opacity: 0; transform: translateY(-6px) scale(.98); }
.toast-ic { flex: none; color: var(--accent); }
.toast.lv-warn .toast-ic { color: var(--warn); }
.toast.lv-error .toast-ic { color: var(--err); }
.toast.lv-error { border-color: rgba(255, 90, 95, .35); }
.toast.lv-ok .toast-ic { color: var(--ok); }
.toast-msg { flex: 1; padding: 4px 0; }
.toast-act { flex: none; height: 32px; padding: 0 12px; border-radius: var(--r-sm); border: 0; background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 13px; }
.toast-act:active { background: rgba(77, 163, 255, .28); }
.toast-act { position: relative; }
.toast-act::after { content: ""; position: absolute; inset: -6px 0; } /* 44 px tall hit area, 32 px visual */

/* ---------------------------------------------------------------------------------------------------- layers / sheets */
#sheets { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.layer { position: absolute; left: 0; right: 0; top: 0; height: calc(100% - var(--kb)); pointer-events: auto; display: flex; }
.scrim { position: absolute; inset: 0; background: rgba(3, 4, 6, .55); opacity: 0; transition: opacity var(--t) var(--ease); }
.layer.in .scrim { opacity: 1; }
.sheet { position: relative; display: flex; flex-direction: column; color: var(--fg); outline: none; }

.layer.v-bottom { align-items: flex-end; justify-content: center; }
.layer.v-bottom .sheet { width: min(560px, 100%); max-height: min(78%, 640px); border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--s1); border: 1px solid var(--line-2); border-bottom: 0; box-shadow: 0 -12px 48px rgba(0, 0, 0, .5);
  padding: 0 calc(var(--sar) + 16px) calc(var(--sab) + 16px) calc(var(--sal) + 16px);
  transform: translateY(100%); transition: transform 240ms var(--ease-out); }
.layer.v-bottom.tall .sheet { max-height: 88%; height: 88%; }
.layer.v-bottom.in .sheet { transform: none; }
.layer.v-bottom.out .sheet { transform: translateY(100%); transition-duration: 180ms; }
.sheet.dragging { transition: none !important; }
.grabber { flex: none; width: 36px; height: 4px; border-radius: 2px; background: var(--line-3); margin: 8px auto 4px; }
.landscape .layer.v-bottom .sheet { max-height: 92%; }
.landscape .layer.v-bottom.tall .sheet { height: 92%; max-height: 92%; }

.layer.v-center { align-items: center; justify-content: center; padding: 24px; }
.layer.v-center .sheet { width: min(360px, 100%); padding: 24px 20px 20px; border-radius: var(--r-xl); background: var(--s1); border: 1px solid var(--line-2);
  box-shadow: var(--shadow); align-items: center; opacity: 0; transform: scale(.96); transition: opacity var(--t) var(--ease), transform var(--t) var(--ease-out); }
.layer.v-center.in .sheet { opacity: 1; transform: none; }
.layer.v-center.out .sheet { opacity: 0; transform: scale(.97); }

.layer.v-page { background: var(--bg); opacity: 0; transition: opacity var(--t) var(--ease); }
.layer.v-page.in { opacity: 1; }
.layer.v-page .scrim { display: none; }
.layer.v-page .sheet { flex: 1; min-height: 0; }
.page-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: calc(var(--sat) + 24px) calc(var(--sar) + 20px) calc(var(--sab) + 24px) calc(var(--sal) + 20px);
  width: 100%; max-width: 560px; margin: 0 auto; }

.sheet-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0 12px; }
.sheet-titles { min-width: 0; }
.sheet-title { margin: 0; font-size: 18px; font-weight: 750; letter-spacing: -.02em; }
.sheet-title.center { text-align: center; }
.sheet-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--fg-3); }
.sheet-body { scrollbar-width: thin; scrollbar-color: var(--s4) transparent; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 -4px; padding: 0 4px 8px; }
.sheet-foot { flex: none; display: flex; justify-content: flex-end; gap: 8px; padding-top: 12px; }
.sheet-hint { margin: 12px 0 0; text-align: center; font-size: 12px; color: var(--fg-3); }
.help-first { flex: none; display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.help-first .sheet-hint { margin: 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: var(--r-md);
  border: 1px solid var(--line-2); background: var(--s3); color: var(--fg); font-size: 14.5px; font-weight: 700; letter-spacing: -.01em;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), opacity var(--t-fast); }
.btn.pressed, .btn:active:not(:disabled) { transform: scale(.98); }
.btn.sm { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; gap: 6px; }
.btn.lg { height: 52px; font-size: 16px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); box-shadow: 0 6px 20px rgba(77, 163, 255, .25); }
.btn.primary.pressed, .btn.primary:active:not(:disabled) { background: #3d93ef; }
.btn.danger { background: var(--err-soft); border-color: rgba(255, 90, 95, .45); color: var(--err); }
.btn.ghost { background: transparent; }
.btn .spinner { display: none; }
.btn.busy .spinner { display: inline-block; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin-top: 20px; }
.link { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 8px; border: 0; background: none; color: var(--fg-2);
  font-size: 13px; font-weight: 600; text-decoration: none; border-radius: var(--r-sm); }
.link.pressed { background: rgba(255, 255, 255, .06); }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .15); border-top-color: currentColor;
  animation: spin .8s linear infinite; flex: none; }

/* confirm */
.confirm-ic { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 12px; }
.confirm-ic.danger { background: var(--err-soft); color: var(--err); }
.confirm-body { margin: 8px 0 0; text-align: center; color: var(--fg-2); font-size: 14px; }

/* groups / rows / controls */
.group { margin-top: 20px; }
.group:first-child { margin-top: 4px; }
.group-title { margin: 20px 4px 8px; font-size: 12px; font-weight: 700; color: var(--fg-3); letter-spacing: .02em; }
.group > .group-title { margin-top: 0; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.row-between .muted { font-weight: 500; }
.group-body { border-radius: var(--r-lg); background: var(--s2); border: 1px solid var(--line); overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 10px 14px;
  border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.row:first-child { border-top: 0; }
.row.stacked { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 14px 14px; }
.row.actions { justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
.row-text { display: flex; flex-direction: column; min-width: 0; }
.row-label { font-size: 14.5px; font-weight: 600; }
.row-hint { font-size: 12px; color: var(--fg-3); margin-top: 2px; }
.link-row.pressed, .link-row:active { background: rgba(255, 255, 255, .04); }

.seg { display: flex; gap: 4px; padding: 4px; border-radius: var(--r-md); background: rgba(0, 0, 0, .3); border: 1px solid var(--line); }
.seg-btn { flex: 1 1 0; min-width: 0; min-height: 36px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  padding: 6px 6px; border: 0; border-radius: 9px; background: transparent; color: var(--fg-2); font-size: 13px; font-weight: 650;
  transition: background var(--t-fast) var(--ease), color var(--t-fast); }
.seg.wide .seg-btn { min-height: 48px; }
.seg-btn[aria-checked="true"], .seg-btn[aria-selected="true"] { background: var(--s4); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 0 0 1px var(--line-2) inset; }
.seg-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.seg-s { font-size: 10.5px; font-weight: 550; color: var(--fg-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.seg-btn[aria-checked="true"] .seg-s { color: var(--accent); }
.seg.tabs { flex: none; overflow-x: auto; scrollbar-width: none; }
.seg.tabs .seg-btn { flex: 1 0 auto; min-width: 56px; }

.switch { position: relative; flex: none; width: 50px; height: 30px; border-radius: 999px; border: 0; padding: 0; background: var(--s4);
  transition: background var(--t) var(--ease); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #f4f6f9;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4); transition: transform var(--t) var(--ease-out); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

.slider-wrap { display: flex; align-items: center; gap: 12px; }
.slider { --p: 50%; flex: 1; height: 28px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; touch-action: pan-y; }
.slider::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--p), var(--s4) var(--p)); }
.slider::-moz-range-track { height: 4px; border-radius: 2px; background: var(--s4); }
.slider::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -10px; border-radius: 50%; background: #f4f6f9;
  border: 0; box-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
.slider::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #f4f6f9; border: 0; }
.slider-val { flex: none; min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; color: var(--fg-2); font-size: 13px; }

/* status + banners + fine print */
.status { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: rgba(255, 255, 255, .06); color: var(--fg-2); }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.good { color: var(--ok); background: var(--ok-soft); }
.status.warn { color: var(--warn); background: var(--warn-soft); }
.status.bad { color: var(--err); background: var(--err-soft); }
.status.accent { color: var(--accent); background: var(--accent-soft); }
.banner { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 12px; border-radius: var(--r-md); font-size: 13px; font-weight: 550; }
.banner.err { background: var(--err-soft); color: #ffb3b5; border: 1px solid rgba(255, 90, 95, .3); }
.banner.warn { background: var(--warn-soft); color: #ffd58a; border: 1px solid rgba(255, 176, 32, .3); }
.banner-text { flex: 1; }
.banner .ic { flex: none; }
.fine { display: flex; align-items: flex-start; gap: 6px; margin: 16px 0 0; color: var(--fg-3); font-size: 12px; line-height: 1.5; }
.fine.center { justify-content: center; text-align: center; margin-top: 10px; }
.fine .ic { margin-top: 2px; }
.loading, .empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 0; color: var(--fg-3); font-size: 13px; }
.empty p { margin: 0; }

/* ---------------------------------------------------------------------------------------------------- login */
.layer.login .page-body { display: flex; flex-direction: column; justify-content: center; max-width: 400px; }
.layer.login .sheet { background: radial-gradient(120% 60% at 50% 0%, rgba(77, 163, 255, .10), transparent 60%); }
.brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 32px; }
.brand-mark { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; color: var(--accent);
  background: linear-gradient(160deg, rgba(77, 163, 255, .22), rgba(77, 163, 255, .06)); border: 1px solid rgba(77, 163, 255, .28);
  box-shadow: 0 12px 40px rgba(77, 163, 255, .15); margin-bottom: 16px; }
.brand-title { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.03em; }
.brand-sub { margin: 6px 0 0; color: var(--fg-2); font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.field-wrap { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 650; color: var(--fg-2); padding-left: 4px; }
.field-box { display: flex; align-items: center; height: 52px; border-radius: 14px; background: var(--s2); border: 1px solid var(--line-2);
  transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.field-box input:focus-visible { outline: none; } /* the box draws the ring */
.field-box:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-ic { flex: none; width: 44px; display: grid; place-items: center; color: var(--fg-3); }
.field { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: var(--fg); font-size: 16px; padding: 0 12px 0 0;
  user-select: text; -webkit-user-select: text; }
.field-btn { flex: none; width: 44px; height: 44px; border: 0; background: none; color: var(--fg-3); display: grid; place-items: center; }
.field-btn[aria-pressed="true"] { color: var(--accent); }
.form-err { margin: -4px 0 0; padding: 10px 12px; border-radius: var(--r-md); background: var(--err-soft); color: #ffb3b5; font-size: 13px; font-weight: 600; }
.login-form .btn { margin-top: 4px; height: 52px; font-size: 16px; border-radius: 14px; }

/* ---------------------------------------------------------------------------------------------------- picker */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: .02em; }
.page-title { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.03em; line-height: 1.2; }
.head-actions { display: flex; gap: 8px; flex: none; }
.resume-card { position: relative; padding: 16px; border-radius: var(--r-xl); overflow: hidden;
  background: linear-gradient(160deg, #1a2230 0%, #141820 55%, #12151a 100%); border: 1px solid rgba(77, 163, 255, .22);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .35); }
.resume-card::before { content: ""; position: absolute; inset: -40% -20% auto auto; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(77, 163, 255, .18), transparent 70%); pointer-events: none; }
.rc-top { position: relative; display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.rc-ic { flex: none; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; color: var(--accent);
  background: rgba(77, 163, 255, .14); border: 1px solid rgba(77, 163, 255, .22); }
.rc-text { flex: 1; min-width: 0; }
.rc-title { font-size: 17px; font-weight: 750; letter-spacing: -.02em; }
.rc-sub { margin-top: 2px; font-size: 13px; color: var(--fg-2); }
.rc-meta { margin-top: 2px; font-size: 12px; color: var(--fg-3); }
.rc-warn { position: relative; margin: -4px 0 12px; font-size: 12.5px; color: #ffb3b5; }
.host-list { display: flex; flex-direction: column; gap: 8px; }
.host { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 12px 0 14px; border-radius: var(--r-lg); background: var(--s2);
  border: 1px solid var(--line); color: var(--fg); text-align: left; transition: border-color var(--t-fast), background var(--t-fast); }
.host[aria-checked="true"] { border-color: var(--accent-line); background: linear-gradient(0deg, var(--accent-soft), var(--accent-soft)), var(--s2); }
.host-ic { color: var(--fg-2); }
.host[aria-checked="true"] .host-ic { color: var(--accent); }
.host-name { flex: 1; min-width: 0; font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-list { display: flex; flex-direction: column; gap: 8px; }
.app { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 10px 8px 10px; border-radius: var(--r-lg); background: var(--s2);
  border: 1px solid var(--line); color: var(--fg); text-align: left; transition: background var(--t-fast), transform var(--t-fast) var(--ease); }
.app.pressed { background: var(--s3); transform: scale(.99); }
.app-ic { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--s4); color: var(--fg); }
.app-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-title { font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-sub { font-size: 12px; font-weight: 600; color: var(--fg-3); }
.app-sub.accent { color: var(--accent); }
.app-sub.warn { color: var(--warn); }
.app-go { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.page-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------------------------------------------- palette */
.layer.palette .sheet { gap: 12px; }
.layer.palette .sheet-head { padding-bottom: 0; }
.pgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.landscape .pgrid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.ptile { position: relative; min-height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 8px 4px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--s2); color: var(--fg); overflow: hidden;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), border-color var(--t-fast); }
.ptile.pressed { background: var(--s3); transform: scale(.96); }
.ptile-label { font-size: 12.5px; font-weight: 650; line-height: 1.25; text-align: center; letter-spacing: -.02em; word-break: keep-all; }
.ptile-chord { color: var(--fg-3); }
.ptile-chord .kt { font-size: 12px; }
.ptile.hold { border-color: rgba(255, 90, 95, .22); }
.ptile.hold .ptile-label { color: #ffc2c4; }
.ptile-ring { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; pointer-events: none; opacity: 0; background: var(--err);
  transform-origin: 0 50%; transform: scaleX(0); }
.ptile.hold::after { content: "길게"; position: absolute; top: 6px; right: 7px; font-size: 9px; font-weight: 700; line-height: 1; color: rgba(255, 90, 95, .8); }
.ptile.hold { padding-top: 14px; }
.ptile.holding { background: linear-gradient(0deg, rgba(255, 90, 95, .12), rgba(255, 90, 95, .12)), var(--s2); border-color: rgba(255, 90, 95, .5); }
.ptile.holding .ptile-ring { opacity: 1; animation: hold-bar var(--hold-ms, 600ms) linear forwards; }
.ptile.shake { animation: shake 300ms var(--ease); }
@property --hp { syntax: "<percentage>"; inherits: false; initial-value: 0%; }

/* ---------------------------------------------------------------------------------------------------- menu / presets / help / log */
.menu-list { display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 8px 8px; border: 0; border-radius: var(--r-md); background: none;
  color: var(--fg); text-align: left; transition: background var(--t-fast); }
.menu-item.pressed { background: rgba(255, 255, 255, .06); }
.menu-ic { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--s3); color: var(--fg-2); }
.menu-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.menu-label { font-size: 15px; font-weight: 600; }
.menu-hint { font-size: 12px; color: var(--fg-3); }
.menu-item.danger .menu-label { color: var(--err); }
.menu-item.danger .menu-ic { background: var(--err-soft); color: var(--err); }
.menu-sep { height: 1px; margin: 6px 8px; background: var(--line); }
.menu-badge { font-size: 12px; color: var(--fg-3); font-weight: 600; }

.preset-list { display: flex; flex-direction: column; gap: 8px; }
.preset { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 14px; border-radius: var(--r-lg); border: 1px solid var(--line);
  background: var(--s2); color: var(--fg); text-align: left; }
.preset[aria-checked="true"] { border-color: var(--accent-line); background: linear-gradient(0deg, var(--accent-soft), var(--accent-soft)), var(--s2); }
.preset-bars { color: var(--accent); flex: none; }
.preset-text { flex: 1; display: flex; flex-direction: column; }
.preset-name { font-size: 15px; font-weight: 700; }
.preset-sub { font-size: 12px; color: var(--fg-3); font-variant-numeric: tabular-nums; }
.preset-sub.warn { color: var(--warn); }
.preset-check { color: var(--accent); }

.help-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.help-list li { display: flex; align-items: center; gap: 14px; padding: 10px 4px; border-top: 1px solid var(--line); }
.help-list li:first-child { border-top: 0; }
.help-ic { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--s3); color: var(--accent); }
.help-text { display: flex; flex-direction: column; font-size: 13px; color: var(--fg-2); }
.help-text b { font-size: 14px; color: var(--fg); font-weight: 650; }

.log-pre { margin: 0; padding: 12px; border-radius: var(--r-md); background: #07080a; border: 1px solid var(--line); font: 11px/1.5 var(--mono);
  color: var(--fg-2); white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; min-height: 100%; }

/* ---------------------------------------------------------------------------------------------------- diag page */
html:has(> body.diag) { overflow: auto; height: auto; }
body.diag { overflow: auto; height: auto; min-height: 100%; }
#diag { max-width: 720px; margin: 0 auto; padding: calc(var(--sat) + 20px) calc(var(--sar) + 16px) calc(var(--sab) + 32px) calc(var(--sal) + 16px); }
#diag h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.03em; }
#diag > p { margin: 6px 0 16px; color: var(--fg-2); }
.diag-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.diag-card { margin-top: 12px; padding: 14px; border-radius: var(--r-lg); background: var(--s2); border: 1px solid var(--line); }
.diag-card h2 { margin: 0 0 10px; font-size: 13px; font-weight: 700; color: var(--fg-3); }
.diag-kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12.5px; margin: 0; }
.diag-kv dt { color: var(--fg-3); }
.diag-kv dd { margin: 0; font-family: var(--mono); font-size: 11.5px; overflow-wrap: anywhere; }
#diag-input { width: 100%; min-height: 88px; resize: vertical; padding: 12px 14px; border-radius: var(--r-md); background: var(--s1); color: var(--fg);
  border: 1px solid var(--line-2); font-size: 16px; }
#diag-input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
#diag-pad { margin-top: 10px; height: 140px; border-radius: var(--r-md); border: 1px dashed var(--line-3); display: grid; place-items: center;
  color: var(--fg-3); font-size: 13px; touch-action: none; user-select: none; -webkit-user-select: none; background-image: radial-gradient(rgba(255,255,255,.05) 1px, transparent 1px); background-size: 12px 12px; }
.diag-actions { display: flex; gap: 8px; margin-top: 12px; position: sticky; bottom: 8px; }
#diag-log { margin: 12px 0 0; padding: 12px; border-radius: var(--r-md); background: #07080a; border: 1px solid var(--line); min-height: 160px;
  max-height: 50vh; overflow: auto; font: 11px/1.5 var(--mono); color: var(--fg-2); white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
.codec-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.codec-row:first-of-type { border-top: 0; }
.codec-row code { font-family: var(--mono); font-size: 11.5px; color: var(--fg-2); }

/* ---------------------------------------------------------------------------------------------------- keyframes */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px var(--accent-soft); } 50% { box-shadow: 0 0 0 6px rgba(77, 163, 255, 0); } }
@keyframes chip-in { from { opacity: 0; transform: scale(.9); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
@keyframes indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
@keyframes hold-bar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes hold-fill { from { --hp: 0%; } to { --hp: 100%; } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

/* ---------------------------------------------------------------------------------------------------- preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .ptile.holding .ptile-ring, .k.holding { animation-duration: var(--hold-ms, 600ms) !important; }
  .spinner, .icon-btn.spin .ic { animation: spin 1.6s linear infinite !important; }
  .ov-progress i { animation: none !important; width: 100%; opacity: .5; }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --bar: #14161a; --blur: none; }
}
.low-power { --blur: none; --bar: #14161a; }
@media (max-width: 359px) {
  .p-host { display: none; }
  .tool .cap { font-size: 9.5px; }
}
