@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/assets/inter.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #2b2520;
  --surface: #332d28;
  --surface-2: #3d362f;
  --border: #544a40;
  --border-light: #655a4e;
  --text: #f0e8de;
  --text-dim: #a89880;
  --text-muted: #8a7d70;

  --leave-bg: #3a1818;
  --rec-dot: #e03030;

  /* Comfortable easing - ease-out for arrivals, never abrupt stops */
  --ease-decel: cubic-bezier(0.0, 0.0, 0.2, 1);
  --ease-standard: cubic-bezier(0.4, 0.0, 0.2, 1);
  --ease-settle: cubic-bezier(0.34, 1.4, 0.64, 1);

  /* Shadow system */
  --shadow-raised: 0 1px 0 rgba(255,248,230,0.08) inset, 0 2px 4px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-pressed: 0 2px 4px rgba(0,0,0,0.7) inset, 0 1px 0 rgba(255,248,230,0.03) inset;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
  height: 100vh;
  overflow: hidden;
}

#videos {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

#remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #1a1510;
  opacity: 0;
  transition: opacity 0.6s var(--ease-decel);
}

#remote-video.visible { opacity: 1; }

#remote-video:fullscreen {
  object-fit: contain;
  background: #000;
}

#local-video {
  position: absolute;
  bottom: 56px;
  right: 16px;
  width: 200px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: #000;
  z-index: 6;
  cursor: grab;
  touch-action: none;
  user-select: none;
  /* scaleX(-1) mirrors the self-view like a mirror - less disorienting for
     the user. Remote peers still see the unflipped camera feed (WebRTC sends
     the raw stream; this is a purely local CSS transform). Every JS transform
     assignment on this element must also include scaleX(-1). */
  transform: translate(0, 0) scaleX(-1);
  transition: transform 0.3s var(--ease-settle), opacity 0.2s, border-color 0.6s var(--ease-decel);
}

#local-video.in-call { border-color: rgba(200, 121, 65, 0.35); }
#local-video.dragging { cursor: grabbing; transition: none; }
#local-video.hidden-pip { opacity: 0; pointer-events: none; }

/* --- Recording LED --- */

#rec-led {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s var(--ease-decel);
}

#rec-led.active { opacity: 1; }

.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rec-dot);
  box-shadow: 0 0 4px rgba(220, 40, 40, 0.8), 0 0 8px rgba(220, 40, 40, 0.4);
  flex-shrink: 0;
}

#rec-led.active .rec-dot {
  animation: rec-breathe 2s ease-in-out infinite;
}

@keyframes rec-breathe {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px rgba(220,40,40,0.8), 0 0 8px rgba(220,40,40,0.4); }
  50% { opacity: 0.4; box-shadow: 0 0 2px rgba(220,40,40,0.4), 0 0 4px rgba(220,40,40,0.2); }
}

.rec-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: #ff4040;
}

.rec-time {
  font-size: 0.6rem;
  font-family: ui-monospace, 'SF Mono', monospace;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 0.05em;
}

/* --- Waiting --- */

#waiting {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

#waiting .call-name {
  font-size: clamp(1.5rem, 3.5vw, 2.8rem);
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  animation: name-breathe 4s ease-in-out infinite;
}

#waiting .waiting-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  margin-top: 1rem;
  opacity: 0.6;
}

@keyframes name-breathe {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.75; }
}

/* --- Controls (removed - all controls via /commands now) --- */
/* Button base styles kept for approval banner buttons */

/* ==========================================================
   Hardware button: translucent cap with LED glow from below
   ==========================================================
   Layers (back to front):
   1. button element = housing/bezel
   2. ::before = translucent cap with LED glow (radial gradient)
   3. ::after = specular highlight (top surface light catch)
   4. .btn-label = fixed text label
   ========================================================== */

button {
  /* Housing / bezel */
  position: relative;
  min-width: 80px;
  height: 56px;
  padding: 0 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #1a1714;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: var(--shadow-raised);
  transform: translateY(0);
  transition: transform 80ms, box-shadow 80ms;
  outline: none;
  overflow: hidden;

  /* LED glow colors - overridden per state */
  --led-glow-strong: transparent;
  --led-glow-mid: transparent;
  --led-glow-weak: transparent;
  --led-outer: transparent;
}

button:focus-visible {
  outline: 2px solid rgba(200, 160, 100, 0.6);
  outline-offset: 2px;
}

/* Translucent cap with LED glow */
button::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 8px;
  z-index: 0;

  background:
    /* LED glow bleeding through cap */
    radial-gradient(
      ellipse 60% 55% at 50% 58%,
      var(--led-glow-strong),
      var(--led-glow-mid) 40%,
      var(--led-glow-weak) 70%,
      transparent 100%
    ),
    /* Cap material: milky translucent plastic */
    linear-gradient(
      180deg,
      rgba(255,255,255,0.08) 0%,
      rgba(255,255,255,0.03) 100%
    );

  /* Fresnel edge darkening */
  box-shadow:
    inset 0 0 10px 3px rgba(0,0,0,0.3),
    inset 0 0 2px 1px rgba(0,0,0,0.15);

  /* Asymmetric transition: fast on (80ms), slower off (200ms) */
  transition: background 200ms var(--ease-decel),
              box-shadow 200ms var(--ease-decel);

  pointer-events: none;
}

/* Specular highlight on cap surface */
button::after {
  content: '';
  position: absolute;
  top: 5px;
  left: 12px;
  right: 12px;
  height: 12px;
  border-radius: 6px 6px 50% 50%;
  z-index: 1;
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.10) 0%,
    rgba(255,255,255,0.01) 100%
  );
  pointer-events: none;
  transition: opacity 80ms;
}

/* Button label sits above the cap layers */
button .btn-label {
  position: relative;
  z-index: 2;
  pointer-events: none;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

button:hover {
  box-shadow: 0 1px 0 rgba(255,248,230,0.10) inset, 0 3px 6px rgba(0,0,0,0.6), 0 1px 3px rgba(0,0,0,0.4);
}

/* Physical depression: 2px travel, cap sinks into housing */
button:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-pressed);
}

button:active::before {
  box-shadow:
    inset 0 0 12px 4px rgba(0,0,0,0.4),
    inset 0 0 3px 1px rgba(0,0,0,0.2);
}

button:active::after {
  opacity: 0.3;
}

/* --- LED ON state: fast turn-on --- */
button.led-on::before {
  transition: background 80ms var(--ease-decel),
              box-shadow 80ms var(--ease-decel);
  box-shadow:
    inset 0 0 8px 2px rgba(0,0,0,0.2),
    inset 0 0 1px 1px rgba(0,0,0,0.1),
    0 0 12px 2px var(--led-outer);
}

/* Toggle pressed: button stays down with sunk cap */
button.pressed {
  transform: translateY(2px);
  box-shadow: var(--shadow-pressed);
}

button.pressed::before {
  box-shadow:
    inset 0 0 12px 4px rgba(0,0,0,0.35),
    inset 0 0 3px 1px rgba(0,0,0,0.18);
}

button.pressed.led-on::before {
  box-shadow:
    inset 0 0 10px 3px rgba(0,0,0,0.25),
    inset 0 0 2px 1px rgba(0,0,0,0.12),
    0 0 12px 2px var(--led-outer);
}

button.pressed::after {
  opacity: 0.3;
}

/* Control-specific LED colors and toggle switch removed - controls now via /commands */

/* --- Status --- */

#status {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 16px;
  background: rgba(0, 0, 0, 0.4);
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  text-align: center;
  z-index: 2;
  pointer-events: none;
}

/* --- Screenshot shutter --- */

.screenshot-shutter {
  position: fixed;
  left: 0;
  right: 0;
  height: 0;
  background: #0a0808;
  pointer-events: none;
  z-index: 100;
}

.screenshot-shutter.top {
  top: 0;
  animation: shutter-close-open 0.55s var(--ease-standard) forwards;
}

.screenshot-shutter.bottom {
  bottom: 0;
  animation: shutter-close-open 0.55s var(--ease-standard) forwards;
}

@keyframes shutter-close-open {
  0% { height: 0; }
  35% { height: 52%; }
  50% { height: 52%; }
  100% { height: 0; }
}

/* --- Chat strip --- */

#chat-strip {
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  max-height: 200px;
  transition: max-height 0.3s var(--ease-decel);
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: transparent;
  pointer-events: none;
  border-radius: 6px 6px 0 0;
  cursor: text;
}
#chat-strip:has(#chat-messages:hover),
#chat-strip.chat-focused {
  max-height: 50vh;
}
#chat-strip.chat-focused {
  pointer-events: auto;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
  font-size: 1rem;
  line-height: 1.6;
  pointer-events: auto;
  max-width: min(65%, 800px);
  scrollbar-width: none;
  border-radius: 6px 6px 0 0;
  transition: background 0.2s var(--ease-decel);
}
#chat-strip:has(#chat-messages:hover) #chat-messages,
#chat-strip.chat-focused #chat-messages {
  background: rgba(0, 0, 0, 0.18);
}

#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Show scrollbar on hover */
#chat-strip:has(#chat-messages:hover) #chat-messages,
#chat-strip.chat-focused #chat-messages {
  scrollbar-width: thin;
}
#chat-strip:has(#chat-messages:hover) #chat-messages::-webkit-scrollbar,
#chat-strip.chat-focused #chat-messages::-webkit-scrollbar { width: 4px; }
#chat-strip:not(:has(#chat-messages:hover)):not(.chat-focused) #chat-messages::-webkit-scrollbar { width: 0; }

@keyframes chat-msg-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg {
  padding: 3px 14px;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  animation: chat-msg-enter 0.2s var(--ease-decel);
}

.chat-msg.self {
  background: none;
}

.chat-msg .chat-name {
  margin-right: 8px;
  font-weight: 600;
}

.chat-mention {
  background: rgba(200, 160, 80, 0.2);
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 600;
}

.chat-msg.system {
  background: none;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
  padding: 2px 14px;
}

.chat-msg a {
  color: var(--text-dim);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-msg a:hover { color: var(--text); }

/* File transfer messages */
.file-msg {
  position: relative;
  --file-progress: 0;
  overflow: hidden;
}
.file-msg::before {
  content: '';
  position: absolute;
  inset: 0;
  width: calc(var(--file-progress) * 100%);
  background: linear-gradient(
    90deg,
    rgba(232, 169, 96, 0.12) 0%,
    rgba(232, 169, 96, 0.07) 85%,
    transparent 100%
  );
  border-radius: 2px;
  transition: width 0.15s ease-out;
  pointer-events: none;
  z-index: -1;
}
.file-msg.file-done::before {
  opacity: 0;
  transition: width 0.15s ease-out, opacity 0.4s ease-out 0.1s;
}
.file-name { color: var(--text); }
.file-meta { color: var(--text-muted); }
.file-status { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.file-complete { color: #7bc47f; }
.file-failed { color: #c47b7b; }
.file-download {
  color: #6bb8d6;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.file-download:hover { color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .file-msg::before { transition: none; }
}

/* Drop zone feedback
 *
 * Two layers:
 *   ::before  = corner attractor glow (radial gradient from bottom-left)
 *   ::after   = chat strip highlight bar (thin amber line above the input)
 *
 * Only opacity and transform are animated to keep the browser in the
 * compositor pipeline - no layout repaints, no backdrop-filter.
 */

#videos::before {
  content: '';
  position: absolute;
  /* Full width so the gradient can track the mouse across the viewport */
  left: -10%;
  bottom: -10%;
  width: 100%;
  height: 70%;
  background: radial-gradient(
    ellipse at var(--drop-x, 18%) 82%,
    rgba(232, 169, 96, 0.22) 0%,
    rgba(200, 130, 60, 0.12) 28%,
    rgba(180, 110, 40, 0.05) 55%,
    transparent 75%
  );
  pointer-events: none;
  z-index: 7;
  opacity: 0;
  transform: scale(0.88);
  transition: opacity 0.35s var(--ease-decel),
              transform 0.35s var(--ease-decel);
}

/* The amber bar that sits just above the chat input */
#videos::after {
  content: '';
  position: absolute;
  bottom: 24px; /* aligns with chat-strip bottom offset */
  /* Bar shifts to loosely follow the glow - clamped via calc so it never exits */
  left: calc((var(--drop-x, 18%) - 18%) * 0.35);
  width: min(65%, 800px);
  height: 1px;
  background: linear-gradient(
    90deg,
    rgba(232, 169, 96, 0.0) 0%,
    rgba(232, 169, 96, 0.55) 35%,
    rgba(232, 169, 96, 0.55) 65%,
    rgba(232, 169, 96, 0.0) 100%
  );
  pointer-events: none;
  z-index: 7;
  opacity: 0;
  transform: scaleX(0.6);
  transform-origin: left center;
  transition: opacity 0.3s var(--ease-decel),
              transform 0.3s var(--ease-decel);
}

/* Active drag: attractor glows and breathes, bar slides in */
#videos.drop-active::before {
  opacity: 1;
  transform: scale(1);
  animation: drop-breathe 1.8s ease-in-out infinite;
}

#videos.drop-active::after {
  opacity: 1;
  transform: scaleX(1);
}

@keyframes drop-breathe {
  0%, 100% { opacity: 0.75; }
  50%       { opacity: 1;    }
}

/* Release flash: collapse attractor to the chat strip */
#videos.drop-release::before {
  opacity: 0;
  transform: scale(0.5) translate(-8%, 8%);
  transition: opacity 0.3s var(--ease-standard),
              transform 0.3s var(--ease-standard);
  animation: none;
}

#videos.drop-release::after {
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left center;
  transition: opacity 0.25s var(--ease-standard),
              transform 0.25s var(--ease-standard);
}

@media (prefers-reduced-motion: reduce) {
  #videos::before,
  #videos::after { transition-duration: 0.01ms !important; animation: none !important; }
}

#input-wrapper {
  position: relative;
  flex-shrink: 0;
}

#ghost-text {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
  font-size: 18px;
  padding: 12px 14px;
  line-height: normal;
  white-space: nowrap;
  overflow: hidden;
  color: transparent;
}
#ghost-text .ghost-suffix {
  color: rgba(200, 180, 160, 0.35);
}

#chat-input {
  position: relative;
  width: 100%;
  border: none;
  background: rgba(0, 0, 0, 0.15);
  color: var(--text);
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
  font-size: 18px;
  padding: 12px 14px;
  outline: none;
  pointer-events: auto;
  transition: background 0.2s var(--ease-decel);
}

#chat-input::placeholder { color: rgba(255, 255, 255, 0.25); }

#chat-input:focus {
  background: rgba(0, 0, 0, 0.45);
  outline: none;
}

/* Hover tint on input matches the strip hover */
#chat-strip:has(#chat-messages:hover) #chat-input {
  background: rgba(0, 0, 0, 0.3);
}
#chat-strip:has(#chat-messages:hover) #chat-input:focus {
  background: rgba(0, 0, 0, 0.45);
}

/* Input mode indicators */
#chat-input.mode-command {
  border-left: 2px solid rgba(232, 169, 96, 0.6);
  caret-color: #e8a960;
}
#chat-input.mode-help {
  border-left: 2px solid rgba(138, 125, 112, 0.6);
  caret-color: #a89880;
}
#chat-input.mode-mention {
  border-left: 2px solid rgba(107, 216, 184, 0.6);
  caret-color: #6bd8b8;
}

#tab-hint {
  flex-shrink: 0;
  padding: 2px 14px;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
  font-size: 0.85rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  max-width: min(65%, 800px);
}

#cmd-panel {
  position: absolute;
  bottom: 100%;
  left: 0;
  pointer-events: auto;
  background: rgba(17, 14, 12, 0.92);
  border: 1px solid var(--border);
  border-radius: 4px;
  max-height: 200px;
  overflow-y: auto;
  margin: 0 8px 4px 8px;
  max-width: min(65%, 800px);
  z-index: 6;
}
#cmd-panel .cmd-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 14px;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
  font-size: 0.95rem;
  cursor: default;
}
#cmd-panel .cmd-row .cmd-name {
  color: #e8a960;
  white-space: nowrap;
}
#cmd-panel .cmd-row .cmd-hint {
  color: var(--text-dim);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#cmd-panel .cmd-row.selected {
  background: rgba(255, 255, 255, 0.06);
}
#cmd-panel .cmd-row .cmd-match {
  color: var(--text);
}
#cmd-panel .cmd-row .cmd-alias {
  color: var(--text-muted);
  font-size: 0.8rem;
}
#cmd-panel .cmd-row .cmd-args {
  color: var(--text-dim);
  opacity: 0.6;
}

/* --- Pending overlay (guest waiting for approval) --- */

#pending-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  flex-direction: column;
  gap: 1rem;
}

#pending-overlay.active { display: flex; }

#pending-overlay .pending-text {
  font-size: 1.1rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}

#pending-overlay .pending-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--text-dim);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Approval banner (host approves/denies guests) --- */

#approval-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: none;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

#approval-banner.active { display: flex; }

#approval-banner .approval-text {
  font-size: 0.85rem;
  color: var(--text);
}

#approval-banner button {
  min-width: 70px;
  height: 40px;
  font-size: 0.75rem;
}

#approval-banner .btn-approve {
  --led-glow-strong: rgba(74, 222, 128, 0.5);
  --led-glow-mid: rgba(74, 222, 128, 0.2);
  --led-glow-weak: rgba(74, 222, 128, 0.03);
  --led-outer: rgba(74, 222, 128, 0.15);
}

#approval-banner .btn-deny {
  --led-glow-strong: rgba(204, 68, 68, 0.42);
  --led-glow-mid: rgba(204, 68, 68, 0.18);
  --led-glow-weak: rgba(204, 68, 68, 0.03);
  --led-outer: rgba(204, 68, 68, 0.15);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  #rec-led.active .rec-dot { animation: none; }
  #waiting .call-name { animation: none; opacity: 0.6; }
  #remote-video { transition: none; }
  #local-video { transition: none; }
  button { transition: none; }
  button::before { transition-duration: 0.01ms !important; }
  button::after { transition: none; }
  .screenshot-shutter { animation-duration: 0.01ms !important; }
  .chat-msg { transition: none; animation: none; }
  #chat-input { transition: none; }
}

@media (max-width: 768px) {
  #chat-messages, #cmd-panel, #tab-hint { max-width: none; }
  #chat-strip { left: 0; right: 0; }
}
