:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #171b1f;
  --panel-2: #1f2428;
  --line: #343b42;
  --text: #f2f5f2;
  --muted: #a8b1aa;
  --accent: #e7c66a;
  --accent-2: #75c8ae;
  --danger: #ff8c77;
}

* {
  box-sizing: border-box;
}

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

.shell {
  width: min(1400px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(360px, 1fr) minmax(300px, 390px);
  grid-template-areas:
    "input result chat";
  gap: 20px;
}

.shell.coach-maximized {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "chat";
}

.shell.intake-only {
  width: min(560px, calc(100vw - 32px));
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "input";
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
}

.input-panel {
  grid-area: input;
  padding: 22px;
}

.result-panel {
  grid-area: result;
  padding: 22px;
}

.chat-panel {
  grid-area: chat;
  padding: 22px;
}

.shell.coach-maximized .input-panel,
.shell.coach-maximized .result-panel {
  display: none;
}

.shell.intake-only .result-panel,
.shell.intake-only .chat-panel {
  display: none;
}

.brand-row,
.result-header,
.result-actions,
.two-up {
  display: flex;
  gap: 14px;
}

.brand-row,
.result-header {
  align-items: flex-start;
  justify-content: space-between;
}

.brand-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.result-actions {
  align-items: center;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 22px;
}

.form-grid {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.qr-panel {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0d0f;
}

.qr-panel[hidden] {
  display: none;
}

.qr-panel img {
  width: 220px;
  height: 220px;
  border-radius: 6px;
  background: #fff;
}

.birth-details {
  display: grid;
  gap: 16px;
}

.birth-details[aria-disabled="true"] {
  opacity: 0.48;
}

.form-hint {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.two-up > label {
  flex: 1 1 0;
  min-width: 0;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}

input:focus {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent);
}

input:disabled {
  cursor: not-allowed;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #15130b;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 0 16px;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.place-candidates {
  display: grid;
  gap: 8px;
}

.place-candidates[hidden] {
  display: none;
}

.place-candidate {
  min-height: 0;
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  text-align: left;
  padding: 11px 12px;
  font-weight: 700;
  line-height: 1.35;
}

.place-candidate small {
  display: block;
  color: var(--muted);
  font-weight: 650;
  margin-top: 4px;
}

.place-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 9px;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.place-guidance {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.place-candidate.selected {
  border-color: var(--accent);
  color: var(--accent);
}

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

.ghost-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.status {
  min-width: 72px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 800;
}

.status.ok {
  color: var(--accent-2);
}

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

.view-switch {
  display: flex;
  gap: 3px;
  margin-top: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111417;
  overflow-x: auto;
}

.view-switch button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 32px;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 0 6px;
  font-size: 12px;
  white-space: nowrap;
}

.view-switch button.active {
  background: var(--panel-2);
  color: var(--accent);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.summary-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-width: 0;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  margin-bottom: 5px;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

pre {
  min-height: 360px;
  max-height: 62vh;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0d0f;
  color: #d7eadf;
  padding: 16px;
  font-size: 13px;
  line-height: 1.5;
}

.chat-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 360px;
  max-height: 62vh;
  overflow: auto;
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0d0f;
  padding: 14px;
}

.shell.coach-maximized .chat-messages {
  min-height: 58vh;
  max-height: 70vh;
}

.chat-message {
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.chat-message.user {
  justify-self: end;
  max-width: 88%;
  background: var(--accent);
  color: #15130b;
  font-weight: 700;
}

.chat-message.ken {
  justify-self: start;
  max-width: 92%;
  background: var(--panel-2);
  color: var(--text);
}

.chat-message.pending {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-2);
  animation: typing-dot 900ms ease-in-out infinite;
}

.typing-dots i:nth-child(2) {
  animation-delay: 120ms;
}

.typing-dots i:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes typing-dot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
}

.chat-form input:disabled {
  opacity: 0.7;
}

@media (max-width: 860px) {
  .shell {
    width: min(100% - 20px, 560px);
    grid-template-columns: 1fr;
    grid-template-areas:
      "input"
      "result"
      "chat";
    gap: 14px;
    padding: 12px 0 18px;
  }

  .shell.coach-maximized {
    grid-template-columns: 1fr;
    grid-template-areas: "chat";
  }

  .input-panel,
  .result-panel,
  .chat-panel {
    padding: 16px;
  }

  .brand-row,
  .result-header {
    gap: 12px;
  }

  .brand-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  h1 {
    font-size: 25px;
  }

  h2 {
    font-size: 20px;
  }

  input,
  button {
    min-height: 46px;
  }

  .view-switch button {
    min-width: 68px;
  }

  .summary-grid,
  .two-up {
    grid-template-columns: 1fr;
    display: grid;
  }

  .summary-grid {
    gap: 8px;
    margin: 16px 0;
  }

  pre,
  .chat-messages {
    min-height: 260px;
    max-height: 54vh;
  }

  .shell.coach-maximized .chat-messages {
    min-height: 64vh;
    max-height: 68vh;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 520px) {
  .shell {
    width: calc(100% - 12px);
    gap: 10px;
    padding-top: 6px;
  }

  .input-panel,
  .result-panel,
  .chat-panel {
    padding: 14px;
  }

  .brand-row,
  .result-header {
    flex-wrap: wrap;
  }

  .brand-actions {
    width: 100%;
  }

  .brand-actions .ghost-button {
    flex: 1 1 0;
  }

  .result-actions {
    width: 100%;
    justify-content: space-between;
  }

  .result-actions .ghost-button {
    flex: 1 1 auto;
  }

  .status {
    flex: 0 0 auto;
  }

  .view-switch {
    scrollbar-width: thin;
  }

  pre {
    font-size: 12px;
    padding: 12px;
  }
}
