:root {
  --bg: #000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --text: #f5f5f7;
  --muted: #8e8e93;
  --accent: #0a84ff;
  --ok: #30d158;
  --warn: #ff9f0a;
  --bad: #ff453a;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none;
}
[hidden] { display: none !important; }
#haptic { position: fixed; opacity: 0; pointer-events: none; width: 1px; height: 1px; overflow: hidden; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }

.screen {
  height: 100%;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 12px);
  display: flex; flex-direction: column;
}

/* Pairing */
#pair { justify-content: center; align-items: center; }
.pair-card { width: 100%; max-width: 360px; text-align: center; }
.logo { width: 72px; height: 72px; margin: 0 auto 20px; border-radius: 18px; background: var(--surface); display: grid; place-items: center; }
.logo svg { width: 36px; height: 36px; }
.pair-card h1 { font-size: 24px; margin: 0 0 8px; }
.pair-card p { color: var(--muted); margin: 0 0 24px; }
#pair-form { display: flex; flex-direction: column; gap: 12px; }
#pair-code {
  font: 600 32px/1 ui-monospace, "SF Mono", monospace; letter-spacing: 0.3em; text-align: center;
  background: var(--surface); color: var(--text); border: 1px solid var(--surface-2); border-radius: 14px;
  padding: 16px; width: 100%; outline: none; -webkit-user-select: text; user-select: text;
}
#pair-code:focus { border-color: var(--accent); }
#pair-form button { background: var(--accent); border-radius: 14px; padding: 14px; font-weight: 600; font-size: 17px; }
.error { color: var(--bad) !important; min-height: 1.4em; margin-top: 12px !important; }

/* Remote */
header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; min-height: 36px; }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; min-width: 0; }
#status-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }

.pad {
  position: relative; flex: 1 1 auto; min-height: 220px; border-radius: 28px; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #3a3a3c 0%, #1c1c1e 70%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08); touch-action: none;
}
.pad-mode { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; background: rgba(0,0,0,.35); padding: 3px; border-radius: 999px; z-index: 2; }
.chip { padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--muted); background: transparent; }
.chip.active { background: var(--surface-2); color: var(--text); }
.pad-hint { position: absolute; bottom: 16px; width: 100%; text-align: center; color: rgba(255,255,255,.3); font-size: 13px; pointer-events: none; }
.ripple { position: absolute; width: 80px; height: 80px; margin: -40px 0 0 -40px; border-radius: 50%; background: rgba(255,255,255,.18); opacity: 0; pointer-events: none; transform: scale(.4); }
.ripple.show { animation: ripple .35s ease-out; }
@keyframes ripple { from { opacity: 1; transform: scale(.4); } to { opacity: 0; transform: scale(1.4); } }

.buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; justify-items: center; align-items: center; }
.icon-btn { width: 64px; height: 64px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; transition: transform .08s, background .08s; }
.icon-btn:active { transform: scale(.92); background: var(--surface-2); }
.icon-btn.small { width: 36px; height: 36px; }
.icon-btn.small svg { width: 18px; height: 18px; }
.volume { display: flex; flex-direction: column; background: var(--surface); border-radius: 32px; }
.volume .icon-btn { background: transparent; }
.buttons { grid-template-areas: "back home vol" "mute kbd vol" "play play play"; }
#btn-back { grid-area: back; } #btn-home { grid-area: home; } .volume { grid-area: vol; }
#btn-mute { grid-area: mute; } #btn-kbd { grid-area: kbd; } #btn-play { grid-area: play; width: 100%; max-width: 280px; border-radius: 32px; }

.apps-wrap { flex: none; }
.apps-title { font-size: 13px; color: var(--muted); margin: 0 4px 8px; text-transform: uppercase; letter-spacing: .06em; }
.apps { display: flex; gap: 12px; overflow-x: auto; padding: 2px 4px 6px; scrollbar-width: none; }
.apps::-webkit-scrollbar { display: none; }
.apps-empty { color: var(--muted); font-size: 14px; padding: 12px 0; }
.app { flex: none; width: 68px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.app img { width: 56px; height: 56px; border-radius: 14px; background: var(--surface); }
.app:active img { transform: scale(.92); }
.app span { width: 100%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app.current span { color: var(--text); }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; align-items: center;
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px); background: rgba(28,28,30,.95);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid var(--surface-2);
}
#kbd-input { flex: 1; min-width: 0; font-size: 17px; padding: 10px 14px; border-radius: 12px; border: 0; background: var(--surface-2); color: var(--text); outline: none; -webkit-user-select: text; user-select: text; }
