:root {
  color-scheme: light dark;
  --accent: #e0574c;
  --bg: #fafafa;
  --panel: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e2e2e2;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15161a;
    --panel: #1e1f24;
    --text: #f0f0f0;
    --muted: #9a9a9a;
    --border: #33343a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

h1 {
  font-size: 1.4rem;
  margin: 0;
}

.ghost-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.85rem;
}

.mic-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 0;
}

#mic-btn {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  font-size: 2rem;
  cursor: pointer;
  box-shadow: 0 0 0 0 rgba(224, 87, 76, 0.5);
  transition: transform 0.15s ease;
}

#mic-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#mic-btn.listening {
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(224, 87, 76, 0.5); }
  70% { box-shadow: 0 0 0 18px rgba(224, 87, 76, 0); }
  100% { box-shadow: 0 0 0 0 rgba(224, 87, 76, 0); }
}

#status {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
  text-align: center;
}

.sound-btn {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  padding: 10px 18px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.sound-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.text-fallback {
  width: min(100%, 460px);
}

.text-fallback label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.text-fallback-controls {
  display: flex;
  gap: 8px;
}

.text-fallback input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}

.text-fallback button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
}

.text-fallback input:disabled,
.text-fallback button:disabled {
  opacity: 0.55;
  cursor: wait;
}

#transcript {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  margin-bottom: 20px;
}

.message {
  padding: 8px 12px;
  border-radius: 10px;
  max-width: 85%;
  line-height: 1.4;
  font-size: 0.95rem;
}

.message.you {
  align-self: flex-end;
  background: var(--accent);
  color: white;
}

.message.agent {
  align-self: flex-start;
  background: var(--border);
  color: var(--text);
}

#order-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  padding: 16px;
}

#order-panel h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

#order-lines {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#order-lines li.order-line {
  border-bottom: 1px dashed var(--border);
  padding-bottom: 8px;
}

.order-line-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
}

.order-line-breakdown {
  list-style: none;
  margin: 4px 0 0;
  padding: 0 0 0 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.order-line-breakdown li {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
}

.order-line-qty {
  margin-top: 2px;
  padding-left: 10px;
  font-size: 0.78rem;
  color: var(--muted);
}

#order-total {
  margin-top: 10px;
  font-weight: 600;
  text-align: right;
}

#fulfillment-info {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
  color: var(--text);
  text-align: right;
  min-height: 1em;
}

#order-status {
  color: var(--accent);
  font-weight: 600;
  text-align: right;
  min-height: 1.2em;
}
