:root {
  color-scheme: light;
  --canvas: #f7f6f2;
  --surface: #ffffff;
  --surface-muted: #efeee9;
  --surface-strong: #e5e4de;
  --ink: #191918;
  --ink-soft: #62625f;
  --ink-faint: #8a8983;
  --line: #d9d8d2;
  --line-strong: #b9b8b1;
  --dark: #232322;
  --dark-hover: #080808;
  --danger: #8a2d26;
  --danger-surface: #fff0ee;
  --ok: #27603d;
  --warning: #765719;
  --shadow: 0 14px 40px rgb(28 28 25 / 8%);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --inspector-width: clamp(360px, 33vw, 470px);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--canvas);
  color: var(--ink);
}

body {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

button:disabled,
textarea:disabled {
  cursor: not-allowed;
}

h1,
h2,
h3,
p {
  margin: 0;
}

code,
pre,
.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--dark);
  color: white;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 140ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--inspector-width);
  width: 100%;
  height: 100dvh;
  min-height: 0;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

.topbar {
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 15px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 94%);
  backdrop-filter: blur(12px);
}

.brand-block,
.topbar-actions,
.dialog-heading,
.dialog-actions,
.key-field,
.card-badges,
.message-meta,
.execution-line {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.08em;
}

.topbar h1 {
  font-size: 16px;
  font-weight: 690;
  letter-spacing: -0.01em;
}

.topbar-actions {
  gap: 8px;
}

.button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  font-weight: 610;
  line-height: 1;
}

.button {
  min-height: 36px;
  padding: 0 14px;
}

.button-quiet {
  border-color: var(--line);
  background: var(--surface);
}

.button-quiet:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
}

.button-strong {
  border-color: var(--dark);
  background: var(--dark);
  color: white;
}

.button-strong:hover {
  background: var(--dark-hover);
}

.conversation {
  position: relative;
  min-height: 0;
  padding: clamp(20px, 4vw, 48px) clamp(18px, 5vw, 64px) 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.empty-chat {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(460px, calc(100% - 40px));
  text-align: center;
  transform: translate(-50%, -55%);
}

.empty-chat h2 {
  margin-top: 9px;
  font-size: clamp(27px, 4vw, 42px);
  font-weight: 590;
  letter-spacing: -0.04em;
}

.eyebrow {
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 730;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: uppercase;
}

.message-row {
  display: flex;
  width: min(840px, 100%);
  margin: 0 auto 24px;
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.assistant,
.message-row.notice {
  justify-content: flex-start;
}

.message-row[data-router-turn] {
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    background-color 120ms ease,
    box-shadow 120ms ease;
}

.message-row[data-router-turn]:hover {
  background: rgb(239 238 233 / 62%);
}

.message-row[data-router-turn]:focus-visible {
  outline: 2px solid #2e5a91;
  outline-offset: 3px;
}

.message-row.is-turn-selected {
  background: var(--surface-muted);
  box-shadow: inset 3px 0 0 var(--dark);
}

.message-row.user.is-turn-selected {
  box-shadow: inset -3px 0 0 var(--dark);
}

.message-row.user.is-turn-selected .message.user {
  border-color: var(--dark);
}

.message {
  max-width: min(76%, 680px);
  font-size: 15px;
  line-height: 1.58;
}

.message.user {
  padding: 11px 15px;
  border: 1px solid #deddd7;
  border-radius: 18px 18px 5px 18px;
  background: var(--surface-muted);
}

.message.assistant {
  max-width: min(86%, 740px);
  padding: 3px 0;
}

.message.notice {
  max-width: min(86%, 740px);
  padding: 10px 13px;
  border-left: 2px solid var(--line-strong);
  color: var(--ink-soft);
  font-size: 13px;
}

.message-content {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-meta {
  gap: 8px;
  margin-bottom: 7px;
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 610;
}

.message-model {
  color: var(--ink-soft);
}

.message.pending {
  color: var(--ink-soft);
}

.typing-dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 8px;
  vertical-align: middle;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentcolor;
  opacity: 0.35;
  animation: pulse 1.2s infinite ease-in-out;
}

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

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

@keyframes pulse {
  0%,
  70%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }

  35% {
    opacity: 0.9;
    transform: translateY(-2px);
  }
}

.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 clamp(18px, 5vw, 64px) 10px;
  padding: 10px 12px;
  border: 1px solid #e7c5c0;
  border-radius: var(--radius-sm);
  background: var(--danger-surface);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.4;
}

.error-banner button {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 20px;
}

.composer {
  z-index: 2;
  padding: 12px clamp(18px, 5vw, 64px) 18px;
  background: linear-gradient(to top, #fff 75%, rgb(255 255 255 / 74%));
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: min(840px, 100%);
  margin: 0 auto;
  padding: 9px 9px 9px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 7px 24px rgb(30 30 28 / 7%);
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}

.composer-box:focus-within {
  border-color: #77766f;
  box-shadow: 0 8px 30px rgb(30 30 28 / 11%);
}

.composer textarea {
  field-sizing: content;
  flex: 1;
  min-width: 0;
  min-height: 34px;
  max-height: 150px;
  padding: 7px 0 3px;
  overflow-y: auto;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
  line-height: 1.45;
}

.composer textarea::placeholder {
  color: var(--ink-faint);
}

.composer textarea:focus-visible {
  outline: 0;
}

.send-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--dark);
  color: white;
  font-size: 20px;
  line-height: 1;
}

.send-button:hover {
  background: var(--dark-hover);
}

.send-button:disabled {
  background: var(--surface-strong);
  color: var(--ink-faint);
}

.inspector {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--line-strong);
  background: var(--surface-muted);
  font-size: 12px;
}

.inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}

.inspector-header h2 {
  font-size: 15px;
  font-weight: 680;
  letter-spacing: -0.01em;
}

.inspector-feed {
  min-height: 0;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.turn-card {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 4px 18px rgb(36 36 33 / 4%);
  overflow: hidden;
}

.turn-card.latest {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.turn-card.is-active {
  margin-bottom: 0;
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.turn-card.is-error {
  border-color: #dfb7b1;
}

.turn-card-header {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.turn-card-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.turn-card-title h3 {
  min-width: 0;
  font-size: 14px;
  font-weight: 690;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.turn-number {
  flex: 0 0 auto;
  color: var(--ink-faint);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.turn-prompt {
  display: -webkit-box;
  margin-top: 7px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-badges {
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 11px;
}

.badge,
.reason-tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 690;
  letter-spacing: 0.03em;
  line-height: 1.2;
}

.badge {
  min-height: 22px;
  padding: 3px 7px;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.badge.dark {
  border-color: var(--dark);
  background: var(--dark);
  color: white;
}

.badge.shadow-demo {
  border-color: #a98438;
  background: #fff6dc;
  color: var(--warning);
}

.badge.cache-hit {
  border-color: #8cb59a;
  background: #edf8f0;
  color: var(--ok);
}

.badge.cache-miss {
  background: var(--surface-muted);
}

.card-section {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.card-section:last-child {
  border-bottom: 0;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-heading h4 {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 740;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-note {
  color: var(--ink-faint);
  font-size: 12px;
}

.metric-grid,
.signal-grid,
.timing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.metric,
.signal-metric,
.timing-metric {
  min-width: 0;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.metric-label,
.signal-label,
.timing-label {
  display: block;
  overflow: hidden;
  color: var(--ink-faint);
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.metric-label-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.metric-label-row .metric-label {
  min-width: 0;
}

.info-tip {
  position: relative;
  z-index: 1;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-soft);
  font-family: Georgia, serif;
  font-size: 11px;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
}

.info-tip:hover,
.info-tip:focus {
  z-index: 20;
  border-color: var(--ink-soft);
  color: var(--ink);
}

.info-tip-content {
  position: absolute;
  z-index: 20;
  top: calc(100% + 7px);
  left: 50%;
  width: min(220px, calc(100vw - 56px));
  padding: 9px 10px;
  visibility: hidden;
  border-radius: var(--radius-sm);
  background: var(--dark);
  box-shadow: 0 8px 24px rgb(20 20 18 / 20%);
  color: white;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  font-style: normal;
  font-weight: 520;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  transform: translateX(-30%);
  transition:
    opacity 120ms ease,
    visibility 120ms ease;
}

.badge-info-tip {
  width: 14px;
  height: 14px;
  margin-left: 4px;
  font-size: 10px;
}

.badge-info-tip .info-tip-content {
  right: 0;
  left: auto;
  transform: none;
}

.metric:nth-child(even) .info-tip-content {
  right: 0;
  left: auto;
  transform: none;
}

.info-tip:hover .info-tip-content,
.info-tip:focus .info-tip-content {
  visibility: visible;
  opacity: 1;
}

.metric-value,
.signal-value,
.timing-value {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 680;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signal-score {
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 520;
}

.candidate-list {
  display: grid;
  gap: 7px;
}

.candidate-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 4px 7px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.candidate-row.is-selected {
  border-color: #94938c;
  background: #f4f3ef;
}

.candidate-rank {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--ink-soft);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.candidate-row.is-selected .candidate-rank {
  background: var(--dark);
  color: white;
}

.candidate-name {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 670;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-cost {
  color: var(--ink-soft);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.candidate-stats {
  display: flex;
  grid-column: 2 / -1;
  flex-wrap: wrap;
  gap: 4px 10px;
  color: var(--ink-faint);
  font-size: 12px;
  line-height: 1.3;
}

.candidate-stats strong {
  color: var(--ink-soft);
  font-weight: 640;
}

.reason-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.reason-tag {
  padding: 4px 7px;
  background: var(--surface-muted);
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.rejected-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.rejected-row {
  padding: 7px 8px;
  border-left: 2px solid var(--line-strong);
  background: var(--surface-muted);
  font-size: 12px;
  line-height: 1.4;
}

.rejected-row strong {
  display: block;
  margin-bottom: 2px;
  overflow-wrap: anywhere;
}

.rejected-row span {
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.details-block {
  border-bottom: 1px solid var(--line);
}

.details-block:last-child {
  border-bottom: 0;
}

.details-block > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 12px;
  font-weight: 710;
  letter-spacing: 0.05em;
  list-style: none;
  text-transform: uppercase;
}

.details-block > summary::-webkit-details-marker {
  display: none;
}

.details-block > summary::after {
  content: "+";
  color: var(--ink-faint);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.details-block[open] > summary::after {
  content: "−";
}

.details-content {
  padding: 0 14px 13px;
}

.version-list {
  display: grid;
  gap: 7px;
}

.version-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px;
  font-size: 12px;
  line-height: 1.4;
}

.version-row dt {
  color: var(--ink-faint);
}

.version-row dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.execution-line {
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  line-height: 1.4;
}

.execution-line + .execution-line {
  margin-top: 7px;
}

.execution-label {
  flex: 0 0 88px;
  color: var(--ink-faint);
}

.execution-value {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

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

.raw-json {
  max-height: 360px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border-radius: var(--radius-sm);
  background: #292927;
  color: #eeede8;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pending-card {
  padding: 15px;
  color: var(--ink-soft);
}

.pending-card p {
  margin-top: 8px;
  font-size: 12px;
}

.pending-line {
  height: 7px;
  margin-top: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e1e0da 25%, #f4f3ee 50%, #e1e0da 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}

.pending-line.short {
  width: 62%;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.settings-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(880px, calc(100dvh - 32px));
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 28px 80px rgb(20 20 18 / 22%);
}

.settings-dialog::backdrop {
  background: rgb(28 28 26 / 38%);
  backdrop-filter: blur(3px);
}

.settings-dialog form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: min(880px, calc(100dvh - 32px));
  padding: 20px;
}

.settings-scroll {
  min-height: 0;
  padding: 1px 4px 1px 1px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.settings-section + .settings-section {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.settings-section h3 {
  margin: 0 0 13px;
  font-size: 14px;
  font-weight: 690;
}

.settings-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 13px;
}

.settings-section-heading h3 {
  margin-bottom: 0;
}

.policy-state {
  margin-top: 4px;
}

.settings-grid,
.policy-fields,
.weight-grid {
  display: grid;
  gap: 13px;
}

.settings-grid-keys,
.policy-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.policy-fields {
  margin-top: 18px;
}

.field-span-2 {
  grid-column: 1 / -1;
}

.field-group {
  min-width: 0;
}

.settings-dialog input,
.settings-dialog select,
.settings-dialog textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: 0;
  background-color: var(--surface);
  font-size: 13px;
  line-height: 1.35;
}

.settings-dialog input,
.settings-dialog select {
  min-height: 40px;
}

.settings-dialog textarea {
  resize: vertical;
}

.settings-dialog input:focus,
.settings-dialog select:focus,
.settings-dialog textarea:focus {
  border-color: #6e6d67;
  box-shadow: 0 0 0 3px rgb(70 70 67 / 10%);
}

.settings-dialog input:disabled,
.settings-dialog select:disabled,
.settings-dialog textarea:disabled {
  background-color: var(--surface-muted);
  color: var(--ink-faint);
}

.weight-fields {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.weight-fields legend {
  padding: 0 4px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 660;
}

.weight-fields legend span {
  color: var(--ink-faint);
  font-weight: 500;
}

.weight-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.weight-grid label {
  color: var(--ink-soft);
  font-size: 11px;
}

.weight-grid input {
  margin-top: 6px;
}

.settings-error {
  margin-top: 14px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: var(--danger-surface);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.4;
}

.settings-error.is-success {
  background: #edf8f0;
  color: var(--ok);
}

#weight-total.is-valid {
  color: var(--ok);
}

#weight-total.is-invalid {
  color: var(--danger);
}

.dialog-heading {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.dialog-heading h2 {
  margin-top: 5px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.icon-button {
  width: 34px;
  height: 34px;
  color: var(--ink-soft);
  font-size: 22px;
}

.icon-button:hover {
  background: var(--surface-muted);
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 660;
}

.key-field {
  gap: 8px;
}

.key-field input {
  min-width: 0;
  min-height: 40px;
  flex: 1;
  padding: 0 11px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.field-help {
  margin-top: 8px;
  color: var(--ink-faint);
  font-size: 11px;
  line-height: 1.5;
}

.field-help code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--ink-soft);
}

.dialog-actions {
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible,
summary:focus-visible,
.conversation:focus-visible {
  outline: 2px solid #2e5a91;
  outline-offset: 2px;
}

noscript {
  position: fixed;
  z-index: 200;
  right: 16px;
  bottom: 16px;
  left: 16px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-surface);
  color: var(--danger);
  text-align: center;
}

@media (max-width: 880px) {
  body {
    overflow: auto;
  }

  .app-shell {
    display: block;
    height: auto;
  }

  .chat-panel {
    height: 100dvh;
    min-height: 560px;
  }

  .inspector {
    min-height: 70dvh;
    border-top: 1px solid var(--line-strong);
    border-left: 0;
  }

  .inspector-feed {
    overflow: visible;
  }

}

@media (max-width: 560px) {
  .topbar {
    min-height: 68px;
    padding: 11px 14px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .button {
    min-height: 34px;
    padding: 0 11px;
    font-size: 12px;
  }

  .topbar-actions {
    gap: 5px;
  }

  .conversation {
    padding: 26px 14px 18px;
  }

  .message {
    max-width: 88%;
  }

  .message.assistant,
  .message.notice {
    max-width: 96%;
  }

  .composer {
    padding: 10px 12px 13px;
  }

  .inspector-header {
    min-height: 68px;
    padding: 13px 14px;
  }

  .inspector-feed {
    padding: 10px;
  }

  .metric-grid,
  .signal-grid,
  .timing-grid {
    gap: 5px;
  }

  .settings-dialog form {
    padding: 15px;
  }

  .settings-grid-keys,
  .policy-fields,
  .weight-grid {
    grid-template-columns: 1fr;
  }

  .field-span-2 {
    grid-column: auto;
  }

  .dialog-actions {
    flex-wrap: wrap;
  }
}

/* Policy settings use a quiet selector first, then a separate focused creator. */
.settings-dialog:not(.policy-dialog) {
  width: min(560px, calc(100vw - 32px));
}

.settings-dialog:not(.policy-dialog) form {
  display: block;
  padding: 28px;
}

.policy-dialog {
  width: min(720px, calc(100vw - 32px));
}

.policy-dialog form {
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 28px;
}

.settings-dialog .dialog-heading {
  margin-bottom: 30px;
}

.settings-dialog .dialog-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  font-weight: 680;
}

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

.policy-picker > label,
.settings-dialog .field-label,
.priority-control > span,
.weight-grid label {
  color: var(--ink);
  font-size: 14px;
  font-weight: 640;
}

.policy-picker > label {
  display: block;
  margin-bottom: 11px;
  font-size: 15px;
}

.policy-picker-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.policy-picker-row select {
  appearance: none;
  min-height: 54px;
  padding: 0 48px 0 15px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%2362625f' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
  background-size: 12px 8px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 560;
}

.add-policy-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.edit-policy-button {
  min-width: 74px;
  min-height: 54px;
  padding: 0 18px;
  font-size: 14px;
}

.add-policy-button:hover {
  background: var(--surface-muted);
}

.add-policy-button:disabled {
  color: var(--ink-faint);
  cursor: not-allowed;
}

.settings-dialog .dialog-actions {
  margin-top: 30px;
}

.settings-dialog .dialog-actions .button {
  min-height: 42px;
  padding: 0 18px;
  font-size: 14px;
}

.policy-dialog-scroll {
  min-height: 0;
  padding: 1px 6px 2px 1px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.policy-name-field {
  margin-bottom: 28px;
}

.settings-dialog input:not([type="range"]),
.settings-dialog select {
  min-height: 44px;
  color: var(--ink);
  font-size: 14px;
}

.priority-fields {
  display: grid;
  gap: 21px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.priority-fields legend {
  margin-bottom: 18px;
  padding: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 680;
}

.priority-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.priority-control output {
  min-width: 30px;
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
  text-align: right;
}

.priority-control input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 20px;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  accent-color: var(--dark);
  box-shadow: none;
}

.advanced-policy {
  margin-top: 30px;
  border-top: 1px solid var(--line);
}

.advanced-policy > summary {
  padding: 19px 0;
  color: var(--ink);
  cursor: pointer;
  font-size: 15px;
  font-weight: 660;
}

.advanced-policy-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 17px;
  padding: 2px 0 8px;
}

.settings-dialog .field-label {
  margin-bottom: 8px;
}

.settings-dialog .weight-fields {
  padding: 15px;
}

.settings-dialog .weight-fields legend {
  color: var(--ink);
  font-size: 14px;
}

.settings-dialog .weight-fields legend span {
  color: var(--ink);
  font-size: 14px;
}

.settings-dialog .weight-grid label {
  color: var(--ink);
  font-size: 14px;
}

.weight-total {
  margin: 10px 0 0;
  color: var(--ink);
  font-size: 14px;
}

.settings-dialog .settings-error {
  color: var(--danger);
  font-size: 14px;
}

@media (max-width: 620px) {
  .settings-dialog:not(.policy-dialog) form,
  .policy-dialog form {
    padding: 20px;
  }

  .advanced-policy-fields,
  .weight-grid {
    grid-template-columns: 1fr;
  }

  .field-span-2 {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
