:root {
  color-scheme: dark;
  --black: #000000;
  --panel: #181818;
  --panel2: #20201f;
  --card: #0b0b0b;
  --field: #050505;
  --text: #f4f1ea;
  --soft: #f1efe9;
  --muted: #a8a29a;
  --muted2: #8c939b;
  --muted3: #5e6570;
  --border: #3a3835;
  --cool: #2b3542;
  --red: #d52b1e;
  --amber: #c9a227;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #0a0a0a;
  color: var(--text);
  font: 16px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--soft);
  outline-offset: 2px;
}

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

.app-shell {
  display: grid;
  width: min(100%, 430px);
  height: 100dvh;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr);
  margin: 0 auto;
  overflow: hidden;
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
  background: var(--black);
}

.topbar {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  padding: max(8px, env(safe-area-inset-top)) 16px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--black);
}

.brand-lockup {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.brand-lockup h1,
.brand-lockup p {
  margin: 0;
}

.brand-lockup h1 {
  color: var(--text);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.brand-dot {
  color: var(--red);
}

.eyebrow {
  color: var(--muted3);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
}

.tester-button {
  border: 1px solid var(--cool);
  border-radius: 999px;
  padding: 6px 11px;
  background: transparent;
  color: var(--muted2);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.2;
}

.tester-button:hover,
.tester-button[aria-expanded="true"] {
  border-color: var(--muted3);
  color: var(--soft);
}

main {
  display: contents;
}

.pattern-banner {
  display: flex;
  min-height: 39px;
  align-items: center;
  gap: 8px;
  padding: 6px 15px;
  border-left: 3px solid var(--red);
  background: rgba(213, 43, 30, 0.07);
  color: var(--soft);
  font-size: 11.5px;
  line-height: 1.35;
}

.pattern-banner span {
  min-width: 0;
}

.pattern-banner strong {
  font-weight: 600;
}

.banner-link,
.gate-sheet-link {
  flex: none;
  margin-left: auto;
  border: 0;
  border-bottom: 1px dotted var(--muted3);
  padding: 0 0 1px;
  background: transparent;
  color: var(--muted2);
  font-size: 11px;
  white-space: nowrap;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

#ask-panel,
.ask-layout,
.result {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.result {
  display: flex;
  flex-direction: column;
}

.conversation-scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 22px 18px 14px;
  overflow: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--muted3) transparent;
}

.empty-thread-welcome {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: center;
  padding: 8px 0 28px;
}

.empty-thread-welcome h2 {
  max-width: 360px;
  margin: 0 0 12px;
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.18;
}

.empty-thread-welcome > p {
  max-width: 370px;
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.pressure-starts > span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted3);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.pressure-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 7px;
}

.pressure-chips button,
.choice-chip,
.auto-pill {
  border: 1px solid #252d38;
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.012);
  color: #d8d5cf;
  font-size: 11.5px;
  line-height: 1.2;
}

.pressure-chips button:hover,
.choice-chip:hover,
.auto-pill:hover {
  border-color: var(--muted3);
}

.choice-chip.selected,
.auto-pill.active {
  border-color: var(--soft);
  background: var(--soft);
  color: var(--black);
}

.composer-shell {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  padding: 11px 18px calc(15px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--black);
}

.composer-shell textarea {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 52px;
  max-height: calc(9em + 22px);
  border: 1px solid var(--cool);
  border-radius: 12px;
  padding: 12px 48px 11px 13px;
  overflow-y: hidden;
  resize: none;
  background: #030303;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.composer-shell textarea::placeholder {
  color: var(--muted3);
}

.composer-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.calibration-summary,
.composer-calibrate,
.start-new {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted2);
  font-size: 10.5px;
  line-height: 1.3;
}

.calibration-summary {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-calibrate,
.start-new {
  border-bottom: 1px dotted var(--muted3);
  color: var(--soft);
}

.send-button {
  display: grid;
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  align-self: end;
  place-items: center;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: var(--text);
  color: var(--black);
  font-size: 14px;
  font-weight: 700;
}

.send-button:disabled {
  opacity: 0.45;
}

.chat-stream {
  display: grid;
  gap: 20px;
}

.chat-pair {
  display: grid;
  gap: 9px;
  scroll-margin-top: 8px;
}

.message-label {
  color: var(--muted3);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.message-body {
  white-space: pre-wrap;
}

.user-message {
  width: fit-content;
  max-width: 82%;
  justify-self: end;
  border: 1px solid var(--cool);
  border-radius: 10px 10px 3px 10px;
  padding: 9px 12px;
  background: var(--panel2);
  color: var(--soft);
  font-size: 12.5px;
  line-height: 1.45;
}

.user-message .message-label {
  margin-bottom: 4px;
}

.answer-card {
  border: 1px solid var(--border);
  border-radius: 3px 10px 10px 10px;
  padding: 15px 16px 0;
  overflow: hidden;
  background: var(--card);
}

.answer-card > .message-label,
.routed-chip {
  display: inline-flex;
  margin-right: 5px;
}

.routed-chip {
  color: var(--muted3);
  font-size: 9.5px;
}

.runtime-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0;
  margin-top: 5px;
  color: var(--muted3);
  font-size: 9.5px;
  line-height: 1.35;
}

.runtime-meta span {
  border: 0;
  padding: 0;
  color: var(--muted2);
}

.runtime-meta span + span::before {
  content: "\00b7";
  margin: 0 6px;
  color: var(--muted3);
}

.runtime-meta .runtime-role {
  color: var(--soft);
}

.runtime-meta .runtime-status-amber {
  color: var(--amber);
}

.runtime-meta .runtime-status-red {
  color: #f06d63;
}

.runtime-meta .runtime-status-routine,
.runtime-meta .runtime-status-advisory {
  color: #b4c5ae;
}

.answer-box {
  margin-top: 12px;
}

.answer-lead {
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.42;
}

.answer-lead-single {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.58;
}

.answer-segment {
  margin-top: 14px;
}

.answer-segment > span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted3);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.answer-segment .answer-text {
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  line-height: 1.6;
}

.answer-text {
  margin-bottom: 8px;
  white-space: pre-wrap;
}

.verdict-banner {
  margin-bottom: 8px;
  border-left: 2px solid var(--amber);
  padding-left: 8px;
  color: var(--text);
}

.verdict-amber {
  color: var(--amber);
}

.verdict-red {
  border-left-color: var(--red);
}

.answer-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 15px -16px 0;
  padding: 10px 13px 12px;
  border-top: 1px solid var(--border);
}

.answer-card-actions button {
  border: 0;
  border-radius: 999px;
  padding: 6px 9px;
  background: transparent;
  color: var(--muted2);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

.answer-card-actions button:first-child {
  border: 1px solid #3b4654;
  padding-right: 12px;
  padding-left: 12px;
  color: var(--soft);
}

.answer-card-actions button:hover {
  color: var(--soft);
}

.answer-sources {
  margin: 0 -16px;
  padding: 12px 16px 15px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12.5px;
  line-height: 1.55;
}

.answer-sources strong {
  display: block;
  margin-bottom: 5px;
  color: var(--muted3);
  font-family: Inter, sans-serif;
  font-size: 9.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.answer-table-wrap {
  max-width: 100%;
  margin: 8px 0;
  overflow-x: auto;
}

.answer-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
}

.answer-table th,
.answer-table td {
  border: 1px solid var(--border);
  padding: 7px;
  text-align: left;
  vertical-align: top;
}

.answer-table th {
  color: var(--soft);
  font-family: Inter, sans-serif;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.decision-snapshot {
  margin-top: 12px;
  border: 1px solid var(--border);
  padding: 12px;
  background: var(--card);
}

.decision-snapshot-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted2);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.decision-snapshot-grid {
  display: grid;
  gap: 9px;
  margin-top: 10px;
}

.decision-snapshot-item p {
  margin: 2px 0 0;
  color: var(--muted);
  font-family: Georgia, serif;
  font-size: 12.5px;
}

.decision-snapshot-label {
  color: var(--soft);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.prompt-box,
.empty,
.helper {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.prompt-box {
  border: 1px solid var(--border);
  padding: 12px;
  white-space: pre-wrap;
  background: var(--card);
}

.actions {
  display: flex;
  gap: 7px;
  margin-top: 9px;
}

.primary,
.secondary,
.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 14px;
  text-decoration: none;
}

.primary {
  border-color: var(--text);
  background: var(--text);
  color: var(--black);
  font-weight: 600;
}

.secondary {
  background: transparent;
  color: var(--soft);
}

.setup-flow {
  position: fixed;
  z-index: 3000;
  display: grid;
  inset: 0;
  place-items: center;
  overflow: auto;
  background: #0a0a0a;
}

.setup-card {
  width: min(100%, 430px);
  min-height: min(100dvh, 706px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: max(30px, env(safe-area-inset-top)) 22px max(30px, env(safe-area-inset-bottom));
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
  background: var(--black);
}

.gate-kicker {
  margin: 0 0 16px;
  color: var(--muted2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.setup-card h2 {
  margin: 0 0 16px;
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.26;
}

.gate-rule,
.gate-live {
  margin: 0 0 12px;
  color: var(--soft);
  font-size: 13.5px;
  line-height: 1.6;
}

.gate-live {
  border-left: 2px solid var(--red);
  padding: 7px 0 7px 12px;
}

.gate-live strong {
  font-weight: 600;
}

.gate-limits {
  margin: 0 0 26px;
  border-top: 1px solid var(--cool);
  padding-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.setup-card .setup-primary {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 14px;
  background: var(--text);
  color: var(--black);
  font-size: 14.5px;
  font-weight: 600;
  text-align: center;
}

.gate-sheet-link {
  margin: 14px auto 0;
  font-size: 12.5px;
}

.sheet-scrim,
.mobile-sheet-scrim {
  position: fixed;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.72);
}

.sheet-scrim {
  z-index: 3900;
}

.mobile-sheet-scrim {
  z-index: 2400;
  display: none;
}

body.mobile-sheet-open .mobile-sheet-scrim {
  display: block;
}

.bottom-sheet,
#calibration-sheet {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  width: min(100%, 430px);
  max-height: 84dvh;
  margin: 0 auto;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  padding: 8px 18px calc(24px + env(safe-area-inset-bottom));
  background: #151515;
  box-shadow: 0 -22px 60px rgba(0, 0, 0, 0.62);
}

#learning-sheet {
  position: fixed;
  z-index: 2500;
  right: 0;
  bottom: 0;
  left: 0;
  display: none;
  width: min(100%, 430px);
  max-height: 94dvh;
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  padding: 0 18px calc(26px + env(safe-area-inset-bottom));
  background: #111111;
  box-shadow: 0 -22px 60px rgba(0, 0, 0, 0.68);
}

body.mobile-learning-open #learning-sheet {
  display: block;
}

.tester-sheet-head {
  position: sticky;
  z-index: 2;
  top: 0;
  margin: 0 -18px;
  padding: 12px 18px 11px;
  border-bottom: 1px solid var(--border);
  background: rgba(17, 17, 17, 0.97);
}

.tester-section {
  display: grid;
  gap: 12px;
  padding: 20px 0 4px;
}

.tester-section + .tester-section {
  margin-top: 20px;
  border-top: 1px solid var(--border);
}

.tester-section h2 {
  margin: 0;
  color: var(--soft);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.tester-section .helper {
  margin: 0;
}

.tester-section label {
  display: grid;
  gap: 6px;
}

.tester-section textarea {
  width: 100%;
  border: 1px solid var(--cool);
  border-radius: 10px;
  padding: 10px 11px;
  resize: vertical;
  background: #050505;
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

.tester-section textarea::placeholder {
  color: var(--muted3);
  font-size: 12px;
}

.verdict-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.verdict-chip {
  border: 1px solid var(--cool);
  border-radius: 999px;
  padding: 6px 10px;
  background: transparent;
  color: var(--muted2);
  font-size: 11px;
  line-height: 1.2;
}

.verdict-chip.selected {
  border-color: var(--soft);
  background: var(--soft);
  color: var(--black);
}

.learning-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tester-primary,
.tester-secondary,
.tester-text-button {
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
}

.tester-primary,
.tester-secondary {
  min-height: 38px;
  padding: 8px 12px;
}

.tester-primary {
  border: 1px solid var(--soft);
  background: var(--soft);
  color: var(--black);
}

.tester-secondary {
  border: 1px solid var(--cool);
  background: transparent;
  color: var(--muted2);
}

.tester-primary:disabled,
.tester-secondary:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

#save-answer-journal {
  grid-column: 1 / -1;
}

.tester-full {
  width: 100%;
}

.tester-status {
  color: var(--muted3);
  font-size: 10.5px;
}

.learning-send-success {
  color: #b4c5ae;
}

.learning-send-error {
  color: #f06d63;
}

.tester-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tester-text-button {
  border: 0;
  border-bottom: 1px dotted var(--muted3);
  border-radius: 0;
  padding: 0 0 2px;
  background: transparent;
  color: var(--muted2);
}

.privacy-disclosure {
  color: var(--muted3);
  font-size: 10px;
}

.journal-list {
  display: grid;
  gap: 9px;
}

.journal-entry {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px;
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.journal-entry time {
  display: block;
  margin-bottom: 5px;
  color: var(--muted3);
  font-size: 10px;
}

.learning-state {
  display: inline-block;
  margin-bottom: 7px;
  border-left: 2px solid var(--amber);
  padding-left: 7px;
  color: var(--amber);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.journal-entry div {
  white-space: pre-wrap;
}

.bottom-sheet {
  z-index: 4000;
}

#calibration-sheet {
  z-index: 2500;
  display: none;
}

body.mobile-calibration-open #calibration-sheet {
  display: block;
}

.sheet-handle {
  width: 34px;
  height: 3px;
  margin: 0 auto 14px;
  border-radius: 2px;
  background: var(--muted3);
}

.bottom-sheet h2,
.mobile-sheet-head {
  margin: 0 0 14px;
  color: var(--muted2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.mobile-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-sheet-head button {
  border: 1px solid var(--muted3);
  border-radius: 999px;
  padding: 6px 11px;
  background: transparent;
  color: var(--text);
  font-size: 11px;
}

.chip-section {
  margin: 14px 0;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted3);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.choice-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.calibration-note {
  margin: 14px 0 0;
}

.detected-chip {
  width: fit-content;
  margin-top: 10px;
  border-left: 2px solid var(--amber);
  padding-left: 8px;
  color: var(--amber);
  font-size: 11px;
}

.pattern-example {
  margin-bottom: 9px;
  border-left: 2px solid var(--red);
  padding: 8px 10px;
  background: var(--card);
}

.pattern-example-yes {
  border-left-color: var(--soft);
}

.pattern-example > span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted2);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pattern-example-no > span {
  color: var(--red);
}

.pattern-example p {
  margin: 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12.5px;
  line-height: 1.5;
}

.sheet-close,
.sheet-cancel {
  width: 100%;
  margin-top: 15px;
  border: 1px solid var(--muted3);
  border-radius: 999px;
  padding: 10px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}

.convert-option {
  display: grid;
  width: 100%;
  grid-template-columns: 84px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  border: 0;
  border-top: 1px solid var(--border);
  padding: 14px 0;
  background: transparent;
  text-align: left;
}

.convert-option strong {
  width: 84px;
  flex: none;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
}

.convert-option span {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}

.convert-option em {
  grid-column: 2;
  color: var(--amber);
  font-size: 9px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.convert-option:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

@media (max-width: 430px) {
  .app-shell,
  .setup-card {
    border-right: 0;
    border-left: 0;
  }

  .pattern-banner {
    font-size: 11px;
  }

  .composer-shell {
    padding-right: 16px;
    padding-left: 16px;
  }

  .conversation-scroll {
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (max-width: 350px) {
  .pattern-banner {
    gap: 5px;
    padding-right: 11px;
    padding-left: 11px;
  }

  .banner-link {
    font-size: 10px;
  }

  .empty-thread-welcome h2 {
    font-size: 20px;
  }

  .answer-card-actions button {
    padding-right: 9px;
    padding-left: 9px;
    font-size: 10.5px;
  }

  .learning-actions {
    grid-template-columns: 1fr;
  }

  #save-answer-journal {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
