:root {
  --bg: #0f1220;
  --panel: #181c30;
  --panel-2: #1f2440;
  --border: #2c3355;
  --text: #eef0fa;
  --muted: #9aa3c7;
  --accent: #4361ee;
  --accent-hover: #5573f5;
  --teal: #24a8ac;
  --radius: 14px;

  /* Behind anything that may be transparent, so the alpha is visible.
     Written once; the tile size varies at each use. */
  --checker: conic-gradient(#23283f 25%, #1b2035 0 50%, #23283f 0 75%, #1b2035 0);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "SF Pro Text", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #232a55 0%, var(--bg) 55%) fixed;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  padding-top: calc(14px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  color: inherit;
  text-decoration: none;
}
.brand-logo { height: 30px; width: auto; }
.brand-name b { color: var(--accent-hover); }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.who { color: var(--muted); font-size: 13px; }

/* =========================================================
   HUB (index.html)
   ========================================================= */
.hub {
  max-width: 980px;
  margin: 0 auto;
  padding: 48px 28px 40px;
}

.hub-title {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 28px;
  text-align: center;
}

.hub-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

/* Icon and name only — the whole card is the link, so it needs no
   caption or call to action to explain itself. */
.hub-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 28px;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.hub-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.hub-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--panel-2);
  color: var(--accent-hover);
  margin-bottom: 18px;
}

.hub-card h2 { margin: 0; font-size: 19px; }

@media (max-width: 720px) {
  .hub { padding: 28px 16px 32px; }
  .hub-title { font-size: 21px; margin-bottom: 20px; }
  .hub-card { padding: 28px 22px; }
  .hub-icon { width: 54px; height: 54px; margin-bottom: 14px; }
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  /* Panels size to their own content instead of stretching to the tallest one. */
  align-items: start;
  gap: 20px;
  padding: 24px 28px;
  max-width: 1500px;
  margin: 0 auto;
}

/* Desktop order: Content · Customize · Preview */
.layout > .panel:nth-child(2) { grid-column: 1; grid-row: 1; }
.layout > .panel:nth-child(3) { grid-column: 2; grid-row: 1; }
.layout > .preview-panel      { grid-column: 3; grid-row: 1; }

/* Customize is the tallest column, so keep the QR in view while scrolling it —
   but only on windows tall enough to show the whole panel, since a sticky
   element taller than the viewport hides its own bottom. */
@media (min-width: 1101px) and (min-height: 800px) {
  .layout > .preview-panel {
    position: sticky;
    top: 24px;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  min-width: 0;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
}

.panel h3 {
  margin: 20px 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
}

/* ---------- Tabs ---------- */
.type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.tab {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tab:hover { color: var(--text); border-color: var(--accent); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.type-form { display: none; }
.type-form.active { display: block; }

/* ---------- Form controls ---------- */
label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

input[type="text"], input[type="url"], input[type="email"], input[type="tel"],
input[type="search"], input[type="password"],
textarea, select {
  width: 100%;
  margin-top: 5px;
  padding: 11px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 16px; /* 16px stops iOS from zooming on focus */
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 16px center, right 11px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

textarea { resize: vertical; }

.field-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; }
.field-row > label { flex: 1 1 150px; min-width: 0; }

input[type="color"] {
  width: 100%;
  height: 44px;
  margin-top: 5px;
  padding: 3px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
}

input[type="range"] {
  width: 100%;
  margin-top: 12px;
  accent-color: var(--accent);
  height: 24px;
}
.range-val { color: var(--text); font-size: 12px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.checkbox-label input { accent-color: var(--accent); width: 20px; height: 20px; flex: 0 0 20px; }

.omq-logo-toggle {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 14px;
  margin-bottom: 12px;
  color: var(--text);
}
/* Small square chip — the mark is dark, so it needs a light tile behind it. */
.omq-logo-toggle .omq-logo-mini {
  height: 20px;
  width: 20px;
  flex: 0 0 20px;
  object-fit: contain;
  background: #fff;
  border-radius: 5px;
  padding: 2px;
}

.file-label {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  border: 1px dashed var(--accent);
  border-radius: 9px;
  padding: 13px 16px;
  cursor: pointer;
  color: var(--accent-hover);
  margin-bottom: 12px;
  font-size: 14px;
}
.file-label input[type="file"] { display: none; }

.hidden { display: none !important; }

/* ---------- Buttons ---------- */
button {
  font-family: inherit;
  font-size: 15px;
  border: none;
  border-radius: 9px;
  padding: 12px 18px;
  min-height: 44px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.actions { display: flex; gap: 10px; margin-top: 14px; }
.actions button { flex: 1; }

/* .plain opts a button out of the filled default. It has to be excluded here
   rather than overridden later: this selector scores higher than a lone class,
   so .link-code and friends would lose the cascade and come out solid blue. */
button:not(.secondary):not(.ghost):not(.plain) { background: var(--accent); color: #fff; }
button:not(.secondary):not(.ghost):not(.plain):hover { background: var(--accent-hover); }
button:not(.secondary):not(.ghost):not(.plain):active { transform: scale(0.98); }

button.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}
button.secondary:hover { border-color: var(--accent); }

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
button.ghost:hover { color: #ff6b6b; border-color: #ff6b6b; }

/* ---------- Preview ---------- */
.preview-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--checker) 0 0 / 24px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 300px;
  padding: 16px;
}

.preview-frame canvas, .preview-frame svg {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.status {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
  margin: 10px 0;
}

.ios-hint {
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 9px;
  padding: 10px 14px;
  margin: 0 0 14px;
}
.ios-hint b { color: var(--text); }

.export-row { display: flex; gap: 14px; }
.export-row > label { flex: 1; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  padding: 18px;
  border-top: 1px solid var(--border);
}
.footer a { color: var(--muted); }
.footer a:hover { color: var(--accent-hover); }

.topbar-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
.topbar-link:hover { color: var(--text); }

.opt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  opacity: 0.75;
}

.muted-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- Short link ---------- */
.short-toggle { margin-top: 4px; white-space: normal; }

.short-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-top: 4px;
}
.short-explain {
  margin: 0 0 12px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}
.short-box .actions { margin-top: 0; }
.short-box .status { text-align: left; margin-bottom: 0; }

.status a { color: var(--accent-hover); }
.status b { color: var(--text); }
.status-ok { color: #2ecc8f; }
.status-warn { color: #ffb454; }

/* ---------- Google sign-in ----------
   The button is an iframe Google renders itself; we only give it
   somewhere to sit and centre it. */
.google-slot {
  display: flex;
  justify-content: center;
  min-height: 44px;
  margin: 18px 0 4px;
}


.short-box .google-slot { margin: 10px 0 2px; }

/* ---------- Short link service ---------- */
.result {
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: 11px;
  padding: 14px;
  margin-top: 14px;
}

.result-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}

.result-row { display: flex; gap: 10px; align-items: stretch; margin-top: 8px; }
.result-row button { flex: 0 0 auto; }

.result-link {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--accent-hover);
  font-size: 16px;
  font-weight: 600;
  word-break: break-all;
}
.result-link:hover { border-color: var(--accent); }

.result .link-actions { margin-top: 10px; }

/* ---------- Link list ---------- */
.admin-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 28px 40px;
  display: grid;
  gap: 20px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.admin-header h2 { margin: 0; }

.how-to {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}
.how-to summary { cursor: pointer; color: var(--accent-hover); }
.how-to ol { margin: 12px 0 0; padding-left: 20px; line-height: 1.7; }
.how-to b { color: var(--text); }

.prefix-input {
  display: flex;
  align-items: stretch;
  margin-top: 5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
}
.prefix-input .prefix {
  display: flex;
  align-items: center;
  padding: 0 4px 0 12px;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}
.prefix-input input {
  border: none;
  margin-top: 0;
  background: transparent;
  padding-left: 0;
  border-radius: 0;
}

.link-row {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 14px;
  margin-top: 12px;
}

.link-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.link-code {
  background: transparent;
  border: none;
  padding: 0;
  min-height: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-hover);
  cursor: pointer;
  word-break: break-all;
  text-align: left;
}
.link-code:hover { text-decoration: underline; }

.link-meta { font-size: 12px; color: var(--muted); }

.link-dest { display: flex; gap: 8px; align-items: stretch; }
.link-dest input { margin-top: 0; flex: 1; min-width: 0; font-size: 14px; }
.link-dest button { flex: 0 0 auto; }

.link-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 13.5px;
  text-decoration: none;
}
.btn-link:hover { border-color: var(--accent); }

.link-row .status { text-align: left; margin: 8px 0 0; }

/* ---------- Mobile action bar (hidden on desktop) ---------- */
.mobile-bar { display: none; }

/* =========================================================
   TABLET
   ========================================================= */
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px;
  }
  /* Preview first so the QR is visible immediately */
  .layout > .panel:nth-child(2),
  .layout > .panel:nth-child(3),
  .layout > .preview-panel { grid-column: 1; grid-row: auto; }
  .layout > .preview-panel { order: -1; }
}

/* =========================================================
   PHONE
   ========================================================= */
@media (max-width: 720px) {
  .topbar { padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); }
  .brand { font-size: 17px; }
  .brand-logo { height: 26px; }

  .layout { padding: 12px; gap: 12px; }
  .panel { padding: 16px; border-radius: 12px; }
  .panel h2 { font-size: 16px; margin-bottom: 14px; }

  .type-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -16px 14px;
    padding: 0 16px 4px;
  }
  .type-tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; scroll-snap-align: start; }

  .field-row { gap: 10px; }
  .field-row > label { flex: 1 1 100%; }
  .field-row > label.checkbox-label { flex: 1 1 auto; }

  .preview-frame { min-height: 260px; padding: 12px; }
  .export-row { flex-direction: column; gap: 0; }

  /* Show the mobile bar, hide the desktop download row.
     Scoped by id — .actions is also used by the short-link box. */
  #desktopActions { display: none; }

  .mobile-bar {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    padding: 10px 14px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: rgba(24, 28, 48, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  .mobile-bar button {
    width: 100%;
    min-height: 50px;
    font-size: 16px;
    font-weight: 600;
  }

  /* Keep the footer clear of the fixed bar */
  .footer { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }

  .admin-wrap { padding: 12px 12px 30px; gap: 12px; }
  .link-dest { flex-direction: column; }
  .link-actions > * { flex: 1; }
}

/* Users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* =========================================================
   DEV TOOLS
   ========================================================= */
.admin-wrap.wide { max-width: 1100px; }

/* ---------- Brand Kit ---------- */
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.asset-card {
  display: flex;
  flex-direction: column;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
}

.asset-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 130px;
  padding: 14px;
  /* Chequerboard, so a transparent logo is readable either way. */
  background: var(--checker) 0 0 / 18px 18px;
}
.asset-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.asset-preview.is-colour { background-image: none; }
.asset-preview.is-file {
  background-image: none;
  background: var(--panel);
  color: var(--muted);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 1px;
}

.asset-body { padding: 12px 14px 14px; display: flex; flex-direction: column; flex: 1; }
.asset-name { margin: 0 0 4px; font-size: 14px; font-weight: 600; word-break: break-word; }
.asset-meta { margin: 0; font-size: 12px; color: var(--muted); word-break: break-all; }
.asset-note { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

.asset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.asset-actions .btn-link,
.asset-actions button {
  flex: 1 1 auto;
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12.5px;
}

/* ---------- Image Tools ---------- */
.file-label.is-over { background: var(--panel); border-style: solid; }

.stage-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--checker) 0 0 / 20px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}
.stage-frame img,
.stage-frame video { max-width: 100%; max-height: 420px; border-radius: 8px; display: block; }

.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin: 8px 0 4px;
}

.swatch {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 2px;
  height: 92px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}
/* A pale swatch needs dark text, not a heavier shadow. */
.swatch.on-light { color: #14172b; text-shadow: none; }
.swatch:hover { border-color: var(--accent); }

.swatch-hex { font-size: 13px; font-weight: 600; letter-spacing: 0.4px; }
.swatch-share { font-size: 11px; opacity: 0.8; }

.font-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.font-row:last-child { border-bottom: none; }
.font-name {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 8px;
}
.font-sample {
  line-height: 1.3;
  word-break: break-word;
  /* Sizing is set inline from the slider. */
}
.font-row.font-failed .font-sample { font-size: 13px !important; color: #ffb454; }

@media (max-width: 720px) {
  .asset-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .asset-preview { height: 105px; }
  .stage-frame img, .stage-frame video { max-height: 300px; }
}

/* ---------- Account chip (api.js mountAccount) ---------- */
.account { display: flex; align-items: center; gap: 10px; }
.account .ghost { min-height: 34px; padding: 6px 12px; font-size: 13px; }

@media (max-width: 720px) {
  /* The email is the first thing to go when the bar gets tight. */
  .account .who { display: none; }
}

/* ---------- Login (login.html) ---------- */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 20px;
  min-height: calc(100vh - 200px);
}

.login-card {
  width: 100%;
  max-width: 430px;
  text-align: center;
  padding: 36px 30px 28px;
}

.login-mark {
  height: 52px;
  width: 52px;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  padding: 5px;
  margin-bottom: 18px;
}

.login-card h1 { margin: 0 0 10px; font-size: 22px; }
.login-card .muted-copy { margin: 0 auto; max-width: 40ch; }
.login-card .google-slot { margin: 22px 0 6px; }
.login-card .status { margin-bottom: 0; }

.login-back { margin: 22px 0 0; font-size: 13px; }
.login-back a { color: var(--muted); text-decoration: none; }
.login-back a:hover { color: var(--accent-hover); }

@media (max-width: 720px) {
  .login-wrap { padding: 28px 14px; min-height: 0; }
  .login-card { padding: 28px 20px 22px; }
}

/* ---------- Email Cards (card.html) ---------- */
/* Its own grid rather than .layout — that one assigns columns by
   nth-child for the QR page's particular three panels. */
.card-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: 20px;
  padding: 24px 28px;
  max-width: 1600px;
  margin: 0 auto;
}

.card-stage {
  display: flex;
  justify-content: center;
  background: var(--checker) 0 0 / 20px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.card-stage iframe {
  display: block;
  width: 100%;
  height: 620px;
  border: 0;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  transition: width 0.2s;
}
/* Narrows the frame itself, so the email's own media query and fluid
   widths do the work — the same way a phone would trigger them. */
.card-stage.is-phone { justify-content: center; }
.card-stage.is-phone iframe { width: 380px; max-width: 100%; }

.device-toggle { display: flex; gap: 6px; }
.device-toggle .tab { padding: 6px 12px; font-size: 12.5px; }

/* Swatches pulled from the Brand Kit, click to use as the accent. */
.brand-chip {
  width: 26px;
  height: 26px;
  min-height: 0;
  padding: 0;
  margin: 0 4px 0 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  vertical-align: middle;
  cursor: pointer;
}
.brand-chip:hover { border-color: var(--accent); }

@media (min-width: 1101px) and (min-height: 800px) {
  .card-preview-panel { position: sticky; top: 24px; }
}

@media (max-width: 1100px) {
  .card-layout { grid-template-columns: 1fr; gap: 16px; padding: 16px; }
  .card-preview-panel { order: -1; }
}

@media (max-width: 720px) {
  .card-layout { padding: 12px; gap: 12px; }
  .card-stage { padding: 8px; }
}

/* ---------- Logo Lab ---------- */
.logo-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 320px;
  padding: 16px;
}
.logo-stage img {
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
}

/* Dimmed rather than hidden, so the controls stay visible as a hint
   at what tracing will offer. */
#vectorControls.is-off { opacity: 0.4; pointer-events: none; }

/* ---------- Palette markers over the source ---------- */
.stage-composite { display: flex; align-items: flex-start; max-width: 100%; }
.stage-composite.is-below { flex-direction: column; }

.stage-media { position: relative; display: inline-block; max-width: 100%; line-height: 0; }

.stage-strip { display: flex; flex-direction: column; overflow: hidden; flex: 0 0 auto; }
.stage-composite.is-below .stage-strip { flex-direction: row; }

.strip-block {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  line-height: 1;
  overflow: hidden;
  min-width: 0;
}
/* Under the picture there is no room for a label in each block. */
.stage-composite.is-below .strip-block { justify-content: center; padding: 0 2px; }
.stage-composite.is-below .strip-block span { display: none; }

/* Square off whichever edge the strip is joined to. */
.stage-composite.is-side .stage-media img,
.stage-composite.is-side .stage-media video { border-radius: 8px 0 0 8px; }
.stage-composite.is-below .stage-media img,
.stage-composite.is-below .stage-media video { border-radius: 8px 8px 0 0; }
.stage-composite.is-side .stage-strip { border-radius: 0 8px 8px 0; }
.stage-composite.is-below .stage-strip { border-radius: 0 0 8px 8px; }

.markers {
  position: absolute;
  inset: 0;
  /* The layer must not swallow clicks meant for the video controls;
     the markers themselves opt back in. */
  pointer-events: none;
}

/* A zero-size anchor sitting exactly on the sampled pixel. The dot and
   the label hang off it and are centred individually — translating the
   whole marker by -50% would centre dot *and* label on the point, and
   a wide label would carry the dot right off the picture. */
.marker {
  --dot: 20px;
  position: absolute;
  width: 0;
  height: 0;
  padding: 0;
  min-height: 0;
  background: none;
  border: 0;
  line-height: 1;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
}
.marker.is-dragging { cursor: grabbing; z-index: 2; }
.marker.is-dragging .marker-dot { transform: translate(-50%, -50%) scale(1.5); }

.marker-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--dot);
  height: var(--dot);
  /* Centres the dot itself, whatever size it is. */
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s;
}
/* A pale swatch needs a dark ring to stay visible on a pale photo. */
.marker.on-light .marker-dot {
  border-color: rgba(20, 23, 31, 0.85);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6), 0 2px 6px rgba(0, 0, 0, 0.4);
}

.marker-hex {
  position: absolute;
  top: 0;
  left: calc(var(--dot) / 2 + 6px);
  transform: translateY(-50%);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: #fff;
  background: rgba(12, 14, 24, 0.82);
  border-radius: 5px;
  padding: 3px 6px;
  white-space: nowrap;
}

/* Past the right edge the label would hang off the picture. */
.marker.flip .marker-hex { left: auto; right: calc(var(--dot) / 2 + 6px); }

.marker.is-lit .marker-dot { transform: translate(-50%, -50%) scale(1.35); }
.swatch.is-lit { border-color: var(--accent); }

@media (max-width: 720px) {
  .marker { --dot: 16px; }
  .marker-hex { font-size: 10px; padding: 2px 4px; }
}

/* =========================================================
   SCRAPER (scrape.html)
   ========================================================= */

/* What was found before committing to a crawl. */
.plan-row {
  display: flex;
  gap: 12px;
  margin: 0 0 6px;
  font-size: 13px;
  line-height: 1.5;
}
.plan-row b { flex: 0 0 96px; color: var(--muted); font-weight: 500; }
.plan-row span { min-width: 0; word-break: break-word; }
.plan-ok span { color: var(--text); }
.plan-muted span { color: var(--muted); }

.progress { margin: 16px 0 6px; }

.progress-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.25s;
}

/* Counting sitemaps or REST pages, where the total is not known until
   the site says so. A bar that sat at zero would read as stalled. */
.progress.is-waiting .progress-bar span {
  width: 35%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: progress-sweep 1.4s linear infinite;
}
@keyframes progress-sweep {
  from { transform: translateX(-100%); }
  to   { transform: translateX(340%); }
}

.progress-note {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar span { transition: none; }
  .progress.is-waiting .progress-bar span { animation: none; width: 100%; opacity: 0.4; }
}

.tally {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.tally-cell {
  flex: 1 1 110px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
}
.tally-cell b { display: block; font-size: 20px; }
.tally-cell span { font-size: 11.5px; color: var(--muted); }

/* Fixed height and its own scroll: the log grows without bound during
   a long crawl, and a panel that grows with it pushes the controls off
   the screen exactly when they are wanted. */
.log {
  height: 220px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.log-line {
  margin: 0 0 4px;
  font-family: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}
.log-ok { color: var(--teal); }
.log-warn { color: #f2b24c; }
.log-muted { color: var(--muted); }

/* The optional inputs sit inside the collapsed block, so they need the
   normal text colour back. */
.how-to label { color: var(--text); display: block; }

/* =========================================================
   ARCHIVES (archive.html)
   ========================================================= */

/* Full width, unlike the other admin pages: this one is a reading
   view, and a column of titles beside an article needs the room. */
.reader {
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px 22px 32px;
}

.reader-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.reader-title { font-size: 17px; font-weight: 600; }
.reader-meta { font-size: 13px; color: var(--muted); }

.reader-body {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.reader-list,
.reader-page {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}

/* Both columns scroll on their own so the list stays put while an
   article is read — the alternative is losing your place in a list of
   two thousand titles every time you open one. */
.reader-list,
.reader-page {
  max-height: calc(100dvh - 190px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.reader-filters { display: grid; gap: 8px; margin-bottom: 10px; }
.reader-count { margin: 0 0 10px; font-size: 12px; color: var(--muted); }

.item-row {
  display: block;
  width: 100%;
  text-align: start;
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 11px;
  margin-bottom: 6px;
  color: var(--text);
  cursor: pointer;
}
.item-row:hover { border-color: var(--border); }
.item-row.is-open { border-color: var(--accent); }
.item-row b { display: block; font-size: 13.5px; font-weight: 500; line-height: 1.45; }
.item-meta { font-size: 11.5px; color: var(--muted); }

.reader-page h1 { margin: 0 0 8px; font-size: 22px; line-height: 1.4; }
.article-meta { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); }
.article-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }

/* The archived markup renders in here, sandboxed. Its height cannot be
   measured from outside a cross-origin frame, so it is given a tall
   box and scrolls within it rather than being clipped at a guess. */
.article-frame {
  width: 100%;
  height: calc(100dvh - 340px);
  min-height: 320px;
  border: 0;
  background: transparent;
}

.article-text {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.85;
  color: var(--text);
}

@media (max-width: 900px) {
  .reader { padding: 14px 14px 28px; }
  .reader-body { grid-template-columns: minmax(0, 1fr); }
  /* Stacked, the two panes share one page scroll; capping their height
     would produce two scrollbars inside a third. */
  .reader-list { max-height: 42dvh; }
  .reader-page { max-height: none; overflow: visible; }
  .article-frame { height: 70dvh; }
}
