:root {
  color-scheme: light;
  --paper: #f7f1e7;
  --paper-strong: #fffdf9;
  --paper-soft: #efe6d7;
  --ink: #2d2924;
  --ink-soft: #756c62;
  --line: #ddd1bf;
  --red: #b33a2f;
  --red-dark: #8f2c24;
  --red-soft: #f3dfda;
  --green: #426b56;
  --shadow: 0 16px 40px rgba(65, 49, 35, 0.09);
  --radius-lg: 24px;
  --radius-md: 18px;
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 88% 5%, rgba(179, 58, 47, 0.13) 0 72px, transparent 73px),
    linear-gradient(180deg, #fbf7f0 0%, var(--paper) 38%, #f4ecdf 100%);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.ambient { position: fixed; pointer-events: none; z-index: 0; }
.ambient-sun {
  width: 112px; height: 112px; border-radius: 50%;
  right: -30px; top: 110px;
  border: 1px solid rgba(179, 58, 47, 0.12);
}
.ambient-wave {
  width: 220px; height: 90px; left: -70px; bottom: 105px;
  border: 1px solid rgba(45, 41, 36, 0.07);
  border-radius: 50%;
  transform: rotate(-8deg);
}

.app-shell { position: relative; z-index: 1; max-width: 720px; min-height: 100dvh; margin: 0 auto; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 18px 12px;
  background: rgba(247, 241, 231, 0.9);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(221, 209, 191, 0.72);
}
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px;
  border-radius: 13px; background: var(--red); color: #fff9f2;
  font-family: Georgia, serif; font-size: 24px; box-shadow: 0 8px 18px rgba(179, 58, 47, 0.2);
}
.brand-copy { min-width: 0; flex: 1; }
.brand-copy h1, .view-header h2, .section-heading h2 { margin: 1px 0 0; font-family: Georgia, "Times New Roman", serif; }
.brand-copy h1 { font-size: 22px; }
.eyebrow, .kicker { font-size: 10px; font-weight: 800; letter-spacing: 0.14em; color: var(--red-dark); }
.role-chip, .read-only-chip {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255, 253, 249, 0.72); color: var(--ink-soft); font-size: 12px; font-weight: 700;
}

.main-content { padding: 16px 16px calc(96px + var(--safe-bottom)); }
.state-panel {
  min-height: 58dvh; display: grid; align-content: center; justify-items: center; text-align: center;
  padding: 40px 28px;
}
.state-panel h2 { margin: 18px 0 6px; font: 700 24px Georgia, serif; }
.state-panel p { max-width: 360px; margin: 0; color: var(--ink-soft); line-height: 1.55; }
.state-symbol { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: var(--red-soft); color: var(--red); font: 700 28px Georgia, serif; }
.loader { width: 36px; height: 36px; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hero-card, .domain-card, .detail-card {
  background: rgba(255, 253, 249, 0.94); border: 1px solid rgba(221, 209, 191, 0.88);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.hero-card { position: relative; overflow: hidden; padding: 24px; }
.hero-card::after {
  content: ""; position: absolute; width: 92px; height: 92px; right: -28px; top: -24px;
  border-radius: 50%; background: rgba(179, 58, 47, 0.08); border: 1px solid rgba(179, 58, 47, 0.12);
}
.hero-topline { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hero-card h2 { margin: 18px 0 6px; font: 700 31px Georgia, serif; }
.hero-card p { margin: 0; color: var(--ink-soft); line-height: 1.5; }
.status-badge { display: inline-flex; align-items: center; width: fit-content; padding: 6px 9px; border-radius: 999px; background: var(--red-soft); color: var(--red-dark); font-size: 11px; font-weight: 800; }
.revision-line { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; padding-top: 14px; border-top: 1px dashed var(--line); color: var(--ink-soft); font-size: 12px; }
.revision-line code { max-width: 58%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }

.section-heading { display: flex; justify-content: space-between; align-items: end; margin: 26px 2px 12px; }
.section-heading h2 { font-size: 23px; }
.module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.module-card {
  min-height: 134px; padding: 17px; text-align: left; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: rgba(255, 253, 249, 0.9); color: var(--ink); box-shadow: 0 10px 24px rgba(65, 49, 35, 0.05);
  display: flex; flex-direction: column; align-items: flex-start; cursor: pointer;
}
.module-card:active:not(:disabled) { transform: scale(.985); }
.module-card-disabled { opacity: .54; cursor: default; }
.module-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--red-soft); color: var(--red-dark); font: 700 18px Georgia, serif; }
.module-title { margin-top: 15px; font-weight: 800; }
.module-meta { margin-top: 4px; color: var(--ink-soft); font-size: 12px; }
.domain-card { margin-top: 12px; padding: 8px 16px; }
.domain-row { display: flex; justify-content: space-between; align-items: center; min-height: 47px; border-bottom: 1px solid rgba(221, 209, 191, 0.65); }
.domain-row:last-child { border-bottom: 0; }
.domain-row span { display: flex; align-items: center; gap: 9px; }
.domain-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }

.view-header { display: flex; align-items: center; gap: 10px; margin: 2px 0 12px; }
.view-title-wrap { min-width: 0; flex: 1; }
.view-header h2 { font-size: 26px; }
.icon-button { width: 42px; height: 42px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper-strong); color: var(--ink); font-size: 20px; cursor: pointer; }
.view-description, .future-note { color: var(--ink-soft); line-height: 1.5; font-size: 13px; }
.future-note { margin: -3px 0 14px 52px; }

.primary-button, .soft-button, .text-button { border: 0; cursor: pointer; }
.primary-button { margin-top: 22px; width: 100%; padding: 14px 18px; border-radius: 15px; background: var(--red); color: white; font-weight: 800; }
.primary-button:active:not(:disabled) { background: var(--red-dark); }
.soft-button { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-strong); color: var(--ink); font-size: 12px; font-weight: 700; }
.soft-button-disabled, .disabled-action { opacity: .48; cursor: default; }
.text-button { background: transparent; color: var(--red-dark); font-size: 12px; font-weight: 800; }

.search-box { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 48px; background: var(--paper-strong); border: 1px solid var(--line); border-radius: 16px; }
.search-box span { color: var(--red-dark); font-size: 21px; }
.search-box input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-box input::placeholder { color: #9a9187; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 12px -16px 0; padding: 0 16px 4px; }
.chip-row::-webkit-scrollbar { display: none; }
.filter-chip { flex: 0 0 auto; padding: 9px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper-strong); color: var(--ink-soft); font-weight: 700; font-size: 12px; }
.filter-chip.active { background: var(--red); border-color: var(--red); color: white; }
.filter-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 9px; margin-top: 10px; }
.select-field { display: grid; gap: 5px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 253, 249, 0.86); }
.select-field span { color: var(--ink-soft); font-size: 10px; font-weight: 800; letter-spacing: .06em; }
.select-field select { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
.list-summary { display: flex; justify-content: space-between; align-items: center; margin: 18px 2px 8px; color: var(--ink-soft); font-size: 12px; }
.card-list { display: grid; gap: 8px; }
.card-row { display: grid; grid-template-columns: 58px minmax(0, 1fr) 24px; gap: 12px; align-items: center; width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 253, 249, .92); color: var(--ink); text-align: left; cursor: pointer; }
.card-thumb { width: 58px; height: 58px; border-radius: 13px; object-fit: cover; background: var(--paper-soft); }
.card-thumb-placeholder { display: grid; place-items: center; color: var(--red-dark); font: 700 19px Georgia, serif; }
.card-main { min-width: 0; }
.card-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.card-meta { display: block; margin-top: 5px; color: var(--ink-soft); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-arrow { color: var(--red-dark); font-size: 18px; }
.empty-card { padding: 32px 20px; text-align: center; border: 1px dashed var(--line); border-radius: 18px; color: var(--ink-soft); }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 14px; }
.pagination span { color: var(--ink-soft); font-size: 12px; }

.section-tree { display: grid; gap: 10px; margin-top: 14px; }
.tree-section { border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 253, 249, .9); overflow: hidden; }
.tree-section > summary { list-style: none; display: flex; align-items: center; gap: 9px; padding: 13px 14px; cursor: pointer; font-weight: 800; }
.tree-section > summary::-webkit-details-marker { display: none; }
.tree-section > summary::before { content: "＋"; color: var(--red-dark); }
.tree-section[open] > summary::before { content: "−"; }
.tree-children { display: grid; gap: 6px; padding: 0 10px 10px 20px; }
.tree-item { padding: 9px 11px; border-left: 2px solid var(--red-soft); color: var(--ink-soft); font-size: 12px; }
.tree-section .tree-section { box-shadow: none; background: rgba(247, 241, 231, .5); }

.detail-card { overflow: hidden; }
.detail-image-wrap { aspect-ratio: 1.45 / 1; background: var(--paper-soft); border-bottom: 1px solid var(--line); }
.detail-image-wrap img { width: 100%; height: 100%; object-fit: contain; }
.detail-head, .detail-section, .advanced-panel { margin: 0 18px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.detail-head h2 { margin: 10px 0 4px; font: 700 27px Georgia, serif; }
.muted { margin: 0; color: var(--ink-soft); font-size: 12px; }
.detail-section h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--red-dark); }
.detail-section p { margin: 0; line-height: 1.58; font-size: 14px; }
.preserve-lines { white-space: pre-line; }
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; }
.tag { padding: 7px 9px; border-radius: 999px; background: var(--paper-soft); color: var(--ink-soft); font-size: 11px; }
.advanced-panel summary { cursor: pointer; color: var(--red-dark); font-weight: 800; font-size: 13px; }
.advanced-list { display: grid; gap: 8px; margin-top: 12px; }
.advanced-row { padding: 10px; border-radius: 12px; background: var(--paper); }
.advanced-row strong { display: block; margin-bottom: 4px; font-size: 11px; }
.advanced-row pre { margin: 0; white-space: pre-wrap; word-break: break-word; color: var(--ink-soft); font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.detail-card > .primary-button { width: calc(100% - 36px); margin: 18px; }

.bottom-nav {
  position: fixed; z-index: 30; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(720px, 100%); display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 14px var(--safe-bottom); background: rgba(255, 253, 249, .94);
  backdrop-filter: blur(18px); border-top: 1px solid var(--line);
}
.nav-item { display: grid; gap: 2px; justify-items: center; padding: 7px 4px; border: 0; background: transparent; color: #91877c; }
.nav-item span { font: 700 18px Georgia, serif; }
.nav-item small { font-size: 10px; font-weight: 800; }
.nav-item.active { color: var(--red); }

.requests-list { display: grid; gap: 10px; }
.request-row { display: grid; gap: 7px; width: 100%; padding: 18px; text-align: left; color: var(--ink); background: var(--paper-strong); border: 1px solid var(--line); border-radius: 16px; overflow-wrap: anywhere; }
.request-row span { color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.request-facts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 12px; font-size: 14px; }
.request-facts dt { color: var(--ink-soft); }
.request-facts dd { margin: 0; overflow-wrap: anywhere; }
.request-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.request-actions .primary-button { width: auto; flex: 1; margin-top: 0; }
.request-row { cursor: pointer; }
#requestConfirm { margin-top: 16px; }
#requestName { overflow-wrap: anywhere; }
.employees-toolbar { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 10px; }
.employees-toolbar input { width: 100%; }
#employeeConfirm { margin-top: 16px; }
#employeeName { overflow-wrap: anywhere; }
.danger-button { color: var(--red-dark); }
@media (max-width: 559px) {
  #employeesView .view-header > #employeesRefresh,
  #employeeDetailView .view-header > #employeeRefresh { grid-column: 2; justify-self: start; }
}

@media (min-width: 560px) {
  .main-content { padding-left: 22px; padding-right: 22px; }
  .module-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .module-card { min-height: 145px; }
}

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

/* Stage 2 editor */
.accent-button { border-color: rgba(179, 58, 47, .28); color: var(--red-dark); background: #fff8f4; }
.editor-form { display: grid; gap: 14px; }
.editor-card, .preview-card {
  background: rgba(255, 253, 249, .96);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.editor-section { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.editor-image-note { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 13px; align-items: center; }
.editor-image-note strong { display: block; margin-bottom: 4px; }
.editor-image-note p { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.editor-photo-placeholder { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 15px; background: var(--red-soft); color: var(--red-dark); font: 700 20px Georgia, serif; }
.field-block { display: grid; gap: 7px; margin: 0; padding: 14px 18px; border: 0; border-bottom: 1px solid var(--line); }
.field-block > span, .field-block legend { color: var(--red-dark); font-size: 11px; font-weight: 800; letter-spacing: .055em; }
.field-block input, .field-block textarea, .field-block select {
  width: 100%; border: 1px solid #d8cab7; border-radius: 13px; outline: 0; background: #fffdfa; color: var(--ink); padding: 12px 13px;
}
.field-block textarea { resize: vertical; min-height: 92px; line-height: 1.5; }
.field-block input:focus, .field-block textarea:focus, .field-block select:focus { border-color: rgba(179, 58, 47, .72); box-shadow: 0 0 0 3px var(--red-soft); }
.field-block small, .field-help { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.45; }
.placement-fieldset { padding-top: 16px; }
.placement-list { display: grid; gap: 7px; max-height: 320px; overflow-y: auto; padding: 3px 1px; }
.placement-option { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 9px 11px; border: 1px solid rgba(221, 209, 191, .86); border-radius: 13px; background: #fffdfa; }
.placement-option input { width: 18px; height: 18px; accent-color: var(--red); }
.placement-option span { font-size: 13px; line-height: 1.35; }
.editor-actions { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.4fr); gap: 9px; }
.editor-actions .soft-button, .editor-actions .primary-button { margin: 0; min-height: 48px; }
.editor-save { width: 100%; }
.inline-message { padding: 12px 14px; border-radius: 14px; font-size: 12px; line-height: 1.5; }
.error-message { border: 1px solid rgba(179, 58, 47, .24); background: var(--red-soft); color: var(--red-dark); }
.success-message { border: 1px solid rgba(66, 107, 86, .23); background: rgba(66, 107, 86, .09); color: var(--green); }
.preview-card { margin-top: 16px; padding: 18px; scroll-margin-top: 78px; }
.preview-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.preview-card h2 { margin: 13px 0 4px; font: 700 26px Georgia, serif; }
.preview-section { padding: 13px 0; border-top: 1px solid var(--line); }
.preview-section:first-of-type { margin-top: 15px; }
.preview-section strong { display: block; margin-bottom: 6px; color: var(--red-dark); font-size: 11px; text-transform: uppercase; letter-spacing: .055em; }
.preview-section p { margin: 0; white-space: pre-line; line-height: 1.55; font-size: 13px; }

@media (max-width: 390px) {
  .editor-actions { grid-template-columns: 1fr; }
  .view-header .accent-button { padding: 9px 10px; }
}

/* Stage 3 photo workflow */
.editor-photo-section { display: grid; gap: 13px; }
.photo-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.photo-section-heading strong { display: block; margin-top: 3px; font-size: 15px; }
.field-kicker { display: block; color: var(--red-dark); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.photo-status { flex: 0 0 auto; border: 1px solid var(--line); background: var(--paper-soft); color: var(--ink-soft); border-radius: 999px; padding: 6px 9px; font-size: 10px; font-weight: 700; }
.photo-stage { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 1 / 1; overflow: hidden; border: 1px solid var(--line); border-radius: 19px; background: linear-gradient(145deg, #fffdf9, #f3eadc); }
.photo-stage img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.photo-empty { display: grid; justify-items: center; gap: 5px; color: var(--ink-soft); text-align: center; }
.photo-empty-mark { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 3px; border-radius: 50%; background: var(--red-soft); color: var(--red-dark); font: 700 20px Georgia, serif; }
.photo-empty strong { color: var(--ink); font-size: 14px; }
.photo-empty small { font-size: 11px; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.photo-actions-row { display: flex; align-items: center; gap: 10px; }
.photo-actions-row .soft-button { flex: 1 1 auto; margin: 0; min-height: 44px; }
.text-danger-button { border: 0; background: transparent; color: var(--red-dark); font-size: 12px; font-weight: 750; padding: 10px 5px; }
.photo-mode-field { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; }
.photo-mode-field > span { font-size: 12px; font-weight: 750; color: var(--ink-soft); }
.photo-mode-field select { width: 100%; }
.photo-help { margin: -2px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }
.photo-preview-button { min-height: 42px; border: 1px dashed rgba(179, 58, 47, .38); border-radius: 13px; background: rgba(179, 58, 47, .045); color: var(--red-dark); font-size: 12px; font-weight: 750; }
.photo-preview-button:disabled, .text-danger-button:disabled { opacity: .45; }
.preview-image-wrap { margin: 14px -2px 4px; aspect-ratio: 1 / 1; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: #fff; }
.preview-image-wrap img { width: 100%; height: 100%; object-fit: contain; }

/* Stage 4: sibling ordering. Touch scrolling remains enabled outside handles. */
.tree-order-button { margin: 8px 0 10px; min-height: 44px; }
.order-list { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0 0 110px; overflow-anchor: none; }
.order-row { display: flex; align-items: center; gap: 7px; min-height: 76px; padding: 8px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper-strong); }
.order-handle { flex: 0 0 44px; width: 44px; height: 52px; border: 0; border-radius: 10px; background: var(--paper-soft); color: var(--ink-soft); font-size: 28px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.order-copy { display: grid; gap: 4px; flex: 1; min-width: 0; }
.order-copy strong { font-size: 14px; overflow-wrap: anywhere; }
.order-copy small { color: var(--ink-soft); font-size: 11px; }
.order-row-actions { display: flex; flex: 0 0 auto; gap: 2px; }
.order-row-actions button { width: 44px; min-height: 44px; border: 0; border-radius: 10px; background: var(--red-soft); color: var(--red-dark); font-size: 20px; }
.order-row button:disabled { opacity: .35; cursor: default; }
.order-dragging { border: 2px solid var(--red); background: var(--red-soft); box-shadow: var(--shadow); }
.order-dragging .order-handle { cursor: grabbing; }
.order-gesture { user-select: none; -webkit-user-select: none; }
.order-actions { position: fixed; z-index: 12; left: 50%; transform: translateX(-50%); bottom: 0; width: min(100%, 760px); padding: 8px 20px var(--safe-bottom); background: var(--paper-strong); border-top: 1px solid var(--line); }
.order-actions p { margin: 0 0 6px; color: var(--ink-soft); font-size: 12px; }
.order-actions button { width: 100%; margin: 0; min-height: 46px; }
.order-row button:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Stage 5: preview and explicit publication. */
#publicationView .view-header { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; }
#publicationRefresh { grid-column: 1 / -1; justify-self: end; }
.publication-summary { display: grid; gap: 5px; margin: 14px 0; padding: 14px; border-radius: 14px; background: var(--paper-strong); }
.publication-summary:empty { display: none; }
.publication-summary p { margin: 0; font-size: 12px; color: var(--ink-soft); }
.publication-quality { margin: 12px 0; padding: 14px; border-radius: 14px; font-size: 12px; line-height: 1.5; }
.publication-quality summary { cursor: pointer; font-weight: 750; }
.publication-quality ul { padding-left: 20px; }
.publication-quality li + li { margin-top: 7px; }
.warning-message { background: #fff3d6; border: 1px solid #d8b773; color: #705319; }
.publication-form { display: grid; gap: 12px; margin: 16px 0 22px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper-strong); }
.publication-form .primary-button { width: 100%; margin: 0; }
.publication-check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; font-size: 13px; line-height: 1.5; }
.publication-check input { flex: 0 0 20px; width: 20px; height: 20px; margin-top: 2px; accent-color: var(--red); }
.publication-diff { display: grid; gap: 12px; }
.publication-change { min-width: 0; overflow: hidden; padding: 16px; border-radius: 17px; background: var(--paper-strong); border: 1px solid var(--line); }
.publication-change h3 { margin: 6px 0; font-size: 16px; overflow-wrap: anywhere; }
.publication-field { color: var(--ink-soft); font-size: 12px; margin: 0 0 12px; }
.publication-value { display: grid; gap: 5px; padding: 10px 0; border-top: 1px solid var(--line); }
.publication-value strong { font-size: 11px; color: var(--red-dark); }
.publication-value p { margin: 0; font-size: 12px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Stage 6: version and archive screens. */
#historyView .view-header, #archiveView .view-header { display: grid; grid-template-columns: 44px minmax(0,1fr); }
#historyRefresh, #archiveRefresh { grid-column: 1 / -1; justify-self: end; }
.history-entries { display: grid; gap: 10px; margin: 14px 0; }
.history-release { display: grid; gap: 7px; min-height: 78px; width: 100%; padding: 16px; text-align: left; border: 1px solid var(--line); border-radius: 17px; background: var(--paper-strong); color: var(--ink); }
.history-release strong { font-size: 15px; overflow-wrap: anywhere; }
.history-release span, .history-release small { font-size: 12px; line-height: 1.4; color: var(--ink-soft); }
.history-audit { padding-left: 20px; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.history-audit li { margin: 9px 0; }
.stage6-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stage6-actions button { min-height: 44px; flex: 1; }
#historyDetail h2, #rollbackTarget, #archiveConfirmTitle { overflow-wrap: anywhere; }
#detailArchiveControls { padding-top: 8px; }

/* Stage 7: one responsive CMS, driven by window width, not device names. */
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.cms-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark .cms-icon { width: 27px; height: 27px; }
.nav-item > span { display: grid; place-items: center; }
html { scroll-padding: 100px 0 110px; }
button, input, select, textarea { font: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 1px; }
.app-shell, .main-content, .view, .editor-fields { min-width: 0; }
.main-content { overflow-wrap: anywhere; }
.icon-button { flex: 0 0 44px; width: 44px; height: 44px; }
.soft-button, .text-button, .filter-chip, .nav-item, .photo-preview-button,
.text-danger-button, .tree-item { min-height: 44px; }
.view-header { flex-wrap: wrap; }
.view-title-wrap { flex-basis: 100px; }
.view-header h2 { overflow-wrap: anywhere; font-size: clamp(23px, 3vw, 28px); }
.read-only-chip { max-width: 100%; overflow-wrap: anywhere; }
.field-block { min-width: 0; }
.field-block input, .field-block select, .field-block textarea,
.search-box input, .select-field select, .photo-mode-field select {
  min-width: 0; max-width: 100%; font-size: 16px;
}
.select-field select, .photo-mode-field select { min-height: 34px; }
.photo-stage { max-width: 300px; justify-self: center; }
.photo-section-heading { flex-wrap: wrap; }
.photo-status { max-width: 100%; overflow-wrap: anywhere; }
.photo-help, .field-help { line-height: 1.6; }
.detail-head h2, .detail-section p, .preview-card h2, .preview-section p,
.placement-option span, .tag, .tree-section > summary { overflow-wrap: anywhere; }
.placement-option input { flex: 0 0 18px; }
.detail-image-wrap { max-height: 380px; }
.detail-card { min-width: 0; }
.preview-card { max-width: 720px; margin-left: auto; margin-right: auto; }
.preview-image-wrap { max-width: 340px; margin-left: auto; margin-right: auto; }
.tree-section > summary { min-height: 48px; }
.tree-children { min-width: 0; }
.tree-item { text-align: left; }
.publication-check span { min-width: 0; overflow-wrap: anywhere; }
.publication-quality, .publication-summary, .inline-message { overflow-wrap: anywhere; }
.inline-message:empty { display: none; }
.publication-form { max-width: 720px; }
.publication-change { margin-bottom: 0; }
.history-release { cursor: pointer; }
.nav-wide { display: none; }
.order-actions { width: min(100%, 1000px); }
.order-list { max-width: 960px; margin-left: auto; margin-right: auto; }
.keyboard-open .bottom-nav { display: none; }
.keyboard-open .topbar { position: relative; }

@media (max-width: 1099px) {
  .nav-context-hidden { display: none; }
}
@media (max-width: 559px) {
  .topbar { padding-left: 14px; padding-right: 14px; gap: 9px; }
  .brand-copy h1 { font-size: 21px; }
  .brand-copy .eyebrow { font-size: 9px; letter-spacing: .1em; }
  .role-chip { font-size: 11px; padding: 7px 9px; }
  .hero-card { padding: 20px; }
  .hero-card h2 { font-size: 28px; }
  .module-card { padding: 15px; min-height: 142px; }
  .view-header { display: grid; grid-template-columns: 44px minmax(0, 1fr); }
  #orderView .view-header { grid-template-columns: auto minmax(0, 1fr); }
  .view-header > .accent-button, .view-header > .read-only-chip { grid-column: 2; justify-self: start; }
  .editor-photo-section { padding: 14px; }
  .filter-row { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
  .detail-image-wrap { max-height: 300px; }
}
@media (min-width: 768px) {
  .app-shell { max-width: 1280px; }
  .main-content { padding: 24px 28px calc(104px + var(--safe-bottom)); }
  .topbar { padding-left: 28px; padding-right: 28px; }
  .bottom-nav { width: min(1280px, 100%); }
  .module-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .module-card { min-height: 155px; }
  .hero-card { padding: 28px; }
  .hero-card h2 { font-size: 36px; }
  .hero-card p { max-width: 650px; }
  .card-list, .history-entries { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card-row { min-height: 90px; }
  .card-title { white-space: normal; overflow-wrap: anywhere; }
  .card-meta { line-height: 1.5; }
  .publication-change { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; padding: 22px; }
  .publication-change > .eyebrow, .publication-change > h3, .publication-field { grid-column: 1 / -1; }
  .publication-value { align-content: start; }
  #publicationView .view-header, #historyView .view-header, #archiveView .view-header { grid-template-columns: 44px minmax(0, 1fr) auto; }
  #publicationRefresh, #historyRefresh, #archiveRefresh { grid-column: auto; }
  .history-release { min-height: 120px; align-content: center; }
  .detail-image-wrap { aspect-ratio: 2 / 1; }
  .photo-stage { max-width: 340px; }
}
@media (min-width: 900px) {
  .editor-card { display: grid; grid-template-columns: minmax(240px, .75fr) minmax(0, 1.25fr); align-items: start; }
  .editor-photo-section { border-bottom: 0; }
  .editor-fields { border-left: 1px solid var(--line); }
  .photo-stage { max-width: 100%; }
  .editor-fields > :last-child { border-bottom: 0; }
  .editor-actions { max-width: 640px; width: 100%; justify-self: end; }
  .detail-card.with-photo { display: grid; grid-template-columns: minmax(240px, .8fr) minmax(0, 1.2fr); align-items: start; }
  .detail-card.with-photo > * { grid-column: 2; }
  .detail-card.with-photo > .detail-image-wrap { grid-column: 1; grid-row: 1 / span 6; aspect-ratio: 1; width: 100%; height: auto; max-height: none; border-bottom: 0; }
}
@media (min-width: 1100px) {
  .app-shell { display: grid; grid-template-columns: 192px minmax(0, 1fr); grid-template-rows: auto 1fr; align-items: start; }
  .topbar { grid-column: 1 / -1; grid-row: 1; }
  .main-content { grid-column: 2; grid-row: 2; padding: 24px 28px 64px 12px; }
  .bottom-nav {
    grid-column: 1; grid-row: 2; position: sticky; top: 94px; left: auto; bottom: auto; transform: none;
    width: auto; display: grid; grid-template-columns: 1fr; gap: 5px; margin: 24px 16px;
    padding: 10px; border: 1px solid var(--line); border-radius: 20px; background: var(--paper-strong);
  }
  .nav-item { display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: 12px; text-align: left; color: var(--ink-soft); }
  .nav-item small { font-size: 12px; }
  .nav-item.active { background: var(--red-soft); }
  .nav-item span { width: 22px; text-align: center; }
  .app-shell.focus-view { grid-template-columns: minmax(0, 1fr); max-width: 1120px; }
  .app-shell.focus-view .main-content { grid-column: 1; padding-left: 28px; }
  .order-actions { border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; }
}
@media (max-height: 520px) and (min-width: 560px) {
  .topbar { position: relative; padding-top: 10px; padding-bottom: 10px; }
  .bottom-nav { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .photo-stage { max-width: 220px; }
  .editor-photo-section { position: static; }
}
@media (hover: hover) and (pointer: fine) {
  .module-card:hover, .card-row:hover, .history-release:hover { border-color: #bbaa94; background: #fff; }
  .soft-button:hover:not(:disabled), .nav-item:hover { background: var(--paper-soft); }
}

/* Admin Stage 4: invitations share the personnel shell. */
.invite-toolbar { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.invite-toolbar label { display: grid; gap: 6px; flex: 1; min-width: 160px; }
.invite-toolbar select, .invite-link { width: 100%; box-sizing: border-box; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-strong); color: inherit; font: inherit; }
.invite-row { padding: 20px; }
.invite-row p { overflow-wrap: anywhere; }
.invite-link { display: block; margin: 10px 0; font-size: 14px; }
@media (max-width: 560px) {
  #invitesRefresh { grid-column: 2; justify-self: start; }
  .invite-toolbar { display: grid; grid-template-columns: minmax(0, 1fr); }
}

/* Admin Stage 5: archive availability in the existing cards list. */
.availability-field { margin: 14px 0; }
.card-availability { display: block; margin-top: 5px; color: var(--green); font-size: 12px; font-weight: 700; }
.card-availability.is-archived { color: var(--red-dark); }
#archiveToCards { margin: 12px 0; }

/* Admin Stage 6: readable audit and developer preview. */
.audit-filters { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 12px; margin: 14px 0; }
.audit-filters input { min-width: 0; width: 100%; border: 0; background: transparent; color: var(--ink); padding: 5px 0; font: inherit; }
.audit-links { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0; }
.audit-list { display: grid; gap: 12px; }
.audit-entry { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 18px; background: var(--paper-strong); }
.audit-entry h3 { margin: 10px 0 8px; font-size: 17px; line-height: 1.35; }
.audit-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; color: var(--ink-soft); font-size: 12px; }
.audit-meta > span { color: var(--red-dark); font-weight: 700; }
.audit-target { margin: 0 0 8px; overflow-wrap: anywhere; }
.audit-author { margin: 0; color: var(--ink-soft); font-size: 13px; overflow-wrap: anywhere; }
.audit-technical { margin-top: 12px; color: var(--ink-soft); font-size: 12px; }
.audit-technical summary { cursor: pointer; padding: 4px 0; }
.audit-technical code { display: block; margin-top: 8px; overflow-wrap: anywhere; }
.preview-banner { padding: 12px 18px; background: #e6eddf; color: #29452f; text-align: center; }
.preview-banner > strong, .preview-banner > span { display: block; font-size: 13px; margin: 3px 0; }
.preview-banner nav { display: flex; gap: 16px; justify-content: center; margin-top: 8px; }
.preview-banner a { color: inherit; font-size: 13px; padding: 6px; text-decoration: underline; }
.preview-banner a[aria-current] { font-weight: 800; }
.view h2[tabindex="-1"]:focus { outline: none; }
.audit-filter-panel { border: 1px solid var(--line); border-radius: 14px; background: var(--paper-strong); padding: 12px; margin: 12px 0; }
.audit-filter-panel > summary { cursor: pointer; font-weight: 700; color: var(--red-dark); }
.audit-filter-panel .audit-links { margin-bottom: 0; }
#adminHistoryView .view-header { display: grid; grid-template-columns: 44px minmax(0,1fr) 44px; }
#adminHistoryRefresh { grid-column: auto; justify-self: end; width: 44px; }
@media (max-width: 560px) {
  .audit-filters { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .audit-filters > label:first-child { grid-column: 1 / -1; }
}
