:root {
  color-scheme: light;
  --ink: #1a1a1a;
  --ink-soft: #3d3d3d;
  --accent: #ffb703;
  --accent-deep: #f77f00;
  --sky: #f4f1de;
  --mist: rgba(255, 255, 255, 0.6);
  --panel: rgba(255, 255, 255, 0.88);
  --stroke: rgba(26, 26, 26, 0.15);
  --shadow: 0 18px 40px rgba(20, 20, 20, 0.12);
  --mono: "IBM Plex Mono", "Courier New", monospace;
  --sans: "Space Grotesk", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background: radial-gradient(circle at top, #fef6e4 0%, #f3e9d2 30%, #f5ebe0 60%, #f7d9c4 100%);
}

.glow {
  position: fixed;
  inset: 12% 15% auto 50%;
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, rgba(255, 183, 3, 0.35) 0%, rgba(255, 255, 255, 0) 65%);
  filter: blur(2px);
  pointer-events: none;
  animation: drift 10s ease-in-out infinite alternate;
}

@keyframes drift {
  0% {
    transform: translate(-50%, -30%) scale(0.95);
  }
  100% {
    transform: translate(-42%, -20%) scale(1.05);
  }
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 48px 6vw 16px;
}

h1 {
  margin: 8px 0 4px;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 16px;
  font-size: 1.25rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  margin: 0;
  color: var(--accent-deep);
}

.subhead {
  margin: 0;
  color: var(--ink-soft);
}

.status-pill {
  background: var(--accent);
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  box-shadow: var(--shadow);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  width: 100%;
  min-width: 0;
}

.tts-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
  flex: 1 1 320px;
}

.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.toggle-ui {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(26, 26, 26, 0.2);
  display: inline-flex;
  align-items: center;
  padding: 2px;
  transition: background 0.2s ease;
}

.toggle-ui::after {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.toggle input:checked + .toggle-ui {
  background: var(--accent-deep);
}

.toggle input:checked + .toggle-ui::after {
  transform: translateX(20px);
}

.toggle input:focus-visible + .toggle-ui {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.toggle-label {
  font-weight: 600;
}

.tts-controls select {
  min-width: 200px;
  max-width: 100%;
  flex: 1 1 220px;
  width: min(320px, 100%);
  text-overflow: ellipsis;
}

.toggle input:disabled + .toggle-ui,
.tts-controls select:disabled {
  opacity: 0.6;
}

main {
  display: grid;
  gap: 20px;
  padding: 24px 6vw 60px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.panel {
  background: var(--panel);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(6px);
}

.panel.full {
  grid-column: 1 / -1;
}

.project-card,
.shell-grid,
.context-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.label {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.value {
  margin: 6px 0 0;
  font-size: 1rem;
  font-weight: 600;
}

.mono {
  font-family: var(--mono);
}

.controls {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

button,
select,
input {
  font-family: var(--sans);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #fff;
  font-size: 0.95rem;
}

button {
  background: var(--accent-deep);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
}

.ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--stroke);
}

.shell-output {
  margin-top: 16px;
  background: rgba(26, 26, 26, 0.9);
  color: #f6f4f2;
  padding: 14px;
  border-radius: 16px;
  min-height: 160px;
  max-height: 240px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.4;
}

.chat-log {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 16px;
  padding: 12px;
  min-height: 220px;
  max-height: 620px;
  overflow-y: auto;
  display: grid;
  gap: 10px;
}

.chat-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.chat-role {
  font-family: var(--mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #cbd5e1;
  min-width: 70px;
}

.chat-bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.chat-bubble.reasoning {
  background: rgba(255, 255, 255, 0.1);
  border-style: dashed;
  color: #cbd5e1;
  font-style: italic;
}

.chat-controls {
  display: none;
}

.inline-input-row .chat-bubble {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  min-height: 28px;
  width: 100%;
  outline: none;
  cursor: text;
}

.inline-input-row .chat-bubble:empty::before {
  content: "Type or dictate; keys stream live (Enter sends)";
  color: #94a3b8;
}

.context-files {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.context-file {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed var(--stroke);
  background: var(--mist);
  font-size: 0.9rem;
}

.tool-log {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
}

.tool-item {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--stroke);
  font-size: 0.9rem;
}

.tool-item strong {
  display: block;
  font-size: 0.95rem;
}

.error {
  margin-top: 6px;
  color: #b00020;
  font-weight: 600;
}

@media (max-width: 720px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .status-pill {
    align-self: flex-start;
  }
}

@media (max-width: 680px) {
  main {
    padding: 0.5rem;
  }

  .chat-log {
    padding: 10px;
    max-height: 70vh;
  }

  .chat-row {
    flex-direction: column;
    gap: 6px;
  }

  .chat-role {
    min-width: auto;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
  }

  .chat-bubble {
    width: 100%;
    font-size: 0.88rem;
  }

  .inline-input-row .chat-bubble {
    min-height: 34px;
  }
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 48px 6vw;
}

.login-shell {
  width: 100%;
  display: flex;
  justify-content: center;
}

.login-card {
  max-width: 420px;
  width: 100%;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.login-field {
  display: grid;
  gap: 6px;
}

.login-form button {
  width: 100%;
}

.login-error {
  margin: 0;
  min-height: 20px;
  color: #b00020;
  font-weight: 600;
}
