/* ── DYNAMITIVE ──
   One stylesheet, deliberately plain. It exists so the site is usable,
   not so it looks finished.

   It has two halves and they are not equal:

     PART 1  BEHAVIOUR — load-bearing. Panels, drawers, spinners and
             hidden states are driven by these rules. Delete them and
             features break: every page renders at once, the cart drawer
             sits open over the page, buttons never show a loading state.

     PART 2  APPEARANCE — throw all of it away. Every rule below the
             divider is a placeholder. The class names it hangs off are
             emitted by assets/js/*, so restyling means writing your own
             CSS against the same names, not editing JavaScript.

   Colours come from six custom properties. Swap those and the whole
   thing moves, including dark mode.
*/

/* ══ PART 1 — BEHAVIOUR (required) ═══════════════════════════════════ */

/* An author display rule beats the browser's default [hidden] styling, so
   without this anything with `display` set ignores the attribute. Half the
   JS toggles visibility through `hidden`. */
[hidden] { display: none !important; }

/* One panel per route. router.js adds .active to exactly one. */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Same again inside the account area. */
.subpanel { display: none; }
.subpanel.active { display: block; }

/* Cart and product-editor drawers slide in from the right. */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  width: min(420px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform 0.25s;
}
.drawer.open { transform: none; }
.drawer-body { flex: 1; overflow-y: auto; }

/* Buttons that report progress: markup is .lbl + .spinner. */
.btn .spinner { display: none; }
.btn.loading .lbl { display: none; }
.btn.loading .spinner { display: inline-block; }

/* Error and notice slots are always in the DOM and filled by JS. */
.field-error:empty, .field-notice:empty { display: none; }

/* Toggled by applications.js and checkout.js respectively. */
.apply-success { display: none; }
.apply-success.show { display: block; }
.perk-hint.hidden { display: none; }

/* The transient notice. Off-screen until showBanner() adds .show. */
.banner {
  position: fixed;
  top: 1rem; left: 50%;
  z-index: 200;
  transform: translate(-50%, -200%);
  transition: transform 0.25s;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 0.6rem 0.9rem;
}
.banner.show { transform: translate(-50%, 0); }

/* Mobile nav sheet. See toggleNav() in router.js. */
@media (max-width: 800px) {
  .nav:not(.open) { display: none; }
  .nav.open {
    position: absolute;
    left: 0; right: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 0.5rem;
  }
}
@media (min-width: 801px) {
  .nav-toggle { display: none; }
}

/* Admin page editing. content.js sets contenteditable on [data-cms]. */
body.editing [data-cms] { outline: 1px dashed var(--accent); cursor: text; }
body.editing [data-cms] a,
body.editing a:has([data-cms]) { pointer-events: none; }
.edit-bar {
  position: fixed;
  bottom: 1rem; left: 50%;
  z-index: 120;
  transform: translate(-50%, 200%);
  transition: transform 0.25s;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 0.6rem;
}
.edit-bar.show { transform: translate(-50%, 0); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ══ PART 2 — APPEARANCE (replace all of this) ═══════════════════════ */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --line: #d4d4d4;
  --text: #1a1a1a;
  --muted: #666666;
  --accent: #1a1a1a;
}
:root[data-theme='dark'] {
  --bg: #141414;
  --surface: #1c1c1c;
  --line: #333333;
  --text: #ededed;
  --muted: #999999;
  --accent: #ededed;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, sans-serif;
}
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
/* Card and control links wrap whole blocks, so a default underline drags
   across the entire card. Underline prose links only. */
a { color: inherit; }
.btn, .side-nav a, .product-card > a, .tab, .filter-btn { text-decoration: none; }
img, svg { display: block; max-width: 100%; }
code, .mono, .num, .price-now, .row-meta { font-family: ui-monospace, monospace; }

h1, h2, h3, p, ul, dl, form, .rows, .product-grid, .table-wrap, .tabs { margin-bottom: 0.75rem; }
h2, h3 { margin-top: 1.25rem; }
.card + .card, .row + .row { margin-top: 0.5rem; }

.wrap { max-width: 60rem; margin: 0 auto; padding: 0 1rem; }
.site-header { border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 0; }
.nav { display: flex; gap: 0.75rem; }
.nav-link.active { font-weight: 600; text-decoration: underline; }
.header-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.footer { border-top: 1px solid var(--line); margin-top: 3rem; padding: 1.5rem 0; color: var(--muted); }

section { padding: 1.5rem 0; }
.label { display: block; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; }
.lead, .field-hint, .row-meta, .adm-sub, .store-count { color: var(--muted); }
.field-hint, .row-meta, .adm-sub { font-size: 0.85rem; }

button, .btn, input, select, textarea { font: inherit; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; }
.btn svg { width: 1em; height: 1em; fill: currentColor; }
.spinner {
  width: 0.8em; height: 0.8em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.field { margin-bottom: 0.75rem; }
.field-label { display: block; margin-bottom: 0.2rem; }
.input { width: 100%; padding: 0.4rem; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.field-error { color: #b00020; }
.field-notice { color: #0a6b3d; }
.form-grid, .adm-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.check, .switch { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }

.card, .row, .product-card, .info-card, .pillar, .thread, .msg,
.empty, .store-empty, .adm-stat, .adm-alert, .offer-form, .twofa-option {
  border: 1px solid var(--line);
  padding: 0.75rem;
}
.card-title, .subpanel-head h2, .pdp-section > h3 { margin-bottom: 0.5rem; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.75rem; }
.pdp-grid, .account-layout, .apply-layout { display: grid; gap: 1.5rem; }
@media (min-width: 801px) {
  .pdp-grid { grid-template-columns: 1fr 20rem; }
  .account-layout { grid-template-columns: 10rem 1fr; }
  .apply-layout { grid-template-columns: 1fr 16rem; }
}
.store-admin-bar, .adm-build, .adm-toolbar, .subpanel-head, .offer-open {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.store-admin-bar { border: 1px solid var(--line); padding: 0.5rem; }
.sab-note { margin-right: auto; }
.sab-actions { display: flex; gap: 0.5rem; align-items: center; }

.side-nav { display: flex; flex-direction: column; gap: 0.25rem; }
.side-nav a.active { font-weight: 600; }
.rows { display: grid; gap: 0.5rem; }
.row-head { display: flex; gap: 1rem; }
.row-right { margin-left: auto; text-align: right; }
.row-actions, .card-actions, .hero-actions, .chips, .tags,
.store-toolbar, .store-filters, .tabs, .contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.row-actions, .chips, .tags { margin-top: 0.5rem; }
.tab, .filter-btn { border: 0; background: none; cursor: pointer; padding: 0.3rem 0.5rem; }
.tab.active, .filter-btn.active { font-weight: 600; text-decoration: underline; }

.badge, .chip, .tag, .work-badge, .status-dot { font-size: 0.75rem; border: 1px solid var(--line); padding: 0 0.3rem; }
.product-icon, .product-icon-fallback, .line-icon { width: 2.5rem; height: 2.5rem; border: 1px solid var(--line); }
.product-icon-fallback, .account-avatar { display: grid; place-items: center; }
.account-avatar { width: 2.5rem; height: 2.5rem; border: 1px solid var(--line); }
.product-top, .pdp-head, .account-head, .drawer-head, .adm-head { display: flex; gap: 0.75rem; align-items: center; }
.product-foot, .price { display: flex; gap: 0.5rem; align-items: baseline; }
.product-foot { margin-top: 0.5rem; }
.price-was { text-decoration: line-through; color: var(--muted); }
.price { margin-right: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { border: 1px solid var(--line); padding: 0.4rem; text-align: left; }
.table-wrap { overflow-x: auto; }

.drawer-head, .drawer-foot { padding: 0.75rem; border-bottom: 1px solid var(--line); }
.drawer-foot { border-bottom: 0; border-top: 1px solid var(--line); }
.drawer-body { padding: 0.75rem; }
.line { display: flex; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.line-right { margin-left: auto; text-align: right; }
.totals-row, .ck-total, .ck-paying { display: flex; justify-content: space-between; margin: 0.75rem 0; }

.thread-body { display: grid; gap: 0.5rem; max-height: 25rem; overflow-y: auto; padding: 0.5rem; }
.msg-user { margin-left: 20%; }
.msg-admin { margin-right: 20%; }
.msg-system { text-align: center; color: var(--muted); font-size: 0.85rem; }
.thread-compose { display: flex; gap: 0.5rem; padding: 0.5rem; }
.thread-head, .thread-controls { display: flex; gap: 0.5rem; align-items: center; padding: 0.5rem; }
.thread-status { margin-left: auto; }

.spec { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; }
.spec dd { text-align: right; }
.offer-figures { display: flex; gap: 1.5rem; margin-top: 0.5rem; }
.copyfield, .amount-input, .qty, .search { display: flex; align-items: center; gap: 0.4rem; }
.adm-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: 0.5rem; }
.adm-dropzone { border: 1px dashed var(--line); padding: 1rem; text-align: center; cursor: pointer; }
.adm-progress { height: 3px; background: var(--line); }
.adm-progress span { display: block; height: 100%; background: var(--accent); }
.theme-picker { display: flex; gap: 0.5rem; }
.theme-option[aria-checked='true'] { font-weight: 600; outline: 2px solid var(--accent); }
.push { margin-left: auto; }
.empty, .store-empty, .adm-empty, .adm-loading, .thread-loading { text-align: center; color: var(--muted); padding: 1.5rem; }
