/* ==========================================================================
   All Printable — base design system
   Shared across every printable generator. Screen chrome only; paper styling
   lives in each printable's own print stylesheet.
   ========================================================================== */

:root {
  --paper:      #ffffff;
  --canvas:     #f4f1ea;
  --surface:    #ffffff;
  --surface-2:  #faf8f3;
  --ink:        #16150f;
  --ink-soft:   #46433a;
  --muted:      #7c7668;
  --line:       #e4dfd2;
  --line-soft:  #efebe0;
  --accent:     #b4472e;
  --accent-ink: #8d3722;
  --accent-bg:  #fbeee9;
  --deep:       #2f4858;
  --ok:         #2f6d4f;

  --radius:     10px;
  --radius-lg:  16px;
  --shadow-sm:  0 1px 2px rgba(22,21,15,.06), 0 1px 1px rgba(22,21,15,.04);
  --shadow-md:  0 2px 8px rgba(22,21,15,.07), 0 8px 24px rgba(22,21,15,.06);
  --shadow-lg:  0 4px 12px rgba(22,21,15,.08), 0 18px 48px rgba(22,21,15,.10);

  --sans: ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --sidebar-w: 340px;
  --topbar-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas:    #17171a;
    --surface:   #1f1f23;
    --surface-2: #26262b;
    --ink:       #f0eee8;
    --ink-soft:  #c8c4ba;
    --muted:     #918c81;
    --line:      #33333a;
    --line-soft: #2b2b31;
    --accent:    #e2795a;
    --accent-ink:#f0a48c;
    --accent-bg: #33231e;
    --deep:      #9fc0d2;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 2px 8px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.4), 0 18px 48px rgba(0,0,0,.45);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 2.6rem; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.15rem; }
p  { margin: 0 0 1em; }

a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent); }

hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }

/* --- Layout helpers ------------------------------------------------------ */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.stack > * + * { margin-top: var(--gap, 12px); }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.spacer { flex: 1 1 auto; }
.hide { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Site header --------------------------------------------------------- */
.site-header {
  display: flex; align-items: center; gap: 16px;
  height: var(--topbar-h);
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; color: var(--ink); text-decoration: none; font-size: 15px; }
.brand:hover { color: var(--ink); }
.brand-mark {
  width: 24px; height: 24px; flex: 0 0 24px;
  border: 1.75px solid var(--accent); border-radius: 5px;
  position: relative; background: var(--accent-bg);
}
.brand-mark::before {
  content: ""; position: absolute; inset: 3px 3px auto 3px; height: 4px;
  border-bottom: 1.75px solid var(--accent);
}
.brand-mark::after {
  content: ""; position: absolute; left: 5px; top: 11px;
  width: 4px; height: 4px; background: var(--accent); border-radius: 1px;
  box-shadow: 6px 0 0 var(--accent), 0 6px 0 var(--accent);
}
.nav { display: flex; gap: 4px; align-items: center; }
.nav a {
  color: var(--ink-soft); text-decoration: none; font-size: 14px;
  padding: 6px 10px; border-radius: 7px;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }

/* --- Buttons ------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-bd: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: 14px; font-weight: 500;
  padding: 8px 14px; border-radius: 8px;
  background: var(--btn-bg); color: var(--btn-fg);
  border: 1px solid var(--btn-bd);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}
.btn:hover { background: var(--surface-2); color: var(--btn-fg); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-primary { --btn-bg: var(--accent); --btn-fg: #fff; --btn-bd: var(--accent); }
.btn-primary:hover { --btn-bg: var(--accent-ink); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn-icon { padding: 6px; width: 30px; height: 30px; }
.btn-ghost { --btn-bd: transparent; --btn-bg: transparent; }

/* --- Form controls ------------------------------------------------------- */
label { font-size: 13px; color: var(--ink-soft); }

.field { display: block; margin-bottom: 12px; }
.field > .field-label {
  display: block; font-size: 12px; font-weight: 600; letter-spacing: .03em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 5px;
}
.field-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.4; }

input[type="text"], input[type="number"], input[type="date"], input[type="url"],
select, textarea {
  width: 100%; font: inherit; font-size: 14px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px;
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.5; font-family: var(--mono); font-size: 12.5px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg);
}
input[type="color"] {
  width: 100%; height: 32px; padding: 2px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); cursor: pointer;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }

.check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; color: var(--ink); cursor: pointer; padding: 3px 0; }
.check input { margin: 3px 0 0; accent-color: var(--accent); flex: 0 0 auto; width: 15px; height: 15px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* Segmented control */
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; }
.seg > label {
  flex: 1 1 0; position: relative; text-align: center;
  font-size: 13px; padding: 5px 4px; border-radius: 6px; cursor: pointer;
  color: var(--ink-soft); user-select: none; white-space: nowrap;
}
.seg > label input { position: absolute; opacity: 0; pointer-events: none; }
.seg > label:hover { color: var(--ink); }
.seg > label:has(input:checked) { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.seg > label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Card-style radio tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 6px; align-items: center;
  padding: 9px 6px 7px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer; text-align: center;
  font-size: 11.5px; color: var(--ink-soft); line-height: 1.25;
  transition: border-color .12s ease, background .12s ease;
}
.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile:hover { border-color: var(--muted); }
.tile:has(input:checked) { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-ink); font-weight: 600; }
.tile:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile-art { width: 100%; height: 36px; display: block; }
.tile-art svg { width: 100%; height: 100%; display: block; }

/* --- Panels / accordions ------------------------------------------------- */
.panel { border-bottom: 1px solid var(--line); }
.panel > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; font-size: 13px; font-weight: 600;
  letter-spacing: .02em; color: var(--ink);
}
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::after {
  content: ""; margin-left: auto; width: 7px; height: 7px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translate(-2px,-2px); transition: transform .15s ease;
}
.panel[open] > summary::after { transform: rotate(-135deg) translate(-2px,-2px); }
.panel > summary:hover { background: var(--surface-2); }
.panel-body { padding: 4px 16px 18px; }

/* --- Misc ---------------------------------------------------------------- */
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; padding: 2px 7px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent-ink);
}
.badge-soon { background: var(--surface-2); color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px);
  background: var(--ink); color: var(--canvas);
  padding: 9px 16px; border-radius: 999px; font-size: 13.5px;
  box-shadow: var(--shadow-md); opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease; z-index: 200;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .site-header { gap: 10px; padding: 0 12px; height: auto; min-height: var(--topbar-h); flex-wrap: wrap; }
  .site-header .nav { display: none; }
  .site-header .btn { padding: 6px 10px; font-size: 13px; }
  .wrap { padding: 0 18px; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 0 44px; margin-top: 64px;
  font-size: 13.5px; color: var(--muted);
  background: var(--surface);
}
.site-footer a { color: var(--ink-soft); }

/* --- Consent bar ---------------------------------------------------------- */
.consent-bar {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 300;
  max-width: 640px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px; line-height: 1.5;
}
.consent-bar p { margin: 0; flex: 1 1 300px; color: var(--ink-soft); }
.consent-actions { display: flex; gap: 8px; margin-left: auto; }

.linkish {
  background: none; border: 0; padding: 0; font: inherit; font-size: 13px;
  color: var(--muted); cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px;
}
.linkish:hover { color: var(--ink-soft); }

@media print { .consent-bar { display: none !important; } }

/* --- Account control in the header --------------------------------------- */
/* Mounted by core/account.js on any page that loads it. Anchored to the right
   edge of .site-header; the popover hangs below it. */
.acct { position: relative; display: flex; align-items: center; }
.acct-trigger { max-width: 220px; }
.acct-trigger-in { padding-left: 5px; gap: 7px; }
.acct-avatar {
  width: 20px; height: 20px; flex: 0 0 20px;
  border-radius: 50%; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; line-height: 1;
}
.acct-avatar-lg { width: 28px; height: 28px; flex: 0 0 28px; font-size: 14px; }
.acct-who {
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.acct-badge { font-size: 10px; padding: 1px 5px; }

.acct-pop {
  /* Placed by core/account.js in viewport coordinates — the header wraps on
     small screens, so a right-anchored popover fell off the left edge. */
  position: fixed; z-index: 60;
  width: 288px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .13);
  display: flex; flex-direction: column; gap: 9px;
}
.acct-pop[hidden] { display: none; }
.acct-pop-title { font-weight: 600; font-size: 14px; margin: 0; }
.acct-pop-note { font-size: 12px; color: var(--ink-soft); margin: 0; line-height: 1.45; }
.acct-pop-fine { font-size: 11px; color: var(--ink-soft); margin: 0; }
.acct-wide { width: 100%; justify-content: center; }

.acct-pop-id { display: flex; align-items: center; gap: 9px; }
.acct-pop-mail {
  font-size: 13px; font-weight: 500; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.acct-pop-plan { display: flex; align-items: center; gap: 8px; margin: 0; }

/* Empty until something needs saying, so it takes no space when quiet. */
.acct-say { font-size: 12px; margin: 0; color: var(--ink-soft); }
.acct-say:empty { display: none; }
.acct-say-ok { color: var(--accent); }
.acct-say-warn { color: #a3341f; }

/* The maker header already carries three action buttons. Below this width the
   address is the first thing to go — the avatar still says who is signed in,
   and the popover carries the full address. */
@media (max-width: 900px) {
  .acct-who { display: none; }
}
@media (max-width: 640px) {
  .acct-pop { width: min(288px, calc(100vw - 16px)); }
}
