:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --sidebar: #f7f4ec;
  --border: #e5dfd2;
  --text: #1c1917;
  --muted: #6b655e;
  --accent: #d97706;
  --accent-strong: #b45309;
  --accent-soft: #fef3c7;
  --note-gold: #eab308;
  --ok-bg: #ecfdf5;
  --ok-text: #047857;
  --ok-border: #a7f3d0;
  --warn-bg: #fffbeb;
  --warn-text: #b45309;
  --danger-bg: #fef2f2;
  --danger-text: #b91c1c;
  --shadow: 0 10px 30px rgba(28, 25, 23, 0.08);
  --radius: 14px;
}

body.theme-dark {
  --bg: #151412;
  --surface: #22211e;
  --surface-2: #1b1a17;
  --sidebar: #191815;
  --border: #33312b;
  --text: #f3f0e8;
  --muted: #a6a095;
  --accent: #eab308;
  --accent-strong: #facc15;
  --accent-soft: rgba(234, 179, 8, 0.14);
  --note-gold: #facc15;
  --ok-bg: rgba(16, 185, 129, 0.14);
  --ok-text: #6ee7b7;
  --ok-border: rgba(16, 185, 129, 0.35);
  --warn-bg: rgba(234, 179, 8, 0.14);
  --warn-text: #fde68a;
  --danger-bg: rgba(239, 68, 68, 0.14);
  --danger-text: #fca5a5;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.balanced-prose .balanced-text,
.balanced-prose .prose p,
.balanced-prose .prose li,
.balanced-prose .prose h2,
.balanced-prose .prose h3 {
  text-wrap: balance;
}

code, pre, .mono {
  font-family: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;
}

code {
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.9em;
  font-weight: 500;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(180deg, #facc15 0%, #eab308 32%, #ffffff 33%, #fef9c3 100%);
  border: 1px solid #d97706;
  color: #451a03;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: -0.02em;
  box-shadow: 0 2px 6px rgba(180, 83, 9, 0.18);
}

.brand h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.brand p {
  margin: 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 18px 80px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}

.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-border); }

/* Apple Notes Interactive Window Frame */
.anotes-window {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.anotes-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.anotes-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.anotes-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  display: inline-block;
}
.anotes-dot.red { background: #ff5f57; }
.anotes-dot.amber { background: #febc2e; }
.anotes-dot.green { background: #28c840; }

.anotes-grid {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  min-height: 360px;
}

@media (max-width: 840px) {
  .anotes-grid { grid-template-columns: 1fr; }
}

.anotes-sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (max-width: 840px) {
  .anotes-sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}

.anotes-pane {
  background: var(--surface);
  padding: 22px 26px;
  position: relative;
}

.anotes-pane::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--note-gold), var(--accent));
  opacity: 0.7;
}

.anotes-list-item {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
}

.anotes-list-item:hover {
  background: color-mix(in srgb, var(--accent-soft) 55%, transparent);
}

.anotes-list-item.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.anotes-list-item .note-title {
  display: block;
  font-weight: 650;
  font-size: 0.86rem;
  line-height: 1.3;
}

.anotes-list-item .note-sub {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pre-Gate Hero + Mini Preview */
.hero-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.preview-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.anote-card-row {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.84rem;
  transition: border-color 0.15s, background 0.15s;
}

.anote-card-row.target-hit {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.anote-card-row.flood-noise {
  opacity: 0.85;
}

/* Gate Tabs & Forms */
.tabs {
  display: inline-flex;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 12px;
  flex-wrap: wrap;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.86rem;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  font-size: 0.85rem;
  font-weight: 600;
}

.input, .textarea {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.94rem;
  font-family: inherit;
}

.input-mono {
  font-family: "SF Mono", "JetBrains Mono", monospace;
  letter-spacing: 0.03em;
}

.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.nda-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.nda-scroll {
  max-height: 112px;
  overflow-y: auto;
  font-size: 0.78rem;
  color: var(--muted);
  padding-right: 6px;
  margin-bottom: 10px;
}

.nda-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.nda-check input {
  margin-top: 3px;
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.radio-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-choice {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.84rem;
  cursor: pointer;
}

.chip-choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #ffffff;
}
body.theme-dark .btn-primary { color: #1c1917; }

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-sm { padding: 6px 11px; font-size: 0.8rem; border-radius: 8px; }

.feedback {
  font-size: 0.85rem;
  min-height: 20px;
}

/* Unlocked Executive Pitch Strip */
.agent-brief-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

@media (max-width: 800px) {
  .agent-brief-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.brief-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.brief-stat .k {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

.brief-stat .v {
  font-size: 0.88rem;
  font-weight: 650;
  margin-top: 3px;
}

/* Markdown Typography in Apple Notes Paper */
.prose { max-width: 68ch; }
.prose h2 { margin-top: 4px; font-size: 1.45rem; letter-spacing: -0.02em; }
.prose h3 { margin: 22px 0 8px; font-size: 1.08rem; color: var(--accent-strong); }
.prose h4 { margin: 16px 0 6px; font-size: 0.96rem; }
.prose p { margin: 0 0 12px; }
.prose blockquote {
  margin: 14px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
}
.prose ul { padding-left: 20px; margin: 8px 0 14px; }
.prose li { margin-bottom: 5px; }
.prose table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 0.86rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.prose th { background: var(--surface-2); font-weight: 650; }

.demo-results {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 270px;
  overflow-y: auto;
}

.demo-note {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.86rem;
}

.demo-note.hit {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.bug-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  box-shadow: var(--shadow);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 15, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 60;
}

.modal-backdrop[hidden], [hidden] { display: none !important; }

.modal {
  width: min(480px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}
