:root {
  color-scheme: dark;
  --bg: #0b0c0f;
  --panel: rgba(22, 24, 28, 0.76);
  --panel-strong: rgba(30, 34, 39, 0.92);
  --line: rgba(214, 230, 238, 0.14);
  --text: #eef3f5;
  --muted: #95a1a8;
  --cyan: #98eaff;
  --blue: #6aa7ff;
  --green: #88f0bd;
  --amber: #ffc977;
  --red: #ff796d;
  --violet: #c1a5ff;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #0b0c0f;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 22% 16%, rgba(92, 120, 132, 0.26), transparent 32%),
    linear-gradient(135deg, #0a0b0d 0%, #111418 48%, #08090b 100%);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  touch-action: manipulation;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 18px;
}

.stage-panel,
.control-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.32);
}

.stage-panel {
  position: relative;
  display: grid;
  min-width: 0;
  overflow: hidden;
  border-radius: 8px;
  place-items: center;
}

.status-strip {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 12, 14, 0.58);
  color: #d9e4e8;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 18px currentColor;
}

.face-stage {
  position: relative;
  width: min(82vw, 1180px);
  max-width: calc(100vw - 430px);
  aspect-ratio: 1448 / 1086;
}

.face-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
  background: transparent;
}

.face-media.is-hidden {
  display: none;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 20px;
  border-radius: 8px;
}

.panel-heading p,
.current-card span,
.control-group h2 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel-heading h1 {
  margin: 6px 0 0;
  font-size: 24px;
  line-height: 1.15;
}

.current-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.current-card strong {
  font-size: 18px;
  line-height: 1.25;
}

.control-group {
  display: grid;
  gap: 10px;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.expression-button,
.command-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  cursor: pointer;
}

.expression-button {
  display: grid;
  align-items: center;
  justify-items: start;
  padding: 0 12px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.expression-button:hover,
.command-button:hover {
  border-color: rgba(152, 234, 255, 0.48);
  background: rgba(152, 234, 255, 0.12);
}

.expression-button.is-active,
.command-button.is-active {
  border-color: color-mix(in srgb, var(--accent) 74%, white 8%);
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.timeline {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.timeline-item {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.timeline-item::before {
  width: 8px;
  height: 8px;
  margin-left: 5px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.timeline-item.is-active {
  color: var(--accent);
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    min-height: auto;
    padding:
      max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .stage-panel {
    position: sticky;
    top: max(10px, env(safe-area-inset-top));
    z-index: 10;
    min-height: auto;
  }

  .face-stage {
    width: 100%;
    max-width: none;
  }

  .control-panel {
    gap: 14px;
  }

  .expression-button,
  .command-button {
    min-height: 48px;
    font-size: 16px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    gap: 10px;
  }

  .control-panel {
    padding: 14px;
  }

  .panel-heading h1 {
    font-size: 22px;
  }

  .current-card strong {
    font-size: 17px;
  }

  .button-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .expression-button {
    min-height: 44px;
    padding: 0 10px;
    font-size: 15px;
  }

  .timeline {
    display: none;
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr) 320px;
    min-height: 100dvh;
  }

  .face-stage {
    max-width: none;
  }

  .button-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timeline {
    display: none;
  }
}
