:root {
  color-scheme: dark;
  --background: #0c0e10;
  --panel: #15191d;
  --panel-raised: #1c2126;
  --line: #303840;
  --text: #f4f1ea;
  --muted: #9ca6ad;
  --accent: #f05a28;
  --accent-dark: #be3b14;
  --good: #53c889;
  --warn: #f0bd4f;
  --bad: #ff7068;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% -10%, rgba(240, 90, 40, .15), transparent 34rem),
    var(--background);
  color: var(--text);
}

button, textarea, input { font: inherit; }
button { touch-action: manipulation; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding:
    calc(1rem + env(safe-area-inset-top, 0px))
    max(1rem, env(safe-area-inset-right, 0px), calc((100vw - 920px) / 2))
    1rem
    max(1rem, env(safe-area-inset-left, 0px), calc((100vw - 920px) / 2));
  background: rgba(12, 14, 16, .88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.45rem, 4vw, 2rem); letter-spacing: -.04em; }
h2 { margin-bottom: .8rem; font-size: 1.15rem; }

.eyebrow {
  margin-bottom: .2rem;
  color: var(--accent);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

main { width: min(920px, 100%); margin: 0 auto; padding: 1rem; }
section { margin-bottom: 1rem; }

.composer, .requests, .trace-panel {
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, .18);
}

.voice-recorder { text-align: center; }
.record-button {
  display: grid;
  place-items: center;
  width: 126px;
  height: 126px;
  min-height: 126px;
  margin: 9px auto 14px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, .14);
  border-radius: 50%;
  background: linear-gradient(145deg, #332b25, #171411);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .42), inset 0 0 0 9px rgba(255, 255, 255, .025);
}
.record-button:hover { background: linear-gradient(145deg, #3c312a, #1c1714); }
.record-button:focus-visible { outline: 3px solid rgba(255, 91, 53, .55); outline-offset: 4px; }
.record-button:disabled { filter: grayscale(1); opacity: .45; }
.record-core {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #ff5b35;
  transition: 160ms ease;
}
.record-button.recording { animation: record-pulse 1.6s infinite; }
.record-button.recording .record-core { width: 48px; height: 48px; border-radius: 14px; }
@keyframes record-pulse {
  50% { box-shadow: 0 18px 48px rgba(0, 0, 0, .42), 0 0 0 16px rgba(255, 91, 53, .08); }
}
.record-label { margin-bottom: 2px; font-weight: 750; }
.record-timer { margin-bottom: 16px; color: var(--muted); font-variant-numeric: tabular-nums; }
#request-form { padding-top: .85rem; border-top: 1px solid var(--line); }

textarea, input {
  width: 100%;
  color: var(--text);
  background: #0e1113;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
}

textarea { min-height: 7.5rem; padding: .85rem; line-height: 1.45; resize: vertical; }
input { padding: .7rem; }
textarea:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240, 90, 40, .12); }

.composer-actions, .section-heading, .button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
}
.composer-actions { justify-content: flex-end; margin-top: .75rem; }

button {
  min-height: 42px;
  padding: .65rem 1rem;
  color: white;
  font-weight: 750;
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); }
button:disabled { opacity: .55; cursor: wait; }
button.secondary { color: var(--text); background: var(--panel-raised); border: 1px solid var(--line); }
button.secondary:hover { border-color: #56616a; background: #252b31; }
button.compact { min-height: 32px; padding: .35rem .6rem; font-size: .78rem; }

.runtime-group, .usage-controls, .integrations { display: flex; align-items: center; gap: .45rem; }
.runtime-group, .integrations { flex-wrap: wrap; justify-content: flex-end; }
.integrations[hidden] { display: none; }
.runtime, .usage, .integration, .top-refresh {
  min-height: 34px;
  padding: .35rem .65rem;
  color: var(--muted);
  font: 700 .78rem ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--panel-raised);
  border: 1px solid var(--line);
}
.usage { font-family: inherit; }
.integration { font-family: inherit; }
.top-refresh { font-family: inherit; }
.runtime.ready, .usage.ready, .integration.ready { color: var(--good); }
.runtime.not-ready, .usage.not-ready, .integration.not-ready { color: var(--bad); }
.integration:disabled { cursor: default; opacity: 1; }

.status, .muted, .empty { color: var(--muted); }
.status { min-height: 1.3rem; margin: .6rem 0 0; font-size: .88rem; }
.empty { margin: 1.5rem 0; text-align: center; }

.request-list { display: grid; gap: .75rem; }
.request-card { padding: .9rem; background: #101316; border: 1px solid #282f35; border-radius: 12px; }
.request-meta { display: flex; flex-wrap: wrap; gap: .4rem .7rem; margin-bottom: .65rem; color: var(--muted); font-size: .75rem; }
.request-number { color: var(--text); font-weight: 800; }
.request-status { color: var(--warn); }
.request-card[data-status="complete"] .request-status { color: var(--good); }
.request-card[data-status="error"] .request-status, .request-error { color: var(--bad); }
.user-request { margin-bottom: .7rem; color: #c8d0d5; white-space: pre-wrap; }
.agent-response { margin: 0 0 .7rem; padding: .8rem; background: #1a1f23; border-left: 3px solid var(--accent); border-radius: 4px 9px 9px 4px; }
.agent-response p { margin-bottom: .7rem; line-height: 1.5; white-space: pre-wrap; user-select: text; }
.request-error { white-space: pre-wrap; }
.request-usage { margin: -.1rem 0 .7rem; color: var(--muted); font-size: .76rem; }
.request-progress {
  align-items: center;
  gap: 11px;
  margin: .8rem 0;
  padding: 11px 12px;
  border: 1px solid rgba(255, 91, 53, .3);
  border-radius: 13px;
  background: rgba(255, 91, 53, .07);
}
.request-progress:not([hidden]) { display: flex; }
.request-progress > div { min-width: 0; }
.request-progress strong, .request-progress span { display: block; }
.progress-label { overflow: hidden; font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.progress-detail { margin-top: 2px; color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.progress-spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, .18);
  border-top-color: #ff5b35;
  border-radius: 50%;
  animation: progress-spin .85s linear infinite;
}
@keyframes progress-spin { to { transform: rotate(360deg); } }

.trace-panel { position: fixed; inset: .5rem; z-index: 20; margin: 0 auto; width: min(1100px, calc(100% - 1rem)); overflow: auto; box-shadow: 0 20px 80px #000; }
.sticky { position: sticky; top: -1rem; z-index: 2; margin: -1rem -1rem 1rem; padding: 1rem; background: rgba(21, 25, 29, .96); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.trace-events { display: grid; gap: .65rem; }
.trace-event { overflow: hidden; background: #0f1214; border: 1px solid var(--line); border-radius: 10px; }
.trace-event summary { padding: .7rem; cursor: pointer; font-weight: 750; }
.trace-event pre { max-height: 65vh; margin: 0; padding: .8rem; overflow: auto; color: #d6dee3; background: #090b0c; border-top: 1px solid var(--line); font: .76rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; user-select: text; }

dialog { width: min(430px, calc(100% - 2rem)); color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
dialog::backdrop { background: rgba(0, 0, 0, .76); backdrop-filter: blur(4px); }
dialog form { display: grid; gap: .8rem; }
dialog h2, dialog p { margin-bottom: 0; }

@media (max-width: 580px) {
  .topbar {
    padding:
      calc(.8rem + env(safe-area-inset-top, 0px))
      max(1rem, env(safe-area-inset-right, 0px))
      .8rem
      max(1rem, env(safe-area-inset-left, 0px));
  }
  .runtime-group { align-items: flex-end; flex-direction: column-reverse; }
  .usage { max-width: 52vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  main { padding: .7rem; }
  .composer, .requests { border-radius: 13px; }
  .trace-panel { inset: 0; width: 100%; border-radius: 0; }
  .button-row { align-items: stretch; flex-direction: column; }
}
