/* ===== Focus Room — Refined UI ===== */

:root {
  color: #e2e8f0;
  background: #0b1120;
  font-family:
    "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #0b1120;
}

/* --- Base controls --- */

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.72);
  color: #e2e8f0;
  height: 40px;
  border-radius: 10px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(6px);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.01em;
}

button:hover:not(:disabled) {
  border-color: var(--room);
  background: rgba(30, 41, 59, 0.88);
  box-shadow: 0 0 20px color-mix(in srgb, var(--room), transparent 82%);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

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

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.55);
  color: #f1f5f9;
  padding: 0 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--room);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--room), transparent 82%);
}

label {
  display: grid;
  gap: 6px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* --- App layout --- */

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-rows: minmax(440px, 58vh) minmax(330px, 42vh);
  gap: 1px;
  background: rgba(148, 163, 184, 0.12);
}

.app.productMode {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 100vh;
}

.stage,
.side,
.chat {
  background: #0f1729;
}

/* --- Stage --- */

.stage {
  position: relative;
  overflow: hidden;
}

.productMode .stage {
  min-height: 100vh;
}

.startMode .stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(11, 17, 32, 0.88) 0%, rgba(15, 23, 42, 0.42) 45%, rgba(15, 23, 42, 0.08) 100%),
    linear-gradient(180deg, rgba(11, 17, 32, 0.04) 0%, rgba(11, 17, 32, 0.62) 100%);
}

/* --- Start screen --- */

.startTop {
  position: absolute;
  top: 28px;
  left: 32px;
  z-index: 4;
}

.startTop strong {
  display: block;
  color: #f1f5f9;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.startHero {
  position: absolute;
  left: clamp(28px, 7vw, 96px);
  bottom: clamp(72px, 13vh, 132px);
  z-index: 4;
  width: min(560px, calc(100vw - 56px));
}

.startHero h1 {
  font-size: clamp(48px, 8vw, 100px);
  line-height: 0.9;
  max-width: 8ch;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #f8fafc 30%, var(--room));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.startMeta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 28px 0 32px;
}

.startMeta span {
  height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.5);
  backdrop-filter: blur(8px);
  color: #94a3b8;
  padding: 0 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.startFlowPanel {
  width: min(420px, 100%);
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.56);
  backdrop-filter: blur(12px);
}

.startFlowPanel label,
.startFlowPanel .flowField {
  display: grid;
  gap: 5px;
  color: #93c5fd;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.flowPanelHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 800;
}

.flowPanelHead button {
  min-height: 28px;
  border: 1px solid rgba(125, 211, 252, 0.35);
  border-radius: 8px;
  background: rgba(14, 165, 233, 0.12);
  color: #e0f2fe;
  font-size: 11px;
  font-weight: 900;
  padding: 0 10px;
}

.startFlowPanel input,
.startFlowPanel select,
.startFlowPanel textarea {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  color: #e2e8f0;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  padding: 9px 10px;
  outline: none;
  resize: vertical;
}

.flowChecklist {
  max-height: 118px;
  overflow: auto;
  display: grid;
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.64);
}

.startFlowPanel .flowChoice {
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: #dbeafe;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
}

.flowChoice input[type="checkbox"] {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  padding: 0;
  accent-color: #7dd3fc;
}

.flowChoice span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.startFlowPanel p {
  margin: 0;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
}

.startButton {
  height: 54px;
  min-width: 200px;
  border: 1px solid color-mix(in srgb, var(--room), white 28%);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--room), #0b1120 52%),
    color-mix(in srgb, var(--room), #0b1120 68%));
  color: #f8fafc;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
  border-radius: 14px;
  box-shadow:
    0 20px 60px color-mix(in srgb, var(--room), transparent 72%),
    0 0 40px color-mix(in srgb, var(--room), transparent 88%),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.startButton:hover {
  transform: translateY(-2px);
  box-shadow:
    0 24px 72px color-mix(in srgb, var(--room), transparent 62%),
    0 0 56px color-mix(in srgb, var(--room), transparent 78%),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.startStatus {
  position: absolute;
  right: 32px;
  bottom: 32px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.startStatus span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.7);
  animation: pulse 2.4s ease-in-out infinite;
}

.startStatus p {
  margin: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* --- 3D Scene container --- */

.scene {
  position: absolute;
  inset: 0;
}

.threeScene,
.cssScene {
  position: absolute;
  inset: 0;
  perspective: 900px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 65% 25%, color-mix(in srgb, var(--accent), transparent 42%), transparent 32%),
    radial-gradient(ellipse at 25% 50%, color-mix(in srgb, var(--room), transparent 52%), transparent 34%),
    radial-gradient(ellipse at 50% 90%, rgba(11, 17, 32, 0.9), transparent 60%),
    linear-gradient(180deg, #141e30 0%, #1a2744 50%, #0f1729 100%);
}

.threeScene canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.cssScene > * {
  position: absolute;
  transform-style: preserve-3d;
}

/* --- CSS room elements (fallback) --- */

.wall {
  inset: 0 0 32%;
  background:
    linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(148, 163, 184, 0.04) 1px, transparent 1px),
    rgba(15, 23, 42, 0.48);
  background-size: 58px 58px;
}

.floor {
  left: -8%;
  right: -8%;
  bottom: -18%;
  height: 48%;
  background:
    linear-gradient(90deg, rgba(125, 211, 252, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(148, 163, 184, 0.04) 1px, transparent 1px),
    #0b1120;
  background-size: 82px 46px;
  transform: rotateX(68deg);
  transform-origin: top;
}

.desk {
  left: 23%;
  bottom: 23%;
  width: 48%;
  height: 14%;
  border-radius: 10px;
  background: linear-gradient(180deg, #3e4f68, #1a2744);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5);
  transform: skewX(-8deg);
}

.monitor {
  left: 34%;
  bottom: 39%;
  width: 18%;
  height: 23%;
  border: 10px solid #0b1120;
  border-radius: 10px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--room), white 10%), transparent 65%),
    #0f172a;
  box-shadow:
    0 0 40px color-mix(in srgb, var(--room), transparent 48%),
    inset 0 0 32px color-mix(in srgb, var(--room), transparent 58%);
}

.lamp {
  right: 22%;
  bottom: 54%;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: var(--accent);
  filter: blur(3px);
  opacity: 0.7;
  box-shadow: 0 0 120px 60px color-mix(in srgb, var(--accent), transparent 68%);
}

.avatar {
  bottom: 21%;
  width: 58px;
  height: 110px;
  border-radius: 999px 999px 18px 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--room), white 10%), #0f172a);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.35);
}

.avatar::before {
  content: "";
  position: absolute;
  left: 10px;
  top: -36px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #cbd5e1;
}

.avatarA { left: 24%; }
.avatarB {
  right: 25%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent), white 8%), #0f1729);
}

.mug {
  right: 31%;
  bottom: 37%;
  width: 36px;
  height: 42px;
  border-radius: 4px 4px 12px 12px;
  background: var(--accent);
  box-shadow: inset -8px 0 rgba(15, 23, 42, 0.18);
}

.mug::after {
  content: "";
  position: absolute;
  right: -14px;
  top: 10px;
  width: 18px;
  height: 18px;
  border: 4px solid var(--accent);
  border-left: 0;
  border-radius: 0 14px 14px 0;
}

.roomName {
  left: 24px;
  bottom: 54%;
  color: rgba(226, 232, 240, 0.07);
  font-size: clamp(54px, 8vw, 112px);
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: -0.03em;
}

.cssScene.running .monitor {
  animation: screenPulse 2s ease-in-out infinite;
}

.cssScene.break .avatar {
  animation: bob 2.6s ease-in-out infinite;
}

.cssScene.break .avatarB {
  animation-delay: 0.6s;
}

@keyframes screenPulse {
  50% { filter: brightness(1.18); }
}

@keyframes bob {
  50% { transform: translateY(-8px); }
}

/* --- Stage top bar --- */

.stageTop {
  position: absolute;
  inset: 28px 28px auto 28px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  z-index: 5;
}

.productMode .stageTop {
  inset: 24px 32px auto 32px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--room);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.02em;
}

h1 {
  font-size: 32px;
  font-weight: 800;
}

h2 {
  font-size: 20px;
  font-weight: 700;
}

/* --- Status badge --- */

.status {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(12px);
  padding: 0 14px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  max-width: 45%;
  transition: all 0.3s ease;
}

.productMode .status {
  max-width: min(460px, 42vw);
}

.status.connected {
  border-color: rgba(52, 211, 153, 0.4);
  color: #a7f3d0;
  background: rgba(6, 78, 59, 0.2);
}

.status.error {
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
  background: rgba(127, 29, 29, 0.2);
}

/* --- Timer panel --- */

.timerPanel {
  position: absolute;
  left: 28px;
  bottom: 28px;
  width: min(520px, calc(100% - 56px));
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 16px;
  background: rgba(11, 17, 32, 0.58);
  backdrop-filter: blur(20px) saturate(1.3);
  padding: 24px;
  z-index: 5;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.productMode .timerPanel {
  left: 32px;
  bottom: 92px;
  width: min(560px, calc(100% - 64px));
}

.phase {
  display: flex;
  justify-content: space-between;
  color: #94a3b8;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.clock {
  margin: 10px 0 16px;
  font-size: clamp(56px, 10vw, 96px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #f8fafc 20%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.progress {
  height: 6px;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.12);
  border-radius: 999px;
}

.progress span {
  display: block;
  height: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--room), var(--accent));
  border-radius: 999px;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 12px color-mix(in srgb, var(--room), transparent 50%);
}

.timerActions,
.toggles,
.split {
  display: flex;
  gap: 10px;
}

.timerActions {
  margin-top: 18px;
  flex-wrap: wrap;
}

.primary,
.send,
.selected {
  border-color: color-mix(in srgb, var(--room), white 22%);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--room), #0b1120 65%),
    color-mix(in srgb, var(--room), #0b1120 78%));
  box-shadow: 0 0 16px color-mix(in srgb, var(--room), transparent 80%);
}

.primary:hover,
.send:hover,
.selected:hover {
  box-shadow: 0 0 24px color-mix(in srgb, var(--room), transparent 65%);
}

/* --- Break overlay --- */

.breakOverlay {
  position: absolute;
  right: 32px;
  bottom: 92px;
  width: min(260px, calc(100% - 680px));
  min-width: 210px;
  border: 1px solid rgba(125, 211, 252, 0.12);
  border-radius: 14px;
  background: rgba(11, 17, 32, 0.42);
  backdrop-filter: blur(16px) saturate(1.2);
  padding: 12px 14px;
  color: #dbeafe;
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  z-index: 5;
}

.breakOverlay div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.breakOverlay span {
  color: var(--room);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.breakOverlay strong {
  color: #f1f5f9;
  font-size: 12px;
}

.breakOverlay p {
  margin: 0;
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.45;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* --- Toast layer --- */

.toastLayer {
  position: absolute;
  right: 32px;
  top: 88px;
  width: min(340px, 36vw);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
}

.talkToast {
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 14px;
  background: rgba(11, 17, 32, 0.52);
  backdrop-filter: blur(16px) saturate(1.2);
  padding: 12px 14px;
  color: #dbeafe;
  animation: toastSlide 10.8s cubic-bezier(0.4, 0, 0.2, 1) both;
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.talkToast strong {
  display: block;
  margin-bottom: 4px;
  color: var(--room);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.talkToast p {
  margin: 0;
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.5;
}

@keyframes toastSlide {
  0% {
    opacity: 0;
    transform: translateX(20px) scale(0.95);
  }
  6%, 72% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-12px) scale(0.97);
  }
}

/* --- Bottom controls (history, volume, audio unlock) --- */

.historyToggle {
  position: absolute;
  right: 32px;
  bottom: 48px;
  z-index: 36;
  width: 72px;
  height: 36px;
  border-color: rgba(148, 163, 184, 0.16);
  background: rgba(3, 7, 18, 0.52);
  backdrop-filter: blur(12px);
  font-size: 12px;
  border-radius: 10px;
}

.volumeToggle {
  position: absolute;
  right: 112px;
  bottom: 48px;
  z-index: 36;
  height: 36px;
  min-width: 74px;
  border-color: rgba(148, 163, 184, 0.16);
  background: rgba(3, 7, 18, 0.52);
  backdrop-filter: blur(12px);
  font-size: 12px;
  border-radius: 10px;
}

.volumePanel {
  position: absolute;
  right: 112px;
  bottom: 92px;
  z-index: 38;
  width: 230px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 14px;
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(20px) saturate(1.2);
  padding: 14px;
  display: none;
  box-shadow:
    0 20px 52px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.volumePanel.open {
  display: grid;
  gap: 14px;
}

.volumeRow {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.volumeRow input[type="range"] {
  width: 100%;
  height: 4px;
  accent-color: var(--room);
  border: none;
  background: transparent;
}

.volumeRow strong {
  color: #e2e8f0;
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.audioUnlock {
  position: absolute;
  right: 194px;
  bottom: 48px;
  z-index: 37;
  height: 36px;
  border-color: rgba(251, 191, 36, 0.32);
  background: rgba(24, 14, 2, 0.55);
  color: #fde68a;
  backdrop-filter: blur(12px);
  font-size: 12px;
  display: none;
  border-radius: 10px;
  animation: gentlePulse 2s ease-in-out infinite;
}

.audioUnlock.visible {
  display: inline-flex;
}

@keyframes gentlePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.2); }
  50% { box-shadow: 0 0 16px 4px rgba(251, 191, 36, 0.15); }
}

/* --- Side panel --- */

.side {
  grid-column: 2;
  grid-row: 1 / 3;
  overflow-y: auto;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.panel {
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  padding: 16px;
  display: grid;
  gap: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.panelTitle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 13px;
  color: #f1f5f9;
  letter-spacing: 0.02em;
}

.split > label {
  flex: 1;
  min-width: 0;
}

.toggles button,
.wide {
  width: 100%;
}

/* --- Chat section --- */

.chat {
  grid-column: 1;
  grid-row: 2;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.productMode .chat {
  position: fixed;
  left: 32px;
  right: 32px;
  bottom: 18px;
  z-index: 20;
  grid-column: auto;
  grid-row: auto;
  min-height: 0;
  background: transparent;
  pointer-events: none;
  grid-template-rows: auto auto;
}

.chatHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.productMode .chatHeader {
  padding: 18px 28px;
}

.topic {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 46%;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
}

/* --- Messages --- */

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.15) transparent;
}

.productMode .messages {
  display: none;
  position: fixed;
  right: 32px;
  bottom: 72px;
  z-index: 30;
  width: min(380px, calc(100vw - 64px));
  max-height: 200px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 14px;
  background: rgba(3, 7, 18, 0.62);
  backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.26);
  pointer-events: auto;
}

.productMode .messages.open {
  display: block;
}

/* --- Chat bubbles --- */

.bubble {
  max-width: 820px;
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 14px;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  animation: bubbleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes bubbleIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.productMode .bubble {
  max-width: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 6px 0;
  box-shadow: none;
  backdrop-filter: none;
  animation: none;
}

.productMode .bubble + .bubble {
  border-top: 1px solid rgba(148, 163, 184, 0.08);
}

.bubble div {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
}

.productMode .bubble div {
  gap: 7px;
  margin-bottom: 2px;
}

.bubble strong {
  color: #f1f5f9;
  font-size: 13px;
}

.productMode .bubble strong {
  font-size: 11px;
  color: var(--room);
}

.bubble time {
  color: #475569;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.productMode .bubble time {
  font-size: 10px;
}

.bubble p {
  margin: 0;
  color: #cbd5e1;
  line-height: 1.65;
  font-size: 13px;
}

.productMode .bubble p {
  font-size: 12px;
  line-height: 1.45;
}

.productMode .bubble.user,
.productMode .bubble.backend,
.productMode .bubble.system {
  align-self: auto;
  border-color: rgba(148, 163, 184, 0.08);
  background: transparent;
}

.bubble.user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--room), #0b1120 78%);
  border-color: color-mix(in srgb, var(--room), transparent 72%);
}

.bubble.backend {
  border-color: color-mix(in srgb, var(--accent), transparent 65%);
  border-left: 3px solid color-mix(in srgb, var(--accent), transparent 40%);
}

.bubble.system {
  max-width: 680px;
  background: rgba(30, 41, 59, 0.4);
  border-color: rgba(148, 163, 184, 0.08);
  font-style: italic;
}

.bubble.system p {
  color: #94a3b8;
}

/* --- Composer --- */

.composer {
  display: grid;
  grid-template-columns: 42px 42px minmax(0, 1fr) 48px;
  gap: 8px;
  padding: 14px 20px 18px;
  border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.productMode .composer {
  padding: 0;
  pointer-events: auto;
  grid-template-columns: 42px 42px minmax(0, 1fr) 48px;
}

.composer input {
  height: 42px;
  border-radius: 12px;
}

/* --- Spinner --- */

.spin {
  animation: spin 0.9s linear infinite;
}

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

/* ===== Responsive ===== */

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(520px, 64vh) auto minmax(420px, 44vh);
  }

  .app.productMode {
    grid-template-rows: 100vh;
  }

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

  .chat {
    grid-row: 3;
  }

  .productMode .chat {
    grid-row: auto;
  }

  .productMode .messages {
    width: min(360px, calc(100vw - 48px));
    right: 24px;
  }

  .breakOverlay {
    right: 24px;
    bottom: 92px;
    width: min(340px, calc(100% - 48px));
    min-width: 0;
  }

  .toastLayer {
    right: 24px;
    top: 88px;
    width: min(320px, calc(100% - 48px));
  }
}

@media (max-width: 680px) {
  .stageTop,
  .chatHeader,
  .timerActions,
  .toggles,
  .split {
    flex-direction: column;
    align-items: stretch;
  }

  .side {
    grid-template-columns: 1fr;
  }

  .status,
  .topic {
    max-width: none;
  }

  .timerPanel {
    left: 16px;
    right: 16px;
    bottom: 16px;
    width: auto;
    border-radius: 14px;
    padding: 20px;
  }

  .productMode .timerPanel {
    left: 16px;
    right: 16px;
    bottom: 88px;
    width: auto;
  }

  .breakOverlay {
    left: 16px;
    right: 16px;
    bottom: 164px;
    width: auto;
  }

  .historyToggle {
    right: 16px;
    bottom: 48px;
  }

  .volumeToggle {
    right: 96px;
    bottom: 48px;
  }

  .volumePanel {
    right: 16px;
    bottom: 92px;
    width: min(220px, calc(100vw - 32px));
  }

  .audioUnlock {
    right: 178px;
    bottom: 48px;
  }

  .productMode .messages {
    right: 16px;
    bottom: 88px;
    width: min(320px, calc(100vw - 32px));
    max-height: 160px;
  }

  .startHero {
    left: 20px;
    right: 20px;
    bottom: 88px;
    width: auto;
  }

  .startMeta {
    margin: 20px 0 24px;
  }

  .startButton {
    width: 100%;
  }

  .startStatus {
    left: 20px;
    right: auto;
    bottom: 28px;
  }

  h1 {
    font-size: 28px;
  }

  .clock {
    font-size: clamp(48px, 14vw, 72px);
  }

  .composer {
    grid-template-columns: 42px 42px minmax(0, 1fr) 48px;
    padding-inline: 12px;
  }
}
