:root {
  --bg: #101014;
  --backdrop-from: #16161b;
  --backdrop-to:   #07070a;
  --fg: #e7e7e7;
  --muted: #8a8a8a;
  --accent: #ef4444;
  --accent-ring: rgba(239, 68, 68, 0.35);
  --ok: #22c55e;
  --border: #2a2a2a;

  --frame-bg:   #0b0b0d;
  --frame-edge: #1e1e24;
  --screen-bg:  #000;
  --phone-w: 400px;
  --phone-h: 840px;
  --frame-pad: 14px;
  --frame-radius: 58px;
  --screen-radius: 46px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}

body {
  min-height: 100vh;
  background: radial-gradient(1200px 700px at 50% 30%, var(--backdrop-from), var(--backdrop-to) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.phone {
  width: var(--phone-w);
  height: var(--phone-h);
  max-height: calc(100vh - 48px);
  background: var(--frame-bg);
  border-radius: var(--frame-radius);
  padding: var(--frame-pad);
  position: relative;
  box-shadow:
    inset 0 0 0 1px var(--frame-edge),
    0 0 0 2px #2a2a32,
    0 40px 80px rgba(0, 0, 0, 0.55),
    0 12px 30px rgba(0, 0, 0, 0.45);
}

.phone::before,
.phone::after {
  content: "";
  position: absolute;
  left: -3px;
  width: 3px;
  background: #2a2a32;
  border-radius: 2px;
}
.phone::before { top: 110px; height: 32px; }           
.phone::after  { top: 160px; height: 56px; box-shadow: 0 78px 0 #2a2a32, 0 146px 0 #2a2a32; } 

.phone-screen {
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--screen-bg);
  border-radius: var(--screen-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dynamic-island {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 118px;
  height: 34px;
  background: #000;
  border-radius: 22px;
  z-index: 5;
  box-shadow: inset 0 0 0 1px #15151a;
}

.brand {
  padding: 50px 20px 6px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #c4c4c8;
  font-weight: 600;
  flex: 0 0 auto;
}

.stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 20px 24px;
  min-height: 0;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #444;
  transition: background 120ms linear, transform 120ms linear;
}
.dot.idle            { background: #444; }
.dot.listening       { background: var(--ok); transform: scale(1.25); animation: pulse-dot 1.4s ease-in-out infinite; }
.dot.processing      { background: #eab308; }
.dot.intent_resolved { background: #3b82f6; }
.dot.session_active  { background: var(--ok); }
@keyframes pulse-dot { 0%,100% { opacity: 0.95; } 50% { opacity: 0.55; } }

.working {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
  text-align: center;
  max-width: 340px;
}

.reply {
  color: var(--fg);
  font-size: 15px;
  line-height: 1.4;
  margin: 0;
  text-align: center;
  max-width: 340px;
  white-space: pre-wrap;
  max-height: 140px;
  overflow: auto;
}

.panel {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #1e1e24;
  border-radius: 10px;
  background: #0e0e12;
}
.panel-row {
  display: grid;
  grid-template-columns: 62px 1fr;
  align-items: baseline;
  gap: 10px;
  font-size: 12px;
}
.panel-label {
  color: #6b6b73;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 600;
}
.panel-value {
  color: #d9d9dc;
  line-height: 1.35;
  word-wrap: break-word;
}

.emotion-panel {
  background: #0c0d12;
  border-color: #1a1c24;
  opacity: 0.92;
}
.emotion-panel .panel-label { color: #5a8ed4; }
.emotion-panel .panel-value { color: #cdd5e2; }

.events-panel {
  width: 100%;
  max-width: 320px;
  background: #0e0e12;
  border: 1px solid #1e1e24;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  opacity: 1;
  transition:
    transform 320ms cubic-bezier(.2,.7,.2,1),
    opacity 200ms ease-out,
    max-height 320ms cubic-bezier(.2,.7,.2,1),
    margin 320ms cubic-bezier(.2,.7,.2,1),
    padding 320ms cubic-bezier(.2,.7,.2,1),
    border-color 200ms ease-out;
  max-height: 220px;
}
.events-panel.collapsed {
  transform: translateX(140%);
  opacity: 0;
  pointer-events: none;
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding: 0;
  border-color: transparent;
}

.events-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.events-body {
  overflow: auto;
  padding: 6px 8px;
}

.events-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.events-empty {
  margin: 6px 4px;
  font-size: 11px;
  color: #5a5a62;
  text-align: center;
}

.ev-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  padding: 6px 8px;
  border-radius: 7px;
  background: #0a0a0e;
  border: 1px solid #16161c;
  transition: opacity 220ms cubic-bezier(.2,.7,.2,1),
              transform 220ms cubic-bezier(.2,.7,.2,1),
              max-height 260ms cubic-bezier(.2,.7,.2,1),
              margin 220ms cubic-bezier(.2,.7,.2,1),
              padding 220ms cubic-bezier(.2,.7,.2,1),
              border-color 220ms linear;
  transform: translateY(0);
  opacity: 1;
  max-height: 80px;
}
.ev-item .ev-time {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8aa9d8;
  font-variant-numeric: tabular-nums;
}
.ev-item .ev-title {
  font-size: 13px;
  color: #e1e3e8;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ev-item .ev-meta {
  font-size: 11px;
  color: #6b6b73;
  font-variant-numeric: tabular-nums;
}

.ev-item.entering {
  opacity: 0;
  transform: translateY(8px);
}

.ev-item.leaving {
  opacity: 0;
  transform: translateY(-4px);
  max-height: 0;
  margin-top: -4px;
  padding-top: 0;
  padding-bottom: 0;
  border-color: transparent;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .events-body,
  .events-chev,
  .ev-item {
    transition: none;
  }
  .ev-item.entering { opacity: 1; transform: none; }
}

.mic {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--accent-ring);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: box-shadow 120ms linear, transform 120ms linear, background 120ms linear;
}
.mic:hover { box-shadow: 0 0 0 6px var(--accent-ring); }
.mic.recording {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 8px var(--accent-ring);
  animation: pulse 1.1s ease-in-out infinite;
}
.mic:disabled { opacity: 0.4; cursor: not-allowed; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 8px var(--accent-ring); }
  50%      { box-shadow: 0 0 0 14px rgba(239, 68, 68, 0.12); }
}

.replay {
  background: #1a1a1a;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}
.replay:hover { background: #232323; }

.text-input {
  width: 100%;
  max-width: 260px;
  background: #111;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  outline: none;
}
.text-input:focus { border-color: #3f3f3f; }

.end {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 16px;
  font: inherit;
  cursor: pointer;
}
.end:hover { background: #141414; }

@media (max-width: 440px) {
  body { padding: 8px; }
  .phone {
    width: 100%;
    height: calc(100vh - 16px);
    max-height: calc(100vh - 16px);
    border-radius: 40px;
    padding: 10px;
  }
  .phone-screen { border-radius: 32px; }
  .brand { padding-top: 44px; }
}
