:root {
  --navy: #182430;
  --navy-2: #22303d;
  --ink: #1c2128;
  --muted: #667085;
  --cream: #f7f4ee;
  --card: #ffffff;
  --border: #e6e2d8;
  --gold: #a9793f;
  --gold-light: #cf9f5e;
  --success: #2f7a4f;
  --success-bg: #e7f3ea;
  --danger: #b1463f;
  --danger-bg: #fbeae8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 6px 24px rgba(24, 36, 48, 0.08);
  --shadow-sm: 0 2px 8px rgba(24, 36, 48, 0.06);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --navy: #0e151c;
  --navy-2: #16212b;
  --ink: #e9e7e0;
  --muted: #9aa5b1;
  --cream: #10161d;
  --card: #17212a;
  --border: #2a3540;
  --gold: #d6ab6e;
  --gold-light: #e9c68f;
  --success: #6fbf8c;
  --success-bg: #163524;
  --danger: #e08a83;
  --danger-bg: #3a2020;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --navy: #0e151c;
    --navy-2: #16212b;
    --ink: #e9e7e0;
    --muted: #9aa5b1;
    --cream: #10161d;
    --card: #17212a;
    --border: #2a3540;
    --gold: #d6ab6e;
    --gold-light: #e9c68f;
    --success: #6fbf8c;
    --success-bg: #163524;
    --danger: #e08a83;
    --danger-bg: #3a2020;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; margin: 0 0 8px; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.5rem; }
.how-it-works h2 { font-size: 1.3rem; }

p { line-height: 1.55; color: var(--ink); }

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--navy);
  color: #f2efe7;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: Georgia, serif; font-size: 1.15rem; letter-spacing: 0.06em; white-space: nowrap; }
.logo { width: 26px; height: 26px; color: var(--gold-light); flex-shrink: 0; }
.brand-text .accent { color: var(--gold-light); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.tab {
  background: transparent;
  border: none;
  color: #cfd6dd;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { background: rgba(255,255,255,0.08); color: #fff; }
.tab.active { background: var(--gold); color: #1a1005; font-weight: 600; }

.theme-toggle {
  border: 1px solid rgba(255,255,255,0.25);
  background: transparent;
  color: #f2efe7;
  border-radius: 999px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle svg { width: 18px; height: 18px; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }

/* Main / layout */
main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }

.tab-panel { display: none; animation: fade 0.2s ease; }
.tab-panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none; } }

.hero { max-width: 760px; margin-bottom: 28px; }
.hero h1 { font-size: 2rem; line-height: 1.25; }
.lede { color: var(--muted); font-size: 1.02rem; }
.hero-actions { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }

.section-sub { color: var(--muted); margin-top: -6px; max-width: 700px; }

/* Buttons */
.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--gold); color: #201404; }
.btn-primary:hover { background: var(--gold-light); }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--border); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-danger { background: var(--danger-bg); color: var(--danger); }

.link-btn {
  background: none; border: none; color: var(--muted);
  text-decoration: underline; cursor: pointer; font-size: 0.85rem; padding: 4px 0;
}
.link-btn.danger { color: var(--danger); }
.footnote-actions { display: flex; gap: 20px; margin-top: 36px; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin: 24px 0 40px; }
.stat-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-tile .stat-value { font-family: Georgia, serif; font-size: 1.7rem; color: var(--gold); display: block; }
.stat-tile .stat-label { font-size: 0.82rem; color: var(--muted); }

/* How it works */
.how-it-works { margin: 36px 0; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 18px; }
.steps li { display: flex; gap: 12px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.step-num {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
  background: var(--navy); color: var(--gold-light);
  display: flex; align-items: center; justify-content: center; font-family: Georgia, serif; font-weight: bold;
}
.steps p { margin: 4px 0 0; font-size: 0.88rem; color: var(--muted); }

/* Forms */
.profile-form { margin-top: 18px; }
.form-row { display: grid; gap: 14px; margin-bottom: 4px; }
.form-row.two-col { grid-template-columns: 1fr 1fr; }
.form-row.three-col { grid-template-columns: repeat(3, 1fr); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--navy-2); }
:root[data-theme="dark"] .field label { color: var(--gold-light); }
.field input, .field select {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  background: var(--card);
  color: var(--ink);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--gold); }
.field input.invalid, .field select.invalid { border-color: var(--danger); }
.field-error { margin: -2px 0 0; font-size: 0.78rem; color: var(--danger); }
.hint { margin: 0; font-size: 0.76rem; color: var(--muted); }
.required-mark { color: var(--danger); }
.form-note { font-size: 0.82rem; color: var(--muted); margin: 10px 0 18px; }
.form-note.trust { display: flex; gap: 8px; align-items: flex-start; background: var(--cream); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
:root[data-theme="dark"] .form-note.trust { background: var(--navy-2); }

.mirror-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; position: relative; }
.panel {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.panel legend { font-family: Georgia, serif; font-weight: bold; padding: 0 6px; color: var(--navy-2); }
:root[data-theme="dark"] .panel legend { color: var(--gold-light); }

.checkbox-row { display: flex; align-items: flex-start; gap: 8px; font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
.checkbox-row input { margin-top: 3px; }

.form-actions { display: flex; gap: 12px; margin-top: 20px; }

/* Profiles grid */
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.search-input {
  padding: 9px 14px; border: 1.5px solid var(--border); border-radius: 999px;
  font-size: 0.88rem; min-width: 240px; background: var(--card); color: var(--ink);
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-head h3 { font-size: 1.05rem; margin: 0; }
.card-agent { font-size: 0.78rem; color: var(--muted); }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
}
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-paused { background: var(--danger-bg); color: var(--danger); }
.badge-gold { background: rgba(169,121,63,0.15); color: var(--gold); }

.mini-block { font-size: 0.85rem; }
.mini-block .label { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; display: block; margin-bottom: 2px;}
.mini-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.card-actions { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }

/* Matches / chains */
.stack { display: flex; flex-direction: column; gap: 16px; margin-top: 18px; }
.match-card, .chain-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.match-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.score-pill {
  font-family: Georgia, serif; font-weight: bold; font-size: 1.1rem;
  background: var(--navy); color: var(--gold-light); padding: 6px 16px; border-radius: 999px;
}
.match-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; }
.swap-icon { font-size: 1.3rem; color: var(--gold); }
.side { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 12px; }
.side h4 { margin: 0 0 6px; font-size: 0.95rem; }
.side .tiny { font-size: 0.78rem; color: var(--muted); margin: 2px 0; }
.reaction-row { display: flex; gap: 6px; margin-top: 8px; }
.reaction-btn {
  border: 1px solid var(--border); background: transparent; border-radius: 999px;
  padding: 4px 10px; font-size: 0.76rem; cursor: pointer; color: var(--ink);
}
.reaction-btn.like.active { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.reaction-btn.pass.active { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }

.match-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; flex-wrap: wrap; gap: 10px; }

.chain-flow { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chain-node { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; background: var(--cream); }
:root[data-theme="dark"] .chain-node { background: var(--navy-2); }
.chain-node strong { display: block; font-size: 0.9rem; }
.chain-node span { font-size: 0.76rem; color: var(--muted); }
.chain-arrow { color: var(--gold); font-size: 1.2rem; }

.empty-state {
  text-align: center; padding: 40px 20px; color: var(--muted);
  border: 1.5px dashed var(--border); border-radius: var(--radius);
}

/* Agent dashboard */
.agent-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.agent-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.agent-stats { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }
.agent-stats div { font-size: 0.8rem; color: var(--muted); }
.agent-stats strong { display: block; font-family: Georgia, serif; font-size: 1.15rem; color: var(--ink); }
.client-chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.client-chip { background: var(--cream); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 0.78rem; }
:root[data-theme="dark"] .client-chip { background: var(--navy-2); }

.site-footer { text-align: center; padding: 20px; font-size: 0.78rem; color: var(--muted); border-top: 1px solid var(--border); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #f2efe7; padding: 12px 22px; border-radius: 999px;
  font-size: 0.88rem; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 50; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Responsive */
@media (max-width: 720px) {
  .mirror-columns { grid-template-columns: 1fr; }
  .form-row.two-col, .form-row.three-col { grid-template-columns: 1fr; }
  .match-pair { grid-template-columns: 1fr; }
  .swap-icon { transform: rotate(90deg); justify-self: center; }
  .hero h1 { font-size: 1.5rem; }
  .topbar { padding: 12px 16px; }
}
