:root {
  color-scheme: dark;
  --bg: #141611;
  --bg-raise: #1e221b;
  --line: #34392f;
  --text: #f4f1e8;
  --muted: #b1aa9c;
  --amber: #e2a13a;
  --amber-ink: #2a1d08;
  --green: #9cba86;
  --danger: #e07a5f;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 10% -10%, #2a2618 0%, transparent 55%),
    var(--bg);
  color: var(--text);
}

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

button { cursor: pointer; }

.hidden, [hidden] { display: none !important; }

.screen, .shell {
  min-height: 100dvh;
  max-width: 42rem;
  margin: 0 auto;
}

.screen {
  display: grid;
  place-items: center;
  padding: 24px;
}

.panel, .settings {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.panel { width: min(100%, 28rem); }

.mark {
  margin: 0;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  color: var(--amber);
}

h1, h2, h3 { font-weight: 600; }

h1 { margin: 8px 0; font-size: 1.8rem; }

h3 { margin: 0 0 10px; font-size: 1rem; }

.muted, .hint, .status { color: var(--muted); }

.hint {
  margin-top: 0;
  padding: 10px 12px;
  border-left: 3px solid var(--amber);
  background: #2a261c;
}

label { display: grid; gap: 6px; margin: 14px 0; }

input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #12140f;
  border-radius: 12px;
  padding: 12px 14px;
}

button[type="submit"], .settings-bar button, .choice, .confirm button, .bubble button {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--amber);
  color: var(--amber-ink);
  font-weight: 650;
}

.error { color: var(--danger); }

.shell {
  display: flex;
  flex-direction: column;
  position: relative;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: calc(12px + env(safe-area-inset-top)) 16px 8px;
}

.top-actions { display: flex; gap: 8px; align-items: center; }

.devices { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); font-size: 0.92rem; }

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}

.pill.online { color: var(--green); border-color: #3e5236; }

.segment {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: #12140f;
}

.segment button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
}

.segment button[aria-pressed="true"] {
  background: var(--amber);
  color: var(--amber-ink);
}

.segment-wide { width: fit-content; margin-bottom: 8px; }

.icon-button {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 8px 12px;
}

.chat {
  flex: 1;
  overflow: auto;
  padding: 8px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty { color: var(--muted); line-height: 1.45; }

.bubble {
  max-width: 92%;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
}

.bubble p { margin: 0; white-space: pre-wrap; line-height: 1.4; }

.bubble.user {
  align-self: flex-end;
  background: #2c2618;
  border-color: #5a4a28;
}

.bubble button, .confirm { margin-top: 8px; }

.confirm {
  border: 1px solid var(--danger);
  border-radius: 16px;
  padding: 12px;
  background: #2a1c18;
}

.confirm p { margin: 0 0 8px; }

.confirm code {
  display: block;
  white-space: pre-wrap;
  margin-bottom: 10px;
  color: #f3d2c8;
}

.confirm .row { display: flex; gap: 8px; }

.confirm .row button { flex: 1; }

.confirm .ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.confirm button:disabled { opacity: 0.65; }

.composer {
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 20%);
}

.status { min-height: 1.2em; margin: 0 0 8px; }

.composer-row { display: flex; gap: 10px; align-items: center; }

.text-form { display: flex; gap: 8px; flex: 1; }

.text-form button { border: 0; border-radius: 12px; background: var(--bg-raise); }

#mic {
  width: 64px;
  height: 64px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--amber);
  touch-action: none;
  box-shadow: var(--shadow);
}

#mic.live { background: var(--danger); }

.mic-dot {
  display: block;
  width: 16px;
  height: 16px;
  margin: auto;
  border-radius: 50%;
  background: var(--amber-ink);
}

.settings {
  position: absolute;
  inset: 0;
  overflow: auto;
  border-radius: 0;
  border: 0;
  padding-bottom: 32px;
}

.settings section { margin: 22px 0; }

.settings-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-bar h2 { margin: 0; font-size: 1.2rem; }

.choices { display: grid; gap: 8px; }

.choice {
  text-align: left;
  background: #12140f;
  color: var(--text);
  border: 1px solid var(--line);
}

.choice.selected { border-color: var(--amber); background: #2c2618; }

.choice small, .choice span { display: block; }

.choice small { color: var(--muted); font-weight: 400; margin-top: 4px; }

.choice-links { margin: 4px 0 0; font-size: 0.85rem; }

.choice-links a { color: var(--amber); }

.custom { display: flex; gap: 8px; }

.custom button { flex: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: #1a1814;
  padding: 10px 14px;
  border-radius: 999px;
  margin: 0;
}

@media (min-width: 800px) {
  .shell { min-height: calc(100dvh - 24px); margin-top: 12px; }
}
