/* ==========================================================================
   QuiltHosting design system
   Warm, crafted, professional. Fraunces for display, Inter for UI.
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap");

:root {
  /* Ink */
  /* Contrast is checked, not eyeballed: every ink/ground pair below clears
     WCAG AA 4.5:1 (src/lib/a11y.test.ts pins the ratios). */
  --ink: #221f1a;
  --ink-2: #57534b;
  --ink-3: #6e6961;
  /* Surfaces */
  --paper: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f4efe7;
  --border: #e7dfd2;
  --border-strong: #d6cbb8;
  /* Brand */
  --brand: #b5501f;
  --brand-hover: #9a431a;
  --brand-soft: #f7e8de;
  --brand-ink: #7c3413;
  /* Supporting hues (quilt palette) */
  --sage: #5f7d64;
  --gold: #d9a441;
  --plum: #8c5a74;
  --sky: #5b7ea3;
  /* Status */
  --ok: #2c7940;
  --ok-soft: #e3f2e6;
  --warn: #98590c;
  --warn-soft: #f9eeda;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --neutral-soft: #eee9df;
  /* Type */
  --font-ui: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  /* Geometry */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(34, 31, 26, 0.05);
  --shadow-md: 0 1px 2px rgba(34, 31, 26, 0.05), 0 6px 24px -8px rgba(34, 31, 26, 0.12);
  --shadow-lg: 0 2px 4px rgba(34, 31, 26, 0.05), 0 16px 48px -12px rgba(34, 31, 26, 0.18);
  /* Focus */
  --focus-ring: #221f1a;
}
/* Dark grounds flip the ring to the on-dark ink so it stays visible. */
.sidebar, .portal-header, .qh-fleet-footer { --focus-ring: #ffffff; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.45rem; margin-top: 0; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 0.75em; }
a { color: var(--brand); }
code {
  background: var(--surface-2);
  padding: 0.15em 0.45em;
  border-radius: 6px;
  font-size: 0.88em;
}

.muted { color: var(--ink-3); font-size: 0.9rem; }
.hidden { display: none !important; }
.error { color: var(--danger); font-size: 0.9rem; margin-bottom: 0.75rem; }

/* --- Focus ------------------------------------------------------------- */
/* One token-driven ring for every keyboard-focusable control. Declared here
   rather than left to the UA default so the ring survives on the dark
   sidebar/header and so anything that turns `outline` off below has to name
   its own :focus-visible replacement. */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 2px;
}
/* Skip link: off-screen until it takes focus. */
.qh-skip {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  padding: 0.5rem 0.85rem;
  background: var(--brand);
  color: #fff;
  border-radius: 0 0 var(--r-sm) 0;
  font-weight: 600;
  text-decoration: none;
}
.qh-skip:focus { left: 0; top: 0; }

/* --- Buttons ----------------------------------------------------------- */

button, .btn {
  font-family: var(--font-ui);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.55rem 1.15rem;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
  box-shadow: var(--shadow-sm);
}
button:hover, .btn:hover { background: var(--brand-hover); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: default; }

button.secondary, .btn.secondary {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--border-strong);
  box-shadow: none;
  font-weight: 500;
}
button.secondary:hover, .btn.secondary:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn { display: inline-block; text-decoration: none; text-align: center; }

/* --- Forms ------------------------------------------------------------- */

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  margin: 0.85rem 0 0.3rem;
}

input, select, textarea {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink);
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
/* The brand halo is decoration; the ring above is what has to be visible, so
   the field keeps its outline (the old rule dropped it, and `select:textarea`
   never matched anything). */
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}
input[type="checkbox"] { width: auto; accent-color: var(--brand); }
input[type="file"] { border: none; padding: 0; background: none; width: auto; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.25rem;
}
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* --- Cards & layout primitives ---------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.4rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }

.toolbar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar input[type="search"] { max-width: 260px; }

/* --- Tables ------------------------------------------------------------ */

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fdfbf7; }
td button { padding: 0.32rem 0.7rem; font-size: 0.82rem; }

/* --- Badges (status) --------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.18em 0.65em;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--ink-2);
  text-transform: capitalize;
}
.badge.active, .badge.succeeded, .badge.registered, .badge.sent, .badge.checked_in {
  background: var(--ok-soft); color: var(--ok);
}
.badge.pending, .badge.waitlist {
  background: var(--warn-soft); color: var(--warn);
}
.badge.cancelled, .badge.failed, .badge.lapsed {
  background: var(--danger-soft); color: var(--danger);
}
.badge.refunded { background: var(--neutral-soft); color: var(--ink-2); }

/* --- Stat tiles (dashboard) -------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.05rem 1.2rem;
  box-shadow: var(--shadow-sm);
}
.stat .label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin-bottom: 0.3rem;
}
.stat .value {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* --- Admin shell ------------------------------------------------------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: #262019;
  color: #efe7da;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
}
.sidebar h1 {
  font-size: 1.25rem;
  color: #fff;
  margin: 0 0.5rem 1.5rem;
}
.sidebar h1 .thread { color: var(--gold); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  color: #cfc4b2;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--r-sm);
  transition: background 0.12s ease, color 0.12s ease;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
/* --brand is only 3.2:1 on the sidebar's #262019; the badge needs its own ink.
   Overrides the inline color on #platform-badge in public/admin.html. */
.sidebar #platform-badge { color: #c87853 !important; }
.sidebar .guild-tag {
  margin-top: auto;
  padding: 0.75rem 0.75rem 0;
  font-size: 0.8rem;
  color: #a89a83;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar .guild-tag-name { display: block; color: #fff; font-size: 0.95rem; font-weight: 600; }
.sidebar .guild-tag-design { display: block; margin-top: 0.25rem; color: #f6efe4; font-size: 1rem; font-weight: 600; line-height: 1.35; }
/* Named on every admin screen, above the page. The sidebar copy is easy to
   miss at the bottom of a long menu; this one is the first line of the page. */
.qh-current-design {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.35;
  background: var(--brand-soft, #f8efe8);
  border: 2px solid var(--brand);
  border-radius: var(--r-md);
}
.qh-current-design[hidden] { display: none; }

.main {
  flex: 1;
  padding: 2.25rem 2.5rem;
  max-width: 1080px;
  min-width: 0;
}
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  /* The sidebar becomes a scrolling strip of links. `min-width: 0` is what
     makes the scrolling actually happen: without it the flex item is sized by
     its content, the nav row sticks out past the viewport, and the whole page
     scrolls sideways instead of the strip. Same reason `.sidebar nav` may not
     shrink below its content — it is the thing being scrolled. */
  .sidebar {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.75rem 1rem;
  }
  .sidebar h1 { margin: 0 1rem 0 0; white-space: nowrap; }
  .sidebar nav { flex-direction: row; flex: 0 0 auto; }
  .sidebar nav a { white-space: nowrap; }
  .sidebar .guild-tag { display: none; }
  .main { padding: 1.25rem; min-width: 0; max-width: 100%; }
  /* Anything still too wide scrolls inside itself, never sideways. */
  .main table { max-width: 100%; }
}

/* --- Auth / centered boxes -------------------------------------------- */

.login-box {
  max-width: 400px;
  margin: 9vh auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 2.25rem 2.25rem 1.75rem;
  box-shadow: var(--shadow-lg);
}
.login-box h1 { text-align: center; font-size: 1.5rem; margin-bottom: 1.25rem; }

/* --- Portal ------------------------------------------------------------ */

.portal-header {
  background: #262019;
  color: #efe7da;
}
.portal-header .inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.portal-header h1 { color: #fff; font-size: 1.25rem; margin: 0; }
.portal-header a { color: var(--gold); text-decoration: none; font-size: 0.88rem; }

.wrap { max-width: 880px; margin: 0 auto; padding: 1.5rem; }

.tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.tabs button {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--ink-3);
  font-weight: 500;
  padding: 0.55rem 0.9rem;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs button:hover { background: none; color: var(--ink); }
.tabs button.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

/* --- Quilt strip motif -------------------------------------------------- */

.quilt-strip { display: flex; height: 6px; border-radius: 3px; overflow: hidden; }
.quilt-strip span { flex: 1; }
.quilt-strip span:nth-child(1) { background: var(--brand); }
.quilt-strip span:nth-child(2) { background: var(--gold); }
.quilt-strip span:nth-child(3) { background: var(--sage); }
.quilt-strip span:nth-child(4) { background: var(--sky); }
.quilt-strip span:nth-child(5) { background: var(--plum); }
.quilt-strip span:nth-child(6) { background: var(--brand); }

/* --- Dialogs ------------------------------------------------------------ */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.75rem;
  max-width: 440px;
  width: 92%;
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(34, 31, 26, 0.45); }

/* --- Notices ------------------------------------------------------------ */

.notice { padding: 0.85rem 1.1rem; border-radius: var(--r-sm); margin: 1rem 0; font-size: 0.95rem; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.err { background: var(--danger-soft); color: var(--danger); }

/* --- Fleet footer (QuiltMap LLC parent bar — matches CreateABlock) ------ */

.qh-fleet-footer {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
  padding: 0.55rem 1.25rem;
  background: #2b2b2e;
  color: #b8b4ab;
  font-size: 0.72rem;
  line-height: 1.4;
  font-family: var(--font-ui);
}
.qh-fleet-footer .brand strong { color: #fff; font-weight: 700; }
.qh-fleet-footer .brand .home {
  color: inherit;
  text-decoration: none;
}
.qh-fleet-footer .brand .home:hover strong { text-decoration: underline; }
.qh-fleet-footer a {
  color: #9ccbd6;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
.qh-fleet-footer a:hover { color: #fff; text-decoration: underline; }
.qh-fleet-footer nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
}
.qh-fleet-footer .legal {
  margin-left: auto;
  color: #9b978f; /* 4.6:1 on #2b2b2e — #8a867d was 3.9:1 at 0.72rem */
}
.qh-fleet-footer .prerelease {
  background: #e9a93d;
  color: #2b2b2e;
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  margin-right: 0.4rem;
}
@media (max-width: 760px) {
  .qh-fleet-footer {
    justify-content: center;
    text-align: center;
  }
  .qh-fleet-footer .legal { margin-left: 0; }
}

/* Pin body layout so fleet footer can sit at bottom of short pages */
body.has-fleet-footer {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body.has-fleet-footer > .qh-fleet-footer { margin-top: auto; }
/* Admin app layout grows to fill */
body.has-fleet-footer > .layout { flex: 1; }
body.has-fleet-footer > .wrap { flex: 1; width: 100%; }

/* --- Month calendar (qh-cal.js) ---------------------------------------- */

.qh-cal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 1.1rem 1.2rem 1.3rem; box-shadow: var(--shadow-sm); }
.qh-cal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.qh-cal-title { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; }
.qh-cal-nav { display: flex; gap: 0.4rem; }
.qh-cal-nav button { padding: 0.3rem 0.8rem; font-size: 0.85rem; }
.qh-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.qh-cal-wd { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); text-align: center; padding: 0.3rem 0; }
.qh-cal-day { min-height: 84px; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 0.3rem; background: var(--paper); display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.qh-cal-day.empty { border: none; background: none; }
.qh-cal-day.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: var(--brand-soft); }
.qh-cal-date { font-size: 0.75rem; font-weight: 600; color: var(--ink-3); }
.qh-cal-day.today .qh-cal-date { color: var(--brand-ink); }
.qh-cal-ev { display: block; width: 100%; text-align: left; background: var(--brand); color: #fff; border: none; border-radius: 6px; font-size: 0.68rem; font-weight: 600; line-height: 1.25; padding: 0.22rem 0.4rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: none; }
.qh-cal-ev:hover { background: var(--brand-hover); }
.qh-cal-empty { text-align: center; margin: 1rem 0 0; }
.qh-view-toggle { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-sm); overflow: hidden; margin-bottom: 1rem; }
.qh-view-toggle button { border: none; border-radius: 0; background: var(--surface); color: var(--ink-2); box-shadow: none; font-weight: 500; padding: 0.4rem 1rem; }
.qh-view-toggle button.on { background: var(--brand); color: #fff; }
@media (max-width: 700px) {
  .qh-cal-day { min-height: 56px; }
  .qh-cal-ev { font-size: 0.6rem; padding: 0.15rem 0.3rem; }
}

/* --- Photo galleries ---------------------------------------------------- */

.qh-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.qh-gallery-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow-sm); transition: box-shadow 0.15s ease, transform 0.05s ease; }
.qh-gallery-card:hover { box-shadow: var(--shadow-md); }
.qh-gallery-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--surface-2); }
.qh-gallery-blank { width: 100%; aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; font-size: 2rem; background: var(--surface-2); }
.qh-gallery-cap { padding: 0.7rem 0.85rem; }
.qh-photo { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-sm); }
.qh-photo img { width: 100%; display: block; background: var(--surface-2); }
.qh-photo figcaption { padding: 0.55rem 0.75rem; }

/* --- Website editor (admin) ------------------------------------------- */
/* Shared by the guild "Website" screen and the business site builder in
   public/admin.html (renderPagesAdmin / qhOpenPageEditor). */
.wb-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.wb-head-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.wb-tabs { display: flex; gap: 0.35rem; margin-bottom: 0.5rem; }
.wb-tabs button.on, .wb-mode button.on, .wb-devices button.on { background: var(--brand-soft); color: var(--brand-ink, var(--brand)); border-color: var(--brand); }
/* Five columns do not fit a 320px phone. The TABLE scrolls sideways inside
   its own box; the page must not, or every screen it is on shifts under the
   reader's thumb. */
.wb-pages-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.wb-pages-list { min-width: 34rem; }
.wb-pages-list td { vertical-align: middle; }
.wb-row-actions { white-space: nowrap; }
.wb-row-actions button { margin-right: 0.25rem; }
.wb-armed { background: var(--danger-soft) !important; color: var(--danger) !important; border-color: var(--danger) !important; }
.wb-readonly-note { font-size: 0.85rem; background: var(--warn-soft); color: var(--warn); padding: 0.5rem 0.75rem; border-radius: var(--r-sm); margin: 0 0 0.75rem; }

.wb-editor { display: flex; flex-direction: column; gap: 0.75rem; }
.wb-topbar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.wb-title { flex: 1 1 220px; min-width: 160px; font-size: 1.05rem; font-weight: 600; }
.wb-pill { font-size: 0.75rem; font-weight: 600; padding: 0.2em 0.7em; border-radius: 999px; background: var(--neutral-soft); color: var(--ink-2); white-space: nowrap; }
.wb-pill.saved { background: var(--ok-soft); color: var(--ok); }
.wb-pill.saving, .wb-pill.dirty { background: var(--warn-soft); color: var(--warn); }
.wb-pill.error { background: var(--danger-soft); color: var(--danger); cursor: pointer; }
.wb-mode, .wb-devices { display: inline-flex; gap: 0.25rem; }
.wb-settings summary { cursor: pointer; font-weight: 600; }
.wb-settings .form-row { margin-top: 0.5rem; }
.wb-checks { display: flex; gap: 1.25rem; flex-wrap: wrap; margin-top: 0.75rem; }
.wb-check { display: flex; align-items: center; gap: 0.4rem; margin: 0; font-weight: 500; }
.wb-field-err { color: var(--danger); font-size: 0.8rem; margin: 0.2rem 0 0; min-height: 0; }
.wb-field-err:empty { display: none; }

.wb-grid { display: grid; grid-template-columns: 190px 1fr 300px; gap: 0; min-height: 560px; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
@media (max-width: 1080px) { .wb-grid { grid-template-columns: 1fr; } .wb-palette, .wb-props { border: none; border-top: 1px solid var(--border); } }
.wb-palette { background: var(--surface-2); border-right: 1px solid var(--border); padding: 0.75rem; overflow-y: auto; max-height: 80vh; }
.wb-palette h4, .wb-props h4 { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin: 0 0 0.5rem; }
.wb-palette h5 { font-size: 0.72rem; color: var(--ink-3); margin: 0.75rem 0 0.35rem; font-weight: 600; }
.wb-chip { display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.45rem 0.55rem; margin-bottom: 0.3rem; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: var(--r-sm); cursor: grab; font-size: 0.85rem; font-weight: 500; text-align: left; box-shadow: none; }
.wb-chip:hover, .wb-chip:focus-visible { border-color: var(--brand); background: var(--surface); color: var(--ink); }
.wb-chip .ico { width: 1.4rem; text-align: center; color: var(--brand); font-weight: 700; font-size: 0.8rem; }
.wb-canvas-wrap { display: flex; flex-direction: column; min-height: 560px; background: #efe9e0; min-width: 0; }
.wb-canvas-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; padding: 0.5rem 0.75rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.wb-canvas-bar button { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.wb-canvas { flex: 1; padding: 1.25rem; overflow-y: auto; }
.wb-page { max-width: 760px; margin: 0 auto; background: #fff; border-radius: 12px; box-shadow: var(--shadow-md); padding: 1.25rem 1.5rem 2rem; min-height: 360px; font-family: var(--font-sans, inherit); }
.wb-page h1, .wb-page h2, .wb-page h3 { font-family: var(--font-display, inherit); }
.wb-drop { min-height: 10px; border: 2px dashed transparent; border-radius: 8px; transition: border-color .15s, background .15s, min-height .15s; }
.wb-drop.over { border-color: var(--brand); background: var(--brand-soft); min-height: 36px; }
.wb-empty { text-align: center; padding: 3rem 1rem; color: var(--ink-3); border: 2px dashed var(--border); border-radius: 12px; }
.wb-block { position: relative; margin: 0.25rem 0; padding: 0.5rem; border: 2px solid transparent; border-radius: 8px; cursor: pointer; }
.wb-block:hover { border-color: var(--border-strong); }
.wb-block:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -1px; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.wb-block.selected { border-color: var(--brand); background: rgba(181, 80, 31, 0.04); }
.wb-block-tools { position: absolute; top: -14px; right: 8px; display: none; gap: 2px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px 6px 2px 10px; box-shadow: var(--shadow-sm); z-index: 2; }
.wb-block:hover .wb-block-tools, .wb-block.selected .wb-block-tools, .wb-block:focus-within .wb-block-tools { display: inline-flex; }
.wb-block-tools .wb-block-name { font-size: 0.7rem; font-weight: 600; color: var(--ink-3); margin-right: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.wb-block-tools button { padding: 0.15rem 0.45rem; font-size: 0.8rem; line-height: 1.2; border-radius: 999px; }
.wb-block-body { pointer-events: none; }
.wb-block-body a, .wb-block-body summary { pointer-events: auto; }
.wb-ph { color: var(--ink-3); padding: 1rem; border: 1px dashed var(--border-strong); border-radius: 8px; font-size: 0.9rem; text-align: center; background: var(--surface-2); }
.wb-spacer { background: repeating-linear-gradient(90deg, transparent, transparent 4px, var(--border) 4px, var(--border) 5px); opacity: 0.5; }
.wb-img-broken { outline: 2px dashed var(--danger); min-height: 40px; }
.wb-img-warn { display: block; font-size: 0.8rem; color: var(--danger); margin-top: 0.25rem; }

.wb-props { background: var(--surface-2); border-left: 1px solid var(--border); padding: 0.75rem; overflow-y: auto; max-height: 80vh; }
.wb-props label { font-size: 0.78rem; margin: 0.6rem 0 0.2rem; }
.wb-props input, .wb-props select, .wb-props textarea { width: 100%; font: inherit; padding: 0.42rem 0.55rem; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); margin-top: 0.15rem; }
.wb-props textarea { min-height: 70px; resize: vertical; }
.wb-props-actions { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.wb-props-actions button { flex: 1 1 auto; font-size: 0.8rem; padding: 0.4rem 0.6rem; }
.wb-hint { font-size: 0.78rem; color: var(--ink-3); margin: 0.25rem 0 0; }
.wb-items .wb-item { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 0.5rem 0.65rem 0.65rem; margin: 0.5rem 0; background: var(--surface); position: relative; }
.wb-items legend { font-size: 0.75rem; font-weight: 600; color: var(--ink-2); padding: 0 0.3rem; }
.wb-item-tools { position: absolute; top: -0.9rem; right: 0.5rem; display: flex; gap: 2px; background: var(--surface); }
.wb-item-tools button { padding: 0.1rem 0.45rem; font-size: 0.75rem; }
.wb-image-field .wb-thumb { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--ink-3); font-size: 0.8rem; margin: 0.2rem 0 0.35rem; }
.wb-image-field .wb-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.wb-image-actions { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.wb-image-actions button { font-size: 0.78rem; padding: 0.3rem 0.6rem; }

.wb-rte { border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); margin-top: 0.4rem; }
.wb-rte-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 0.3rem; border-bottom: 1px solid var(--border); }
.wb-rte-bar button { padding: 0.15rem 0.5rem; font-size: 0.8rem; min-width: 2rem; }
.wb-rte-link { display: flex; gap: 0.3rem; padding: 0.3rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.wb-rte-link input { flex: 1 1 140px; margin: 0; }
.wb-rte-link button { font-size: 0.78rem; padding: 0.25rem 0.5rem; }
.wb-rte-area { min-height: 160px; max-height: 50vh; overflow-y: auto; padding: 0.6rem 0.75rem; font-size: 0.92rem; line-height: 1.55; }
.wb-rte-area:focus { box-shadow: inset 0 0 0 2px var(--brand-soft); }
.wb-rte-area:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.wb-rte-area p { margin: 0 0 0.6em; }
.wb-rte-area a { color: var(--brand); }

.wb-preview { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.wb-preview-stage { background: #efe9e0; padding: 1rem; display: flex; justify-content: center; min-height: 560px; }
.wb-preview-stage iframe { width: 100%; max-width: 100%; height: 80vh; min-height: 560px; border: none; background: #fff; border-radius: 8px; box-shadow: var(--shadow-md); transition: width .2s; }

.wb-swatches { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.wb-swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; padding: 0; box-shadow: var(--shadow-sm); }
.wb-swatch.on, .wb-swatch:focus-visible { border-color: var(--ink); outline: 2px solid #fff; outline-offset: -4px; }
.wb-swatch-custom { display: inline-flex; align-items: center; gap: 0.3rem; margin: 0; font-size: 0.8rem; font-weight: 500; }
.wb-swatch-custom input[type="color"] { width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 1px solid var(--border); cursor: pointer; }
.wb-font-sample { margin-top: 0.75rem; padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); }
.wb-font-sample .btn { background: var(--brand); padding: 0.25rem 0.7rem; font-size: 0.8rem; margin-left: 0.4rem; }

.wb-nav-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.wb-nav-item { display: grid; grid-template-columns: 110px 1fr auto; gap: 0.5rem; align-items: start; padding: 0.5rem; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); }
@media (max-width: 640px) { .wb-nav-item { grid-template-columns: 1fr; } }
.wb-nav-item select, .wb-nav-item input { margin: 0; }
.wb-nav-body { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.wb-nav-warn { font-size: 0.78rem; color: var(--warn); margin: 0; }
.wb-nav-warn:empty { display: none; }
.wb-nav-tools { display: flex; gap: 2px; }
.wb-nav-tools button { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.wb-nav-add { display: flex; gap: 0.4rem; margin-top: 0.5rem; flex-wrap: wrap; }

.wb-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.6rem; margin: 0.5rem 0 1rem; }
.wb-preset { text-align: left; padding: 0.6rem; border: 2px solid var(--border); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); box-shadow: none; font-weight: 500; }
.wb-preset:hover { background: var(--surface); border-color: var(--border-strong); color: var(--ink); }
.wb-preset.on { border-color: var(--brand); }
.wb-preset-swatches { display: flex; gap: 3px; margin-bottom: 0.4rem; }
.wb-preset-swatches span { flex: 1; height: 18px; border-radius: 4px; }
.wb-preset-name { font-size: 0.85rem; }
.wb-preset-sample { font-size: 1.1rem; line-height: 1.1; margin-top: 0.25rem; }
.wb-contrast { font-size: 0.8rem; margin: 0.5rem 0; padding: 0.4rem 0.6rem; border-radius: var(--r-sm); }
.wb-contrast.ok { background: var(--ok-soft); color: var(--ok); }
.wb-contrast.bad { background: var(--warn-soft); color: var(--warn); }
.wb-tokens { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.4rem 0.75rem; }
.wb-tokens label { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 0.3rem 0; }
.wb-tokens input[type="color"] { width: 44px; height: 28px; padding: 0; }

dialog#wb-library, dialog#wb-history-dlg { max-width: 720px; width: 94%; }
.wb-lib-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.5rem; }
.wb-lib-tools { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
.wb-lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.5rem; max-height: 55vh; overflow-y: auto; }
.wb-lib-item { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.35rem; background: var(--surface); color: var(--ink); border: 2px solid var(--border); border-radius: var(--r-sm); box-shadow: none; font-weight: 500; }
.wb-lib-item:hover, .wb-lib-item:focus-visible { border-color: var(--brand); background: var(--surface); color: var(--ink); }
.wb-lib-thumb { display: block; aspect-ratio: 1; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.wb-lib-thumb img { width: 100%; height: 100%; object-fit: cover; }
.wb-lib-name { font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wb-hist { list-style: none; padding: 0; margin: 0; max-height: 55vh; overflow-y: auto; }
.wb-hist li { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }

/* --- Website editor, phase 2: section thumbnails, Style tab, focal picker,
       upload progress, palette-from-logo, upgrade preview ---------------- */
.wb-pal-search { width: 100%; margin: 0 0 0.5rem; font: inherit; padding: 0.4rem 0.55rem; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); }
.wb-pal-list h5 { margin: 0.6rem 0 0.3rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); }
.wb-chip--thumb { align-items: center; padding: 0.35rem 0.45rem; }
.wb-chip--thumb .wb-thumb-svg { width: 48px; height: 30px; flex: 0 0 48px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--ink); }
.wb-chip-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.wb-chip-text small { font-size: 0.68rem; color: var(--ink-3); font-weight: 400; }
.wb-ptabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin: 0.25rem 0 0.5rem; }
.wb-ptabs button { background: none; color: var(--ink-2); box-shadow: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 0.35rem 0.7rem; font-size: 0.85rem; font-weight: 600; margin: 0 0 -1px; }
.wb-ptabs button:hover { background: var(--surface); color: var(--ink); }
.wb-ptabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.wb-style-row { margin: 0.6rem 0 0; }
.wb-style-label { font-size: 0.78rem; font-weight: 600; margin: 0 0 0.25rem; }
.wb-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 0.3rem; }
.wb-tiles--variants { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.wb-tile { display: flex; flex-direction: column; align-items: stretch; gap: 0.2rem; padding: 0.25rem; background: var(--surface); color: var(--ink); border: 2px solid var(--border); border-radius: var(--r-sm); box-shadow: none; font-weight: 500; cursor: pointer; }
.wb-tile:hover, .wb-tile:focus-visible { border-color: var(--border-strong); background: var(--surface); color: var(--ink); }
.wb-tile.on { border-color: var(--brand); }
.wb-tile > svg { width: 100%; height: auto; display: block; border-radius: 3px; color: var(--ink); }
.wb-tile-swatch { display: flex; align-items: center; justify-content: center; height: 26px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.08); font-size: 0.75rem; font-weight: 700; overflow: hidden; }
.wb-tile-swatch svg { width: 100%; height: 100%; }
.wb-tile-cap { font-size: 0.66rem; text-align: center; color: var(--ink-2); line-height: 1.15; }
.wb-style-pattern[hidden] { display: none; }
.wb-style-reset { margin-top: 0.75rem; font-size: 0.8rem; }
.wb-progress { display: block; width: 100%; height: 6px; margin: 0.3rem 0 0; }
.wb-focal { margin-top: 0.5rem; }
.wb-focal-stage { position: relative; display: block; width: 100%; cursor: crosshair; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.wb-focal-stage:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.wb-focal-stage img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.wb-focal-mark { position: absolute; width: 22px; height: 22px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(0,0,0,0.5); transform: translate(-50%, -50%); pointer-events: none; }
.wb-focal-mark::before, .wb-focal-mark::after { content: ""; position: absolute; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.4); }
.wb-focal-mark::before { left: 50%; top: -8px; width: 1px; height: 34px; transform: translateX(-50%); }
.wb-focal-mark::after { top: 50%; left: -8px; height: 1px; width: 34px; transform: translateY(-50%); }
.wb-crops { display: grid; grid-template-columns: 3fr 2fr; gap: 0.4rem; margin-top: 0.4rem; }
.wb-crop { margin: 0; position: relative; overflow: hidden; border-radius: 4px; border: 1px solid var(--border); background: var(--surface-2); }
.wb-crop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.wb-crop figcaption { position: absolute; left: 0; right: 0; bottom: 0; font-size: 0.62rem; padding: 0.1rem 0.3rem; background: rgba(0,0,0,0.55); color: #fff; }
.qh-logo-pal { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0.5rem 0 0; }
.qh-logo-pal-tiles:empty { display: none; }
.qh-logo-pal-score { font-size: 0.72rem; margin-top: 0.2rem; }
dialog.qh-upgrade-dlg { max-width: 1100px; width: 96%; }
.qh-upgrade-frame { width: 100%; height: 62vh; min-height: 420px; border: 1px solid var(--border); border-radius: var(--r-sm); background: #fff; }

/* --- Motion ------------------------------------------------------------ */
/* Everything above animates for polish only; honour the OS setting. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
