/* app.css — Assistant PWA v1
 * Mobile-first. Targets iPhone Safari (375–430px wide) primarily;
 * scales up cleanly. Dark by default — no light-mode work in v1.
 */

* { box-sizing: border-box; }
:root {
  --bg: #0b0f12;
  --fg: #e8eef3;
  --muted: #98a2b3;
  --accent: #6ea8fe;
  --accent-hot: #ff5d62;
  --speaking: #50d878;
  --card: #161b22;
  --border: #2a3138;
  --error: #ff5d62;

  /* safe areas (notched iPhones) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text",
        "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: contain;
}

body {
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bot);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
header h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
}
.header-controls {
  display: flex;
  gap: 4px;
}
.header-controls button {
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 20px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.header-controls button:hover {
  background: var(--card);
}

main {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

#transcript {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 700px;
  margin: 0 auto;
}

.turn {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.turn .speaker {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.turn .text {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.turn.user .text {
  background: #1d2530;
  border-color: #2a3a55;
  align-self: flex-end;
  max-width: 85%;
}
.turn.assistant .text {
  align-self: flex-start;
  max-width: 95%;
}
.turn.pending .text {
  color: var(--muted);
  font-style: italic;
}
.turn.error .text {
  border-color: var(--error);
  color: var(--error);
}

footer {
  padding: 12px 16px calc(12px + var(--safe-bot)) 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--bg);
}

#ptt {
  width: 100%;
  max-width: 360px;
  min-height: 72px;
  border: none;
  border-radius: 18px;
  background: var(--accent);
  color: white;
  font-size: 17px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s, transform 0.05s;
}
#ptt:active {
  transform: scale(0.98);
}
#ptt.recording {
  background: var(--accent-hot);
  animation: pulse 1.2s ease-in-out infinite;
}
#ptt:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#ptt-icon {
  font-size: 22px;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 93, 98, 0.45); }
  50%      { box-shadow: 0 0 0 12px rgba(255, 93, 98, 0); }
}

#status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  min-height: 20px;
}
#status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.2s;
}
#status[data-state="recording"]    #status-dot { background: var(--accent-hot); }
#status[data-state="transcribing"] #status-dot { background: var(--accent); }
#status[data-state="thinking"]     #status-dot { background: var(--accent); animation: blink 1s ease-in-out infinite; }
#status[data-state="speaking"]     #status-dot { background: var(--speaking); }
#status[data-state="error"]        #status-dot { background: var(--error); }
@keyframes blink { 50% { opacity: 0.35; } }

dialog {
  border: none;
  border-radius: 16px;
  background: var(--card);
  color: var(--fg);
  padding: 24px;
  max-width: 90vw;
  width: 360px;
}
dialog::backdrop {
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}
dialog h2 {
  margin: 0 0 8px 0;
  font-size: 17px;
}
dialog p {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 16px 0;
}
dialog input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  margin-bottom: 16px;
}
.dialog-buttons {
  display: flex;
  justify-content: flex-end;
}
.dialog-buttons button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
