/* ==========================================================================
   webding — one fixed look: cream paper, ink borders, hard shadows.
   ========================================================================== */

:root {
  --paper: #f1efe9;
  --paper-2: #e7e4dc;
  --card: #fbfaf6;
  --ink: #111111;
  --muted: #5f5f5f;
  --line: #111111;
  --accent: #111111;
  --accent-ink: #ffffff;
  --accent-2: #555555;
  --accent-3: #333333;
  --accent-hover: #000000;
  --accent-soft: #e5e2da;
  --link: #111111;
  --focus: #111111;
  --highlight: #e4e1d9;
  --danger: #8f2b1f;
  --danger-soft: #f2dcd7;
  --border-w: 4px;
  --radius: 0px;
  --radius-sm: 0px;
  --button-radius: 0px;
  --button-shadow: 4px 4px 0 var(--ink);
  --shadow: 8px 8px 0 var(--ink);
  --shadow-lg: 8px 8px 0 var(--ink);
  --bg-image: none;
  --bg-size: auto;
  --header-bg: transparent;
  --heading-weight: 900;
  --heading-letter: -0.045em;
  --code-bg: #111111;
  --code-ink: #f1efe9;
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "Courier New", ui-monospace, Consolas, monospace;
  --display: "Arial Black", "Helvetica Neue", Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image: var(--bg-image);
  background-size: var(--bg-size);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--highlight); color: var(--ink); }

a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--link); }

img { max-width: 100%; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 10000;
  background: var(--ink); color: var(--card); padding: 8px 12px;
  border-radius: 6px; font-weight: 600;
}
.skip-link:focus { left: 12px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wrap { width: min(980px, calc(100% - 36px)); margin: 0 auto; }
.narrow { width: min(720px, calc(100% - 36px)); margin: 0 auto; }

/* ------------------------------- top bar ---------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 16px 0;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--line);
  background: var(--header-bg);
}

.brand {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  text-decoration: none;
  line-height: 1;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--display);
}
.brand .dot { color: var(--ink); font-size: 1.55rem; line-height: 0; }
.brand:hover { text-decoration: none; color: var(--link); }

.topnav { display: flex; align-items: center; gap: 22px; margin-left: 6px; }
.topnav a {
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 4px 0;
  color: var(--muted);
  border-bottom: 1px solid transparent;
}
.topnav a:hover { color: var(--ink); border-bottom-color: var(--accent); text-decoration: none; }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* -------------------------------- buttons --------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 3px solid var(--line);
  border-radius: var(--button-radius);
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--button-shadow);
  white-space: nowrap;
}
.btn:hover { background: var(--paper-2); border-color: var(--link); text-decoration: none; }
.btn:active { background: var(--accent-soft); }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn.coral { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--accent-soft); border-color: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 82%, #000); border-color: color-mix(in srgb, var(--danger) 82%, #000); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 0.8rem; }
.btn.tiny { padding: 4px 9px; font-size: 0.74rem; }
.btn.wide { width: 100%; }
.btn .arr { transition: transform 120ms ease; }
.btn:hover .arr { transform: translateX(2px); }

.linkish {
  border: 0; background: none; padding: 0; font: inherit; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.linkish:hover { color: var(--link); }
.linkish.danger { color: var(--danger); }

/* --------------------------------- cards ---------------------------------- */

.card {
  background: var(--card);
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.card.flat { box-shadow: none; }
.card.dashed { border-style: dashed; box-shadow: none; background: transparent; }

.muted { color: var(--muted); }
.tiny-text { font-size: 0.78rem; color: var(--muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* --------------------------------- typography ----------------------------- */

h1, h2, h3, h4 { line-height: 1.1; letter-spacing: -0.025em; margin: 0 0 0.5em; }
h1 {
  font-family: var(--display);
  font-weight: var(--heading-weight);
  text-transform: uppercase;
  letter-spacing: var(--heading-letter);
  font-size: clamp(2.5rem, 6.5vw, 4.6rem);
  line-height: 1.02;
}
h2 {
  font-family: var(--font);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  line-height: 1.08;
}
h3 { font-size: 1.1rem; font-weight: 600; }
h4 { font-weight: 600; }
p { margin: 0 0 1em; }
.lead { font-size: 1.1rem; color: var(--ink); max-width: 36rem; }
.marker {
  font-style: normal;
  background: linear-gradient(transparent 62%, var(--highlight) 62%);
  padding: 0 2px;
}
.marker.lime { background: linear-gradient(transparent 70%, var(--lime) 70%); }
.marker.sky { background: linear-gradient(transparent 70%, var(--sky) 70%); }

/* --------------------------------- forms ---------------------------------- */

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label, .field-label { font-weight: 600; font-size: 0.86rem; }
.field .hint { margin: 0; font-size: 0.78rem; color: var(--muted); }

input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="number"], select, textarea {
  width: 100%;
  background: var(--card);
  border: var(--border-w) solid var(--line);
  border-width: 3px;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--ink);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--link);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.72; }
input[type="color"] {
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  padding: 2px;
  height: 36px;
  width: 52px;
  cursor: pointer;
}
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 0.86rem;
  line-height: 1.45;
  margin: 0 0 16px;
}
.check input { margin-top: 2px; flex: none; }

.error-box {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--ink);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 14px;
}
.ok-box {
  background: color-mix(in srgb, var(--accent-3) 16%, var(--card));
  border: 1px solid var(--accent-3);
  color: var(--ink);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 14px;
}
[hidden] { display: none !important; }

/* ---------------------------------- home ---------------------------------- */

.home-main { max-width: 760px; margin: 0 auto; padding: 48px 0 72px; }
.home-panel {
  position: relative;
  overflow: hidden;
  text-align: center;
  background: var(--card);
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(32px, 6vw, 58px) clamp(20px, 5vw, 52px);
}
.home-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 10px;
  background: linear-gradient(90deg, var(--accent) 0 50%, var(--accent-2) 50%);
}
.welcome {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--link);
}
.home-panel h1 {
  margin: 0 0 16px;
  font-size: clamp(2.9rem, 9vw, 5rem);
  line-height: 0.98;
  letter-spacing: var(--heading-letter);
}
.title-dot { color: var(--ink); }
.tagline {
  max-width: 32rem;
  margin: 0 auto 10px;
  font-size: clamp(1.05rem, 2.4vw, 1.25rem);
  color: var(--ink);
}
.subline {
  max-width: 34rem;
  margin: 0 auto 26px;
  font-size: 0.96rem;
  color: var(--muted);
}
.home-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.home-meta { margin: 18px 0 0; font-size: 0.78rem; color: var(--muted); }

.recent {
  max-width: 620px;
  margin: 36px auto 0;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.recent-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.recent-head h2 {
  margin: 0;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.recent-head a { font-size: 0.8rem; color: var(--link); text-decoration: none; }
.recent-head a:hover { text-decoration: underline; }
.recent-list { display: grid; }
.recent-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  min-width: 0;
}
.recent-item:hover { text-decoration: none; }
.recent-item:hover .recent-title { color: var(--link); }
.recent-main { display: flex; align-items: center; gap: 9px; min-width: 0; }
.recent-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  border: 1px solid color-mix(in srgb, var(--ink) 18%, transparent);
}
.recent-title { font-size: 0.92rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-by { font-size: 0.76rem; color: var(--muted); text-align: right; white-space: nowrap; }
.recent-empty { margin: 12px 0 0; color: var(--muted); font-size: 0.85rem; }

/* -------------------------------- footer ---------------------------------- */

.footer {
  margin-top: 56px;
  padding: 28px 0 48px;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
}
.footer-inner { display: flex; gap: 20px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }

/* ---------------------------------- auth ---------------------------------- */

.auth-shell {
  width: min(440px, calc(100% - 36px));
  margin: 36px auto 80px;
}
.auth-card { padding: 30px; }
.auth-card h1 { font-size: clamp(1.9rem, 5vw, 2.4rem); margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); margin-bottom: 24px; }
.show-pw {
  position: relative;
}
.show-pw input { padding-right: 76px; }
.show-pw button {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink);
  font-size: 0.68rem; font-weight: 500; padding: 3px 8px; border-radius: var(--radius-sm); cursor: pointer;
}
.pow-status {
  margin: 4px 0 14px;
  font-size: 0.78rem;
  color: var(--muted);
  min-height: 1.4em;
  display: flex; align-items: center; gap: 7px;
}
.spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(31, 27, 22, 0.25);
  border-top-color: var(--ink);
  animation: spin 0.7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.recovery-code {
  display: block;
  margin: 14px 0;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  text-align: center;
  background: var(--paper-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  user-select: all;
  word-break: break-all;
}
.recovery-actions { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

/* ------------------------------- dashboard -------------------------------- */

.dash { padding: 40px 0 80px; }
.dash-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}
.dash-head h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin: 0 0 4px; }
.dash-head .sub { color: var(--muted); margin: 0; font-size: 0.9rem; }
.dash-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dash-grid { display: grid; grid-template-columns: 1.55fr 0.85fr; gap: 26px; align-items: start; }
.slot-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.slot-head h2 { margin: 0; font-size: 0.9rem; font-weight: 600; }
.slot-count { font-size: 0.74rem; font-weight: 600; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
.slot-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }

.site-card {
  display: flex;
  flex-direction: column;
  min-height: 200px;
  position: relative;
  padding: 16px;
  background: var(--card);
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.site-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.site-swatch { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0,0,0,.08); }
.site-card h3 { margin: 0 0 2px; font-size: 1rem; line-height: 1.25; font-weight: 600; }
.site-card .site-url {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 10px;
}
.site-card .site-meta { font-size: 0.76rem; color: var(--muted); margin-bottom: 14px; }
.site-card .site-actions { margin-top: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.66rem; font-weight: 600; padding: 2px 8px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper-2); color: var(--ink);
}
.badge.live { background: color-mix(in srgb, var(--accent-3) 18%, var(--card)); border-color: color-mix(in srgb, var(--accent-3) 45%, var(--line)); }
.badge.paused { background: color-mix(in srgb, var(--accent-2) 16%, var(--card)); border-color: color-mix(in srgb, var(--accent-2) 40%, var(--line)); }
.badge.hidden { background: color-mix(in srgb, var(--danger) 14%, var(--card)); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.badge.draft { background: var(--card); border-color: var(--line); color: var(--muted); }

.empty-slot {
  min-height: 200px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.empty-slot:hover { background: var(--paper-2); border-color: var(--link); }
.empty-slot .plus {
  display: grid; place-items: center;
  width: 40px; height: 40px; margin: 0 auto 10px;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--accent-soft); color: var(--link);
  font-size: 1.2rem; font-weight: 500;
}
.empty-slot h3 { margin: 0 0 4px; font-size: 1rem; }
.empty-slot p { margin: 0; font-size: 0.78rem; color: var(--muted); }

.account-card { position: sticky; top: 18px; }
.account-card h2 { font-size: 1rem; font-weight: 600; margin: 0 0 2px; }
.account-email { color: var(--muted); font-size: 0.82rem; margin: 0 0 10px; overflow-wrap: anywhere; }
.account-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.82rem; }
.account-row:last-of-type { border-bottom: 0; }
.account-row .k { color: var(--muted); }
.account-row .v { font-weight: 500; overflow-wrap: anywhere; text-align: right; }
.account-actions { display: grid; gap: 8px; margin-top: 16px; }
.account-note { margin: 12px 0 0; font-size: 0.76rem; color: var(--muted); }

/* -------------------------------- dialogs --------------------------------- */

dialog {
  padding: 0;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  width: min(580px, calc(100% - 30px));
  max-height: calc(100vh - 40px);
  overflow: auto;
}
dialog::backdrop { background: color-mix(in srgb, var(--ink) 32%, transparent); }
.dialog-body { padding: 24px; }
.dialog-body h2 { margin-bottom: 6px; font-size: 1.6rem; }
.dialog-body > p:first-of-type { color: var(--muted); margin-bottom: 18px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; }
.dialog-actions .spacer { margin-right: auto; }

.url-preview {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  margin-top: 6px; padding: 9px 12px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 0.76rem; overflow-wrap: anywhere;
}
.slug-state { min-height: 1.2em; font-size: 0.75rem; margin-top: 4px; }
.slug-state.ok { color: var(--accent-3); }
.slug-state.bad { color: var(--danger); }

/* --------------------------------- editor --------------------------------- */

body.editor-page { height: 100vh; overflow: hidden; }

.editor-top {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  border-bottom: 2px solid var(--line);
  background: var(--card);
  position: relative;
  z-index: 5;
}
.editor-top .back { font-weight: 500; font-size: 0.84rem; text-decoration: none; white-space: nowrap; color: var(--muted); }
.editor-top .back:hover { color: var(--ink); }
.editor-title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.editor-title-wrap input {
  border: 1px solid transparent;
  background: transparent;
  font-weight: 600;
  font-size: 0.98rem;
  padding: 4px 7px;
  border-radius: 6px;
  min-width: 0;
  max-width: 340px;
}
.editor-title-wrap input:hover { border-color: var(--line); }
.editor-title-wrap input:focus { border-color: var(--focus); background: var(--card); box-shadow: 0 0 0 3px var(--accent-soft); }
.save-state { font-size: 0.7rem; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.save-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.save-state.saved::before { background: var(--accent-3); }
.save-state.dirty::before { background: var(--accent-2); }
.save-state.saving::before { background: var(--link); }
.save-state.error::before { background: var(--danger); }
.editor-actions { display: flex; gap: 8px; align-items: center; }
.editor-actions .hide-mobile { display: inline-flex; }
.editor-page .btn { border-width: 2px; box-shadow: none; border-radius: 0; }
.editor-page input, .editor-page select, .editor-page textarea { border-width: 2px; }

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  height: calc(100vh - 60px);
  min-height: 0;
}
.editor-left { display: flex; flex-direction: column; min-height: 0; background: var(--card); border-right: 2px solid var(--line); }
.editor-page .panel-head h2, .editor-page .tab, .editor-page .panel-head .muted { font-family: var(--font); }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 2px solid var(--line); overflow-x: auto; flex: none; }
.tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  padding: 12px 10px;
  border-radius: 0;
  font-weight: 500;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  color: var(--muted);
  margin-bottom: -1px;
}
.tab:hover { color: var(--ink); background: transparent; }
.tab.active { background: transparent; border-color: var(--accent); color: var(--ink); box-shadow: none; }
.tab.settings-tab { margin-left: auto; }
.panel { display: none; flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.panel.active { display: flex; flex-direction: column; }
.panel.intro { padding: 14px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 1rem; font-weight: 600; font-family: var(--font); letter-spacing: -0.01em; }
.panel-head .muted { font-size: 0.72rem; }
.code-wrap { display: flex; flex-direction: column; flex: 1; min-height: 0; }
textarea.code {
  flex: 1; min-height: 280px; resize: none;
  font-family: var(--mono); font-size: 0.82rem; line-height: 1.55;
  background: var(--code-bg); color: var(--code-ink); border: 2px solid var(--line);
  white-space: pre; tab-size: 2; caret-color: var(--link);
}
textarea.code:focus { border-color: var(--link); box-shadow: 0 0 0 3px var(--accent-soft); }
.code-hint { font-size: 0.7rem; color: var(--muted); margin-top: 7px; display: flex; justify-content: space-between; gap: 10px; }

.editor-right { display: flex; flex-direction: column; min-height: 0; background: var(--paper-2); }
.preview-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 2px solid var(--line);
  background: var(--card);
  font-size: 0.74rem;
  font-weight: 500;
  flex: none;
}
.preview-bar .spacer { flex: 1; }
.preview-bar .preview-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-3); }
.preview-frame-wrap {
  flex: 1; min-height: 0; padding: 14px;
  display: flex; justify-content: center; align-items: stretch;
  overflow: auto;
}
.preview-frame-wrap iframe {
  width: 100%; height: 100%; min-height: 320px;
  border: 2px solid var(--line); border-radius: 0;
  background: var(--card); box-shadow: 4px 4px 0 var(--line);
  transition: width 160ms ease;
}
.preview-frame-wrap.phone iframe { width: 390px; max-width: 100%; }
.editor-banner {
  margin: 10px 16px 0;
  padding: 9px 12px;
  border: 2px solid var(--danger);
  background: var(--danger-soft);
  color: var(--ink);
  border-radius: 0;
  font-size: 0.8rem;
  font-weight: 500;
}
.editor-banner.hidden { display: none; }

/* ----------------------------- editor / build ----------------------------- */

.page-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 2px solid var(--line); background: var(--card); flex: none; flex-wrap: wrap; }
.page-bar label { font-weight: 700; font-size: 0.78rem; }
.page-bar select { flex: 1; min-width: 130px; padding: 5px 8px; border-width: 2px; font-size: 0.8rem; }
.page-bar .page-path { width: 100%; font-family: var(--mono); font-size: 0.7rem; color: var(--muted); overflow-wrap: anywhere; }

.subtabs { display: flex; gap: 4px; padding: 8px 10px; border-bottom: 2px solid var(--line); flex: none; }
.subtab { border: 2px solid transparent; background: transparent; padding: 4px 9px; font-weight: 600; font-size: 0.75rem; cursor: pointer; border-radius: 0; }
.subtab:hover { background: var(--paper-2); }
.subtab.active { border-color: var(--ink); background: var(--card); }

.element-palette { display: grid; gap: 10px; margin-bottom: 14px; }
.palette-group h3 { margin: 0 0 4px; font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.palette-items { display: flex; flex-wrap: wrap; gap: 5px; }
.element-chip { border: 2px solid var(--line); background: var(--card); color: var(--ink); padding: 4px 8px; font-size: 0.74rem; font-weight: 600; cursor: grab; border-radius: 0; }
.element-chip:hover { background: var(--paper-2); }
.element-chip:active { cursor: grabbing; }

.element-canvas { display: grid; gap: 10px; padding-bottom: 16px; }
.element-empty { padding: 26px 18px; border: 2px dashed var(--line); text-align: center; color: var(--muted); font-size: 0.8rem; display: grid; gap: 4px; }
.element-empty strong { color: var(--ink); }
.element-card { border: 2px solid var(--line); background: var(--card); }
.element-card.drag-over { outline: 3px solid var(--accent); outline-offset: 2px; }
.element-card-head { display: flex; align-items: center; gap: 7px; padding: 5px 7px; background: var(--paper-2); border-bottom: 2px solid var(--line); font-size: 0.76rem; }
.element-card-head strong { font-weight: 700; }
.element-drag { cursor: grab; letter-spacing: -2px; font-size: 0.8rem; opacity: 0.6; user-select: none; }
.element-drag:active { cursor: grabbing; }
.element-tools { margin-left: auto; display: flex; gap: 1px; }
.element-tools button { border: 0; background: transparent; cursor: pointer; padding: 2px 5px; font-weight: 700; font-size: 0.72rem; }
.element-tools button:hover { background: var(--card); }
.element-preview { padding: 8px 10px; border-bottom: 1px dashed var(--line); font-size: 0.82rem; }
.element-preview .ep-heading { font-family: var(--font); text-transform: none; font-size: 1.25rem; margin: 0; line-height: 1.15; letter-spacing: -0.02em; }
.element-preview .ep-paragraph { margin: 0; }
.element-preview .ep-quote { margin: 0; padding-left: 10px; border-left: 3px solid var(--line); }
.element-preview .ep-list { margin: 0; padding-left: 18px; }
.element-preview .ep-link { text-decoration: underline; }
.element-preview .ep-button { display: inline-block; padding: 3px 8px; background: var(--ink); color: var(--card); font-size: 0.75rem; }
.element-preview .ep-divider { border: 0; border-top: 2px dashed var(--line); margin: 2px 0; }
.element-preview .ep-spacer { border: 1px dashed var(--line); background: var(--paper-2); display: flex; align-items: center; justify-content: center; font-size: 0.65rem; color: var(--muted); }
.element-preview .ep-html { margin: 0; font-family: var(--mono); font-size: 0.7rem; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }
.media-preview { display: flex; align-items: center; gap: 8px; border: 1px dashed var(--line); background: var(--paper-2); padding: 7px 9px; font-size: 0.75rem; color: var(--muted); overflow-wrap: anywhere; }
.media-icon { font-size: 1rem; color: var(--ink); flex: none; }
.element-fields { padding: 7px 9px 9px; display: grid; gap: 6px; }
.element-field { display: flex; align-items: flex-start; gap: 7px; font-size: 0.72rem; }
.ef-label { color: var(--muted); flex: none; width: 74px; padding-top: 4px; }
.ef-control { display: flex; gap: 5px; flex: 1; min-width: 0; }
.ef-control input, .ef-control select, .ef-control textarea { border-width: 2px; padding: 4px 6px; font-size: 0.76rem; min-width: 0; }
.ef-control textarea { resize: vertical; min-height: 38px; }
.ef-control .media-picker { flex: none; width: 112px; }
.element-tip { margin-top: 12px; font-size: 0.72rem; color: var(--muted); }

.media-form { border: 2px solid var(--line); padding: 12px; background: var(--card); margin-bottom: 16px; }
.media-form-grid { display: grid; grid-template-columns: 1fr 120px; gap: 10px; }
.media-form .field { margin-bottom: 10px; }
.media-list { display: grid; gap: 8px; }
.media-empty { padding: 20px; border: 2px dashed var(--line); text-align: center; color: var(--muted); font-size: 0.8rem; }
.media-item { border: 2px solid var(--line); background: var(--card); padding: 9px 10px; display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.media-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; font-size: 0.78rem; }
.media-main strong { font-weight: 700; }
.media-type { font-size: 0.64rem; text-transform: uppercase; background: var(--paper-2); border: 1px solid var(--line); padding: 1px 5px; }
.media-alias { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }
.media-open { font-size: 0.72rem; }
.media-actions { display: flex; gap: 5px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.archive-meta { font-family: var(--mono); font-size: 0.78rem; background: var(--paper-2); border: 2px solid var(--line); padding: 8px 10px; margin-bottom: 8px; overflow-wrap: anywhere; }

/* -------------------------------- settings -------------------------------- */

.settings-block { margin-bottom: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.settings-block:last-child { border-bottom: 0; }
.settings-block h3 { font-size: 0.92rem; margin-bottom: 8px; font-weight: 600; }
.danger-zone { background: var(--danger-soft); border: 1px solid var(--danger); border-radius: 8px; padding: 14px; }
.danger-zone h3 { color: var(--ink); }
.danger-zone p { font-size: 0.78rem; color: var(--ink); }

/* -------------------------------- explore --------------------------------- */

.explore-page { padding: 40px 0 80px; }
.explore-head { margin-bottom: 24px; }
.explore-head h1 { font-size: clamp(1.9rem, 4vw, 2.5rem); margin: 0 0 2px; }
.explore-head .sub { margin: 0; color: var(--muted); font-size: 0.88rem; }
.explore-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.explore-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  transition: border-color 120ms ease;
}
.explore-card:hover { border-color: var(--link); }
.explore-card-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.explore-card h2 { margin: 0; font-family: var(--font); font-size: 0.95rem; line-height: 1.3; font-weight: 600; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.explore-by { margin: 6px 0 16px; font-size: 0.76rem; color: var(--muted); }
.explore-actions { margin-top: auto; display: flex; gap: 12px; align-items: center; }
.explore-actions .report-link { margin-left: auto; font-size: 0.74rem; color: var(--muted); }
.explore-note { margin: 28px 0 0; padding-top: 18px; border-top: 1px solid var(--line); font-size: 0.78rem; color: var(--muted); }
.empty-explore { padding: 42px 24px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); background: transparent; }

/* ------------------------------- safety page ------------------------------ */

.prose { max-width: 760px; margin: 0 auto; padding: 26px 0 70px; }
.prose h1 { font-size: clamp(2.3rem, 6vw, 4rem); }
.prose h2 { margin-top: 34px; font-size: 1.6rem; }
.prose p, .prose li { font-size: 1rem; color: var(--ink); }
.prose ul, .prose ol { padding-left: 24px; }
.prose li { margin-bottom: 8px; }
.prose .card { margin: 20px 0; }
.prose .callout { padding: 16px 18px; background: var(--accent-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: none; }
.prose .callout.lime { background: var(--paper-2); border-color: var(--line); }

/* --------------------------------- report --------------------------------- */

.report-shell { width: min(700px, calc(100% - 36px)); margin: 30px auto 70px; }

/* --------------------------------- admin ---------------------------------- */

.admin-page { padding: 26px 0 70px; }
.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 26px; }
.stat-card { padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: none; }
.stat-card .n { font-size: 1.7rem; font-weight: 500; line-height: 1; font-family: var(--display); }
.stat-card .l { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.admin-section { margin-top: 30px; }
.admin-item {
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  padding: 14px 16px; margin-bottom: 12px; box-shadow: none;
}
.admin-item-head { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.admin-item-head h3 { margin: 0 0 2px; font-size: 1rem; }
.admin-item-head .meta { font-size: 0.74rem; color: var(--muted); overflow-wrap: anywhere; }
.admin-item-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.admin-details { margin-top: 8px; padding: 9px 11px; background: var(--paper-2); border-radius: 8px; font-size: 0.82rem; }
.admin-details .reason { font-weight: 600; }
.admin-empty { padding: 28px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.hidden-list { display: grid; gap: 10px; }

/* ---------------------------------- toast --------------------------------- */

#toasts {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 10000;
  display: grid;
  gap: 8px;
  width: min(430px, calc(100% - 30px));
  pointer-events: none;
}
.toast {
  background: #2b2b26;
  color: #f7f4ec;
  border: 1px solid #43433c;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 12px 32px rgba(36, 36, 31, 0.18);
  animation: toast-in 160ms ease;
  pointer-events: auto;
}
.toast.bad { background: #7a2e22; border-color: #8f3a2c; }
.toast.good { background: #2f4f33; border-color: #3f6544; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* -------------------------------- responsive ------------------------------ */

@media (max-width: 980px) {
  .dash-grid { grid-template-columns: 1fr; }
  .account-card { position: static; }
  .editor-grid { grid-template-columns: 1fr; height: auto; min-height: calc(100vh - 60px); }
  body.editor-page { height: auto; overflow: auto; }
  .editor-left { border-right: 0; border-bottom: 2px solid var(--line); min-height: 55vh; }
  .editor-right { min-height: 58vh; }
  .preview-frame-wrap iframe { min-height: 420px; }
}

@media (max-width: 700px) {
  .topbar { gap: 12px; }
  .topnav { margin-left: 0; order: 3; width: 100%; gap: 14px; font-size: 0.85rem; }
  .top-actions { margin-left: auto; }
  .home-main { padding: 28px 0 48px; }
  .home-panel { padding: 34px 20px 30px; }
  .home-panel h1 { font-size: clamp(2.8rem, 15vw, 4.2rem); }
  .tagline { font-size: 1rem; }
  .subline { font-size: 0.9rem; }
  .home-actions .btn { flex: 1 1 auto; }
  .recent { margin-top: 28px; padding-bottom: 0; }
  .slot-grid { grid-template-columns: 1fr; }
  .admin-stats { grid-template-columns: 1fr 1fr; }
  .editor-top { height: auto; min-height: 62px; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .editor-title-wrap { order: 3; flex: 1 0 100%; width: auto; }
  .editor-title-wrap input { max-width: none; }
  .editor-actions { margin-left: auto; }
  .editor-actions .hide-mobile { display: none; }

  /* Keep both the editor and the preview on screen: a split view instead of
     making a phone scroll through a whole code panel to find the preview. */
  body.editor-page { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
  .editor-top { flex: none; }
  .editor-grid { flex: 1 1 auto; display: flex; flex-direction: column; height: auto; min-height: 0; }
  .editor-left { flex: 1 1 56%; min-height: 0; border-bottom: 2px solid var(--line); }
  .editor-right { flex: 1 1 44%; min-height: 0; }
  .panel { overflow: auto; }
  .preview-frame-wrap { min-height: 0; padding: 8px; }
  .preview-frame-wrap iframe { min-height: 0; height: 100%; }
  .preview-bar #device-toggle { display: none; }
  .preview-frame-wrap.phone iframe { width: 100%; }
  .page-bar { gap: 6px; padding: 7px 10px; }
  .page-bar .page-path { display: none; }
  .element-field { flex-direction: column; align-items: stretch; gap: 3px; }
  .ef-label { width: auto; padding-top: 0; }
  .media-form-grid { grid-template-columns: 1fr; gap: 0; }
  .element-chip { padding: 7px 10px; }
  .settings-block .field { margin-bottom: 12px; }
  .dialog-body { padding: 18px; }
  .footer-inner { flex-direction: column; }
}

@media (max-width: 440px) {
  .wrap { width: calc(100% - 26px); }
  .auth-shell { width: calc(100% - 26px); }
  .auth-card { padding: 22px; }
  .btn { padding: 8px 14px; }
  .top-actions .btn { padding: 7px 12px; font-size: 0.84rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* Print? Sure. */
@media print {
  .topbar, .footer, .editor-actions, #toasts { display: none !important; }
  body { background: #fff; }
}
