/* WebrykOS editor shell. Nuit tokens (docs/revamp/DESIGN.md): dark by default, never follows the OS.
   Green is reserved for money in Nuit, so nothing here is green: a saved state is neutral. */
/* Inter Tight, the one Nuit face, served by the editor itself (latin subset, variable 400 to 700,
   SIL Open Font License). Without it the shell fell back to the system font. */
@font-face {
  font-family: "Inter Tight"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/assets/inter-tight-latin.woff2") format("woff2");
}
:root {
  color-scheme: dark;
  --n-ground: #0B0B0C; --n-card: #141415; --n-raised: #1C1C1E; --n-hover: #1A1A1C; --n-active: #232325;
  --n-edge: rgba(255,255,255,.07); --n-line: rgba(255,255,255,.12); --n-hair: rgba(255,255,255,.06); --n-track: rgba(255,255,255,.08);
  --n-t1: #F4F4F2; --n-t2: #9A9AA0; --n-t3: #86868C; --n-label: #C9C9CC;
  --n-info: #8FA2F0; --n-info-text: #AEBBF5; --n-info-bg: rgba(143,162,240,.16);
  --n-neg: #FF6B5E; --n-neg-text: #FF8A7E; --n-neg-bg: rgba(255,107,94,.14); --n-neg-line: rgba(255,107,94,.28);
  --n-neutral-text: #D5D5D8; --n-neutral-bg: rgba(255,255,255,.08);
  --n-primary-bg: #F4F4F2; --n-primary-t: #0B0B0C; --n-primary-hover: #FFFFFF;
  --n-shadow-pop: 0 16px 40px rgba(0,0,0,.5); --n-shadow-page: 0 14px 36px rgba(0,0,0,.42);
  --n-focus: var(--n-info);
  --n-r-ctl: 14px; --n-r-card: 20px; --n-r-panel: 24px; --n-r-pill: 999px;
  --n-d-1: 140ms; --n-d-2: 180ms; --n-d-3: 280ms; --n-ease: cubic-bezier(.2,.8,.2,1);
  --n-font: "Inter Tight", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --inspector: 348px;
  --sheet: min(46dvh, 400px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; height: 100dvh; overflow: hidden; display: grid; grid-template-rows: auto auto minmax(0, 1fr);
  background: var(--n-ground); color: var(--n-t1); font: 15px/1.5 var(--n-font); letter-spacing: -.01em;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--n-focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -80px; z-index: 50; padding: 10px 16px; border-radius: var(--n-r-pill); background: var(--n-primary-bg); color: var(--n-primary-t); font-weight: 700; }
.skip:focus { top: 8px; }

/* ---------- buttons ---------- */
.primary, .secondary, .quiet, .publish-button, .back {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--n-r-pill); font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background-color var(--n-d-2) var(--n-ease), color var(--n-d-2) var(--n-ease), transform var(--n-d-1) var(--n-ease);
}
.primary { background: var(--n-primary-bg); color: var(--n-primary-t); font-weight: 700; }
.primary:hover:not(:disabled) { background: var(--n-primary-hover); }
/* The one action that leaves the editor for Webryk carries the accent, so it is never mistaken
   for a button of the client's own page shown beside it. */
.primary.accent { background: var(--n-info); }
.primary.accent:hover:not(:disabled) { background: var(--n-info-text); }
.secondary { background: transparent; border-color: var(--n-line); color: var(--n-t1); }
.secondary:hover:not(:disabled) { background: var(--n-hover); }
.quiet, .back { min-height: 36px; padding: 0 4px; background: none; color: var(--n-t2); }
.quiet:hover, .back:hover { color: var(--n-t1); }
.quiet.danger { color: var(--n-neg-text); }
.icon-button {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; padding: 0; border: 0; border-radius: 12px;
  background: none; color: var(--n-t2); transition: background-color var(--n-d-2) var(--n-ease), color var(--n-d-2) var(--n-ease);
}
.icon-button:hover:not(:disabled) { background: var(--n-hover); color: var(--n-t1); }
:is(.primary, .secondary, .publish-button, .icon-button, .segment button):active:not(:disabled) { transform: scale(.97); }
[aria-busy="true"]::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2.4px solid currentColor; border-right-color: transparent;
  animation: spin .8s linear infinite;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.segment { display: inline-flex; gap: 2px; padding: 4px; border-radius: var(--n-r-ctl); background: var(--n-card); border: 1px solid var(--n-edge); }
.segment button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 34px; padding: 0 12px; border: 0; border-radius: 10px;
  background: none; color: var(--n-t2); font-size: 13.5px; font-weight: 600;
  transition: background-color var(--n-d-2) var(--n-ease), color var(--n-d-2) var(--n-ease), transform var(--n-d-1) var(--n-ease);
}
.segment button:hover { color: var(--n-t1); }
.segment button[aria-pressed="true"] { background: var(--n-active); color: var(--n-t1); }
.segment.wide { display: flex; background: var(--n-ground); }
.segment.wide button { flex: 1 1 auto; padding: 0 10px; white-space: nowrap; }

/* ---------- top bar ---------- */
.bar {
  grid-row: 1; position: relative; z-index: 30; display: flex; align-items: center; gap: 12px; min-height: 60px;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); padding-top: max(8px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--n-hair);
}
.bar-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo { flex: none; height: auto; }
.logo-icon { display: none; }
.site-name { min-width: 0; max-width: 200px; padding-left: 14px; border-left: 1px solid var(--n-line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.page-switch { flex: none; }
select {
  appearance: none; min-height: 42px; max-width: 100%; padding: 0 38px 0 14px; border: 1px solid var(--n-line); border-radius: var(--n-r-ctl);
  background: var(--n-raised) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239A9AA0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 16px;
  font-size: 16px; font-weight: 500; text-overflow: ellipsis;
}
.page-switch select { border-radius: var(--n-r-pill); background-color: var(--n-card); font-size: 15px; font-weight: 600; }
.bar-tools { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.history { display: flex; }
.bar-end { display: flex; align-items: center; gap: 10px; }
.short-label { display: none; }

.save-state { display: flex; align-items: center; gap: 8px; min-width: 104px; color: var(--n-t2); font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.save-mark { width: 14px; height: 14px; flex: none; }
.save-state[data-status="saved"] .save-mark { width: 6px; height: 11px; margin: 0 4px 3px; border: solid var(--n-t2); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.save-state[data-status="saving"] .save-mark { border-radius: 50%; border: 2.4px solid var(--n-t2); border-right-color: transparent; animation: spin .8s linear infinite; }
.save-state[data-status="offline"] { color: var(--n-t1); }
.save-state[data-status="offline"] .save-mark { width: 8px; height: 8px; margin: 0 3px; border-radius: 50%; background: var(--n-neg); }

.pill-status, .chip {
  display: inline-flex; align-items: center; min-height: 28px; padding: 0 12px; border: 0; border-radius: var(--n-r-pill);
  background: var(--n-neutral-bg); color: var(--n-neutral-text); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.pill-status:disabled { opacity: 1; }
.pill-status[data-tone="info"], .chip[data-tone="info"] { background: var(--n-info-bg); color: var(--n-info-text); }
button.pill-status:not(:disabled)::after { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 0 3px 8px; border: solid currentColor; border-width: 0 1.8px 1.8px 0; transform: rotate(45deg); }
.status-note {
  position: absolute; right: 16px; top: calc(100% + 8px); display: grid; gap: 10px; justify-items: start; width: min(380px, calc(100vw - 32px)); padding: 18px;
  border: 1px solid var(--n-line); border-radius: var(--n-r-card); background: var(--n-raised); box-shadow: var(--n-shadow-pop); animation: arrive var(--n-d-3) var(--n-ease) both;
}
.status-note-title { font-weight: 600; }
#status-note-text { color: var(--n-label); white-space: pre-wrap; overflow-wrap: anywhere; }

.banner { grid-row: 2; padding: 9px 16px; background: var(--n-info-bg); color: var(--n-info-text); font-size: 13.5px; font-weight: 500; text-align: center; }
.review-only { display: none; }
body[data-mode="review"] .edit-only { display: none; }
body[data-mode="review"] .review-only { display: inline-flex; }

/* ---------- stage ---------- */
.work { grid-row: 3; display: grid; grid-template-columns: minmax(0, 1fr) var(--inspector); min-height: 0; }
/* The page floats on a lighter gutter: a dark site must not merge with the dark shell. */
.stage { position: relative; min-width: 0; min-height: 0; padding: 16px; background: var(--n-raised); }
.viewport { position: relative; height: 100%; overflow: hidden; border-radius: var(--n-r-ctl); background: var(--n-card); box-shadow: 0 0 0 1px var(--n-line), var(--n-shadow-page); }
.viewport iframe { position: absolute; top: 0; border: 0; background: #fff; transform-origin: top left; }
.viewport[data-framed="true"] { background: none; border-radius: 0; box-shadow: none; overflow: visible; }
.viewport[data-framed="true"] iframe { border-radius: 16px; box-shadow: 0 0 0 1px var(--n-line), var(--n-shadow-page); }
.viewport[data-loading] iframe { visibility: hidden; }
.skeleton { position: absolute; inset: 0; display: none; align-content: start; gap: 18px; padding: clamp(20px, 6%, 64px); background: var(--n-card); }
.viewport[data-loading] .skeleton { display: grid; }
.skeleton span { height: 18px; border-radius: 8px; background: linear-gradient(90deg, var(--n-track) 0%, rgba(255,255,255,.14) 50%, var(--n-track) 100%) 0 0 / 200% 100%; animation: sweep 1.4s linear infinite; }
.skeleton span:nth-child(1) { width: 46%; height: 44px; }
.skeleton span:nth-child(2) { width: 72%; }
.skeleton span:nth-child(3) { width: 64%; }
.skeleton span:nth-child(4) { width: 100%; height: min(38vh, 320px); margin-top: 14px; border-radius: var(--n-r-ctl); }

.pip-toggle {
  position: absolute; right: 28px; bottom: 28px; z-index: 6; display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 16px;
  border: 1px solid var(--n-line); border-radius: var(--n-r-pill); background: var(--n-raised); color: var(--n-t1); font-weight: 600; box-shadow: var(--n-shadow-pop);
  transition: background-color var(--n-d-2) var(--n-ease);
}
.pip-toggle:hover { background: var(--n-active); }
.pip-toggle[aria-pressed="true"] { background: var(--n-active); }
.pip { position: absolute; right: 28px; bottom: 84px; z-index: 7; width: 258px; border: 1px solid var(--n-line); border-radius: var(--n-r-card); background: var(--n-raised); box-shadow: var(--n-shadow-pop); overflow: hidden; }
.pip-bar { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 4px 0 14px; color: var(--n-t2); font-size: 13px; font-weight: 600; cursor: grab; touch-action: none; user-select: none; }
.pip-bar:active { cursor: grabbing; }
.pip-bar .icon-button { width: 32px; height: 32px; }
.pip-view { position: relative; height: min(470px, 56dvh); overflow: hidden; background: var(--n-card); }
.pip-view iframe { position: absolute; top: 0; border: 0; background: #fff; transform-origin: top left; }

.coach, .notice { border: 1px solid var(--n-line); background: var(--n-raised); box-shadow: var(--n-shadow-pop); }
.coach { position: absolute; left: 28px; bottom: 28px; z-index: 8; display: grid; gap: 8px; width: min(340px, calc(100% - 56px)); padding: 18px; border-radius: var(--n-r-card); }
.coach h2 { font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.coach p:not(.kicker) { color: var(--n-label); }
.coach .actions { margin-top: 6px; }
.notices { position: absolute; left: 50%; bottom: 28px; z-index: 9; display: grid; gap: 8px; width: min(520px, calc(100% - 56px)); transform: translateX(-50%); pointer-events: none; }
.notice { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 6px 10px; padding: 14px 10px 14px 18px; border-radius: 18px; pointer-events: auto; animation: arrive var(--n-d-3) var(--n-ease) both; }
.notice p { padding-top: 8px; font-size: 14.5px; }
.notice-actions { grid-column: 1; display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 2px; }
.notice .icon-button { grid-column: 2; grid-row: 1; }
.notice[role="alert"] { border-color: var(--n-neg-line); }

/* ---------- inspector ---------- */
.inspector { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--n-edge); background: var(--n-ground); }
.inspector:focus-visible { outline-offset: -2px; }
.sheet-bar { display: none; }
.inspector-body { display: flex; flex-direction: column; gap: 18px; min-height: 0; overflow-y: auto; padding: 20px 20px max(28px, env(safe-area-inset-bottom)); overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--n-active) transparent; }
.panel-head { display: grid; justify-items: start; gap: 2px; }
.panel-head h2 { font-size: 21px; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; overflow-wrap: anywhere; }
.panel-head .where { color: var(--n-t2); font-weight: 500; }
.back { margin: -6px 0 6px -6px; gap: 2px; font-size: 13.5px; }
.kicker { color: var(--n-t2); font-size: 13px; font-weight: 600; }
.hint { color: var(--n-t2); }
.fine { color: var(--n-t3); font-size: 13px; line-height: 1.45; }
.panel-stack { display: flex; flex-direction: column; gap: 18px; }
.field { display: grid; gap: 8px; }
label, .label { color: var(--n-label); font-size: 14px; font-weight: 600; }
input[type="text"], textarea {
  width: 100%; min-height: 46px; padding: 11px 14px; border: 1px solid var(--n-line); border-radius: var(--n-r-ctl); background: var(--n-raised);
  font-size: 16px; line-height: 1.45; transition: border-color var(--n-d-2) var(--n-ease), box-shadow var(--n-d-2) var(--n-ease);
}
.field select { width: 100%; }
textarea { resize: vertical; }
textarea[readonly] { color: var(--n-t2); }
:is(input[type="text"], textarea, select):focus-visible { outline: none; border-color: var(--n-info); box-shadow: 0 0 0 4px rgba(143,162,240,.16); }
input[type="range"] { width: 100%; height: 28px; accent-color: var(--n-info); }
.counter { color: var(--n-t3); font-size: 13px; font-variant-numeric: tabular-nums; }
.warn, .note { padding: 10px 14px; border-radius: var(--n-r-ctl); font-size: 13.5px; line-height: 1.45; }
.warn { background: var(--n-info-bg); color: var(--n-info-text); }
.warn[role="alert"] { background: var(--n-neg-bg); color: var(--n-neg-text); border: 1px solid var(--n-neg-line); }
.note { background: var(--n-neutral-bg); color: var(--n-neutral-text); }
.origin { display: grid; gap: 6px; justify-items: start; padding-top: 14px; border-top: 1px solid var(--n-hair); }
.origin-text { max-height: 9.5em; overflow-y: auto; color: var(--n-t2); font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; scrollbar-width: thin; scrollbar-color: var(--n-active) transparent; }
.inline { display: flex; gap: 8px; }
.inline select { flex: 1; min-width: 0; }
.count { margin-left: 8px; padding: 1px 8px; border-radius: var(--n-r-pill); background: var(--n-neutral-bg); color: var(--n-neutral-text); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

.setting-list li + li, .element-list li + li, .order-list li + li { border-top: 1px solid var(--n-hair); }
.setting-list button {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) 16px; align-items: center; gap: 14px; width: 100%; min-height: 60px; padding: 8px 6px; border: 0; border-radius: 10px;
  background: none; color: var(--n-t2); text-align: left; transition: background-color var(--n-d-2) var(--n-ease);
}
.setting-list button:hover, .element-list button:hover, .row-name:hover { background: var(--n-hover); }
.setting-list strong { display: block; color: var(--n-t1); font-weight: 600; }
.setting-list small { display: block; font-size: 13px; line-height: 1.35; }
.navigator summary { display: flex; align-items: center; min-height: 44px; color: var(--n-label); font-size: 14px; font-weight: 600; cursor: pointer; list-style: none; border-top: 1px solid var(--n-hair); }
.navigator summary::-webkit-details-marker { display: none; }
.navigator summary::after { content: ""; width: 7px; height: 7px; margin: 0 6px 3px auto; border: solid var(--n-t2); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.navigator[open] summary::after { margin-bottom: -3px; transform: rotate(225deg); }
.element-list button { display: grid; gap: 1px; width: 100%; min-height: 52px; padding: 7px 6px; border: 0; border-radius: 10px; background: none; text-align: left; transition: background-color var(--n-d-2) var(--n-ease); }
.element-kind { color: var(--n-t3); font-size: 12px; font-weight: 600; }
.element-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }

.photo-preview { width: 100%; max-height: 210px; object-fit: cover; border-radius: var(--n-r-ctl); background: var(--n-raised); }
.drop { display: grid; justify-items: center; gap: 4px; padding: 20px 14px; border: 1.5px dashed var(--n-line); border-radius: var(--n-r-ctl); color: var(--n-t2); text-align: center; cursor: pointer; transition: border-color var(--n-d-2) var(--n-ease), background-color var(--n-d-2) var(--n-ease); }
.drop strong { color: var(--n-t1); font-size: 15px; }
.drop small { font-size: 13px; font-weight: 400; }
.drop:hover, .drop[data-over] { border-color: var(--n-info); background: var(--n-info-bg); }
input:focus-visible + .drop { outline: 2px solid var(--n-focus); outline-offset: 2px; }
.library { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.library button { display: block; width: 100%; padding: 0; border: 0; border-radius: 10px; background: var(--n-raised); overflow: hidden; }
.library img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.library button[aria-pressed="true"] { outline: 2px solid var(--n-info); outline-offset: 2px; }
.crop-canvas { display: block; width: 100%; border-radius: 12px; background: var(--n-raised); cursor: grab; touch-action: none; }
.crop-canvas:active { cursor: grabbing; }

.order-list li { display: flex; align-items: center; gap: 2px; min-height: 52px; border-radius: 10px; }
.order-list li[aria-current="true"] { background: var(--n-active); }
.row-name { flex: 1; min-width: 0; min-height: 44px; padding: 0 8px; border: 0; border-radius: 10px; background: none; text-align: left; font-weight: 500; }
.row-name span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block-settings { display: grid; gap: 16px; padding-top: 16px; border-top: 1px solid var(--n-hair); justify-items: stretch; }
.block-settings .quiet { justify-self: start; }

/* ---------- changes, review, dialog ---------- */
.changes { display: grid; gap: 22px; }
.changes h3 { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; margin-bottom: 4px; padding: 6px 0; background: var(--n-card); font-size: 16px; font-weight: 600; }
.inspector .changes h3 { background: var(--n-ground); }
.changes ul { display: grid; gap: 8px; }
.change { display: grid; gap: 10px; padding: 14px 16px; border-radius: var(--n-r-ctl); background: var(--n-raised); }
.change-head { display: grid; justify-items: start; gap: 0; }
.change-head strong { font-size: 14px; font-weight: 600; color: var(--n-label); overflow-wrap: anywhere; }
.change-head .quiet { min-height: 28px; font-size: 13px; }
.diff { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.diff-side + .diff-side { padding-left: 18px; border-left: 1px solid var(--n-hair); }
.refusal { display: grid; gap: 12px; padding: 16px 18px; border: 1px solid var(--n-neg-line); border-radius: var(--n-r-ctl); background: var(--n-neg-bg); }
.refusal > p { color: var(--n-neg-text); font-size: 14.5px; line-height: 1.5; }
.refusal ul { display: grid; gap: 8px; }
.refusal li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; padding: 10px 12px 10px 14px; border-radius: 12px; background: var(--n-card); }
.refusal li span { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; font-size: 14.5px; }
.refusal .secondary { min-height: 36px; padding: 0 14px; font-size: 13.5px; }
.diff-side { display: grid; align-content: start; gap: 2px; min-width: 0; }
.diff-tag { color: var(--n-t3); font-size: 12px; font-weight: 600; }
.diff-side p { white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-side:first-child p { color: var(--n-t2); }
.diff-photos { display: flex; align-items: center; gap: 14px; color: var(--n-t2); }
.diff-photos img { width: 132px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; }
.diff-photos figcaption { margin-top: 4px; color: var(--n-t3); font-size: 12px; font-weight: 600; }
.inspector .diff-photos img { width: 108px; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; color: var(--n-t2); font-size: 13px; }
.publish { display: grid; gap: 10px; justify-items: start; padding-top: 18px; border-top: 1px solid var(--n-hair); }
.publish-button { border-radius: var(--n-r-ctl); border-color: var(--n-info); background: var(--n-info-bg); color: var(--n-info-text); font-weight: 700; }
.publish-button:hover { background: rgba(143,162,240,.26); }

.dialog {
  width: min(760px, calc(100vw - 32px)); max-height: min(860px, calc(100dvh - 48px)); padding: 0; border: 1px solid var(--n-line); border-radius: var(--n-r-panel);
  background: var(--n-card); color: var(--n-t1); box-shadow: var(--n-shadow-pop); overflow: hidden;
}
.dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.dialog::backdrop { background: rgba(0,0,0,.62); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 16px 12px 28px; }
.dialog-head h2 { font-size: 24px; font-weight: 700; letter-spacing: -.03em; line-height: 1.2; }
.dialog-body { display: grid; align-content: start; gap: 18px; padding: 0 28px 36px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--n-active) transparent; }
.dialog-body > p { max-width: 62ch; color: var(--n-label); font-size: 16px; }
.dialog-body > p.fine { color: var(--n-t3); font-size: 13.5px; }
.dialog-foot { position: relative; display: flex; flex-wrap: wrap; gap: 10px; padding: 16px 28px max(20px, env(safe-area-inset-bottom)); border-top: 1px solid var(--n-hair); }
/* A list longer than the panel fades out above the actions instead of being cut by them. */
.dialog-foot::before { content: ""; position: absolute; left: 0; right: 0; bottom: calc(100% + 1px); height: 32px; background: linear-gradient(to top, var(--n-card), transparent); pointer-events: none; }
.dialog-foot:empty { display: none; }

/* ---------- full-page states ---------- */
.screen { display: none; }
body[data-state="screen"] { display: block; overflow: auto; }
body[data-state="screen"] > :not(.screen) { display: none; }
body[data-state="screen"] .screen { display: grid; justify-items: start; align-content: center; gap: 28px; min-height: 100dvh; width: min(560px, 100%); margin: 0 auto; padding: 40px 24px; }
#screen-body { display: grid; gap: 14px; justify-items: start; }
.screen-title { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
#screen-body p { color: var(--n-t2); font-size: 16px; }
#screen-body .actions { margin-top: 10px; }
#screen-body .primary { min-height: 46px; padding: 0 22px; }
body[data-state="loading"] :is(.page-switch, .bar-tools, .bar-end, .pip-toggle) { visibility: hidden; }
body[data-state="loading"] .inspector-body::before { content: ""; height: 120px; border-radius: var(--n-r-ctl); background: linear-gradient(90deg, var(--n-track) 0%, rgba(255,255,255,.14) 50%, var(--n-track) 100%) 0 0 / 200% 100%; animation: sweep 1.4s linear infinite; }

/* ---------- widths ---------- */
/* Webryk's review reads two versions side by side: its column is wider than the client's panel. */
body[data-mode="review"] { --inspector: 432px; }
@media (max-width: 1359px) {
  .devices span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .devices button { width: 40px; padding: 0; }
}
@media (max-width: 1119px) {
  .site-name { display: none; }
  :root { --inspector: 320px; }
  body[data-mode="review"] { --inspector: 380px; }
}
@media (max-width: 899px) {
  .bar { flex-wrap: wrap; row-gap: 6px; }
  .bar-end { margin-left: auto; }
  .bar-tools { order: 3; width: 100%; margin: 0; }
  .save-state { margin-left: auto; min-width: 0; }
  .work { grid-template-columns: minmax(0, 1fr); }
  .stage { padding: 10px 10px calc(66px + env(safe-area-inset-bottom)); }
  body[data-sheet="open"] .stage { padding-bottom: calc(var(--sheet) + 8px); }
  .inspector { position: fixed; inset: auto 0 0; z-index: 20; max-height: var(--sheet); border-left: 0; border-top: 1px solid var(--n-line); border-radius: var(--n-r-card) var(--n-r-card) 0 0; box-shadow: 0 -12px 32px rgba(0,0,0,.45); }
  .inspector[data-open="true"] { height: var(--sheet); }
  .inspector[data-open="false"] .inspector-body { display: none; }
  .sheet-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 6px 12px 6px 18px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .inspector[data-open="true"] .sheet-bar { padding-bottom: 6px; border-bottom: 1px solid var(--n-hair); }
  .sheet-bar p { min-width: 0; color: var(--n-t2); font-size: 14px; line-height: 1.3; }
  .inspector[data-open="true"] .sheet-bar p { color: var(--n-t1); font-weight: 600; }
  .sheet-bar .secondary { min-height: 40px; padding: 0 14px; font-size: 14px; }
  .inspector-body { padding-top: 16px; }
  .inspector-body .back { display: none; }
  .pip-toggle, .pip { display: none !important; }
  .coach { left: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); width: min(340px, calc(100% - 32px)); }
  body[data-sheet="open"] .coach { display: none; }
  .notices { bottom: calc(76px + env(safe-area-inset-bottom)); width: calc(100% - 24px); }
  body[data-sheet="open"] .notices { bottom: calc(var(--sheet) + 16px); }
  .status-note { right: 12px; }
}
@media (max-width: 639px) {
  .devices { display: none; }
  .logo-full { display: none; }
  .logo-icon { display: block; }
  .wide-label { display: none; }
  .short-label { display: inline; }
  /* Two rows: brand, page and "Soumettre"; then undo, redo, save state, status and "Fermer la session". */
  .bar { gap: 6px 8px; }
  .bar::before { content: ""; order: 4; flex-basis: 100%; height: 0; margin-top: -6px; }
  .bar-brand { order: 1; }
  .page-switch { order: 2; flex: 1 1 0; min-width: 0; }
  .page-switch select { width: 100%; }
  .bar-end { display: contents; }
  .bar-end .primary { order: 3; padding: 0 16px; }
  .bar-tools { order: 5; width: auto; flex: none; gap: 8px; }
  .save-state { margin-left: 0; }
  .save-state[data-status="saved"] #save-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .bar-end .pill-status { order: 6; flex: 0 1 auto; min-width: 0; margin-left: auto; overflow: hidden; text-overflow: ellipsis; line-height: 28px; }
  body[data-mode="edit"] .bar-end .pill-status.edit-only, body[data-mode="review"] .bar-end .pill-status.review-only { display: block; }
  .bar-end .leave { order: 7; }
  .diff { grid-template-columns: minmax(0, 1fr); }
  .diff-side + .diff-side { padding-left: 0; border-left: 0; }
  .dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; border: 0; border-radius: 0; }
  .dialog-head { padding: max(16px, env(safe-area-inset-top)) 8px 10px 18px; }
  .dialog-head h2 { font-size: 21px; }
  .dialog-body { padding: 4px 18px 20px; }
  .dialog-foot { padding-inline: 18px; }
  .dialog-foot > * { flex: 1 1 auto; }
  .diff-photos img { width: 104px; }
  .screen-title { font-size: 26px; }
}
@media (pointer: coarse) {
  .primary, .secondary, .publish-button, select, .page-switch select { min-height: 46px; }
  .icon-button { width: 44px; height: 44px; }
  .segment button { min-height: 44px; }
  .devices button { width: 44px; }
  .quiet, .back, .change-head .quiet { min-height: 44px; }
  .pip-bar .icon-button { width: 44px; height: 40px; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes sweep { to { background-position: -200% 0; } }
@keyframes arrive { from { opacity: 0; translate: 0 -4px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
