/* Layout only: where things go. Styling comes later. */
/* Flex, not grid rows: browser extensions inject <div>s into <body>, which would take the rows. */
body { max-width: 960px; margin: 0 auto; padding: 0 16px; min-height: 100vh; display: flex; flex-direction: column; font-family: system-ui, sans-serif; }
header, nav { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
header { justify-content: space-between; padding: 12px 0; }
nav form, td form { display: inline; }
/* The menu button: only the paint layer (coat.css) shows it, on a phone. */
.nav-toggle { display: none; }
main { flex: 1; padding: 16px 0; }
/* viewport-fit=cover (base.html) lets the page reach under a phone's notch and rounded corners; its content stays clear of them. */
body { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
footer { padding: 12px 0; }
.stack { display: grid; gap: 8px; max-width: 480px; }
.stack label { display: grid; gap: 4px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 4px 8px; vertical-align: top; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.unread { font-weight: bold; }
.drop { border: 2px dashed; padding: 16px; margin: 8px 0; }
.nowrap { white-space: nowrap; }
.log { max-height: 60vh; overflow: auto; white-space: pre-wrap; }
/* Diffs: one block per line, so a line's color spans the width. */
.diff span { display: block; }
.diff .add { background: #e6ffec; }
.diff .del { background: #ffebe9; }
.diff .hunk { color: #57606a; }
.drop.over { border-style: solid; }
.debug { color: #e0b400; font-size: small; }
.center { text-align: center; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 24px; }
.features h3 { margin-bottom: 4px; }
.features p { margin-top: 0; }
.feature-icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.new-code code { font-size: 1.3em; }

/* The offer: the one styled thing on the site (buy page card, home page promo). */
@property --offer-angle { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@keyframes offer-spin { to { --offer-angle: 360deg; } }
/* Fully off the left to fully off the right, then a rest out of sight; the restart is never seen. */
@keyframes offer-shine { 0% { transform: translateX(-160%) skewX(-20deg); animation-timing-function: cubic-bezier(.45, 0, .25, 1); } 55%, 100% { transform: translateX(360%) skewX(-20deg); } }
@keyframes offer-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes offer-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes offer-pop { 0% { transform: scale(1); } 40% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes offer-ring { to { transform: rotate(360deg); } }
@keyframes offer-tick { to { stroke-dashoffset: 0; } }
@keyframes offer-fill { to { stroke-dashoffset: 0; } }

.offer-wrap, .promo-wrap { --red: #d4122e; --red-dark: #9e0b20; --gold: #ffb800; position: relative; margin: 40px auto 24px; color: #1c1c1f; }
.offer-wrap { max-width: 400px; }
.offer-glow { position: absolute; inset: -14px; border-radius: 34px; filter: blur(22px); opacity: .45; z-index: 0;
  background: conic-gradient(from var(--offer-angle), var(--red), #ff7a59, var(--gold), #ff4f8b, var(--red)); animation: offer-spin 6s linear infinite; }
.offer, .promo { position: relative; z-index: 1; border: 2px solid transparent; border-radius: 22px; overflow: hidden;
  background: linear-gradient(#fff, #fff) padding-box, conic-gradient(from var(--offer-angle), var(--red), #ff7a59, var(--gold), #ff4f8b, var(--red)) border-box;
  animation: offer-spin 6s linear infinite; box-shadow: 0 18px 50px -18px rgb(158 11 32 / .45); }
/* border-box: buy.js sets the height it measured with offsetHeight, which includes padding and border. */
.offer { box-sizing: border-box; padding: 36px 32px 28px; text-align: center; transition: height .3s ease; }
.offer.pop { animation: offer-spin 6s linear infinite, offer-pop .5s ease; }
.offer-view[hidden] { display: none; }
.offer h2 { margin: 6px 0 4px; font-size: 1.6rem; letter-spacing: -.01em; }
.offer p { margin: 6px 0; }
.offer-what { color: #5b5b66; padding: 0 12px; }
.offer-tag { display: inline-block; padding: 4px 12px; border-radius: 99px; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--red-dark); background: #ffe8ec; }
.offer-ribbon { position: absolute; top: 28px; right: -44px; width: 170px; padding: 6px 0; transform: rotate(45deg); text-align: center;
  font-size: .8rem; font-weight: 800; letter-spacing: .06em; color: #fff; background: linear-gradient(90deg, var(--red-dark), var(--red)); box-shadow: 0 4px 10px rgb(0 0 0 / .2); }
.offer:not([data-view="buy"]) .offer-ribbon { display: none; }
.offer-price { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 18px; }
.offer-was { font-size: 1.4rem; color: #8b8b96; text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--red); }
.offer-off { padding: 3px 10px; border-radius: 8px; font-weight: 800; color: #fff; background: var(--red); animation: offer-pulse 2.4s ease-in-out infinite; }
/* The gradient fills only the text's box: at line-height 1 the $ reaches past it above and below, and with the
   tight letter spacing the last figure past its right end. Room on those sides for the fill, taken back from
   the margins so nothing around it moves. */
.offer-now { font-size: 5rem; font-weight: 900; line-height: 1; letter-spacing: -.04em; padding: .12em .12em .12em 0; margin: calc(6px - .12em) -.12em calc(2px - .12em) 0;
  background: linear-gradient(135deg, var(--red-dark), var(--red) 55%, #ff6a3d); -webkit-background-clip: text; background-clip: text; color: transparent; }
.offer-now small { font-size: 1rem; font-weight: 600; letter-spacing: 0; margin-left: 6px; color: #5b5b66; -webkit-text-fill-color: #5b5b66; }
.offer .offer-note { font-weight: 700; font-style: italic; color: var(--red); }
.offer-list { list-style: none; padding: 0; margin: 18px 0 22px; display: grid; gap: 6px; text-align: left; justify-content: center; }
.offer-list li::before { content: "✓"; display: inline-block; width: 1.4em; font-weight: 800; color: var(--red); }
.offer-cta, .promo-cta { position: relative; overflow: hidden; display: block; width: 100%; box-sizing: border-box; padding: 14px 20px; border: 0; border-radius: 12px; cursor: pointer;
  font: inherit; font-size: 1.1rem; font-weight: 800; text-align: center; text-decoration: none; color: #fff;
  background: linear-gradient(180deg, #e8203d, var(--red-dark)); box-shadow: 0 8px 20px -8px rgb(158 11 32 / .8); }
.offer-cta::after, .promo-cta::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 40%; background: linear-gradient(90deg, transparent, rgb(255 255 255 / .45), transparent); animation: offer-shine 3.5s infinite; }
/* Hover darkens; nothing moves. */
.offer-cta:hover, .offer-cta:focus-visible, .promo:hover .promo-cta, .promo:focus-visible .promo-cta { background: linear-gradient(180deg, var(--red-dark), #6e0716); }
.offer-cta:disabled { cursor: progress; opacity: .7; }
.offer form { margin: 0; }
.offer-alt { max-width: 400px; margin: 10px auto 0; text-align: right; font-size: .85rem; }
.offer-alt a { color: #5b5b66; }
.offer-alt a:hover { color: var(--red); }
.offer-back { position: absolute; top: 14px; left: 14px; width: 36px; height: 36px; border: 0; border-radius: 50%; cursor: pointer; font-size: 1.2rem; color: #1c1c1f; background: #f1f1f4; transition: background .15s; }
.offer-back:hover { background: #e4e4ea; }
.offer-code { display: block; width: 100%; box-sizing: border-box; margin: 18px 0 8px; padding: 12px; border: 2px solid #dcdce3; border-radius: 12px; outline: none;
  font: 600 1.25rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; text-align: center; text-transform: uppercase; transition: border-color .15s; }
.offer-code:focus { border-color: var(--red); }
.offer-code.bad { border-color: var(--red); animation: offer-shake .4s ease; }
.offer .offer-error { min-height: 1.3em; font-size: .9rem; color: var(--red); }
.offer-seal { width: 96px; height: 96px; margin: 8px auto 6px; display: block; }
.offer-seal circle { fill: none; stroke: var(--red); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 100 45; transform-box: fill-box; transform-origin: center; animation: offer-ring .9s linear infinite; }
.offer-seal path { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; }
.offer-seal.ok circle { stroke-dasharray: 145; stroke-dashoffset: 145; fill: var(--red); transition: fill .3s .3s; animation: offer-fill .4s ease forwards; }
.offer-seal.ok path { animation: offer-tick .35s .45s ease forwards; }
.offer-links { display: grid; gap: 10px; margin-top: 18px; }
.offer .debug { margin-top: 12px; }

.promo-wrap { max-width: 620px; }
.promo-wrap .offer-glow { inset: -10px; border-radius: 30px; }
.promo { color: inherit; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; padding: 22px 26px; text-decoration: none; }
.promo-text { display: grid; gap: 2px; }
.promo-text .offer-tag { justify-self: start; }
.promo-title { font-size: 1.15rem; font-weight: 700; }
.promo-price { display: flex; align-items: baseline; gap: 10px; }
.promo-price .offer-now { font-size: 3rem; margin: -.12em -.12em -.12em 0; }
.promo-price .offer-was { font-size: 1.1rem; }
.promo-note { font-weight: 700; font-style: italic; color: var(--red); }
.promo-cta { width: auto; flex: 0 0 auto; }

@media (max-width: 480px) {
  .offer { padding: 32px 20px 24px; }
  .offer-now { font-size: 4rem; }
  .promo-cta { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .offer-glow, .offer, .promo, .offer-off, .offer-cta::after, .promo-cta::after { animation: none !important; }
}

/* Download page: three platform cards, the Lite card under them. Hover only recolors. */
.dl-cards, .dl-lite, .nav-lite { --red: #d4122e; --red-dark: #9e0b20; }
.dl-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 28px 0 16px; }
.dl-card { display: flex; flex-direction: column; align-items: center; padding: 28px 20px 22px; border: 1px solid #e3e3e8; border-radius: 16px; text-align: center; color: #1c1c1f; background: #fff; transition: border-color .15s; }
.dl-icon { width: 40px; height: 40px; fill: none; stroke: var(--red); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dl-card h2 { margin: 10px 0 2px; font-size: 1.35rem; }
.dl-version { margin: 0 0 18px; font-size: .9rem; color: #6b6b75; }
.dl-button { display: inline-block; box-sizing: border-box; min-width: 160px; padding: 11px 22px; border-radius: 10px; font-weight: 700; text-align: center; text-decoration: none; color: #fff; background: var(--red); transition: background-color .15s; }
.dl-button:hover, .dl-button:focus-visible { background: var(--red-dark); }
.dl-button.off { color: #8b8b96; background: #f1f1f4; }
.dl-alt { margin-top: 8px; font-size: .85rem; color: #6b6b75; }
.dl-needs { margin: 14px 0 0; font-size: .8rem; line-height: 1.4; color: #6b6b75; }
.dl-lite { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; padding: 20px 24px; border: 1px solid #e3e3e8; border-radius: 16px; color: #1c1c1f; text-decoration: none; background: linear-gradient(90deg, #fff6f7, #fff); transition: border-color .15s; }
.dl-lite-text { display: grid; gap: 4px; flex: 1 1 380px; }
.dl-lite-title { font-size: 1.1rem; font-weight: 700; }
.dl-lite-desc { font-size: .9rem; color: #5b5b66; }
.dl-archive-title { margin-top: 48px; }
.nav-lite { padding: 4px 12px; border: 1px solid var(--red); border-radius: 99px; font-size: .9rem; font-weight: 600; color: var(--red); text-decoration: none; transition: background-color .15s, color .15s; }
.nav-lite:hover, .nav-lite:focus-visible { color: #fff; background: var(--red); }

/* Lite (templates/lite.html, static/lite.js): the app's canvas fills the window; hidden (but laid out, so it starts at its size) until a PDF is open. */
.lite-app { position: fixed; inset: 0; z-index: 100; box-sizing: border-box; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: #fff; visibility: hidden; opacity: 0; transition: opacity .2s ease, visibility 0s linear .2s; }
.lite-app.on { visibility: visible; opacity: 1; transition: opacity .2s ease; }
.lite-app canvas { display: block; width: 100%; height: 100%; outline: none; touch-action: none; }
body.lite-on { overflow: hidden; }
.lite-recents ul { list-style: none; padding: 0; }
.lite-status.error { color: #b3122b; }
@media (prefers-reduced-motion: reduce) { .lite-app, .lite-app.on { transition: none; } }

/* The admin page's sections as tabs (templates/admin.html). */
.admin-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0 20px; }
.admin-tabs-links { margin-left: auto; display: flex; gap: 6px; }
/* The git pages: their tab bar comes first in the markup (git_base.html), shown under the page's heading as on the others. */
body.git main { display: flex; flex-direction: column; }
body.git main > * { order: 2; }
body.git main > h1 { order: 0; }
body.git main > .admin-tabs { order: 1; }
.code-uses input { width: 6em; margin-left: 6px; }

/* Admin mail (templates/mail.html): the mailboxes along the top, the message list on the left, the open message (or a new one) on the right. */
body:has(.mail) { max-width: 1280px; }
/* Exactly the window's height: scrolled to, it fills the screen, and the list and the message scroll inside it. */
/* Two resting places: the page's top, and the mail area filling the window. A scroll that ends near the mail settles onto it, a small one away springs back, and a fling from the top stops there. */
html:has(.mail) { scroll-snap-type: y proximity; }
html:has(.mail) body { scroll-snap-align: start; }
/* Nothing under it: scrolled down, the mail area is the page's end. */
main:has(.mail) { padding-bottom: 0; }
body:has(.mail) > footer { display: none; }
.mail { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "top top" "list pane"; gap: 16px; box-sizing: border-box; height: 100vh; height: 100dvh; padding: 12px 0; scroll-snap-align: start; scroll-snap-stop: always; }
.mail-top { grid-area: top; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mail-boxes, .mail-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mail-new { margin-left: auto; }
.mail-list { grid-area: list; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.mail-folders { display: grid; grid-template-columns: 1fr 1fr; text-align: center; }
.mail-search input { width: 100%; box-sizing: border-box; }
.mail-list ul { flex: 1; min-height: 0; list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.mail-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; }
.mail-who, .mail-subject, .mail-snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-subject, .mail-snippet { grid-column: 1 / -1; }
.mail-pane { grid-area: pane; min-width: 0; min-height: 0; overflow-y: auto; }
.mail-pane > .mail-tools { position: sticky; top: 0; z-index: 1; }
.mail-tools form { display: inline; }
.mail-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.mail-files { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }
/* One block per line: a quoted line's bar spans the width, and an empty line keeps its height. */
.mail-body span { display: block; min-height: 1lh; white-space: pre-wrap; overflow-wrap: anywhere; }
.mail-compose { display: grid; gap: 12px; }
.mail-compose label { display: grid; gap: 4px; }
.mail-back { display: none; }
/* A phone: the list, or the open message with a way back to it. */
@media (max-width: 760px) {
  .mail { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .mail-list, .mail-pane { grid-area: main; }
  .mail.reading .mail-list, .mail:not(.reading) .mail-pane { display: none; }
  .mail-back { display: inline-block; }
  .mail-head { grid-template-columns: auto minmax(0, 1fr); }
  .mail-head time { grid-column: 2; }
}
