:root {
  color-scheme: dark;
  --panel: rgba(8, 11, 15, 0.91);
  --panel-border: rgba(255, 255, 255, 0.15);
  --text: #f4f2ed;
  --muted: #aaa9a5;
  --green: #00ff00;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--green);
}

body {
  min-height: 100svh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select { font: inherit; }

button { color: inherit; }

.app,
.stage {
  position: relative;
  width: 100vw;
  height: 100svh;
  overflow: hidden;
  background: var(--green);
}

.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.video-stack {
  position: relative;
  width: min(100vw, calc(100svh * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--green);
}

.app.fill-frame .video-stack {
  width: 100vw;
  height: 100svh;
  aspect-ratio: auto;
}

.character-video {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--green);
  opacity: 0;
  pointer-events: none;
  transition: opacity 520ms ease-in-out;
  will-change: opacity;
}

.app.fill-frame .character-video { object-fit: cover; }

.character-video.is-visible {
  z-index: 2;
  opacity: 1;
}

.start-panel {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  padding: 24px;
  place-items: center;
  background: rgba(3, 4, 5, 0.6);
  backdrop-filter: blur(14px);
  transition: opacity 240ms ease, visibility 240ms ease;
}

.start-panel.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.start-card {
  width: min(440px, 100%);
  padding: 30px;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(22, 25, 30, 0.97), rgba(8, 10, 13, 0.96));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.54);
  text-align: center;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  color: #b7b2aa;
  font-size: 0.75rem;
  font-weight: 760;
  letter-spacing: 0.17em;
}

.start-card h1,
.panel h2 {
  margin: 0;
  font-weight: 720;
  letter-spacing: -0.035em;
}

.start-card h1 { font-size: clamp(1.9rem, 7vw, 2.7rem); }

.start-card p:not(.eyebrow) {
  margin: 14px auto 22px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.58;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  border-color: rgba(255, 255, 255, 0.25);
  background: #e6e1d8;
  color: #090b0e;
  font-weight: 750;
}

.primary-button:disabled { cursor: wait; opacity: 0.48; }
.button-icon { color: #9b2d2d; font-size: 0.72rem; }
.start-card .start-hint { margin-bottom: 0; font-size: 0.84rem; }

.primary-button:not(:disabled):hover,
.secondary-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.34);
}

.loading-badge,
.status-bar,
.control-dock {
  position: absolute;
  z-index: 11;
  border: 1px solid var(--panel-border);
  background: rgba(7, 9, 12, 0.8);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(16px);
}

.loading-badge {
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  padding: 9px 13px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.82rem;
  transform: translateX(-50%);
}

.loading-badge.is-hidden { display: none; }

.status-bar {
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(390px, calc(100vw - 28px));
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.84rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #686b71;
  box-shadow: 0 0 0 4px rgba(104, 107, 113, 0.14);
}

.status-dot.is-live {
  background: #b9d4bd;
  box-shadow: 0 0 0 4px rgba(185, 212, 189, 0.14);
}

.status-dot.is-speaking {
  background: #fff;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.16);
}

.meter {
  width: 78px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.11);
}

.meter-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #e6e1d8;
  transition: width 70ms linear;
}

.control-dock {
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 16px;
}

.icon-button,
.close-button {
  border: 0;
  cursor: pointer;
  background: transparent;
}

.icon-button {
  min-width: 58px;
  min-height: 42px;
  padding: 0 10px;
  border-radius: 11px;
  color: #b9b7b2;
  font-size: 0.68rem;
  font-weight: 780;
  letter-spacing: 0.08em;
}

.icon-button:hover,
.icon-button.is-active { background: rgba(255, 255, 255, 0.1); color: #fff; }

.panel {
  position: absolute;
  z-index: 30;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 62px);
  width: min(410px, calc(100vw - 28px));
  max-height: min(650px, calc(100svh - 110px));
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(24px);
}

.panel[hidden] { display: none; }

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel h2 { font-size: 1.55rem; }

.close-button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 1.65rem;
}

.close-button:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }

.field {
  display: grid;
  gap: 10px;
  margin: 18px 0;
  color: #d5d2cc;
  font-size: 0.9rem;
}

.field > span { display: flex; justify-content: space-between; gap: 12px; }
.field output { color: var(--muted); }
input[type="range"] { width: 100%; accent-color: #d7d1c7; }

select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 11px;
  background: #11151a;
  color: var(--text);
}

.secondary-button {
  width: 100%;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.06);
  color: #dfdcd6;
}

.panel-note {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.48;
}

kbd {
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: #dedad2;
  font-size: 0.72rem;
}

.toast {
  position: absolute;
  z-index: 50;
  bottom: 84px;
  left: 50%;
  max-width: min(440px, calc(100vw - 32px));
  padding: 11px 15px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: rgba(8, 10, 13, 0.94);
  color: #e8e4dc;
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 170ms ease, transform 170ms ease;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.app.clean-ui .status-bar,
.app.clean-ui .control-dock,
.app.clean-ui .panel,
.app.clean-ui .loading-badge { display: none !important; }

.app.clean-ui .toast { display: none !important; }

@media (max-width: 640px) {
  .control-dock { right: 50%; transform: translateX(50%); }
  .icon-button { min-width: 55px; padding-inline: 7px; font-size: 0.62rem; }
  .status-bar { right: 14px; left: 14px; justify-content: center; }
  .panel { right: 14px; left: 14px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .character-video { transition-duration: 1ms; }
}
