:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
  --bg:#03080d; --panel:#09151e; --panel-2:#0d1c27; --text:#f3f8f7;
  --muted:#91a5aa; --line:rgba(255,255,255,.12); --mint:#8ef1cf;
  --cyan:#63c9ff; --danger:#ee7479; --shadow:0 22px 70px rgba(0,0,0,.45);
}
* { box-sizing:border-box; }
html, body { margin:0; min-height:100%; background:var(--bg); color:var(--text); }
body { min-height:100vh; overflow-x:hidden; }
button, input, select { font:inherit; }
button { color:inherit; -webkit-tap-highlight-color:transparent; cursor:pointer; }
button:active { transform:scale(.97); }
[hidden] { display:none !important; }
.brand { display:flex; align-items:center; gap:12px; font-size:13px; font-weight:850; letter-spacing:.22em; }
.brand-star { color:var(--mint); font-size:28px; text-shadow:0 0 22px rgba(99,201,255,.8); }
.auth-shell {
  min-height:100vh; padding:max(28px,env(safe-area-inset-top)) 20px max(28px,env(safe-area-inset-bottom));
  display:flex; flex-direction:column; position:relative; overflow:hidden;
  background:radial-gradient(circle at 76% 4%,rgba(31,99,111,.48),transparent 38%),linear-gradient(160deg,#07131b,#020609 72%);
}
.auth-glow { position:absolute; width:420px; height:420px; border-radius:50%; top:-250px; right:-170px; background:rgba(99,201,255,.16); filter:blur(40px); }
.auth-card {
  width:100%; max-width:470px; min-width:0; margin:auto; display:grid; gap:18px; padding:28px 22px;
  border:1px solid var(--line); border-radius:30px; background:linear-gradient(150deg,rgba(20,42,54,.88),rgba(6,15,22,.92));
  box-shadow:var(--shadow); backdrop-filter:blur(24px);
}
.eyebrow { color:var(--mint); font-size:11px; font-weight:850; letter-spacing:.2em; }
h1, h2, p { margin:0; }
h1 { font-size:clamp(34px,9vw,48px); line-height:.98; letter-spacing:-.045em; }
h2 { font-size:25px; letter-spacing:-.025em; }
.lede, .section-copy { color:var(--muted); line-height:1.5; }
.auth-tabs { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); min-width:0; gap:5px; padding:5px; border-radius:16px; background:rgba(0,0,0,.3); }
.auth-tab { min-width:0; min-height:42px; padding:0 5px; border:0; border-radius:12px; background:transparent; color:var(--muted); font-size:12px; font-weight:750; }
.auth-tab.active { background:rgba(255,255,255,.1); color:white; }
.auth-form, .auth-form label { min-width:0; }
.auth-form { display:grid; gap:14px; }
label { display:grid; gap:7px; color:#c8d5d5; font-size:13px; font-weight:750; }
input, select {
  width:100%; height:56px; padding:0 16px; border-radius:16px; border:1px solid var(--line);
  outline:0; background:rgba(255,255,255,.06); color:white; font-size:17px;
}
input:focus, select:focus { border-color:var(--cyan); box-shadow:0 0 0 3px rgba(99,201,255,.12); }
.primary, .secondary, .danger {
  min-height:54px; border-radius:16px; border:0; padding:0 18px; font-weight:850;
}
.primary { color:#031015; background:linear-gradient(135deg,var(--mint),var(--cyan)); }
.secondary { border:1px solid var(--line); background:rgba(255,255,255,.06); }
.danger { border:1px solid rgba(238,116,121,.32); background:rgba(238,116,121,.1); color:#ff9da1; }
.auth-form small, .auth-foot { color:var(--muted); line-height:1.4; }
.auth-foot { position:relative; text-align:center; font-size:12px; }
.message { min-height:20px; color:#ffd18a; font-size:13px; line-height:1.4; }

.app-shell {
  min-height:100vh; padding:max(18px,env(safe-area-inset-top)) 16px calc(92px + env(safe-area-inset-bottom));
  background:radial-gradient(circle at 78% 0,rgba(20,70,83,.45),transparent 34%),linear-gradient(165deg,#07131b,#020609 72%);
}
.app-header { height:48px; display:flex; align-items:center; justify-content:space-between; }
.brand.compact { font-size:11px; }
.brand.compact .brand-star { font-size:23px; }
.avatar, .large-avatar {
  display:grid; place-items:center; border-radius:50%; font-weight:900; color:#062027;
  background:linear-gradient(135deg,var(--mint),var(--cyan));
}
.avatar { width:42px; height:42px; border:0; }
.large-avatar { width:58px; height:58px; font-size:22px; }
.views { width:min(100%,680px); margin:0 auto; }
.view { display:none; animation:enter .22s ease-out; }
.view.active { display:grid; gap:18px; }
@keyframes enter { from { opacity:0; transform:translateY(7px); } }
.welcome { display:grid; gap:8px; padding:22px 2px 4px; }
.welcome p { color:var(--muted); }
.hero-card {
  min-height:238px; padding:22px; display:flex; flex-direction:column; justify-content:flex-end; gap:8px;
  border:1px solid rgba(121,224,255,.22); border-radius:28px; overflow:hidden; position:relative;
  background:
    linear-gradient(180deg,transparent 15%,rgba(2,8,13,.28) 46%,rgba(2,8,13,.95)),
    radial-gradient(circle at 60% 10%,#245b6d,#0c2532 43%,#061017 76%);
  box-shadow:var(--shadow);
}
.hero-card::before { content:"✦"; position:absolute; top:22px; right:25px; color:var(--mint); font-size:44px; text-shadow:0 0 30px var(--cyan); }
.live-dot, #dot { display:inline-block; width:9px; height:9px; border-radius:50%; background:#f0b96b; margin-right:7px; }
.hero-card p { color:var(--muted); }
.hero-actions { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:12px; }
.quick-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.quick-card {
  min-height:136px; padding:17px; display:flex; flex-direction:column; align-items:flex-start; gap:7px;
  border:1px solid var(--line); border-radius:22px; background:linear-gradient(145deg,rgba(18,38,50,.9),rgba(7,16,23,.94));
  text-align:left; box-shadow:0 12px 32px rgba(0,0,0,.25);
}
.quick-card > span { color:var(--mint); font-size:23px; }
.quick-card strong { font-size:17px; }
.quick-card small { color:var(--muted); line-height:1.35; }
.section-heading { display:flex; gap:14px; align-items:center; padding-top:15px; }
.section-heading h1 { font-size:36px; margin-top:5px; }
.back { width:44px; height:44px; border-radius:14px; border:1px solid var(--line); background:rgba(255,255,255,.06); font-size:28px; }
.call-status { display:flex; align-items:center; color:#b7c6c7; font-size:14px; }
#stage {
  position:relative; width:100%; height:min(58vh,580px); min-height:350px; overflow:hidden;
  border-radius:28px; background:#010406; border:1px solid var(--line); box-shadow:var(--shadow);
}
#stage video { position:absolute; inset:0; width:100%; height:100%; object-fit:contain; background:#010406; }
#remote { z-index:1; }
#emptyVideo { position:absolute; inset:0; z-index:0; display:grid; place-content:center; text-align:center; color:var(--muted); }
#emptyVideo span { color:var(--mint); font-size:40px; }
#local {
  inset:auto 14px 14px auto !important; width:31% !important; height:25% !important; min-width:110px; min-height:145px;
  z-index:3 !important; border:2px solid rgba(255,255,255,.65); border-radius:19px; box-shadow:0 12px 35px rgba(0,0,0,.55);
}
.call-button { width:100%; }
#callControls {
  display:grid; grid-template-columns:repeat(4,1fr); gap:8px; padding:9px; border-radius:21px;
  border:1px solid var(--line); background:rgba(5,14,20,.9); backdrop-filter:blur(20px);
}
#callControls button {
  min-height:58px; border:0; border-radius:15px; background:rgba(255,255,255,.09); display:grid; place-content:center; gap:3px; font-size:12px;
}
#callControls button span { font-size:18px; }
#callControls .hangup { background:var(--danger); color:white; }
#volumeControl { display:flex; align-items:center; gap:12px; padding:11px 15px; border:1px solid var(--line); border-radius:17px; background:var(--panel); }
#volumeSlider { height:25px; padding:0; border:0; background:transparent; }
.notice { padding:16px; border:1px solid var(--line); border-radius:17px; background:rgba(255,255,255,.05); color:var(--muted); line-height:1.45; }
.remote-mode-toggle { display:grid; grid-template-columns:1fr 1fr; gap:5px; padding:5px; border:1px solid var(--line); border-radius:17px; background:rgba(0,0,0,.28); }
.remote-mode { min-height:46px; border:0; border-radius:13px; background:transparent; color:var(--muted); font-weight:800; }
.remote-mode.active { color:white; background:linear-gradient(145deg,rgba(87,202,255,.3),rgba(80,255,196,.1)); box-shadow:inset 0 0 0 1px rgba(99,201,255,.35); }
.remote-voice-card { display:grid; gap:10px; margin:12px 0; padding:14px; border:1px solid var(--line); border-radius:23px; background:linear-gradient(145deg,rgba(16,36,49,.94),rgba(7,16,24,.96)); box-shadow:var(--shadow); }
#remoteVoiceButton { min-height:72px; display:grid; grid-template-columns:48px 1fr; grid-template-rows:1fr 1fr; align-items:center; text-align:left; border:1px solid rgba(117,224,213,.28); border-radius:18px; background:linear-gradient(135deg,rgba(125,239,208,.18),rgba(87,202,255,.12)); color:white; padding:10px 15px; }
#remoteVoiceButton > span { grid-row:1/3; width:40px; height:40px; display:grid; place-items:center; border-radius:50%; color:var(--mint); background:rgba(121,238,210,.1); box-shadow:0 0 20px rgba(87,202,255,.24); }
#remoteVoiceButton strong { font-size:18px; } #remoteVoiceButton small,#remoteVoiceState { color:var(--muted); }
#remoteVoiceButton.listening { border-color:var(--mint); box-shadow:0 0 0 3px rgba(121,238,210,.1),0 0 28px rgba(87,202,255,.24); }
#remoteCommandForm { display:grid; grid-template-columns:1fr auto; gap:8px; }
#remoteCommandForm input { min-width:0; border:1px solid var(--line); border-radius:15px; background:rgba(255,255,255,.06); color:white; padding:13px; }
#remoteCommandForm button { border:0; border-radius:15px; padding:0 18px; background:linear-gradient(135deg,var(--mint),var(--cyan)); color:#031015; font-weight:900; }
.remote-now { display:grid; gap:12px; margin-top:14px; padding:16px; border:1px solid var(--line); border-radius:23px; background:linear-gradient(145deg,rgba(16,36,49,.9),rgba(7,16,24,.94)); box-shadow:var(--shadow); }
.remote-now-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.remote-now-heading h2 { margin:4px 0 0; font-size:20px; }
.remote-now-heading button { min-height:42px; padding:0 15px; border:1px solid var(--line); border-radius:13px; background:rgba(255,255,255,.08); color:white; font-weight:750; }
.remote-now-list { display:grid; gap:8px; }
.remote-now-list > p { margin:0; color:var(--muted); line-height:1.45; }
.remote-now-item { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:12px; border:1px solid var(--line); border-radius:15px; background:rgba(255,255,255,.045); }
.remote-now-item div { display:grid; min-width:0; gap:3px; }
.remote-now-item strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.remote-now-item small,#remoteSurfaceUpdated { color:var(--muted); }
.remote-now-item > span { flex:none; font-size:11px; color:var(--mint); }
.remote-card { padding:16px; border:1px solid var(--line); border-radius:30px; background:linear-gradient(160deg,#102431,#071018); box-shadow:var(--shadow); }
.trackpad-card { display:grid; gap:10px; }
#trackpad {
  min-height:min(52vh,430px); padding:28px; border:1px solid rgba(99,201,255,.28); border-radius:30px;
  display:grid; place-content:center; gap:9px; text-align:center; touch-action:none; user-select:none; -webkit-user-select:none;
  background:radial-gradient(circle at 50% 36%,rgba(58,150,174,.3),transparent 38%),linear-gradient(150deg,#102735,#061018);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.08),var(--shadow);
}
#trackpad.active-touch { border-color:var(--mint); box-shadow:inset 0 0 0 2px rgba(142,241,207,.16),var(--shadow); }
#trackpad.locked, .trackpad-buttons button:disabled { opacity:.38; }
.trackpad-star { color:var(--mint); font-size:38px; text-shadow:0 0 26px var(--cyan); }
#trackpad small { color:var(--muted); line-height:1.5; }
.trackpad-buttons { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.trackpad-buttons button { min-height:58px; border:1px solid var(--line); border-radius:17px; background:rgba(255,255,255,.07); color:white; font-weight:800; }
.remote-top, .remote-bottom { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; }
.remote-bottom { grid-template-columns:repeat(3,1fr); }
.remote-card button {
  min-height:64px; border:1px solid var(--line); border-radius:18px; background:rgba(255,255,255,.07);
  display:grid; place-content:center; gap:3px; font-size:21px;
}
.remote-card button small { color:#b6c5c7; font-size:10px; font-weight:750; }
.remote-card button:disabled { opacity:.35; }
.dpad { width:260px; height:260px; margin:24px auto; display:grid; grid-template:repeat(3,1fr)/repeat(3,1fr); gap:7px; }
.dpad button { border-radius:25px; min-height:0; }
.dpad .up { grid-area:1/2; } .dpad .left { grid-area:2/1; } .dpad .select { grid-area:2/2; background:linear-gradient(135deg,var(--mint),var(--cyan)); color:#031015; font-size:16px; font-weight:900; }
.dpad .right { grid-area:2/3; } .dpad .down { grid-area:3/2; }

.contact-list { display:grid; gap:10px; }
.contact {
  width:100%; display:grid; grid-template-columns:48px 1fr auto; align-items:center; gap:12px; padding:14px;
  border:1px solid var(--line); border-radius:19px; background:rgba(255,255,255,.045); color:inherit; text-align:left;
}
.contact-avatar { width:48px; height:48px; display:grid; place-items:center; border-radius:50%; background:#15313f; color:var(--mint); font-weight:900; }
.contact div { display:grid; gap:3px; }
.contact small { color:var(--muted); text-transform:capitalize; }
.presence { width:10px; height:10px; border-radius:50%; background:#617278; }
.presence.online { background:#51e9a5; box-shadow:0 0 12px rgba(81,233,165,.6); }

.settings-card {
  display:flex; align-items:center; gap:14px; padding:17px; border:1px solid var(--line); border-radius:21px; background:rgba(255,255,255,.05);
}
.settings-card div { display:grid; gap:4px; }
.settings-card small, .settings-card p { color:var(--muted); }
.form-card { display:grid; align-items:stretch; }
.settings-actions { display:grid; gap:10px; }
.invite-result { display:grid; gap:9px; padding:14px; border:1px solid rgba(142,241,207,.25); border-radius:17px; background:rgba(142,241,207,.06); }
.invite-result code { color:var(--mint); font-size:22px; font-weight:900; letter-spacing:.08em; }
.dialog-close { position:absolute; top:14px; right:14px; width:38px; height:38px; border:1px solid var(--line); border-radius:50%; background:rgba(255,255,255,.07); color:white; font-size:22px; }

.bottom-nav {
  position:fixed; z-index:20; left:10px; right:10px; bottom:max(10px,env(safe-area-inset-bottom));
  display:grid; grid-template-columns:repeat(5,1fr); gap:4px; padding:7px;
  border:1px solid var(--line); border-radius:23px; background:rgba(5,14,20,.9); backdrop-filter:blur(24px); box-shadow:0 15px 40px rgba(0,0,0,.45);
}
.nav-button { min-height:58px; border:0; border-radius:16px; background:transparent; display:grid; place-content:center; gap:2px; color:var(--muted); }
.nav-button span { font-size:20px; }
.nav-button small { font-size:10px; font-weight:750; }
.nav-button.active { color:white; background:linear-gradient(145deg,rgba(87,202,255,.3),rgba(80,255,196,.1)); box-shadow:inset 0 0 0 1px rgba(99,201,255,.4); }

dialog { width:min(calc(100% - 34px),430px); border:1px solid var(--line); border-radius:26px; padding:24px; background:#091720; color:white; box-shadow:var(--shadow); }
dialog::backdrop { background:rgba(0,0,0,.76); backdrop-filter:blur(8px); }
dialog[open] { display:grid; gap:15px; }
dialog code { padding:16px; border-radius:15px; background:#02070a; color:var(--mint); text-align:center; font-size:18px; overflow-wrap:anywhere; }
#toast {
  position:fixed; z-index:100; left:20px; right:20px; bottom:105px; padding:14px 17px; border-radius:16px;
  background:#e9f7f2; color:#061015; font-weight:800; text-align:center; transform:translateY(30px); opacity:0; pointer-events:none; transition:.2s;
}
#toast.show { transform:none; opacity:1; }
body.in-call .app-header, body.in-call .bottom-nav, body.in-call #callView > .section-heading, body.in-call .call-status, body.in-call .call-button { display:none; }
body.in-call .app-shell { padding:0; background:#000; }
body.in-call .views, body.in-call #callView { width:100%; height:100vh; margin:0; display:block; }
body.in-call #stage { position:fixed; inset:0; width:100vw; height:100vh; min-height:0; border:0; border-radius:0; }
body.in-call #callControls { position:fixed; z-index:30; left:12px; right:12px; bottom:max(18px,env(safe-area-inset-bottom)); }
body.in-call #volumeControl { position:fixed; z-index:31; left:18px; right:18px; bottom:calc(max(18px,env(safe-area-inset-bottom)) + 80px); }
body.in-call #local { inset:max(58px,env(safe-area-inset-top)) 14px auto auto !important; height:23% !important; }

@media (min-width:700px) {
  .app-shell { padding-left:28px; padding-right:28px; }
  .quick-grid { grid-template-columns:repeat(4,1fr); }
  .bottom-nav { left:50%; right:auto; width:620px; transform:translateX(-50%); }
}
/* Visual foundation R1: shared material, depth, focus and motion without layout coupling. */
:root {
  --edge:rgba(160,226,236,.18);
  --edge-strong:rgba(142,241,207,.42);
  --glass:linear-gradient(145deg,rgba(18,39,51,.88),rgba(5,14,21,.94));
  --glass-soft:linear-gradient(145deg,rgba(255,255,255,.075),rgba(255,255,255,.025));
  --focus-ring:0 0 0 3px rgba(99,201,255,.2),0 0 0 1px rgba(142,241,207,.86);
  --shadow-soft:0 14px 38px rgba(0,0,0,.3);
  --shadow-deep:0 28px 80px rgba(0,0,0,.52);
  --ease-out:cubic-bezier(.2,.8,.2,1);
}
html { background:#02070b; }
body { -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility; }
button,.auth-tab,.nav-button,.quick-card,.contact,.remote-mode {
  transition:transform .18s var(--ease-out),border-color .18s ease,background .18s ease,
    color .18s ease,box-shadow .18s ease,opacity .18s ease;
}
button:focus-visible,input:focus-visible,select:focus-visible {
  outline:none; box-shadow:var(--focus-ring);
}
.primary {
  box-shadow:inset 0 1px 0 rgba(255,255,255,.48),0 12px 30px rgba(64,199,218,.2);
}
.auth-card,.hero-card,.quick-card,.remote-card,.settings-card,.notice,dialog {
  border-color:var(--edge);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.055),var(--shadow-soft);
}
.auth-card,.remote-card { background:var(--glass); }
.quick-card,.settings-card,.notice {
  background:var(--glass-soft);
  backdrop-filter:blur(20px) saturate(120%);
}
.hero-card {
  box-shadow:inset 0 1px 0 rgba(255,255,255,.1),var(--shadow-deep);
}
.hero-card::after {
  content:""; position:absolute; inset:0; pointer-events:none;
  background:linear-gradient(118deg,rgba(255,255,255,.08),transparent 24%,transparent 76%,rgba(99,201,255,.045));
}
.quick-card > *, .hero-card > * { position:relative; z-index:1; }
.bottom-nav,#callControls {
  border-color:var(--edge);
  background:rgba(4,13,19,.82);
  backdrop-filter:blur(28px) saturate(135%);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.065),0 20px 52px rgba(0,0,0,.48);
}
.nav-button.active,.remote-mode.active {
  background:linear-gradient(145deg,rgba(91,205,255,.27),rgba(117,244,205,.1));
  box-shadow:inset 0 0 0 1px rgba(118,224,242,.36),0 8px 22px rgba(36,146,177,.12);
}
@media (hover:hover) {
  .quick-card:hover,.contact:hover,.settings-card:hover { transform:translateY(-2px); border-color:var(--edge-strong); }
  .primary:hover { filter:brightness(1.06); transform:translateY(-1px); }
  .secondary:hover,.remote-card button:hover,.trackpad-buttons button:hover { border-color:var(--edge-strong); background:rgba(255,255,255,.1); }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation:none !important; transition:none !important; } }
