:root {
  --brand: #2f5d50;
  --brand-soft: #e3ece6;
  --ink: #2b2b2b;
  --muted: #6b665e;
  --line: #e8dfd2;
  --bg: #fbf6ef;
  --card: #fffdf8;
  --good: #1f7a3f;
  --warn: #9a6200;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --warn-soft: #fdf3e0;
  --good-soft: #e5f3ea;
  --radius: 10px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font:
    16px/1.5 system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a {
  color: var(--brand);
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 0.25rem;
}

h2 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.5rem;
}

code {
  font-size: 0.85em;
  color: var(--muted);
  word-break: break-all;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

[hidden] {
  display: none !important;
}

/* ---- Frame ---- */

.top {
  position: sticky;
  min-height: 52px;
  box-sizing: border-box;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--brand);
  color: #fff;
}

.brand {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  font-size: 1.1rem;
}

.brand span {
  font-weight: 400;
  opacity: 0.8;
}

.env {
  font-size: 0.8rem;
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  background: rgb(255 255 255 / 0.18);
}

.env.production {
  background: #f2c94c;
  color: #3a2c00;
  font-weight: 600;
}

.spacer {
  flex: 1;
}

.user {
  font-size: 0.85rem;
  opacity: 0.85;
}

.pill {
  font-size: 0.85rem;
  padding: 0.3rem 0.75rem;
  border-radius: 99px;
  text-decoration: none;
  background: #fff;
  color: var(--brand);
  font-weight: 600;
}

.pill.pending {
  background: #f2c94c;
  color: #3a2c00;
}

.pill.publishing {
  background: #cfe7ff;
  color: #0b3d6b;
}

.pill.failed {
  background: var(--bad-soft);
  color: var(--bad);
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 52px);
}

.nav {
  padding: 1rem 0.5rem;
  border-right: 1px solid var(--line);
  background: var(--card);
}

.nav h3 {
  margin: 1rem 0.75rem 0.35rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.nav a {
  display: block;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
}

.nav a:hover {
  background: var(--bg);
}

.nav a.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

.main {
  padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 5rem;
  max-width: 1000px;
  width: 100%;
  min-width: 0;
  outline: none;
}

.menu-toggle {
  display: none;
}

/* ---- Pieces ---- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.75rem;
}

.cards a.card {
  text-decoration: none;
  color: inherit;
}

.cards a.card:hover {
  border-color: var(--brand);
}

.card strong {
  display: block;
  font-size: 1.05rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.page-head > div:first-child {
  flex: 1;
  min-width: 220px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.sticky-actions {
  position: sticky;
  top: 52px;
  z-index: 5;
  background: var(--bg);
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
}

/* Why the last save failed: a full-width line at the bottom of the save bar, so it stays in sight while scrolling. */
.sticky-actions .save-problem {
  order: 1;
  flex-basis: 100%;
  margin: 0;
  padding: 0.55rem 0.8rem;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.save-problem[hidden] {
  display: none;
}

button,
.button {
  font: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

button:hover,
.button:hover {
  border-color: var(--brand);
}

button.primary,
.button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

button.danger {
  color: var(--bad);
}

button.link {
  border: 0;
  background: none;
  padding: 0.2rem 0.3rem;
  color: var(--brand);
  text-decoration: underline;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.icon {
  padding: 0.25rem 0.5rem;
  min-width: 2rem;
  justify-content: center;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 99px;
  background: var(--good-soft);
  color: var(--good);
  font-weight: 600;
  white-space: nowrap;
}

.badge.draft {
  background: #eceff1;
  color: var(--muted);
}

.badge.estimate {
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 500;
}

.notice {
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  background: var(--brand-soft);
  margin: 0 0 1rem;
}

.notice.error {
  background: var(--bad-soft);
  color: var(--bad);
}

.notice.warn {
  background: var(--warn-soft);
  color: #5c3b00;
}

table.list {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Its rounded corners clip, but a dropdown's menu (the people page's roles) must show over the rows below. */
table.list:has(.menu-select) {
  overflow: visible;
}

table.list td,
table.list th {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

table.list th {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  background: var(--bg);
}

table.list tr:last-child td {
  border-bottom: 0;
}

table.list .thumb {
  width: 72px;
  height: 48px;
}

.thumb {
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
  display: block;
}

.thumb.empty {
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px dashed var(--line);
}

/* ---- Forms ---- */

.fields {
  display: grid;
  /* minmax(0, …): a long one-line value (a dropdown, a link) gets cut short instead of widening the form. */
  grid-template-columns: minmax(0, 1fr);
  gap: 1.1rem;
}

.field > label,
.field > .label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.field .help {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

input[type='text'],
input[type='number'],
input[type='date'],
input[type='search'],
input[type='url'],
select,
textarea {
  font: inherit;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid #c5d0cf;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

/* A dropdown drawn by the CMS (menuSelect in app.js): looks like a text box, opens a list right under it. */
.menu-select {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}

button.menu-button {
  display: block;
  width: 100%;
  padding: 0.5rem 2rem 0.5rem 0.65rem;
  border: 1px solid #c5d0cf;
  background: #fff;
  font-size: 1rem;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

button.menu-button::after {
  content: '▾';
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

button.menu-button:disabled {
  opacity: 0.6;
  cursor: default;
}

.menu-list {
  position: absolute;
  z-index: 60;
  top: calc(100% + 4px);
  left: 0;
  display: grid;
  min-width: max(100%, 12rem);
  max-width: min(26rem, calc(100vw - 2rem));
  max-height: 16rem;
  overflow: auto;
  padding: 0.25rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 15%);
}

.menu-list.up {
  top: auto;
  bottom: calc(100% + 4px);
}

.menu-list[hidden] {
  display: none;
}

.menu-list button {
  display: block;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.5rem 0.65rem;
  border: 0;
  border-radius: 6px;
  background: none;
  text-align: left;
  white-space: nowrap;
}

.menu-list button:hover,
.menu-list button:focus-visible {
  background: var(--bg);
}

.menu-list button.selected {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

textarea {
  resize: vertical;
  min-height: 2.6rem;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

input[readonly] {
  background: var(--bg);
  color: var(--muted);
}

.check {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-weight: 500;
}

.check input {
  width: 1.1rem;
  height: 1.1rem;
}

.prefixed {
  display: flex;
  align-items: stretch;
}

.prefixed > span {
  display: flex;
  align-items: center;
  padding: 0 0.6rem;
  background: var(--bg);
  border: 1px solid #c5d0cf;
  border-right: 0;
  border-radius: 8px 0 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.prefixed > input {
  border-radius: 0 8px 8px 0;
}

/* A fieldset is as wide as its widest line by default; min-width: 0 lets it shrink to the screen. */
fieldset {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 1rem 1rem;
  margin: 0;
  background: var(--card);
}

fieldset fieldset {
  background: var(--bg);
}

legend {
  font-weight: 700;
  padding: 0 0.35rem;
}

.meter {
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.meter.good {
  color: var(--good);
}

.meter.warn {
  color: var(--warn);
}

.meter.bad {
  color: var(--bad);
}

.serp {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  background: #fff;
  font-family: arial, sans-serif;
}

.serp .u {
  font-size: 0.8rem;
  color: #4d5156;
}

.serp .t {
  color: #1a0dab;
  font-size: 1.15rem;
  line-height: 1.3;
  margin: 0.15rem 0;
}

.serp .d {
  color: #4d5156;
  font-size: 0.875rem;
}

.items {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
}

details.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

details.item > summary {
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
}

details.item > summary::-webkit-details-marker {
  display: none;
}

/* When the title and its buttons don't fit on one line, the buttons go under it. */
details.item > summary .title {
  flex: 1 1 12rem;
  min-width: 0;
  overflow-wrap: break-word;
  font-weight: 600;
}

details.item > summary::before {
  content: '▸';
  color: var(--muted);
}

details.item[open] > summary::before {
  content: '▾';
}

details.item > .fields {
  padding: 0.25rem 0.75rem 0.9rem;
}

.image-field {
  display: flex;
  gap: 0.9rem;
  align-items: center;
}

.image-field .thumb {
  width: 160px;
  height: 100px;
  flex: none;
}

.image-meta {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.image-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.image-list .tile {
  width: 140px;
  display: grid;
  gap: 0.2rem;
}

.image-list .thumb {
  width: 140px;
  height: 92px;
}

.status-choice {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ---- Photo picker and library ---- */

dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(960px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  box-shadow: 0 20px 60px rgb(0 0 0 / 0.3);
}

dialog::backdrop {
  background: rgb(10 20 20 / 0.5);
}

.dialog-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.dialog-head h2 {
  margin: 0;
  flex: 1;
}

.dialog-body {
  padding: 1rem 1.1rem 1.25rem;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.9rem;
}

.tabs button[aria-selected='true'] {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}

.filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.filters .menu-select {
  max-width: 14rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
}

.grid button.tile {
  display: grid;
  gap: 0.3rem;
  padding: 0.35rem;
  text-align: left;
  align-content: start;
}

.grid .thumb {
  width: 100%;
  aspect-ratio: 3 / 2;
  height: auto;
}

.grid .cap {
  font-size: 0.8rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.grid .cap.bad {
  color: var(--bad);
}

.upload-preview {
  max-width: 100%;
  max-height: 260px;
  border-radius: 8px;
  display: block;
  margin: 0.5rem 0;
}

/* ---- Lists of things ---- */

.issues {
  display: grid;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.issues li {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--warn);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
}

.issues li.error {
  border-left-color: var(--bad);
}

.recent {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.recent li {
  font-size: 0.92rem;
}

/* ---- Toasts ---- */

.toasts {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: grid;
  gap: 0.5rem;
  z-index: 100;
  max-width: min(420px, calc(100vw - 2rem));
}

.toast {
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
}

.toast.error {
  background: var(--bad);
}

textarea.prompt {
  font:
    0.8rem/1.45 ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
}

/* ---- Signed out ---- */

body.signed-out .nav,
body.signed-out .top .env,
body.signed-out .top .pill,
body.signed-out .top .user,
body.signed-out .menu-toggle {
  display: none !important;
}

body.signed-out .layout {
  grid-template-columns: 1fr;
}

body.signed-out .main {
  margin: 0 auto;
  max-width: 440px;
  padding-top: 3rem;
}

.card.signin {
  padding: 1.5rem;
}

input[type='email'],
input[type='password'] {
  font: inherit;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid #c5d0cf;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

code.secret {
  display: block;
  font-size: 1.25rem;
  color: var(--ink);
  letter-spacing: 0.04em;
  user-select: all;
}

/* ---- Phones (kept last so these win over the rules above) ---- */

@media (max-width: 760px) {
  .top {
    height: 52px;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
  }

  .brand,
  .env,
  .menu-toggle {
    white-space: nowrap;
  }

  .brand {
    font-size: 1rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .env {
    font-size: 0.72rem;
    padding: 0.1rem 0.45rem;
  }

  .user {
    display: none;
  }

  .pill {
    font-size: 0.75rem;
    padding: 0.25rem 0.55rem;
    max-width: 9.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* The menu opens over the page from the ☰ button. */
  .menu-toggle {
    display: inline-flex;
    background: rgb(255 255 255 / 0.15);
    border-color: transparent;
    color: #fff;
    padding: 0.35rem 0.65rem;
    min-height: 0;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .nav {
    display: none;
    position: fixed;
    inset: 52px 0 0 0;
    z-index: 20;
    overflow-y: auto;
    border-right: 0;
    padding: 0.5rem 0.75rem 2rem;
    box-shadow: 0 12px 30px rgb(0 0 0 / 0.2);
  }

  .nav.open {
    display: block;
  }

  .nav a {
    padding: 0.7rem 0.75rem;
    font-size: 1.05rem;
  }

  .main {
    padding: 1rem 1rem 6rem;
  }

  h1 {
    font-size: 1.3rem;
  }

  /* Bigger taps. */
  button,
  .button {
    min-height: 44px;
    padding: 0.5rem 0.9rem;
  }

  button.icon {
    min-width: 44px;
  }

  button.link {
    min-height: 0;
  }

  .check input {
    width: 1.35rem;
    height: 1.35rem;
  }

  .sticky-actions {
    margin-left: -1rem;
    margin-right: -1rem;
    padding: 0.5rem 1rem;
  }

  /* Two short rows, so the form keeps most of the screen: on the site or hidden (and Delete, away from Save), then
     the buttons. */
  .sticky-actions {
    gap: 0.4rem;
  }

  .sticky-actions .status-choice {
    order: -3;
    flex: 1 1 auto;
    gap: 0.75rem;
    font-size: 0.92rem;
  }

  .sticky-actions > .danger {
    order: -2;
  }

  /* The break between the two rows. */
  .sticky-actions:has(.status-choice)::before {
    content: '';
    order: -1;
    flex-basis: 100%;
    margin-top: -0.4rem;
  }

  .sticky-actions .spacer {
    display: none;
  }

  .sticky-actions button,
  .sticky-actions .button {
    min-height: 40px;
    padding: 0.3rem 0.65rem;
    font-size: 0.875rem;
  }

  /* A folded block shows two lines of its words under its kind, not three cut-off words beside it. */
  details.block > summary {
    flex-wrap: wrap;
    row-gap: 0.15rem;
  }

  details.block > summary .block-title {
    flex: 1;
  }

  details.block > summary .block-preview {
    order: 1;
    flex-basis: 100%;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: 0.92rem;
  }

  .page-head .button.primary {
    width: 100%;
    justify-content: center;
  }

  fieldset {
    padding: 0.6rem 0.7rem 0.8rem;
  }

  details.item > .fields {
    padding: 0.25rem 0.6rem 0.8rem;
  }

  .prefixed {
    flex-direction: column;
  }

  .prefixed > span {
    border-right: 1px solid #c5d0cf;
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    padding: 0.3rem 0.6rem;
    white-space: normal;
    word-break: break-all;
  }

  .prefixed > input {
    border-radius: 0 0 8px 8px;
  }

  .image-field {
    flex-direction: column;
    align-items: stretch;
  }

  .image-field .thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 10;
  }

  .image-list .tile,
  .image-list .thumb {
    width: calc(50vw - 2.5rem);
  }

  /* Tables become a stack of cards. */
  table.list,
  table.list tbody,
  table.list tr,
  table.list td {
    display: block;
    width: 100%;
  }

  table.list thead {
    display: none;
  }

  table.list {
    border: 0;
    background: none;
  }

  table.list tr {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
    padding: 0.6rem 0.75rem;
  }

  table.list td {
    border: 0;
    padding: 0.15rem 0;
  }

  table.list.rows tr {
    display: grid;
    grid-template-columns: 84px 1fr;
    column-gap: 0.75rem;
    align-items: center;
  }

  table.list.rows td:first-child {
    grid-row: span 3;
  }

  table.list.rows .thumb {
    width: 84px;
    height: 60px;
  }

  table.list.rows td.order {
    grid-column: 1 / -1;
    padding-top: 0.4rem;
  }

  table.list.rows td.order .actions {
    justify-content: flex-end;
  }

  /* The photo picker and dialogs take the whole screen. */
  dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .filters {
    flex-direction: column;
  }

  .filters .menu-select {
    max-width: none;
  }

  .grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .toasts {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    max-width: none;
  }
}

@media (max-width: 360px) {
  .brand span {
    display: none;
  }
}

@media (max-width: 760px) {
  .actions.quick {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .quick .button {
    justify-content: center;
    text-align: center;
  }

  .quick .button.primary {
    grid-column: 1 / -1;
  }
}

/* History: earlier versions of a page or setting. */
.history {
  margin: 0.5rem 0 1.25rem;
}

.history summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--brand);
}

.history > div {
  margin-top: 0.6rem;
}

.history li .badge {
  margin-left: 0.4rem;
}

/* ---- Finding and crediting photos from online ---- */

.photo-hint {
  margin-top: 0.6rem;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  background: var(--warn-soft);
  display: grid;
  gap: 0.3rem;
}

.search-links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.search-links a {
  font-weight: 600;
}

details.credit > summary {
  cursor: pointer;
  font-weight: 600;
}

details.credit[open] > summary {
  margin-bottom: 0.5rem;
}

/* ---- The article, block by block ---- */

fieldset.article {
  padding-bottom: 1.1rem;
}

.blocks {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.block {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0.5rem 0.85rem 0.85rem;
}

.block.kind-heading,
.block.kind-subheading {
  border-left-color: var(--brand);
}

.block.kind-note {
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

.block.kind-youtube,
.block.kind-instagram,
.block.kind-image {
  border-left-color: #8a6bbf;
}

.block.kind-cta {
  border-left-color: #e9a23b;
  background: #fff8ec;
}

/* Folded, a block is one line: its kind and the start of its words. Open, it shows its fields. */
details.block:not([open]) {
  padding-bottom: 0.5rem;
}

details.block > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.25rem;
  cursor: pointer;
  list-style: none;
}

details.block > summary::-webkit-details-marker {
  display: none;
}

details.block > summary::after {
  content: '▸';
  color: var(--muted);
}

details.block[open] > summary {
  margin-bottom: 0.5rem;
}

details.block[open] > summary::after {
  content: '▾';
}

.block-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.block-preview {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.block-preview.empty {
  font-style: italic;
}

.block.kind-heading .block-preview,
.block.kind-subheading .block-preview {
  color: var(--ink);
  font-weight: 700;
}

.block-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.block-head .menu-select.kind {
  width: auto;
}

.block-head .kind .menu-button {
  padding: 0.2rem 1.6rem 0.2rem 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-color: transparent;
  background: var(--bg);
}

.block-head .spacer {
  flex: 1;
}

.block-note {
  margin: 0 0 0.5rem;
}

/* The words of a heading or paragraph need no "Text" label: the kind above says what it is. */
.block .field[data-field='text'] > label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.block.kind-heading textarea {
  font-size: 1.25rem;
  font-weight: 700;
}

.block.kind-subheading textarea {
  font-size: 1.08rem;
  font-weight: 600;
}

.block .fields {
  gap: 0.75rem;
}

.sign {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  height: 1.6rem;
  padding: 0 0.3rem;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.8rem;
  font-weight: 700;
}

/* The + between blocks: a thin line until it's pointed at. */
.insert {
  display: flex;
  justify-content: center;
  min-height: 1.1rem;
  margin: 0.15rem 0;
}

.insert:first-child {
  min-height: 0.5rem;
}

.insert-open {
  padding: 0 0.6rem;
  min-height: 0;
  line-height: 1.1rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: 1px dashed transparent;
  opacity: 0.35;
}

.insert:hover .insert-open,
.insert-open:focus-visible {
  opacity: 1;
  border-color: var(--brand);
  color: var(--brand);
  background: var(--card);
}

.insert-panel {
  width: 100%;
  display: grid;
  gap: 0.4rem;
  padding: 0.6rem;
  margin: 0.3rem 0;
  border: 1px dashed var(--brand);
  border-radius: 8px;
  background: var(--card);
}

.insert-panel > button.link {
  justify-self: start;
}

.add-block {
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--line);
}

.add-block > .label {
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.block-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.block-buttons button {
  padding: 0.3rem 0.65rem 0.3rem 0.35rem;
  font-size: 0.9rem;
}

/* A YouTube or Instagram link, checked as it's pasted. */
.link-check {
  margin-top: 0.4rem;
}

.link-check.good {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 8px;
  background: var(--good-soft);
}

.link-check.good strong {
  color: var(--good);
}

.link-check.bad {
  font-size: 0.9rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  color: var(--bad);
  background: var(--bad-soft);
}

.link-thumb {
  width: 120px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  flex: none;
  background: var(--line);
}

.link-thumb.tall {
  width: 54px;
  aspect-ratio: 9 / 16;
}

.ig-mark {
  position: relative;
  flex: none;
  width: 2.4rem;
  height: 2.4rem;
  border: 3px solid #b0397f;
  border-radius: 0.75rem;
}

.ig-mark::after {
  content: '';
  position: absolute;
  inset: 0.45rem;
  border: 3px solid #b0397f;
  border-radius: 50%;
}

/* ---- Folded sections under a form ---- */

.groups {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.6rem;
  margin-top: 1.5rem;
}

.groups > h2 {
  margin: 0 0 0.2rem;
}

details.group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

details.group > summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.6rem;
  list-style: none;
}

details.group > summary::-webkit-details-marker {
  display: none;
}

details.group > summary::before {
  content: '▸';
  color: var(--muted);
}

details.group[open] > summary::before {
  content: '▾';
}

details.group > :not(summary) {
  margin: 0 1rem 1rem;
}

/* ---- Lists: show or hide a row from the list ---- */

.show-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.show-toggle input {
  width: 1.1rem;
  height: 1.1rem;
}

/* ---- Website pages: each page's sections ---- */

.sections {
  display: grid;
  gap: 0.6rem;
  padding: 0;
  margin: 1rem 0 0;
  list-style: none;
  counter-reset: section;
}

.sections .card {
  display: block;
  text-decoration: none;
  color: inherit;
}

.sections a.card:hover {
  border-color: var(--brand);
}

.sections .card .where {
  display: block;
  margin-top: 0.35rem;
  color: var(--brand);
  font-weight: 600;
}

.sections .card.fixed {
  background: var(--bg);
}

.sections .card.fixed .where {
  color: var(--muted);
  font-weight: 400;
}

.sections .card strong::before {
  counter-increment: section;
  content: counter(section) '. ';
  color: var(--muted);
}

/* ---- Preview: the site's real pages, beside the form (wide screens) or over it (phones) ---- */

.preview-drawer {
  position: fixed;
  top: 52px;
  right: 0;
  bottom: 0;
  width: min(58vw, 1100px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 30px rgb(0 0 0 / 0.08);
}

/* The form stays usable beside it. */
body.previewing .layout {
  margin-right: min(58vw, 1100px);
  grid-template-columns: 1fr;
}

body.previewing .nav {
  display: none;
}

.preview-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.preview-bar .menu-select {
  width: auto;
  max-width: 16rem;
}

.preview-bar .close {
  margin-left: auto;
  font-size: 1.3rem;
  line-height: 1;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  background: var(--card);
}

.segmented button + button {
  border-left: 1px solid var(--line);
}

.segmented button[aria-pressed='true'] {
  background: var(--brand);
  color: #fff;
}

.preview-status {
  margin: 0;
  padding: 0.45rem 0.9rem;
  color: var(--muted);
}

.preview-status.error {
  color: var(--bad);
  background: var(--bad-soft);
}

.preview-late {
  margin: 0 0 0.5rem;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  color: var(--bad);
  background: var(--bad-soft);
}

.preview-frames {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 0.75rem;
  padding: 0 0.9rem 0.9rem;
}

.preview-frames.both {
  grid-template-columns: 1fr 1fr;
}

.preview-frame {
  margin: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.preview-frame figcaption {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.35rem 0 0.3rem;
}

.preview-device {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

/* A phone keeps its own width, centred, so it reads like a phone. */
.preview-frame.phone .preview-device {
  width: min(100%, 390px);
  margin: 0 auto;
  border-radius: 22px;
  border: 6px solid var(--ink);
}

.preview-device iframe {
  display: block;
  border: 0;
  transform-origin: 0 0;
}

@media (max-width: 900px) {
  .preview-drawer {
    top: 0;
    width: 100%;
    z-index: 60;
    border-left: 0;
  }

  body.previewing .layout {
    margin-right: 0;
  }

  .preview-bar .menu-select {
    max-width: 100%;
    flex: 1 1 100%;
    order: 5;
  }
}
