/* ============================================================================
   MW 4.0 — APPLICATION DESIGN SYSTEM
   Shared by the customer portal and the owner console.

   Colour comes from tokens.css, which is generated from the marketing site's
   palette. Nothing in this file writes a hex value: every surface, rule and
   accent resolves through a token, so light/dark is a token switch and never a
   second stylesheet.

   Direction: quiet luxury, minimal engineering. Depth from 1px rules and
   surface elevation, not glow. Copper appears only where it carries meaning.
   ========================================================================== */

@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-latin-ext.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Noto Sans Arabic';
  src: url('/fonts/noto-arabic.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --app-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --app-arabic: 'Noto Sans Arabic', 'SF Arabic', 'Geeza Pro', 'Segoe UI', sans-serif;
  --app-mono: 'SF Mono', ui-monospace, 'JetBrains Mono', monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-pill: 999px;

  --dur: 180ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --topbar: 58px;
  --sidebar: 236px;
}

html[data-theme-ready] body { transition: background-color 220ms var(--ease), color 220ms var(--ease); }

html { color-scheme: light dark; }
:root { color-scheme: dark; }
@media (prefers-color-scheme: light) { :root { color-scheme: light; } }
html[data-theme='light'] { color-scheme: light; }
html[data-theme='dark'] { color-scheme: dark; }

* { box-sizing: border-box; }

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

html[lang='ar'] body {
  font-family: var(--app-arabic);
  line-height: 1.75;
  letter-spacing: 0;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
html[lang='ar'] h1, html[lang='ar'] h2, html[lang='ar'] h3, html[lang='ar'] h4 { letter-spacing: 0; line-height: 1.45; }

p { margin: 0; }
img { max-width: 100%; display: block; }

::selection { background: var(--color-accent-soft); color: var(--color-text); }

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

/* ------------------------------------------------------------------ type -- */
.h1 { font-size: clamp(1.65rem, 2.4vw, 2.15rem); }
.h2 { font-size: 1.35rem; }
.h3 { font-size: 1.05rem; }
.lead { font-size: 1rem; color: var(--color-muted); max-width: 62ch; }
.muted { color: var(--color-muted); }
.small { font-size: 0.84rem; }
.tiny { font-size: 0.75rem; }
.mono { font-family: var(--app-mono); font-size: 0.82rem; letter-spacing: 0.01em; }
.eyebrow {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--color-muted);
  font-weight: 500;
}
html[lang='ar'] .eyebrow { letter-spacing: 0.02em; text-transform: none; font-size: 0.75rem; }
.numeric { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----------------------------------------------------------------- layout -- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-inline: var(--space-5);
  border-bottom: 1px solid var(--color-line-soft);
  background: var(--color-ink);
  backdrop-filter: saturate(1.2) blur(8px);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.01em; }
.brand img { width: 22px; height: 22px; }
html[data-theme='light'] .brand img { filter: brightness(0) saturate(0); }
.brand .brand-sub {
  font-weight: 400;
  color: var(--color-muted);
  font-size: 0.82rem;
  border-inline-start: 1px solid var(--color-line);
  padding-inline-start: 10px;
  margin-inline-start: 2px;
}

.topbar-spacer { margin-inline-start: auto; display: flex; align-items: center; gap: var(--space-2); }

.body-row { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  border-inline-end: 1px solid var(--color-line-soft);
  padding: var(--space-5) var(--space-3);
  position: sticky;
  top: var(--topbar);
  align-self: flex-start;
  height: calc(100vh - var(--topbar));
  overflow-y: auto;
}

.sidebar-group + .sidebar-group { margin-top: var(--space-5); }
.sidebar-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-muted);
  padding-inline: var(--space-3);
  margin-bottom: var(--space-2);
}
html[lang='ar'] .sidebar-label { letter-spacing: 0.02em; text-transform: none; font-size: 0.74rem; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  color: var(--color-muted);
  font-size: 0.9rem;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-link:hover { background: var(--color-surface); color: var(--color-text); }
.nav-link[aria-current='page'] { background: var(--color-surface); color: var(--color-text); font-weight: 500; }
.nav-link .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--color-accent); opacity: 0; }
.nav-link[aria-current='page'] .dot { opacity: 1; }
.nav-count { margin-inline-start: auto; font-size: 0.72rem; color: var(--color-muted); font-variant-numeric: tabular-nums; }

.main { flex: 1; min-width: 0; padding: var(--space-6) var(--space-5) var(--space-8); }
.main-narrow { max-width: 880px; }
.main-wide { max-width: 1180px; }

.page-center { display: grid; place-items: center; min-height: 100vh; padding: var(--space-5); }

.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-tight { display: flex; flex-direction: column; gap: var(--space-2); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-6); }
.page-head .lead { margin-top: 6px; }

/* ----------------------------------------------------------------- panel -- */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-line-soft);
  border-radius: var(--r-lg);
  padding: var(--space-5);
}
.panel-flat { background: transparent; }
.panel-narrow { width: 100%; max-width: 420px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-line-soft);
}
.panel-head h2 { font-size: 0.95rem; font-weight: 600; }

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-line-soft);
  border-radius: var(--r-md);
  padding: var(--space-4) var(--space-5);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
a.card:hover { border-color: var(--color-line); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-3); }

.metric { display: flex; flex-direction: column; gap: 2px; }
.metric-value { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.metric-label { font-size: 0.76rem; color: var(--color-muted); }

/* ---------------------------------------------------------------- buttons -- */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--color-text);
  --btn-border: var(--color-line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 15px;
  min-height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  text-align: center;
}
.btn:hover { border-color: var(--color-line-hover, var(--color-line)); background: var(--color-surface-2); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.45; cursor: not-allowed; }

.btn-primary { --btn-bg: var(--color-text); --btn-fg: var(--color-ink); --btn-border: var(--color-text); font-weight: 550; }
.btn-primary:hover { background: var(--color-text); opacity: 0.9; border-color: var(--color-text); }

.btn-quiet { --btn-border: transparent; color: var(--color-muted); }
.btn-quiet:hover { color: var(--color-text); background: var(--color-surface); }

.btn-danger { --btn-border: var(--color-line); color: #e08276; }
html[data-theme='light'] .btn-danger { color: #a33a2c; }
.btn-danger:hover { background: color-mix(in oklab, #e08276 12%, transparent); }

.btn-sm { min-height: 30px; padding: 4px 11px; font-size: 0.8rem; }
.btn-icon { min-height: 32px; min-width: 32px; padding: 0; }
.btn-block { width: 100%; }

/* ----------------------------------------------------------------- badges -- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  border: 1px solid var(--color-line);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-muted);
  white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge-plain::before { display: none; }
.badge-ok { color: #7fb98d; border-color: color-mix(in oklab, #7fb98d 30%, transparent); }
.badge-warn { color: var(--color-accent); border-color: color-mix(in oklab, var(--color-accent) 40%, transparent); }
.badge-off { color: var(--color-muted); }
.badge-bad { color: #e08276; border-color: color-mix(in oklab, #e08276 34%, transparent); }
html[data-theme='light'] .badge-ok { color: #2f6b41; }
html[data-theme='light'] .badge-bad { color: #a33a2c; }

/* ------------------------------------------------------------------ table -- */
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table caption { text-align: start; color: var(--color-muted); font-size: 0.8rem; padding-bottom: var(--space-3); }
.table th {
  text-align: start;
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-muted);
  padding: 0 var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--color-line-soft);
}
html[lang='ar'] .table th { text-transform: none; letter-spacing: 0.02em; font-size: 0.78rem; }
.table td { padding: 11px var(--space-3); border-bottom: 1px solid var(--color-line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in oklab, var(--color-surface-2) 55%, transparent); }
.table-wrap { overflow-x: auto; }

/* ----------------------------------------------------------------- forms -- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 0.8rem; font-weight: 500; color: var(--color-text); display: flex; gap: 6px; align-items: baseline; }
.label .opt { color: var(--color-muted); font-weight: 400; font-size: 0.74rem; }
.input, .textarea, .select {
  width: 100%;
  padding: 9px 12px;
  min-height: 38px;
  background: var(--color-ink);
  border: 1px solid var(--color-line);
  border-radius: var(--r-sm);
  color: var(--color-text);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: color-mix(in oklab, var(--color-muted) 75%, transparent); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--color-line-hover, var(--color-line)); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--color-accent) 18%, transparent); }
.textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
.select { appearance: none; padding-inline-end: 30px; background-image: none; }
.hint { font-size: 0.76rem; color: var(--color-muted); }
.hint-error { color: #e08276; }
html[data-theme='light'] .hint-error { color: #a33a2c; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }

/* theme + language switchers */
.segmented { display: inline-flex; border: 1px solid var(--color-line); border-radius: var(--r-pill); padding: 2px; gap: 2px; }
.segmented button, .segmented a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 28px;
  padding: 2px 11px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--color-muted);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.segmented [aria-pressed='true'], .segmented [aria-current='true'] { background: var(--color-surface); color: var(--color-text); }
.segmented button:hover, .segmented a:hover { color: var(--color-text); }

/* ----------------------------------------------------------------- alerts -- */
.alert {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--color-line);
  background: var(--color-surface);
  font-size: 0.86rem;
}
.alert-error { border-color: color-mix(in oklab, #e08276 45%, transparent); color: #e9a79d; }
html[data-theme='light'] .alert-error { color: #8f2f22; border-color: color-mix(in oklab, #a33a2c 40%, transparent); }
.alert-ok { border-color: color-mix(in oklab, #7fb98d 40%, transparent); color: #9ecfaa; }
html[data-theme='light'] .alert-ok { color: #2f6b41; }
.alert-note { border-color: color-mix(in oklab, var(--color-accent) 35%, transparent); }

.empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  border: 1px dashed var(--color-line);
  border-radius: var(--r-md);
  color: var(--color-muted);
  font-size: 0.88rem;
}

/* ------------------------------------------------------------------ misc -- */
.divider { height: 1px; background: var(--color-line-soft); border: 0; margin: var(--space-4) 0; }
.kbd { font-family: var(--app-mono); font-size: 0.72rem; border: 1px solid var(--color-line); border-radius: 4px; padding: 1px 5px; color: var(--color-muted); }
.skip-link { position: absolute; inset-inline-start: -9999px; }
.skip-link:focus { inset-inline-start: var(--space-4); top: var(--space-2); z-index: 100; background: var(--color-text); color: var(--color-ink); padding: 8px 14px; border-radius: var(--r-sm); }
.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; }

.footer-note {
  margin-top: var(--space-7);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-line-soft);
  color: var(--color-muted);
  font-size: 0.76rem;
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* ------------------------------------------------------------ auth pages -- */
.auth-card { width: 100%; max-width: 430px; }
.auth-card .panel { padding: var(--space-6); }
.auth-alt { text-align: center; font-size: 0.86rem; color: var(--color-muted); margin-top: var(--space-4); }
.passkey-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: 11px 0; border-bottom: 1px solid var(--color-line-soft); }
.passkey-row:last-child { border-bottom: 0; }

/* --------------------------------------------------------------- editor -- */
.editor {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 330px;
  gap: 0;
  height: calc(100vh - var(--topbar));
  min-height: 0;
}
.editor-pane { min-width: 0; display: flex; flex-direction: column; border-inline-end: 1px solid var(--color-line-soft); overflow: hidden; }
.editor-pane:last-child { border-inline-end: 0; border-inline-start: 1px solid var(--color-line-soft); }
.editor-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--color-line-soft);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-muted);
  min-height: 44px;
}
html[lang='ar'] .editor-pane-head { text-transform: none; letter-spacing: 0.02em; font-size: 0.78rem; }
.editor-scroll { overflow-y: auto; padding: var(--space-3); flex: 1; }

.canvas-area { flex: 1; overflow: auto; padding: var(--space-5); background: var(--color-surface-2); display: flex; justify-content: center; align-items: flex-start; }
.canvas {
  width: 100%;
  background: var(--color-ink);
  border: 1px solid var(--color-line);
  border-radius: var(--r-md);
  overflow: hidden;
  transform-origin: top center;
}
.canvas[data-viewport='tablet'] { max-width: 820px; }
.canvas[data-viewport='mobile'] { max-width: 390px; }
.canvas[data-lang='ar'] { direction: rtl; }

.section-node {
  position: relative;
  padding: var(--space-2) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.section-node:hover { border-color: var(--color-line); }
.section-node[aria-selected='true'] { border-color: var(--color-accent); background: color-mix(in oklab, var(--color-accent) 7%, transparent); }
.section-node .node-label { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--color-muted); }
.section-node .node-tag { font-family: var(--app-mono); font-size: 0.68rem; color: var(--color-accent); }
.node-hidden { opacity: 0.4; }

.tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  color: var(--color-muted);
  cursor: pointer;
  user-select: none;
}
.tree-item:hover { background: var(--color-surface); color: var(--color-text); }
.tree-item[aria-selected='true'] { background: var(--color-surface); color: var(--color-text); }
.tree-item .grip { color: var(--color-line); font-family: var(--app-mono); }
.tree-item.dragging { opacity: 0.4; }
.tree-item.drop-before { box-shadow: inset 0 2px 0 var(--color-accent); }
.tree-item.drop-after { box-shadow: inset 0 -2px 0 var(--color-accent); }

.inspector-section { padding: var(--space-4); border-bottom: 1px solid var(--color-line-soft); }
.inspector-section h3 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--color-muted); margin-bottom: var(--space-3); font-weight: 500; }
html[lang='ar'] .inspector-section h3 { text-transform: none; letter-spacing: 0.02em; font-size: 0.8rem; }
.inspector-field { display: grid; grid-template-columns: 1fr 96px; gap: var(--space-2); align-items: center; margin-bottom: var(--space-2); }
.inspector-field-full { grid-template-columns: 1fr; }
.inspector-field label { font-size: 0.79rem; color: var(--color-muted); }
.inspector-field .input, .inspector-field .select { min-height: 32px; padding: 4px 9px; font-size: 0.82rem; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--color-line); cursor: pointer; }

.toolbar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.save-state { font-size: 0.76rem; color: var(--color-muted); min-width: 84px; text-align: end; }

.revision-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 9px 0; border-bottom: 1px solid var(--color-line-soft); font-size: 0.82rem; }
.diff-line { font-family: var(--app-mono); font-size: 0.76rem; padding: 2px 8px; border-radius: 4px; white-space: pre-wrap; }
.diff-add { background: color-mix(in oklab, #7fb98d 16%, transparent); }
.diff-del { background: color-mix(in oklab, #e08276 16%, transparent); }

/* ---------------------------------------------------------------- media -- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--space-3); }
.media-tile { border: 1px solid var(--color-line-soft); border-radius: var(--r-md); overflow: hidden; background: var(--color-surface); }
.media-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--color-surface-2); }
.media-meta { padding: 9px 11px; font-size: 0.76rem; color: var(--color-muted); display: flex; flex-direction: column; gap: 2px; }
.media-tile[aria-selected='true'] { border-color: var(--color-accent); }

.dropzone {
  border: 1px dashed var(--color-line);
  border-radius: var(--r-md);
  padding: var(--space-6);
  text-align: center;
  color: var(--color-muted);
  font-size: 0.86rem;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.dropzone.dragover { border-color: var(--color-accent); background: color-mix(in oklab, var(--color-accent) 6%, transparent); }

/* ------------------------------------------------------------- responsive -- */
@media (max-width: 1080px) {
  .editor { grid-template-columns: 210px minmax(0, 1fr) 300px; }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    inset-inline-start: 0;
    top: var(--topbar);
    z-index: 30;
    background: var(--color-ink);
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease);
    box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  }
  html[dir='rtl'] .sidebar { transform: translateX(100%); }
  .sidebar[data-open='true'] { transform: translateX(0); }
  .main { padding: var(--space-5) var(--space-4) var(--space-7); }
  .editor { grid-template-columns: minmax(0, 1fr); height: auto; }
  .editor-pane-tree, .editor-pane-inspector { display: none; }
  .editor[data-pane='tree'] .editor-pane-tree { display: flex; }
  .editor[data-pane='inspector'] .editor-pane-inspector { display: flex; }
  .editor[data-pane='tree'] .canvas-area, .editor[data-pane='inspector'] .canvas-area { display: none; }
}

@media (max-width: 620px) {
  .topbar { padding-inline: var(--space-3); gap: var(--space-2); }
  .brand .brand-sub { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .panel { padding: var(--space-4); border-radius: var(--r-md); }
  .auth-card .panel { padding: var(--space-5); }
  .metric-value { font-size: 1.35rem; }
}

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

@media print {
  .topbar, .sidebar, .footer-note, .toolbar { display: none; }
}

/* ------------------------------------------------------------------ spacing --
 * Inline style attributes are blocked by the strict CSP (style-src 'self'), so
 * layout adjustments are expressed as a small utility layer instead. The set is
 * intentionally tiny: a fixed spacing scale, a few alignment helpers, and three
 * compound patterns that recur in lists and quotes.
 */
.mt-4 { margin-top: 4px; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mt-18 { margin-top: 18px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.m-0 { margin: 0; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.gap-12 { gap: 12px; }
.gap-24 { gap: 24px; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.justify-end { justify-content: flex-end; }
.ms-auto { margin-inline-start: auto; }
.flex-1 { flex: 1; }
.grid-span-all { grid-column: 1 / -1; }
.cursor-default { cursor: default; }
.w-auto { width: auto; }
.w-150 { width: 150px; }
.maxw-220 { max-width: 220px; overflow-wrap: anywhere; }
.maxw-260 { max-width: 260px; overflow-wrap: anywhere; }
.maxw-320 { max-width: 320px; }
.maxw-560 { max-width: 560px; }
.maxw-70ch { max-width: 70ch; }
.maxh-220 { max-height: 220px; }
.border-top { border-top: 1px solid var(--color-line-soft); }

/* A list row: the repeated "line item with a hairline under it". */
.list-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--color-line-soft);
}
.list-row-tight {
  padding: 6px 0;
  border-bottom: 1px solid var(--color-line-soft);
}
.list-row-roomy {
  padding: 10px 0;
  border-bottom: 1px solid var(--color-line-soft);
}
/* A quoted block: accent rule on the inline-start edge. */
.quote-block {
  margin-top: 6px;
  padding-inline-start: 10px;
  border-inline-start: 2px solid var(--color-accent);
}
/* A select that should size to its content inside a table cell. */
.select-inline {
  width: auto;
  min-height: 30px;
  font-size: 0.8rem;
}
/* Author-defined font weights, from the section schema. */
.fw-300 { font-weight: 300; }
.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
/* Feature-grid column counts, from the section schema. */
.cols-1 { --cols: 1; }
.cols-2 { --cols: 2; }
.cols-3 { --cols: 3; }
