:root {
    color-scheme: light dark;
    --bg: #f6f7fb;
    --surface: #ffffff;
    --text: #1b1e28;
    --muted: #5b6172;
    --border: #e2e4ec;
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --danger: #dc2626;
    --success: #15803d;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #14151c;
      --surface: #1d1f29;
      --text: #eef0f6;
      --muted: #a2a6b8;
      --border: #2c2f3c;
      --brand: #818cf8;
      --brand-dark: #6366f1;
    }
  }
  * { box-sizing: border-box; }
  body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
  }
  header {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    flex-shrink: 0;
  }
  .nav-toggle:hover { background: var(--bg); }
  .nav-toggle svg { width: 18px; height: 18px; flex: none; }
  .brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
  }
  .beta-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--brand);
    border: 1px solid var(--brand);
    border-radius: 999px;
    padding: 1px 6px;
    margin-left: 6px;
    vertical-align: middle;
  }
  .tier-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-radius: 999px;
    padding: 1px 6px;
    margin-left: 6px;
    vertical-align: middle;
    border: 1px solid var(--border);
    color: var(--muted);
  }
  .tier-badge[data-tier="free"] { color: var(--muted); border-color: var(--border); }
  .tier-badge[data-tier="silver"] { color: #c3c8d4; border-color: #c3c8d4; }
  .tier-badge[data-tier="gold"] { color: #e6b800; border-color: #e6b800; }
  .tier-badge[data-tier="platinum"] { color: var(--brand); border-color: var(--brand); }
  .nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 29;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .nav-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }
  nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    gap: 2px;
    overflow-y: auto;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  nav.open { transform: translateX(0); }
  nav .brand {
    padding: 0 10px 16px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }
  nav a:not(.brand), nav button.nav-authed-only {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.95rem;
    padding: 10px 10px;
    border-radius: 8px;
  }
  nav a:not(.brand):not(.btn):hover, nav button.nav-authed-only:hover {
    color: var(--brand);
    background: var(--bg);
  }
  nav a:not(.brand) svg, nav button.nav-authed-only svg {
    width: 18px;
    height: 18px;
    flex: none;
  }
  html:not([data-auth]) .nav-guest-only,
  html:not([data-auth]) .nav-authed-only,
  html[data-auth="guest"] .nav-authed-only,
  html[data-auth="authed"] .nav-guest-only {
    display: none;
  }
  nav button.nav-authed-only {
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
  }
  nav a.btn, nav a.btn:hover { color: #fff; }
  nav .nav-heading {
    padding: 16px 10px 4px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    opacity: 0.7;
  }
  nav .nav-heading:first-of-type { padding-top: 8px; }
  main {
    max-width: 960px;
    margin: 0 auto;
    padding: 48px 24px 96px;
  }
  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    max-width: 420px;
  }
  h1 { font-size: 1.9rem; margin: 0 0 8px; }
  h2 { font-size: 1.4rem; margin: 0 0 16px; }
  p.lede { color: var(--muted); font-size: 1.05rem; max-width: 640px; }
  .hero { padding-bottom: 24px; }
  .cta-row { display: flex; gap: 12px; margin-top: 24px; }
  .steps {
    list-style: none;
    padding: 0;
    margin: 32px 0 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
  }
  .steps li {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
  }
  .steps li .num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--brand);
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 10px;
  }
  form { display: flex; flex-direction: column; gap: 14px; }
  label { font-size: 0.9rem; color: var(--muted); }
  input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
  }
  input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
  .field { display: flex; flex-direction: column; gap: 6px; }
  .hint { font-size: 0.8rem; color: var(--muted); }
  .hint.success { color: var(--success); }
  .hint.error { color: var(--danger); }
  .required-mark { color: var(--danger); font-weight: 700; }
  .optional-mark { color: var(--muted); font-weight: 400; font-size: 0.85em; }
  .field-checkbox label { display: flex; align-items: flex-start; gap: 8px; }
  .field-checkbox input[type="checkbox"] { width: auto; margin-top: 3px; flex-shrink: 0; }
  button:disabled, .btn:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }
  button, .btn {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    background: var(--brand);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
  }
  button:hover, .btn:hover { background: var(--brand-dark); }
  .btn.secondary {
    background: transparent;
    color: var(--brand);
    border: 1px solid var(--border);
  }
  .btn.secondary:hover { background: var(--surface); }
  .message {
    margin-top: 4px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    display: none;
  }
  .message.error { display: block; background: rgba(220,38,38,0.1); color: var(--danger); }
  .message.success { display: block; background: rgba(21,128,61,0.12); color: var(--success); }
  .links { margin-top: 16px; font-size: 0.9rem; color: var(--muted); }
  .links a { color: var(--brand); text-decoration: none; }
  .links a:hover { text-decoration: underline; }
  footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 24px;
  }
  footer .footer-links {
    margin-top: 6px;
  }
  footer .footer-links a {
    color: var(--muted);
    text-decoration: none;
    margin: 0 8px;
  }
  footer .footer-links a:hover {
    color: var(--brand);
    text-decoration: underline;
  }
  .legal h2 { margin-top: 32px; font-size: 1.15rem; }
  .legal h2:first-of-type { margin-top: 0; }
  .legal p, .legal li { color: var(--muted); }
  .legal .updated { color: var(--muted); font-size: 0.85rem; margin-bottom: 24px; }
  .banner {
    background: rgba(79,70,229,0.1);
    border: 1px solid var(--brand);
    color: var(--text);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.9rem;
    margin-bottom: 16px;
  }
  .referral-card {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
  }
  .referral-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
  }
  .referral-row textarea {
    flex: 1;
    font-size: 0.85rem;
    font-family: inherit;
    resize: vertical;
  }
  .referral-row button {
    flex-shrink: 0;
    padding: 10px 16px;
  }
  .founding-note {
    margin-top: 12px;
    font-weight: 600;
    color: var(--brand);
  }
  html:not([data-auth="authed"]) .dashboard { display: none; }
  html[data-auth="authed"] .hero,
  html[data-auth="authed"] .steps,
  html[data-auth="authed"] .faq {
    display: none;
  }
  .dashboard h1 { margin-bottom: 4px; }
  .dashboard .lede { margin-top: 0; margin-bottom: 32px; }
  .stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
  }
  .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
  }
  .stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
  }
  .stat-card .stat-label {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 4px;
  }
  .dashboard-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
  }
  .dashboard-cols .card { max-width: none; }
  .list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
  }
  .list-row:last-child { margin-bottom: 0; }
  .list-row code {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
  .list-row a {
    flex: none;
    white-space: nowrap;
  }
  .pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 32px;
    align-items: stretch;
  }
  .tier-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
  }
  .tier-card.featured {
    border-color: var(--brand);
    box-shadow: 0 0 0 1px var(--brand);
  }
  .tier-card h3 { margin: 0 0 4px; font-size: 1.3rem; }
  .tier-price { font-size: 2rem; font-weight: 700; margin: 12px 0 4px; }
  .tier-price span { font-size: 0.95rem; font-weight: 400; color: var(--muted); }
  .tier-features {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .tier-features li {
    color: var(--text);
    font-size: 0.92rem;
    padding-left: 22px;
    position: relative;
  }
  .tier-features li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: 700;
  }
  .free-tier-row {
    margin-top: 20px;
  }
  .free-tier-row .tier-card {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px 24px;
    background: transparent;
  }
  .free-tier-row .tier-card h3 { margin: 0; }
  .free-tier-row .tier-price { margin: 0; font-size: 1.3rem; }
  .free-tier-row .tier-features {
    flex-direction: column;
    margin: 0;
    gap: 10px;
  }
  .free-tier-row .tier-savings { display: none !important; }
  .free-tier-row .btn { margin-left: auto; }
  .billing-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 28px;
  }
  .toggle-label {
    font-size: 0.95rem;
    color: var(--muted);
  }
  .toggle-label[data-active="true"] {
    color: var(--text);
    font-weight: 600;
  }
  .switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
  }
  .switch input {
    opacity: 0;
    width: 0;
    height: 0;
  }
  .switch-track {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 999px;
    transition: background 0.15s;
  }
  .switch-track::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.15s;
  }
  .switch input:checked + .switch-track {
    background: var(--brand);
  }
  .switch input:checked + .switch-track::before {
    transform: translateX(20px);
  }
  .tier-savings {
    font-size: 0.82rem;
    color: var(--success);
    font-weight: 600;
    margin-top: -6px;
  }
  .tier-trial {
    font-size: 0.82rem;
    color: var(--brand);
    font-weight: 600;
    margin-top: 4px;
  }
  .coupon-row {
    margin-top: 28px;
    max-width: 320px;
  }
  .coupon-row label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 6px;
  }
  .coupon-row input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
  }
  .coupon-error {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 8px;
  }
  .chat-thread {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 4px 4px 12px;
  }
  .bubble-row {
    display: flex;
  }
  .bubble-row.mine {
    justify-content: flex-end;
  }
  .bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.4;
    word-wrap: break-word;
  }
  .bubble-row:not(.mine) .bubble {
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
  }
  .bubble-row.mine .bubble {
    background: var(--brand);
    color: #fff;
    border-bottom-right-radius: 4px;
  }
  .bubble-time {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 3px;
  }
  .bubble-row.mine .bubble-time {
    text-align: right;
  }
  .sender-name {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 2px;
  }
  .sender-color-0 { color: #d946ef; }
  .sender-color-1 { color: #0ea5e9; }
  .sender-color-2 { color: #16a34a; }
  .sender-color-3 { color: #ea580c; }
  .sender-color-4 { color: #dc2626; }
  .sender-color-5 { color: #7c3aed; }
  .sender-color-6 { color: #0d9488; }
  .sender-color-7 { color: #ca8a04; }
  .icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
  }
  .icon-btn:hover {
    background: var(--surface);
    color: var(--text);
  }
  .icon-btn.danger:hover {
    background: rgba(220,38,38,0.1);
    color: var(--danger);
  }
  .icon-btn svg {
    width: 15px;
    height: 15px;
  }
  .chat-composer {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
  }
  .chat-composer input {
    flex: 1;
  }
  .chat-composer button {
    flex-shrink: 0;
  }
  .hero {
    padding: 56px 0 40px;
    text-align: left;
  }
  .hero h1 {
    font-size: 2.75rem;
    line-height: 1.12;
    letter-spacing: -0.02em;
    max-width: 780px;
  }
  .hero .lede { font-size: 1.15rem; max-width: 620px; }
  .eyebrow {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--brand);
    margin-bottom: 14px;
  }
  .value-section {
    margin-top: 64px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 360px);
    gap: 40px;
    align-items: center;
  }
  @media (max-width: 700px) {
    .value-section {
      grid-template-columns: 1fr;
    }
  }
  .value-section h2 { font-size: 1.9rem; letter-spacing: -0.01em; }
  .value-section p { color: var(--muted); font-size: 1.02rem; }
  .iceberg {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
  }
  .iceberg-visual {
    display: flex;
    flex-direction: column;
    height: 220px;
    border-radius: 10px;
    overflow: hidden;
  }
  .iceberg-tip {
    flex: 0 0 10%;
    background: rgba(79, 70, 229, 0.3);
  }
  .iceberg-body {
    flex: 1 1 auto;
    background: var(--brand);
  }
  .iceberg-waterline {
    height: 0;
    border-top: 2px dashed rgba(255,255,255,0.6);
  }
  .iceberg-legend {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .iceberg-legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .iceberg-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
  }
  .iceberg-swatch.tip { background: rgba(79, 70, 229, 0.3); }
  .iceberg-swatch.body { background: var(--brand); }
  .iceberg-pct {
    font-weight: 700;
    font-size: 0.95rem;
  }
  .iceberg-label {
    font-size: 0.9rem;
    color: var(--muted);
  }
  .section-heading {
    margin-top: 72px;
    max-width: 640px;
  }
  .section-heading h2 { font-size: 1.9rem; letter-spacing: -0.01em; margin-bottom: 10px; }
  .section-heading p { color: var(--muted); font-size: 1.02rem; }
  .feature-grid {
    margin-top: 28px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
  }
  .feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
  }
  .feature-card .icon-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(79, 70, 229, 0.12);
    color: var(--brand);
    font-weight: 700;
    margin-bottom: 14px;
  }
  .feature-card h3 { margin: 0 0 8px; font-size: 1.1rem; }
  .feature-card p { margin: 0; color: var(--muted); font-size: 0.95rem; }
  .pull-quote {
    margin-top: 56px;
    padding: 32px 36px;
    border-left: 4px solid var(--brand);
    background: var(--surface);
    border-radius: 0 14px 14px 0;
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.01em;
  }
  .cta-band {
    margin-top: 72px;
    padding: 44px 40px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    text-align: center;
  }
  .cta-band h2 { color: #fff; margin-bottom: 8px; }
  .cta-band p { color: rgba(255,255,255,0.85); margin: 0 auto 24px; max-width: 480px; }
  .cta-band .cta-row { justify-content: center; }
  .cta-band .btn { background: #fff; color: var(--brand-dark); }
  .cta-band .btn:hover { background: rgba(255,255,255,0.9); }
  .cta-band .btn.secondary { background: transparent; border-color: rgba(255,255,255,0.5); color: #fff; }
  .cta-band .btn.secondary:hover { background: rgba(255,255,255,0.12); }
  .steps { margin-top: 28px; }
  html[data-auth="authed"] .value-section,
  html[data-auth="authed"] .section-heading,
  html[data-auth="authed"] .pull-quote,
  html[data-auth="authed"] .cta-band {
    display: none;
  }
  .faq {
    margin-top: 48px;
  }
  .faq-list {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .faq-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px 20px;
  }
  .faq-item summary {
    cursor: pointer;
    list-style: none;
    padding: 16px 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .faq-item summary::-webkit-details-marker { display: none; }
  .faq-item summary::after {
    content: "+";
    color: var(--muted);
    font-weight: 400;
    font-size: 1.2rem;
    flex-shrink: 0;
  }
  .faq-item[open] summary::after { content: "−"; }
  .faq-item p {
    margin: 0 0 16px;
    color: var(--muted);
  }
  .messages-layout {
    display: flex;
    gap: 0;
    height: 70vh;
    min-height: 420px;
  }
  .contacts-pane {
    width: 260px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    padding-right: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .contacts-pane input {
    margin-bottom: 8px;
  }
  .contact-item {
    display: block;
    text-decoration: none;
    color: inherit;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    border: 1px solid transparent;
  }
  .contact-item:hover { background: var(--bg); }
  .contact-item.active {
    background: var(--bg);
    border-color: var(--border);
  }
  .contact-item .name { font-weight: 600; font-size: 0.92rem; }
  .contact-item .preview {
    color: var(--muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .thread-pane {
    flex: 1;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .thread-pane .chat-thread { flex: 1; }
  .thread-empty {
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 20px;
  }
  @media (min-width: 900px) {
    nav {
      transform: none;
    }
    .nav-toggle, .nav-backdrop {
      display: none;
    }
    header, main, footer {
      margin-left: 260px;
    }
  }
