/* flat-warm.css — flat-warm-ui (lite flat rules, willemstad warm palette).
   Drop-in stylesheet. Rules: no decorative borders, radius 0, hierarchy from background
   tints, teal --accent is the only interactive colour, rubric for ornament, amber for
   stars, no monospace outside code, nothing under 12px, motion <= 160 ms.
   Set data-theme="dark" | "light" on <html>; dark is the default token set. */

/* ---------- fonts (self-hosted; paths relative to this file) ---------- */
@font-face { font-family: "Inter"; font-weight: 400 600; font-display: swap; src: url("/fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-weight: 400 600; font-display: swap; src: url("/fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Manrope"; font-weight: 400; font-display: swap; src: url("/fonts/manrope-400.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 600; font-display: swap; src: url("/fonts/manrope-600.woff2") format("woff2"); }

/* ---------- tokens ---------- */
:root {
  /* semantic ink (theme-independent hex, mapped below) */
  --rubric-d: #b5442f; --rubric-l: #8e2418;   /* ornament: titles, field labels, errors, danger */
  --nacht-d: #7b93ad;  --nacht-l: #44607e;    /* secondary ink: addresses, h3 */
  --gold-d: #a98c4b;   --gold-l: #7e6326;     /* highlights: counts, tags, file icons */

  /* dark (default): warm charcoal, warm greys */
  --bg: #0a0703; --bg-high: #15110a; --bg-input: #1c170f;
  --fg: #d5d0c6; --fg-title: #f6f1e7; --fg-dim: #9c988e;
  --fg-second: #c4beb2; --fg-faint: #8f8a80;
  --accent: #6fc0c7; --accent-hover: #7ccdd4;
  --chip: #231f17; --chip-fg: #e9e4da; --chip-hover: #312d25;
  --chip-on: #bcb7ad; --chip-on-fg: #0a0703;
  --star: #ffb81c;
  --paper: #fffff8;                            /* light paper, also behind third-party HTML */
  --rubric: var(--rubric-d); --nacht: var(--nacht-d); --gold: var(--gold-d);

  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;          /* reading text */
  --font-heading: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;   /* labels, chips, numbers */
  --font-inscription: "P22StGSchriftOne", Georgia, serif;                         /* brand only (not bundled) */
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;        /* code only */
  --hit: 1.9rem;                               /* control height; 2.5rem on touch */
  color-scheme: dark;
}
[data-theme="light"] {
  /* willemstad paper: off-white ground, warm greys */
  --bg: #fffff8; --bg-high: #f8f5ee; --bg-input: #fffff8;
  --fg: #181611; --fg-title: #070603; --fg-dim: #66635d;
  --fg-second: #3d3a34; --fg-faint: #83807a;
  --accent: #0d5257; --accent-hover: #2a686d;
  --chip: #f1eee7; --chip-fg: #181611; --chip-hover: #ebe7e0;
  --chip-on: #302d28; --chip-on-fg: #fffff8;
  --star: #e8a20a;
  --rubric: var(--rubric-l); --nacht: var(--nacht-l); --gold: var(--gold-l);
  color-scheme: light;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font-ui); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button, .fw-btn, select, label { touch-action: manipulation; }
code, pre, kbd, samp { font-family: var(--font-mono); }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

/* links: teal, 1px line drawn as a background, 2px on hover */
a { color: var(--accent); text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent)); background-size: 100% 1px;
  background-position: 0 100%; background-repeat: no-repeat; }
a:hover { color: var(--accent-hover); background-size: 100% 2px; }
a.fw-btn, a.fw-file { background-image: none; }

/* ---------- nav ---------- */
.fw-nav { display: flex; align-items: center; gap: 0.9rem; padding: 0.55rem 1rem; background: var(--bg-high); }
.fw-brand { font-family: var(--font-inscription); font-size: 1.25rem; color: var(--fg-title); }
.fw-spacer { flex: 1; }

/* ---------- buttons: flat chips with an optional line icon ---------- */
.fw-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: var(--hit); padding: 0 0.7rem;
  font-family: var(--font-heading); font-weight: 600; font-size: 0.8125rem; line-height: 1;
  background: var(--chip); color: var(--chip-fg);
  border: none; border-radius: 0; text-decoration: none; white-space: nowrap; vertical-align: middle;
  transition: background-color 70ms, color 70ms;
}
.fw-btn:hover { background: var(--chip-hover); }
.fw-btn--on, .fw-btn--primary { background: var(--chip-on); color: var(--chip-on-fg); }
.fw-btn--primary:hover { background: var(--accent); color: var(--chip-on-fg); }
.fw-btn--danger .ico { color: var(--rubric); }
.fw-btn--danger:hover { background: var(--rubric); color: #fff; }
.fw-btn--danger:hover .ico { color: inherit; }
.fw-btn:disabled { opacity: 0.45; cursor: default; }
.fw-btn:disabled:hover { background: var(--chip); }
.fw-btn--icon { width: var(--hit); padding: 0; }                 /* square, label kept for AT */
.fw-btn--icon .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.fw-btn[aria-pressed="true"].fw-btn--star .ico { fill: currentColor; color: var(--star); }
.fw-group { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }   /* inside a group */
.fw-toolbar { display: flex; flex-wrap: wrap; gap: 0.45rem 0.9rem; align-items: center; }  /* between groups */

/* icons: one sprite (<symbol id="i-…">) in the page, drawn in the text colour */
.ico { width: 1rem; height: 1rem; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* star toggle (rows) */
.fw-star { display: grid; place-items: center; width: 1.6rem; height: 1.6rem; padding: 0;
  background: none; border: none; color: var(--fg-faint); transition: color 70ms, background-color 70ms; }
.fw-star:hover { color: var(--star); background: color-mix(in srgb, var(--star) 12%, transparent); }
.fw-star.is-on { color: var(--star); }
.fw-star.is-on .ico { fill: currentColor; }

/* ---------- checkbox chip: hidden input + flat square control ---------- */
.fw-check { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; user-select: none; position: relative; }
.fw-check input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.fw-check-box { flex-shrink: 0; width: 1.35rem; height: 1.35rem; background: var(--chip); position: relative; transition: background-color 70ms, opacity 70ms; }
.fw-check:hover .fw-check-box { background: var(--chip-hover); }
.fw-check input:checked + .fw-check-box, .fw-check input:indeterminate + .fw-check-box { background: var(--accent); }
.fw-check input:checked + .fw-check-box::after {
  content: ""; position: absolute; left: 50%; top: 46%; width: 0.32rem; height: 0.56rem;
  border: solid var(--chip-on-fg); border-width: 0 2px 2px 0; transform: translate(-50%, -50%) rotate(45deg); }
.fw-check input:indeterminate + .fw-check-box::after {
  content: ""; position: absolute; left: 25%; right: 25%; top: calc(50% - 1px); height: 2px; background: var(--chip-on-fg); }
.fw-check input:focus-visible + .fw-check-box { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }

/* avatar inside a checkbox chip: shows the initial; the box appears on hover/focus/selection */
.fw-avatar { position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 1.35rem; height: 1.35rem;
  background: var(--av, var(--gold)); color: var(--paper); font-family: var(--font-heading); font-weight: 600;
  font-size: 0.75rem; line-height: 1; pointer-events: none; transition: opacity 70ms; }
.fw-check:has(.fw-avatar) .fw-check-box { opacity: 0; }
.fw-check:has(.fw-avatar):is(:hover, :focus-within) .fw-check-box,
.is-selecting .fw-check:has(.fw-avatar) .fw-check-box,
.fw-check input:checked + .fw-check-box { opacity: 1; }
.fw-check:has(.fw-avatar):is(:hover, :focus-within) .fw-avatar,
.is-selecting .fw-avatar, .fw-check input:checked ~ .fw-avatar { opacity: 0; }

/* ---------- inputs ---------- */
.fw-input, .fw-select { width: 100%; padding: 6px 8px; border: none; border-radius: 0; font: inherit; color: var(--fg);
  background: color-mix(in srgb, var(--fg-faint) 6%, transparent); transition: background-color 70ms; }
.fw-input { min-height: var(--hit); }
.fw-input:hover { background: color-mix(in srgb, var(--fg-faint) 11%, transparent); }
.fw-input:focus { outline: none; background: color-mix(in srgb, var(--accent) 10%, var(--bg-input)); }
.fw-select { width: auto; min-height: var(--hit); padding: 0 0.5rem; background: var(--chip); color: var(--chip-fg);
  font-family: var(--font-heading); font-weight: 600; font-size: 0.8125rem; }
.fw-select:hover { background: var(--chip-hover); }
.fw-field { display: grid; gap: 0.2rem; margin-top: 0.7rem; }
.fw-field-label { font-family: var(--font-heading); font-weight: 600; font-size: 0.75rem; color: var(--fg-second); }
.fw-error { color: var(--rubric); font-size: 0.85rem; min-height: 1.2em; margin: 0.6rem 0 0; }
.fw-actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.8rem; flex-wrap: wrap; }

/* ---------- panels ---------- */
.fw-section { background: var(--bg-high); padding: 1.15rem 1.25rem; }
.fw-label { font-size: 0.75rem; color: var(--fg-faint); letter-spacing: 0.03em; margin: 0; }
.fw-band {   /* a panel heading as a full-width tinted strip */
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  font-family: var(--font-heading); font-size: 1rem; font-weight: 600; letter-spacing: -0.015em;
  color: color-mix(in srgb, var(--accent) 80%, var(--fg));
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-high));
  margin: -1.15rem -1.25rem 0.9rem; padding: 0.55rem 1.25rem; }
.fw-title { font-family: var(--font-heading); font-weight: 600; font-size: 1rem; margin: 0; color: var(--rubric); }

/* ---------- lists: zebra rows, accent tints for hover / checked / active ---------- */
.fw-list { list-style: none; margin: 0; padding: 0; }
.fw-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: start; gap: 0 0.3rem;
  padding: 0 0.6rem 0 0.7rem; transition: background-color 70ms; }
.fw-row:nth-child(even) { background: color-mix(in srgb, var(--fg) 3.5%, transparent); }
.fw-row:hover { background: color-mix(in srgb, var(--accent) 8%, transparent) !important; }
.fw-row.is-checked { background: color-mix(in srgb, var(--accent) 11%, var(--bg)) !important; }
.fw-row.is-active { background: color-mix(in srgb, var(--accent) 16%, var(--bg)) !important; }
.fw-row > .fw-check { margin-top: 0.5rem; padding: 0 0.1rem; }
.fw-row > .fw-star { margin-top: 0.38rem; }
.fw-row-main { display: grid; grid-template-columns: 1fr auto; gap: 0.1rem 0.6rem; min-width: 0; width: 100%;
  padding: 0.5rem 0.3rem 0.5rem 0.2rem; background: none; border: none; color: var(--fg-second); text-align: left; }
.fw-row-title { font-family: var(--font-heading); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fw-row-sub { grid-column: 1 / -1; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-dim); }
.fw-row.is-unread .fw-row-title, .fw-row.is-unread .fw-row-sub { color: var(--fg-title); font-weight: 600; }
.fw-row.is-unread .fw-row-title::before { content: ""; display: inline-block; width: 0.45rem; height: 0.45rem;
  margin-right: 0.4rem; background: var(--accent); vertical-align: 0.1em; }   /* a square, not a middle dot */
.fw-num { font-family: var(--font-heading); font-size: 0.75rem; color: var(--fg-faint); font-variant-numeric: tabular-nums; }
.fw-tag { display: inline-block; margin-left: 0.4rem; padding: 0 0.35rem; font-size: 0.75rem;
  background: var(--chip); color: var(--gold); vertical-align: 0.05em; }
.fw-count { display: inline-block; margin-left: 0.4rem; padding: 0 0.35rem; font-size: 0.75rem; font-weight: 600;
  font-variant-numeric: tabular-nums; background: var(--chip); color: var(--chip-fg); }
.fw-empty { padding: 1.5rem 0.9rem; color: var(--fg-faint); font-size: 0.85rem; }

/* nav list (folders, sections) */
.fw-navlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.fw-navlist button, .fw-navlist a { width: 100%; display: flex; justify-content: space-between; gap: 0.5rem;
  padding: 5px 8px; background: none; border: none; color: var(--fg-second); font-family: var(--font-heading);
  font-size: 0.85rem; text-align: left; transition: background-color 70ms; }
.fw-navlist button:hover, .fw-navlist a:hover { background: var(--chip); }
.fw-navlist .is-active { background: color-mix(in srgb, var(--accent) 18%, var(--bg-high)); color: var(--fg-title); }

/* bulk action bar (shown while rows are selected) */
.fw-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; padding: 0.5rem 0.8rem;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-high)); }
.fw-bulk .fw-group { gap: 0.25rem; }

/* ---------- file chips, notices, toast ---------- */
.fw-file { display: inline-grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0.35rem;
  padding: 2px 7px 2px 5px; background: var(--chip); color: var(--chip-fg); border: none; font-size: 0.8rem; }
.fw-file:hover { background: var(--chip-hover); }
.fw-file .ico { color: var(--gold); width: 0.95em; height: 0.95em; }
.fw-file-name { font-family: var(--font-heading); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 18rem; }
.fw-notice { display: flex; gap: 0.6rem; align-items: center; padding: 0.4rem 0.7rem;
  background: color-mix(in srgb, var(--gold) 12%, transparent); font-size: 0.82rem; color: var(--fg-second); }
.fw-toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 30; padding: 0.45rem 0.9rem;
  background: var(--chip-on); color: var(--chip-on-fg); font-family: var(--font-heading); font-weight: 600; font-size: 0.85rem;
  max-width: calc(100vw - 2rem); }
.fw-toast.is-error { background: var(--rubric); color: #fff; }

/* ---------- sheet (modal panel), autocomplete, drop target ---------- */
.fw-sheet-wrap { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 1rem;
  background: color-mix(in srgb, var(--bg) 70%, transparent); }
.fw-sheet { position: relative; width: min(48rem, 100%); max-height: calc(100vh - 2rem); overflow-y: auto; }
.fw-suggest { position: absolute; z-index: 5; left: 0; right: 0; top: 100%; margin: 0; padding: 0.2rem 0; list-style: none;
  background: var(--bg-high); max-height: 16rem; overflow-y: auto; }
.fw-suggest li { display: flex; gap: 0.5rem; align-items: baseline; padding: 0.3rem 0.6rem; cursor: pointer; font-size: 0.85rem; }
.fw-suggest li.is-active, .fw-suggest li:hover { background: color-mix(in srgb, var(--accent) 14%, var(--bg-high)); }
.fw-drop-hint { display: none; position: absolute; inset: 0; place-items: center; z-index: 6; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-high)); color: var(--fg-title);
  font-family: var(--font-heading); font-weight: 600; font-size: 1.1rem; }
.is-drop > .fw-drop-hint { display: grid; }

/* third-party HTML (mail bodies...) in a sandboxed iframe */
.fw-frame { width: 100%; min-height: 20rem; border: none; display: block; background: var(--paper); }
[data-theme="dark"] .fw-frame { background: var(--bg); }

/* ---------- loading: shimmering placeholders ---------- */
.sk { display: block; height: 0.8rem;
  background: linear-gradient(90deg, color-mix(in srgb, var(--fg) 7%, transparent) 0%,
    color-mix(in srgb, var(--fg) 14%, transparent) 40%, color-mix(in srgb, var(--fg) 7%, transparent) 80%);
  background-size: 300% 100%; animation: sk-shimmer 1.3s ease-in-out infinite; }
@keyframes sk-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.sk-row { display: grid; grid-template-columns: 1.35rem 1fr; gap: 0.45rem 0.9rem; align-items: center; padding: 0.7rem 0.9rem; }
.sk-row .sk-av { width: 1.35rem; height: 1.35rem; grid-row: span 2; }
.sk-row .sk-sub { height: 0.65rem; opacity: 0.7; }
.sk-row:nth-child(2n+1) .sk { animation-delay: 0.15s; }
.sk-title { height: 1.3rem; width: 60%; }

/* ---------- phone (single column) ---------- */
.fw-phone-only, .fw-fab { display: none; }
@media (max-width: 860px) {
  .fw-phone-only { display: inline-flex; }
  .fw-desktop-only { display: none !important; }
  /* floating primary action */
  .fw-fab { display: inline-flex; align-items: center; gap: 0.5rem; position: fixed; z-index: 15;
    right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); min-height: 3rem; padding: 0 1.15rem;
    border: none; background: var(--chip-on); color: var(--chip-on-fg);
    font-family: var(--font-heading); font-weight: 600; font-size: 0.95rem; }
  .fw-fab .ico { width: 1.15rem; height: 1.15rem; }
  /* a toolbar becomes one sticky row of icon buttons that scrolls sideways */
  .fw-toolbar--sticky { position: sticky; top: 0; z-index: 4; flex-wrap: nowrap; overflow-x: auto; gap: 0.6rem;
    margin: 0 -1rem; padding: 0.55rem 1rem; background: color-mix(in srgb, var(--bg-high) 45%, var(--bg)); scrollbar-width: none; }
  .fw-toolbar--sticky::-webkit-scrollbar { display: none; }
  .fw-toolbar--sticky .fw-group { flex-wrap: nowrap; }
  .fw-toolbar--sticky .fw-btn:not(.fw-keep-label) { width: var(--hit); padding: 0; }
  .fw-toolbar--sticky .fw-btn:not(.fw-keep-label) .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  /* sheets open full screen */
  .fw-sheet-wrap { padding: 0; place-items: stretch; }
  .fw-sheet { width: 100%; max-height: none; height: 100dvh; display: flex; flex-direction: column;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
}
/* touch: 40px targets, 16px inputs (iOS zooms into smaller ones) */
@media (pointer: coarse) {
  :root { --hit: 2.5rem; }
  .fw-star { width: 2.2rem; height: 2.2rem; }
  .fw-input, .fw-select, textarea { font-size: 16px; }
  .fw-navlist button, .fw-navlist a { padding: 0.65rem 0.6rem; font-size: 0.95rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .sk { animation: none; }
}

/* urtifack: the way back to the gallery, top left; arrow only on narrow phones */
@media (max-width: 600px) {
  .fw-home { width: var(--hit); padding: 0; }
  .fw-home-t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
