:root {
  /* Layout: deal-type picker on top, form left, live letter center, ad column right */
  --ink: #1b2230;
  --muted: #5d6676;
  --paper: #f4f5f7;
  --card: #ffffff;
  --line: #dde1e7;
  --accent: #1f5f8b;
  --accent-ink: #ffffff;
  --ad: #eef1f5;
  --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-doc: "Source Serif 4", Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e6e9ef; --muted: #9aa3b2; --paper: #12161d; --card: #1a202a;
    --line: #2c3442; --accent: #5aa3d6; --accent-ink: #0d1218; --ad: #1f2632;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e6e9ef; --muted: #9aa3b2; --paper: #12161d; --card: #1a202a;
  --line: #2c3442; --accent: #5aa3d6; --accent-ink: #0d1218; --ad: #1f2632;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--font-ui); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
header.old { border-bottom: 1px solid var(--line); background: var(--card); }
header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; padding-bottom: 14px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.brand span { color: var(--accent); }
.tag { color: var(--muted); font-size: 13px; }
.ad { background: var(--ad); border: 1px dashed var(--line); color: var(--muted); display: flex; align-items: center; justify-content: center; text-align: center; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; border-radius: 6px; }
.ad-top { height: 90px; max-width: 728px; margin: 18px auto; }
.intro { padding: 6px 0 14px; }
.intro h1 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; text-wrap: balance; letter-spacing: -0.015em; }
.intro p { margin: 0; color: var(--muted); max-width: 70ch; }
.types { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 18px; }
.types a { text-decoration: none; font-size: 14px; font-weight: 500; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; }
.types a:hover { border-color: var(--accent); }
.types a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.types a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.grid { display: grid; grid-template-columns: 380px 1fr 300px; gap: 20px; align-items: start; padding-bottom: 40px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
form.panel { padding: 18px; display: flex; flex-direction: column; gap: 18px; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
legend { font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); margin-bottom: 8px; padding: 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
label.full { grid-column: 1 / -1; }
input, select, textarea { font: inherit; font-size: 14px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 5px; padding: 7px 9px; width: 100%; }
textarea { resize: vertical; min-height: 54px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 13.5px; }
.check input { width: auto; }
.preview-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
button { font: inherit; font-weight: 600; font-size: 14px; border-radius: 6px; padding: 9px 16px; cursor: pointer; border: 1px solid var(--accent); }
.primary { background: var(--accent); color: var(--accent-ink); }
.ghost { background: transparent; color: var(--accent); }
.status { font-size: 13px; color: var(--muted); }
.letter { padding: 40px 44px; font-family: var(--font-doc); font-size: 15px; line-height: 1.55; }
.letter h2 { font-size: 20px; text-align: center; margin: 0 0 4px; letter-spacing: 0.02em; }
.letter .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; font-family: var(--font-ui); }
.letter p { margin: 0 0 12px; }
.terms { display: grid; grid-template-columns: 190px 1fr; border-top: 1px solid var(--line); }
.terms > div { padding: 9px 0; border-bottom: 1px solid var(--line); }
.terms .k { font-weight: 600; padding-right: 14px; }
table.sched { border-collapse: collapse; margin-top: 6px; font-family: var(--font-ui); font-size: 13px; font-variant-numeric: tabular-nums; width: 100%; max-width: 420px; }
table.sched th, table.sched td { text-align: right; padding: 3px 8px; border-bottom: 1px solid var(--line); }
table.sched th:first-child, table.sched td:first-child { text-align: left; }
table.sched th { color: var(--muted); font-weight: 500; }
.sig { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 30px; }
.sig div { border-top: 1px solid var(--ink); padding-top: 6px; font-size: 13px; font-family: var(--font-ui); }
.disclaim { font-size: 12px; color: var(--muted); font-family: var(--font-ui); margin-top: 22px; }
aside { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }
.ad-side { height: 250px; }
.promo { padding: 16px; font-size: 14px; }
.promo strong { display: block; margin-bottom: 4px; }
.promo p { margin: 0 0 10px; color: var(--muted); }
footer.old { border-top: 1px solid var(--line); padding: 18px 0 30px; color: var(--muted); font-size: 12.5px; }
footer.old .wrap { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 1100px) {
  .grid { grid-template-columns: 360px 1fr; }
  aside { grid-column: 1 / -1; position: static; flex-direction: row; flex-wrap: wrap; }
  aside > * { flex: 1 1 280px; }
}
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .letter { padding: 24px 18px; }
  .terms { grid-template-columns: 1fr; }
  .ad-top { height: 60px; }
  .intro h1 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- site chrome ---- */
header.site { border-bottom: 1px solid var(--line); background: var(--card); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; padding-bottom: 14px; flex-wrap: wrap; }
a.brand { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
nav.top { display: flex; gap: 18px; }
nav.top a { color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500; }
nav.top a:hover { color: var(--accent); }
nav.top { align-items: center; }
.theme-btn { font: inherit; font-size: 13px; font-weight: 500; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; cursor: pointer; }
.theme-btn:hover { color: var(--ink); border-color: var(--accent); }
@media print { .theme-btn { display: none; } }
footer.site { border-top: 1px solid var(--line); padding: 20px 0 32px; color: var(--muted); font-size: 12.5px; margin-top: 20px; }
footer.site .wrap { display: flex; flex-direction: column; gap: 8px; }
.foot-links { display: flex; flex-wrap: wrap; gap: 16px; }
.foot-links a { color: var(--muted); }
.page { padding-top: 10px; padding-bottom: 30px; }
.prose { max-width: 70ch; }
.prose h1 { font-size: 32px; line-height: 1.2; letter-spacing: -0.015em; margin: 8px 0 14px; text-wrap: balance; }
.prose h2 { font-size: 20px; margin: 26px 0 8px; text-wrap: balance; }
.prose p, .prose li { font-size: 16px; line-height: 1.65; }
.prose ul, .prose ol { padding-left: 22px; display: flex; flex-direction: column; gap: 4px; }
.meta, .small, .crumbs { color: var(--muted); font-size: 13px !important; }
.crumbs a { color: var(--muted); }
.big { font-size: 20px !important; font-weight: 600; }
.hero { padding: 18px 0 8px; }
.hero h1 { font-size: 40px; line-height: 1.1; letter-spacing: -0.02em; margin: 0 0 10px; }
.hero p { max-width: 68ch; color: var(--muted); font-size: 17px; margin: 0; }
h2.section { font-size: 20px; margin: 28px 0 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 6px; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); }
.card:hover { border-color: var(--accent); }
.card strong { font-size: 16px; color: var(--accent); }
.card span { font-size: 14px; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 18px; }
.guide-list { list-style: none; padding: 0 !important; gap: 14px !important; }
.guide-list span { color: var(--muted); font-size: 14px; }
.cta { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin: 26px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { font-size: 13.5px; text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; color: var(--ink); }
.chip:hover { border-color: var(--accent); }
.below { padding: 10px 0 20px; }
.ad-inline { height: 120px; margin: 24px 0; }
.noscript { color: var(--muted); }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } .hero h1 { font-size: 30px; } }

/* ---- layout fix: keep the letter inside its card ---- */
.wrap { max-width: 1320px; }
.grid { grid-template-columns: 350px minmax(0, 1fr) 260px; }
.letter { padding: 36px 32px; overflow-wrap: anywhere; }
.terms { grid-template-columns: minmax(110px, 160px) minmax(0, 1fr); }
.terms > div { min-width: 0; }
.sched-wrap { overflow-x: auto; max-width: 100%; }
table.sched { width: auto; min-width: 0; max-width: none; font-size: 12.5px; }
table.sched th, table.sched td { padding: 3px 6px; white-space: nowrap; }
@media (max-width: 1280px) {
  .grid { grid-template-columns: 340px minmax(0, 1fr); }
  aside { grid-column: 1 / -1; position: static; flex-direction: row; flex-wrap: wrap; }
  aside > * { flex: 1 1 260px; }
}
@media (max-width: 760px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .letter { padding: 22px 16px; }
  .terms { grid-template-columns: minmax(0, 1fr); }
  .terms .k { border-bottom: 0; padding-bottom: 0; }
}

/* ---- additional terms ---- */
fieldset > .full { grid-column: 1 / -1; }
.crow textarea { min-height: 80px; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.clist { display: flex; flex-direction: column; gap: 12px; }
.clist:empty { display: none; }
.crow { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.crow input, .crow textarea { background: var(--card); }
.rm { align-self: flex-start; background: none; border: 0; padding: 0; font-size: 12.5px; font-weight: 500; color: var(--muted); text-decoration: underline; cursor: pointer; }
.rm:hover { color: var(--ink); }
.addterm { border-style: dashed; }

/* ---- remove built-in terms ---- */
.terms .k { position: relative; padding-right: 30px; }
.rmk { position: absolute; top: 7px; right: 8px; width: 22px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--card); color: var(--muted); font-size: 15px; line-height: 1; font-family: var(--font-ui); font-weight: 500; cursor: pointer; opacity: 0.45; }
.terms .k:hover .rmk, .terms .k + div:hover ~ .rmk, .rmk:focus-visible { opacity: 1; }
.rmk:hover { color: #b42318; border-color: #b42318; opacity: 1; }
.exporting .rmk { display: none; }
@media (hover: none) { .rmk { opacity: 0.8; } }
@media (max-width: 760px) { .terms .k { padding-right: 34px; } .rmk { top: 6px; right: 0; } }
@media print { .rmk { display: none !important; } }
@media print {
  header.site, footer.site, .crumbs, .intro, .types, form.panel, .toolbar, aside, .below, .ad { display: none !important; }
  body { background: #fff; color: #000; }
  .grid { display: block; }
  .letter { border: 0; padding: 0; }
}

/* ---- library ---- */
.library { padding-top: 6px; }
.search { display: flex; flex-direction: column; gap: 6px; max-width: 560px; font-weight: 600; font-size: 14px; color: var(--ink); }
.search input { font-size: 16px; padding: 11px 14px; background: var(--card); }
.qcount { display: block; color: var(--muted); font-size: 13px; min-height: 18px; margin-top: 6px; }
.jump { margin: 8px 0 6px; }
.noresults { color: var(--muted); }
.cat { margin-top: 8px; }
.cat-head { display: flex; align-items: baseline; gap: 10px; }
.cat-head h2 a { color: var(--ink); text-decoration: none; }
.cat-head h2 a:hover { color: var(--accent); }
.count { font-size: 12.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; }
.cat-blurb { margin: -4px 0 12px; color: var(--muted); font-size: 14px; }
.subcat h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 14px 0 8px; font-weight: 600; }
.doctype { font-style: normal; font-size: 12px; color: var(--muted); }
.types a.all { border-style: dashed; }
.gcat { margin-top: 26px; }
.gcat .cat-head h2 { margin: 0; }
.guide-cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.guide-cards .card { text-decoration: none; }
.prose .guide-cards .card span { font-size: 14px; line-height: 1.5; }
.soon { color: var(--muted); font-size: 14px !important; margin: 0 0 10px; }
.chip .n { color: var(--muted); font-size: 12px; margin-left: 2px; }
h3.gsub { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; margin: 16px 0 4px; }
h3.gsub a { color: var(--muted); text-decoration: none; }
h3.gsub a:hover { color: var(--accent); }
.logo-wrap { display: flex; justify-content: center; margin: -8px 0 20px; }
.doc-logo { max-height: 64px; max-width: 220px; width: auto; height: auto; object-fit: contain; }
.intro p.warn { margin-top: 10px; max-width: 80ch; padding: 10px 14px; border: 1px solid var(--line); border-left: 3px solid #b7791f; border-radius: 6px; background: var(--card); color: var(--ink); font-size: 14px; }
.crumbs.top { display: block; padding-top: 14px; }
[hidden] { display: none !important; }
