:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #eef3f4;
  --line: #d7e0e2;
  --ink: #172024;
  --muted: #68777d;
  --blue: #1769e0;
  --green: #158452;
  --red: #c93434;
  --amber: #a66a00;
  --shadow: 0 18px 45px rgba(31, 47, 55, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: env(safe-area-inset-top) 18px env(safe-area-inset-bottom);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1320px;
  margin: 0 auto;
  padding: 14px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #10181d;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(17, 27, 32, 0.18);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.16;
  max-width: min(52vw, 360px);
  overflow-wrap: anywhere;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.badge,
.timer {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 4px 11px;
  font-size: 13px;
  font-weight: 700;
}

.badge.ready {
  border-color: rgba(21, 132, 82, 0.28);
  color: var(--green);
}

.badge.warn {
  border-color: rgba(166, 106, 0, 0.28);
  color: var(--amber);
}

.badge.error {
  border-color: rgba(201, 52, 52, 0.28);
  color: var(--red);
}

.badge.muted {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
  min-height: calc(100vh - 76px);
}

.stage,
.side-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stage {
  position: relative;
  display: grid;
  grid-template-rows: minmax(360px, 1fr) auto;
  overflow: hidden;
  min-width: 0;
  min-height: 620px;
}

.ai-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  min-height: 0;
  padding: 32px 32px 112px;
  background:
    linear-gradient(130deg, rgba(23, 105, 224, 0.10), transparent 34%),
    linear-gradient(220deg, rgba(21, 132, 82, 0.10), transparent 34%),
    #f8fbfc;
}

.ai-pane::before {
  content: "";
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(23, 32, 36, 0.06);
  border-radius: 8px;
  pointer-events: none;
}

.ai-orb {
  --voice-level: 0;
  --voice-jitter-x: 0;
  --voice-jitter-y: 0;
  position: relative;
  display: grid;
  place-items: center;
  width: min(34vw, 280px);
  min-width: 168px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.20), transparent 18%),
    radial-gradient(circle at 50% 50%, #1d2a30 0%, #111b20 62%, #0b1115 100%);
  color: white;
  box-shadow:
    0 24px 60px rgba(17, 27, 32, 0.24),
    0 0 calc(20px + var(--voice-level) * 44px) rgba(23, 105, 224, calc(0.10 + var(--voice-level) * 0.28));
  transform: translate3d(calc(var(--voice-jitter-x) * 1px), calc(var(--voice-jitter-y) * 1px), 0)
    scale(calc(1 + var(--voice-level) * 0.055));
  transition: transform 90ms linear, box-shadow 90ms linear, background 140ms ease;
}

.ai-orb::before {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  background: conic-gradient(from 90deg, rgba(68, 208, 255, 0.0), rgba(68, 208, 255, 0.52), rgba(69, 210, 126, 0.34), rgba(68, 208, 255, 0.0));
  opacity: calc(0.24 + var(--voice-level) * 0.42);
  filter: blur(2px);
  animation: orbSweep 5s linear infinite;
}

.orb-ring {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, calc(0.16 + var(--voice-level) * 0.36));
  border-radius: 50%;
  box-shadow: 0 0 calc(5px + var(--voice-level) * 18px) rgba(64, 180, 255, calc(0.10 + var(--voice-level) * 0.22));
  animation: voicePulse 2.4s ease-in-out infinite;
}

.ring-one {
  inset: calc(17% - var(--voice-level) * 8%);
  animation-delay: 0s;
}

.ring-two {
  inset: 30%;
  animation-delay: 0.34s;
}

.ring-three {
  inset: calc(42% + var(--voice-level) * 2%);
  animation-delay: 0.68s;
}

.ai-orb strong {
  position: relative;
  z-index: 2;
  font-size: 48px;
  line-height: 1;
  text-shadow: 0 0 calc(8px + var(--voice-level) * 26px) rgba(255, 255, 255, calc(0.22 + var(--voice-level) * 0.46));
  transition: opacity 160ms ease;
}

.ai-orb.emoji-ready strong {
  opacity: 0;
}

.ai-emoji {
  position: absolute;
  z-index: 3;
  width: 74%;
  height: 74%;
  object-fit: contain;
  opacity: 0;
  filter: drop-shadow(0 13px 18px rgba(6, 12, 16, 0.32));
  transform: translateY(0) scale(calc(0.96 + var(--voice-level) * 0.06));
  transition: opacity 180ms ease, filter 180ms ease;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.ai-orb.emoji-ready .ai-emoji {
  opacity: 1;
}

.ai-orb[data-expression-group="listening"] .ai-emoji {
  animation: emojiListen 1.1s ease-in-out infinite;
}

.ai-orb[data-expression-group="thinking"] .ai-emoji {
  animation: emojiThink 1.55s ease-in-out infinite;
}

.ai-orb[data-expression-group="happy"] .ai-emoji {
  animation: emojiHappy 0.92s ease-in-out infinite;
}

.ai-orb[data-expression-group="serious"] .ai-emoji {
  animation: emojiSerious 1.2s ease-in-out infinite;
}

.ai-orb[data-expression-group="surprised"] .ai-emoji {
  animation: emojiSurprised 0.7s ease-in-out infinite;
}

.ai-orb[data-expression-group="error"] .ai-emoji {
  animation: emojiError 0.88s ease-in-out infinite;
}

.ai-orb[data-expression-group="sleepy"] .ai-emoji {
  animation: emojiSleepy 1.8s ease-in-out infinite;
}

.ai-orb[data-speaking="1"] .ai-emoji {
  filter: drop-shadow(0 12px 20px rgba(40, 124, 255, 0.36));
}

.stage.connected .ai-orb span {
  animation-duration: 1.5s;
}

.stage.speaking .ai-orb {
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.26), transparent 20%),
    radial-gradient(circle at 50% 50%, #1769e0 0%, #13408c 64%, #10181d 100%);
}

@keyframes voicePulse {
  0%,
  100% {
    transform: scale(calc(0.94 + var(--voice-level) * 0.08));
    opacity: calc(0.62 + var(--voice-level) * 0.28);
  }
  50% {
    transform: scale(calc(1.08 + var(--voice-level) * 0.16));
    opacity: calc(0.20 + var(--voice-level) * 0.30);
  }
}

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

@keyframes emojiListen {
  0%,
  100% {
    transform: translateY(0) scale(calc(0.96 + var(--voice-level) * 0.06));
  }
  50% {
    transform: translateY(-4px) scale(calc(0.99 + var(--voice-level) * 0.08));
  }
}

@keyframes emojiThink {
  0%,
  100% {
    transform: rotate(-3deg) translateY(0) scale(calc(0.96 + var(--voice-level) * 0.06));
  }
  50% {
    transform: rotate(3deg) translateY(-3px) scale(calc(0.98 + var(--voice-level) * 0.07));
  }
}

@keyframes emojiHappy {
  0%,
  100% {
    transform: translateY(0) scale(calc(0.98 + var(--voice-level) * 0.08));
  }
  45% {
    transform: translateY(-8px) scale(calc(1.03 + var(--voice-level) * 0.10));
  }
}

@keyframes emojiSerious {
  0%,
  100% {
    transform: translateX(-1px) scale(calc(0.96 + var(--voice-level) * 0.05));
  }
  50% {
    transform: translateX(1px) scale(calc(0.98 + var(--voice-level) * 0.06));
  }
}

@keyframes emojiSurprised {
  0%,
  100% {
    transform: scale(calc(0.98 + var(--voice-level) * 0.06));
  }
  50% {
    transform: scale(calc(1.08 + var(--voice-level) * 0.10));
  }
}

@keyframes emojiError {
  0%,
  100% {
    transform: translateX(0) rotate(0deg) scale(calc(0.96 + var(--voice-level) * 0.04));
  }
  35% {
    transform: translateX(-5px) rotate(-4deg) scale(calc(0.98 + var(--voice-level) * 0.06));
  }
  70% {
    transform: translateX(5px) rotate(4deg) scale(calc(0.98 + var(--voice-level) * 0.06));
  }
}

@keyframes emojiSleepy {
  0%,
  100% {
    transform: translateY(1px) scale(0.95);
    opacity: 0.92;
  }
  50% {
    transform: translateY(5px) scale(0.93);
    opacity: 0.78;
  }
}

.live-captions {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 8px;
  width: min(760px, 100%);
  border: 1px solid rgba(23, 32, 36, 0.10);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 10px 12px;
  box-shadow: 0 18px 45px rgba(31, 47, 55, 0.10);
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.live-captions:hover {
  border-color: rgba(23, 105, 224, 0.28);
}

.live-captions:focus-visible {
  outline: 3px solid rgba(23, 105, 224, 0.20);
  outline-offset: 3px;
}

.live-caption-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 34px;
}

.live-caption-row span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  background: #eef3ff;
  color: #405678;
  font-size: 12px;
  font-weight: 900;
}

.live-caption-row p {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-caption-row p.placeholder {
  color: var(--muted);
  font-weight: 700;
}

.ai-meta {
  position: absolute;
  left: 30px;
  right: 30px;
  bottom: 28px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
}

.ai-meta p,
.ai-meta small {
  margin: 0;
}

.ai-meta p {
  font-size: 16px;
  font-weight: 800;
}

.ai-meta small {
  max-width: 420px;
  color: var(--muted);
  text-align: right;
}

.local-tile {
  position: absolute;
  right: 22px;
  top: 22px;
  width: min(32vw, 330px);
  min-width: 210px;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  background: #182329;
  box-shadow: 0 14px 36px rgba(17, 27, 32, 0.25);
}

video,
canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#localVideo {
  object-fit: cover;
  transform: scaleX(-1);
}

#frameCanvas {
  display: none;
}

.local-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 8px 10px;
  color: white;
  font-size: 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
}

.meter {
  width: 42px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  overflow: hidden;
  flex: 0 0 auto;
}

.meter i {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: #45d27e;
  transition: width 120ms linear;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 86px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  padding: 14px;
}

.icon-btn,
.primary-btn,
.danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.icon-btn {
  width: 46px;
  padding: 0;
}

.primary-btn,
.danger-btn {
  padding: 0 20px;
}

.primary-btn {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.danger-btn {
  border-color: rgba(201, 52, 52, 0.35);
  color: var(--red);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.icon {
  position: relative;
  display: block;
  width: 22px;
  height: 22px;
}

.icon.mic::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 2px;
  width: 8px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.icon.mic::after {
  content: "";
  position: absolute;
  left: 4px;
  bottom: 2px;
  width: 14px;
  height: 10px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid transparent;
  border-right: 2px solid transparent;
  border-radius: 0 0 10px 10px;
}

.icon.camera::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 6px;
  width: 13px;
  height: 11px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.icon.camera::after {
  content: "";
  position: absolute;
  right: 1px;
  top: 8px;
  border-left: 7px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.icon.settings::before,
.icon.settings::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon.settings::after {
  inset: 0;
  border-style: dashed;
}

.icon.panel::before,
.icon.panel::after {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.icon.panel::before {
  top: 4px;
  height: 5px;
}

.icon.panel::after {
  bottom: 4px;
  height: 9px;
}

.icon-btn.off {
  color: var(--red);
  background: #fff1f1;
  border-color: rgba(201, 52, 52, 0.28);
}

.panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(12, 18, 22, 0.28);
  opacity: 0;
  transition: opacity 180ms ease;
}

.panel-backdrop.open {
  opacity: 1;
}

.side-panel {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 76px);
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  z-index: 40;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(420px, calc(100vw - 36px));
  overflow: hidden;
  min-height: 0;
  max-height: calc(100vh - 76px);
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(100% + 30px));
  transition: transform 220ms ease, opacity 180ms ease;
}

.side-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.tab {
  min-height: 48px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
}

.tab:last-child {
  border-right: 0;
}

.tab.active {
  color: var(--ink);
  background: var(--surface-2);
}

.panel-close {
  display: grid;
  place-items: center;
  width: 48px;
  min-height: 48px;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 25px;
  line-height: 1;
}

.panel-close:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.panel-view {
  display: none;
  min-height: 0;
  overflow: hidden;
  padding: 16px;
}

.panel-view.active {
  display: block;
}

#chatTab.active {
  display: grid;
}

#settingsTab.active,
#eventsTab.active {
  overflow-y: auto;
}

.caption-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  height: 100%;
}

.caption-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
  padding: 12px;
}

.caption-header strong,
.caption-header span {
  display: block;
}

.caption-header strong {
  margin-bottom: 4px;
  font-size: 15px;
}

.caption-header span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.caption-count {
  flex: 0 0 auto;
  min-width: 54px;
  border: 1px solid rgba(23, 105, 224, 0.18);
  border-radius: 999px;
  background: #f3f7ff;
  color: var(--blue) !important;
  padding: 4px 8px;
  text-align: center;
  font-weight: 800;
}

.scroll-progress {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf0;
}

.scroll-progress i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 120ms linear;
}

.transcript,
.event-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.transcript {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-color: #9fb3bc #edf2f4;
  scrollbar-width: thin;
}

.transcript::-webkit-scrollbar,
.event-log::-webkit-scrollbar {
  width: 9px;
}

.transcript::-webkit-scrollbar-thumb,
.event-log::-webkit-scrollbar-thumb {
  border: 2px solid #edf2f4;
  border-radius: 999px;
  background: #9fb3bc;
}

.transcript::-webkit-scrollbar-track,
.event-log::-webkit-scrollbar-track {
  background: #edf2f4;
}

.event-log {
  max-height: 100%;
  overflow-y: auto;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
}

.message.user {
  border-color: rgba(23, 105, 224, 0.22);
  background: #f3f7ff;
}

.message.assistant {
  border-color: rgba(21, 132, 82, 0.20);
  background: #f2fbf6;
}

.message .role {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.message p {
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.toggle-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.toggle-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.toggle-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--blue);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(23, 105, 224, 0.62);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.12);
}

.event-item {
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .stage {
    min-height: 560px;
  }

  .side-panel {
    top: auto;
    right: 12px;
    bottom: calc(env(safe-area-inset-bottom) + 12px);
    left: 12px;
    width: auto;
    height: min(72vh, 560px);
    min-height: 0;
    max-height: none;
    transform: translateY(calc(100% + 28px));
  }

  .side-panel.open {
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 10px 0;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  h1 {
    font-size: 16px;
    max-width: 210px;
  }

  .brand p {
    max-width: 210px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .status-cluster {
    gap: 6px;
  }

  .badge {
    display: none;
  }

  .timer {
    min-height: 28px;
    padding: 3px 9px;
  }

  .stage {
    grid-template-rows: minmax(390px, 1fr) auto;
    min-height: calc(100vh - 92px);
  }

  .ai-pane {
    gap: 18px;
    padding: 74px 18px 112px;
  }

  .ai-pane::before {
    inset: 12px;
  }

  .ai-orb {
    width: min(56vw, 220px);
    min-width: 150px;
  }

  .ai-orb strong {
    font-size: 38px;
  }

  .live-captions {
    width: 100%;
    padding: 9px 10px;
  }

  .live-caption-row {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 9px;
    min-height: 32px;
  }

  .live-caption-row p {
    font-size: 14px;
  }

  .ai-meta {
    left: 18px;
    right: 18px;
    bottom: 18px;
    display: block;
  }

  .ai-meta p {
    font-size: 15px;
  }

  .ai-meta small {
    display: block;
    margin-top: 5px;
    text-align: left;
  }

  .local-tile {
    top: 14px;
    right: 14px;
    width: 38vw;
    min-width: 132px;
  }

  .controls {
    display: grid;
    grid-template-columns: 40px 40px minmax(0, 1fr) minmax(48px, auto);
    gap: 6px;
    min-height: 78px;
    padding: 10px;
  }

  #panelBtn,
  #settingsBtn {
    display: none;
  }

  .icon-btn,
  .primary-btn,
  .danger-btn {
    min-height: 42px;
    border-radius: 8px;
  }

  .icon-btn {
    width: 40px;
  }

  .primary-btn,
  .danger-btn {
    padding: 0 10px;
    font-size: 13px;
  }

  .side-panel {
    height: min(76vh, 520px);
  }
}

@media (max-width: 360px) {
  .controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .icon-btn {
    width: 100%;
  }
}
