/* The Market Quill — base styles */
:root {
  --paper: #faf7f1;
  --surface: #ffffff;
  --ink: #1c2230;
  --ink-soft: #4a5263;
  --muted: #7a8193;
  --line: #e4dfd4;
  --accent: #1f5f4f;      /* quill green */
  --accent-soft: #e5efe9;
  --gold: #a87b2c;
  --warn-bg: #fff6e0;
  --warn-line: #ecd59a;
  --good: #1f7a4d;
  --shadow: 0 1px 2px rgba(28,34,48,.06), 0 4px 16px rgba(28,34,48,.05);
  --radius: 12px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12151c; --surface: #1a1e27; --ink: #eceae4; --ink-soft: #c2c5cd;
    --muted: #8d93a1; --line: #2c313d; --accent: #6cc3a8; --accent-soft: #1d2f2a;
    --gold: #d6a85a; --warn-bg: #2a2416; --warn-line: #5a4a22; --good: #6cc3a8;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --paper: #12151c; --surface: #1a1e27; --ink: #eceae4; --ink-soft: #c2c5cd;
  --muted: #8d93a1; --line: #2c313d; --accent: #6cc3a8; --accent-soft: #1d2f2a;
  --gold: #d6a85a; --warn-bg: #2a2416; --warn-line: #5a4a22; --good: #6cc3a8;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.65 var(--sans);
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 5vw, 3rem); margin: .2em 0 .4em; }
h2 { font-size: clamp(1.4rem, 3vw, 1.85rem); margin: 2em 0 .6em; }
h3 { font-size: 1.2rem; margin: 1.4em 0 .4em; }
p { margin: 0 0 1em; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 760px; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 10; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand svg { width: 30px; height: 30px; color: var(--accent); flex: none; }
.brand-name { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; letter-spacing: -.01em; }
.brand-name em { font-style: italic; color: var(--accent); font-weight: 500; }
.nav { display: flex; gap: 4px 18px; flex-wrap: wrap; font-size: .95rem; }
.nav a { color: var(--ink-soft); text-decoration: none; padding: 4px 0; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--accent); }

/* Hero */
.hero { padding: 56px 0 32px; }
.kicker { font-size: .8rem; text-transform: uppercase; letter-spacing: .14em; color: var(--gold); font-weight: 600; margin-bottom: 8px; }
.lede { font-size: 1.15rem; color: var(--ink-soft); max-width: 640px; }
.btn { display: inline-block; background: var(--accent); color: #fff; text-decoration: none; padding: 12px 20px; border-radius: 999px; font-weight: 600; border: 0; cursor: pointer; font-size: 1rem; }
:root[data-theme="dark"] .btn { color: #0e1714; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn { color: #0e1714; } }
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }

/* Cards */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h3 { margin-top: 0; }
.card a.more { font-weight: 600; text-decoration: none; }
.card p:last-child { margin-bottom: 0; }

/* Notices */
.note { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: 12px 16px; font-size: .92rem; color: var(--ink-soft); }
.note strong { color: var(--ink); }
.muted { color: var(--muted); font-size: .9rem; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; background: var(--accent-soft); color: var(--ink); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
#broker-table td:first-child { min-width: 170px; }
#broker-table td { min-width: 110px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.best td { background: color-mix(in srgb, var(--accent-soft) 70%, transparent); }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff; vertical-align: middle; }
:root[data-theme="dark"] .tag { color: #0e1714; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tag { color: #0e1714; } }

/* Calculator */
.calc { display: grid; gap: 20px; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); align-items: start; }
@media (max-width: 820px) { .calc { grid-template-columns: 1fr; } }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
.form input, .form select {
  font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); width: 100%;
}
.form input:focus, .form select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.seg button { font: inherit; font-size: .9rem; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .seg button[aria-pressed="true"] { color: #0e1714; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg button[aria-pressed="true"] { color: #0e1714; } }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.stat .k { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; }
details.breakdown summary { cursor: pointer; color: var(--accent); font-weight: 600; margin: 12px 0; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 24px 22px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.timeline .date { font-size: .82rem; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: .08em; }
.timeline h3 { margin: 2px 0 6px; }

/* Article */
.article { padding: 32px 0 16px; }
.article ul, .article ol { padding-left: 1.3em; }
.article li { margin-bottom: .4em; }
.byline { color: var(--muted); font-size: .9rem; margin-bottom: 24px; }
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin: 16px 0 24px; }
.toc ol { margin: 6px 0 0; }

/* Newsletter */
.signup { background: var(--accent-soft); border-radius: var(--radius); padding: 24px; margin: 48px 0 0; }
.signup h2 { margin-top: 0; }
.signup form { display: flex; gap: 8px; flex-wrap: wrap; }
.signup input { flex: 1 1 220px; font: inherit; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); margin-top: 64px; padding: 32px 0 40px; font-size: .88rem; color: var(--muted); }
.site-footer .cols { display: grid; gap: 20px; grid-template-columns: 2fr 1fr 1fr; }
@media (max-width: 700px) { .site-footer .cols { grid-template-columns: 1fr; } }
.site-footer a { color: var(--ink-soft); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 6px; }
.disclaimer { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .8rem; line-height: 1.55; }
/* Broker links & account CTAs */
a.broker-link { font-weight: 600; text-decoration: underline; text-decoration-style: dotted; text-decoration-color: var(--accent); }
a.broker-link:hover { text-decoration-style: solid; }
.btn-block { display: block; text-align: center; width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .85rem; white-space: nowrap; }
.nav a.nav-cta { background: var(--accent); color: #fff; padding: 6px 14px; border-radius: 999px; font-weight: 600; }
.nav a.nav-cta:hover { color: #fff; filter: brightness(1.08); }
:root[data-theme="dark"] .nav a.nav-cta { color: #0e1714; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nav a.nav-cta { color: #0e1714; } }
.broker-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.broker-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.broker-card-head { display: flex; gap: 12px; align-items: center; }
.broker-initial { width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-family: var(--serif); font-weight: 600; font-size: 1.3rem; flex: none; }
.broker-card-name { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
.broker-points { margin: 0; padding-left: 1.1em; font-size: .92rem; color: var(--ink-soft); flex: 1; }
.broker-points li { margin-bottom: 4px; }
.cta-band { background: var(--accent); color: #fff; border-radius: var(--radius); padding: 24px; margin: 32px 0; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.cta-band h2 { margin: 0 0 4px; color: inherit; font-size: 1.5rem; }
.cta-band p { margin: 0; opacity: .9; }
.cta-band .btn { background: #fff; color: var(--accent); }
:root[data-theme="dark"] .cta-band { color: #0e1714; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cta-band { color: #0e1714; } }
.aff-note { font-size: .8rem; color: var(--muted); margin-top: 8px; }
.sticky-cta { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0,0,0,.08); padding: 10px 16px; display: flex; gap: 12px; align-items: center; justify-content: center; font-size: .92rem; }
.sticky-cta[hidden] { display: none; }
.sticky-cta .x { background: none; border: 0; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: 0 4px; }
body.has-sticky { padding-bottom: 64px; }
.theme-toggle { background: none; border: 1px solid var(--line); color: var(--ink-soft); border-radius: 999px; padding: 4px 10px; cursor: pointer; font: inherit; font-size: .85rem; }
