/* UnoRouter Posts: the old workspace's Swiss Signal world (ink rules, a black rail, square
   corners, Archivo) in its Ember rendition: warm greys and one coral-orange signal.
   Every colour is a semantic role; dark mode remaps roles, never individual rules. */

@font-face {
  font-family: "Archivo";
  src: url("/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

/* ---------- Roles: light ----------
   Ember: the workspace's world (ink rules, black rail, Archivo, square corners) on warm
   greys, with one coral-orange signal. Light and dark are each composed, not inverted. */
:root {
  --bg: #fbf9f7;
  --surface: #fbf9f7;
  --surface-2: #f1ece7;
  --surface-3: #e3dcd4;
  --fg: #1a1512;
  --fg-muted: #6b5f56;
  --rule: #1a1512; /* section, stage and frame rules */
  --rule-cell: #cfc5bb; /* calendar grid, dotted */
  --head-bg: #1a1512; /* stage heads, weekday bar */
  --head-fg: #fbf9f7;
  --rail-bg: #1a1512;
  --rail-fg: #d9cfc6;
  --rail-hover: #2d2520;
  --weekend: #f6f2ee;
  --danger: #b8001a;
  --danger-soft: rgb(184 0 26 / 0.1);
  --draft: #8a5200;
  --draft-soft: rgb(138 82 0 / 0.13);
  --done: #6b5f56;
  --accent: #ff6a3d;
  --accent-fg: #1a1512;
  --accent-soft: rgb(255 106 61 / 0.14);
  --accent-ring: rgb(255 106 61 / 0.55);
  --backdrop: rgb(26 21 18 / 0.5);
  --rail-w: 200px;
  color-scheme: light;
}

/* ---------- Roles: dark ---------- */
:root[data-mode="dark"] {
  --bg: #14110f;
  --surface: #1b1714;
  --surface-2: #25201c;
  --surface-3: #332c27;
  --fg: #f3ece6;
  --fg-muted: #ab9f95;
  --rule: #f3ece6;
  --rule-cell: #3a322c;
  --head-bg: #2b2420;
  --head-fg: #f3ece6;
  --rail-bg: #0d0b0a;
  --rail-fg: #c4b8ae;
  --rail-hover: #221d19;
  --weekend: #17130f;
  --danger: #ff6170;
  --danger-soft: rgb(255 97 112 / 0.14);
  --draft: #f2b84b;
  --draft-soft: rgb(242 184 75 / 0.14);
  --done: #ab9f95;
  --accent: #ff7a50;
  --accent-fg: #14110f;
  --accent-soft: rgb(255 122 80 / 0.16);
  --accent-ring: rgb(255 122 80 / 0.6);
  --backdrop: rgb(0 0 0 / 0.65);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* {
  box-sizing: border-box;
  border-radius: 0;
}

html {
  font-family: "Archivo", Helvetica, Arial, sans-serif;
  font-size: 16px;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  accent-color: var(--accent);
  caret-color: var(--accent);
  scrollbar-color: var(--surface-3) transparent;
}

/* The whole layout was drawn a size too large on desktop: show it at 90%, like browser zoom.
   Viewport units (the full-height rail, dialog limits) still fill the window under CSS zoom. */
@media (min-width: 721px) {
  html {
    zoom: 0.9;
  }
}

body {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.43;
  background: var(--bg);
  color: var(--fg);
}

::selection {
  background: var(--accent);
  color: var(--accent-fg);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--fg-muted);
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.03em;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--accent-ring);
  outline-offset: 1px;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.meta {
  font-size: 0.75rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted);
}

/* ---------- Rail ---------- */
.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail-w);
  background: var(--rail-bg);
  color: var(--rail-fg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--rule-cell);
}

.rail-brand {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.rail-mark {
  width: 14px;
  height: 14px;
  background: var(--accent);
}

.rail-item {
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  color: var(--rail-fg);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.rail-item:hover {
  background: var(--rail-hover);
  color: #ffffff;
}

/* The current page: theme.js marks html[data-view] before first paint, views.ts keeps aria-current in step. */
.rail-item[aria-current="page"],
html[data-view="posts"] .rail-item[data-view="posts"],
html[data-view="notes"] .rail-item[data-view="notes"],
html[data-view="gallery"] .rail-item[data-view="gallery"] {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 800;
}

/* Only the view named on html[data-view] shows, from the first paint on. */
html[data-view="posts"] #view-notes,
html[data-view="posts"] #view-gallery,
html[data-view="notes"] #view-posts,
html[data-view="notes"] #view-gallery,
html[data-view="gallery"] #view-posts,
html[data-view="gallery"] #view-notes,
html:not([data-view="posts"]) #new-post {
  display: none;
}

/* ---------- Shell ---------- */
.shell {
  margin-left: var(--rail-w);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: var(--bg);
  border-bottom: 2px solid var(--rule);
}

.app-name {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.content {
  max-width: 1600px;
  padding: 40px 32px 56px;
}

.section-head {
  border-top: 8px solid var(--rule);
  padding-top: 16px;
  margin-bottom: 32px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.section-head h1 {
  font-size: 3.25rem;
  line-height: 0.95;
}

.section-head p {
  margin: 10px 0 0;
  font-weight: 500;
  max-width: 60ch;
}

/* ---------- Buttons ---------- */
.btn {
  height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  background: none;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color 0.12s,
    color 0.12s,
    border-color 0.12s;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: progress;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 82%, var(--fg));
}

.btn-outline {
  background: var(--surface);
  border-color: var(--rule);
}

.btn-outline:hover,
.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-destructive {
  color: var(--danger);
  background: var(--danger-soft);
}

.btn-destructive:hover {
  background: var(--danger);
  color: var(--bg);
}

.btn-sq {
  width: 36px;
  padding: 0;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-nav h2 {
  font-size: 1.75rem;
  min-width: 11ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.filters {
  display: flex;
  gap: 16px;
}

.filters label {
  display: grid;
  gap: 4px;
}

select,
input,
textarea {
  height: 36px;
  padding: 4px 10px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--fg);
}

select {
  appearance: none;
  padding-right: 32px;
  min-width: 140px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--fg) 50%), linear-gradient(135deg, var(--fg) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 15px,
    calc(100% - 11px) 15px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

input::placeholder,
textarea::placeholder {
  color: var(--fg-muted);
}

textarea {
  height: auto;
  resize: vertical;
  line-height: 1.5;
}

select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  border-color: var(--accent);
}

.error {
  color: var(--danger);
  font-weight: 700;
  margin: 0 0 16px;
}

/* ---------- Board ---------- */
.board {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 24px;
  align-items: start;
}

/* Up next stage */
.stage {
  position: sticky;
  top: 80px;
}

.stage-head {
  background: var(--head-bg);
  color: var(--head-fg);
  padding: 12px 16px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  transition: background-color 0.15s;
}

.stage-head.alert {
  background: var(--accent);
  color: var(--accent-fg);
}

.stage-head h3 {
  font-size: 1.125rem;
  line-height: 1;
}

.stage-count {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 0.8;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 0;
  border-bottom-width: 2px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

.rows li + li {
  border-top: 1px solid var(--rule-cell);
}

.row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border: 0;
  background: none;
  cursor: pointer;
  transition: background-color 0.1s;
}

.row:hover {
  background: var(--accent);
  color: var(--accent-fg);
}

.row-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 600;
  line-height: 1.375;
}

.row .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
  margin-top: 6px;
}

.row:hover .meta,
.row:hover .late {
  color: inherit;
}

.late {
  color: var(--danger);
  font-weight: 700;
}

.empty {
  padding: 16px;
  color: var(--fg-muted);
}

.row-with-thumb {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 10px;
  align-items: start;
}

.row-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  display: block;
  outline: 1px solid var(--rule-cell);
  outline-offset: -1px;
  background: var(--surface-2);
}

/* ---------- Status ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge.s-Idea {
  box-shadow: inset 0 0 0 1px var(--fg-muted);
  color: var(--fg-muted);
}
.badge.s-Draft {
  color: var(--draft);
  background: var(--draft-soft);
}
.badge.s-Ready {
  color: var(--accent-fg);
  background: var(--accent);
}
.badge.s-Posted {
  color: var(--done);
  background: var(--surface-2);
}
.badge.s-Skipped {
  color: var(--fg-muted);
  background: var(--surface-2);
  text-decoration: line-through;
}

.row:hover .badge {
  box-shadow: inset 0 0 0 1px currentColor;
  background: transparent;
  color: inherit;
}

.dot {
  width: 8px;
  height: 8px;
  flex: none;
  display: inline-block;
}

.dot.s-Idea {
  box-shadow: inset 0 0 0 1.5px var(--fg-muted);
}
.dot.s-Draft {
  background: var(--draft);
}
.dot.s-Ready {
  background: var(--accent);
}
.dot.s-Posted {
  background: var(--done);
  border-radius: 50%;
}
.dot.s-Skipped {
  background: linear-gradient(135deg, transparent 42%, var(--fg-muted) 42% 58%, transparent 58%);
  box-shadow: inset 0 0 0 1px var(--fg-muted);
}

/* ---------- Calendar ---------- */
.weekdays,
.grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekdays {
  background: var(--head-bg);
  color: var(--head-fg);
}

.weekdays span {
  padding: 9px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.grid {
  border-left: 1px solid var(--rule-cell);
  border-bottom: 2px solid var(--rule);
  background: var(--surface);
}

.day {
  position: relative;
  min-height: 132px;
  border-right: 1px solid var(--rule-cell);
  border-top: 1px solid var(--rule-cell);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  min-width: 0;
  transition: background-color 0.1s;
}

.day:nth-child(7n + 6),
.day:nth-child(7n) {
  background: var(--weekend);
}

.day:hover {
  background: var(--surface-2);
}

.day.outside .day-num {
  color: var(--fg-muted);
  font-weight: 500;
}

.day.outside > .chip {
  opacity: 0.6;
}

.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 22px;
}

.day-num {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 0 5px;
  line-height: 22px;
}

.day.today .day-num {
  background: var(--accent);
  color: var(--accent-fg);
}

.day-add {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.1s;
}

.day-add .icon {
  width: 14px;
  height: 14px;
}

.day:hover .day-add,
.day-add:focus-visible {
  opacity: 1;
}

.day-add:hover {
  background: var(--accent);
  color: var(--accent-fg);
}

.chip {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  column-gap: 6px;
  width: 100%;
  text-align: left;
  border: 0;
  background: var(--surface-2);
  padding: 5px 6px;
  color: var(--fg);
  cursor: pointer;
  min-width: 0;
  transition:
    background-color 0.1s,
    color 0.1s;
}

.chip:hover {
  background: var(--accent);
  color: var(--accent-fg);
}

.chip.s-Ready {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.chip.s-Posted .chip-title,
.chip.s-Skipped .chip-title {
  color: var(--fg-muted);
}

.chip.s-Skipped .chip-title {
  text-decoration: line-through;
}

.chip:hover .chip-title,
.chip:hover .meta {
  color: inherit;
}

.chip:hover .dot {
  box-shadow: inset 0 0 0 1.5px currentColor;
  background: currentColor;
}

.chip-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.chip .icon {
  width: 13px;
  height: 13px;
  color: var(--fg-muted);
}

.chip:hover .icon {
  color: inherit;
}

.chip .meta {
  grid-column: 2 / -1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Dialog ---------- */
dialog {
  width: min(580px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 2px solid var(--rule);
  background: var(--surface);
  color: var(--fg);
}

dialog[open] {
  animation: dialog-in 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dialog-in {
  from {
    transform: translateY(8px);
    opacity: 0.6;
  }
}

dialog::backdrop {
  background: var(--backdrop);
}

/* The day sheet: every post on a day as a card, up to three across. */
/* Head and footer stay put; only the cards scroll. The sheet is as wide as its columns. */
dialog.sheet {
  --cols: 1;
  --card-w: 480px;
  width: min(calc(var(--cols) * var(--card-w) + (var(--cols) - 1) * 16px + 48px), calc(100vw - 32px));
  max-width: none;
  height: min(860px, calc(100vh - 32px));
}

dialog.sheet[open] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sheet-head {
  flex: none;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--rule-cell);
}

.cards {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  align-items: start;
  gap: 16px;
  padding: 20px 24px 24px;
  background: var(--surface-2);
}

.card {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--rule);
  background: var(--surface);
  transition:
    background-color 0.2s,
    box-shadow 0.2s;
}

.card.flash {
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Posted: done, so it steps back and the ones still to go stand out. */
.card.is-posted {
  background: var(--surface-2);
  border-color: var(--rule-cell);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-head input {
  flex: 1;
  min-width: 0;
  font-weight: 800;
  font-size: 1.0625rem;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.copy-btn {
  height: 26px;
  padding: 0 8px;
}

.sheet-hint {
  margin: 4px 0 0;
}

.dialog-actions.sheet-actions {
  flex: none;
  position: static;
  margin: 0;
}

.segmented .toggle input[value="Posted"]:checked + span {
  background: var(--done);
  border-color: var(--done);
  color: var(--bg);
}

.dialog-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.dialog-head h2 {
  font-size: 1.5rem;
}

.field {
  display: grid;
  gap: 6px;
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.field legend {
  padding: 0;
  margin-bottom: 6px;
}

.chips,
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.toggle {
  position: relative;
}

.toggle input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.toggle span {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--rule-cell);
  font-weight: 700;
  transition:
    background-color 0.1s,
    border-color 0.1s;
}

.toggle:hover span {
  border-color: var(--fg);
}

.toggle input:checked + span {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}

.segmented .toggle input[value="Ready"]:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.toggle input:focus-visible + span {
  outline: 3px solid var(--accent-ring);
}

.dialog-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  margin: 0 -24px;
  padding: 16px 24px;
  background: var(--surface);
  border-top: 2px solid var(--rule);
}

.spacer {
  flex: 1;
}

/* Images field: a strip of tiles; the first is the cover. */
.image-drop {
  border: 1px dashed var(--fg-muted);
  min-height: 132px;
  display: grid;
  align-content: center;
  padding: 8px;
  background: var(--surface-2);
  transition:
    border-color 0.1s,
    background-color 0.1s;
}

.image-drop.dragging {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.image-empty {
  text-align: center;
}

.image-strip {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
}

.image-strip:empty {
  display: none;
}

.image-tile {
  position: relative;
  aspect-ratio: 1;
  background: var(--surface-3);
  outline: 1px solid var(--rule-cell);
  outline-offset: -1px;
}

.tile-pic,
.tile-pic img {
  display: block;
  width: 100%;
  height: 100%;
}

.tile-pic img {
  object-fit: cover;
}

.tile-tags {
  position: absolute;
  top: 4px;
  left: 4px;
  display: flex;
  gap: 4px;
  pointer-events: none;
}

.tile-tag {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 1px 6px;
  background: var(--head-bg);
  color: var(--head-fg);
}

.tile-new {
  background: var(--accent);
  color: var(--accent-fg);
}

.tile-actions {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.1s;
}

.image-tile:hover .tile-actions,
.image-tile:focus-within .tile-actions {
  opacity: 1;
}

.tile-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--rule);
}

.tile-btn:hover {
  background: var(--fg);
  color: var(--bg);
}

.tile-btn .icon {
  width: 16px;
  height: 16px;
}

.image-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

/* ---------- Gallery ---------- */
.gallery-grid {
  list-style: none;
  margin: 0;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 0;
  border-bottom-width: 2px;
}

.g-tile {
  display: grid;
  width: 100%;
  padding: 0;
  border: 1px solid var(--rule-cell);
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: zoom-in;
  transition: border-color 0.1s;
}

.g-tile:hover {
  border-color: var(--fg);
}

.g-tile:focus-visible {
  outline: 3px solid var(--accent-ring);
  outline-offset: 2px;
}

.g-frame {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--surface-3);
  overflow: hidden;
}

.g-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.g-tile:hover .g-frame img {
  transform: scale(1.03);
}

.g-cap {
  display: grid;
  gap: 4px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--rule-cell);
}

.g-title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g-cap .meta {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
}

.gallery-grid > .empty {
  grid-column: 1 / -1;
}

/* Lightbox: one image as large as the window allows. */
dialog.lightbox {
  width: min(1280px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  display: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

dialog.lightbox[open] {
  display: grid;
}

.lightbox-head,
.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.lightbox-head {
  justify-content: space-between;
  border-bottom: 2px solid var(--rule);
}

.lightbox-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.lightbox-text h2 {
  font-size: 1.25rem;
  font-stretch: 118%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lightbox-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: min(60vh, 560px);
  padding: 16px 64px;
  background: var(--surface-2);
}

.lightbox-stage img {
  display: block;
  min-width: min(100%, 480px);
  max-width: 100%;
  max-height: calc(100vh - 220px);
  object-fit: contain;
  box-shadow: 0 0 0 1px var(--rule-cell);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
}

#lightbox-prev {
  left: 12px;
}

#lightbox-next {
  right: 12px;
}

.lightbox-actions {
  border-top: 2px solid var(--rule);
}

/* ---------- Sign-in page ---------- */
.gate {
  max-width: 640px;
  margin: 15vh auto 0;
  padding: 0 24px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .board {
    grid-template-columns: 1fr;
  }
  .stage {
    position: static;
  }
  .rows {
    max-height: none;
  }
}

@media (max-width: 1100px) {
  dialog.sheet {
    --cols: 1 !important;
    --card-w: 560px;
  }
}

@media (max-width: 720px) {
  :root {
    --rail-w: 0px;
  }
  .cards {
    padding: 12px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    padding: 10px;
  }
  .lightbox-stage {
    padding: 8px 8px 56px;
  }
  .lightbox-nav {
    top: auto;
    bottom: 8px;
    translate: none;
  }
  .tile-actions {
    opacity: 1;
  }
  .rail {
    display: none;
  }
  .content,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }
  .section-head h1 {
    font-size: 2.5rem;
  }
  .day {
    min-height: 76px;
    padding: 3px;
  }
  .chip {
    grid-template-columns: 8px 1fr;
  }
  .chip .meta,
  .chip .icon {
    display: none;
  }
  .weekdays span {
    padding: 6px 3px;
  }
  .day-add {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

a.btn {
  color: inherit;
}

/* ---------- Ember details ---------- */

/* Wide display face (Archivo's width axis) for names of places. */
.section-head h1,
.month-nav h2,
.stage-head h3,
.dialog-head h2 {
  font-stretch: 118%;
}

.section-head {
  display: block;
}

.section-head h1 {
  font-size: 3.5rem;
  letter-spacing: -0.035em;
}

/* Dotted minor rules: the grid is a sheet to write on, the frame stays solid. */
.grid,
.day {
  border-style: dotted;
  border-color: var(--rule-cell);
}

.grid {
  border-bottom: 2px solid var(--rule);
}

.rows li + li {
  border-top-style: dotted;
}

.stage-head {
  padding: 14px 16px;
}

/* Big light day numerals; today is the one heavy number. */
.day-num {
  font-size: 1.5rem;
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.day.today .day-num {
  font-weight: 700;
}

.day.outside .day-num {
  opacity: 0.45;
}

.day.outside > .chip {
  opacity: 0.5;
}

/* Posts in a day: a soft warm slip, title up to two lines. */
.chip {
  align-items: start;
  padding: 5px 6px;
}

.chip .dot {
  margin-top: 5px;
}

.chip-title {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}

.chip .icon {
  margin-top: 2px;
}

@media (max-width: 720px) {
  .topbar .app-name {
    display: none;
  }
  .topbar {
    justify-content: flex-end;
  }
  .section-head h1 {
    font-size: 2.5rem;
  }
  .month-nav h2 {
    font-size: 1.375rem;
    min-width: 0;
  }
  .month-nav {
    flex-wrap: wrap;
  }
  .filters {
    width: 100%;
  }
  .filters label {
    flex: 1;
  }
  .filters select {
    width: 100%;
    min-width: 0;
  }
  .day-num {
    font-size: 1.125rem;
  }
  .chip {
    padding: 3px;
  }
  .chip-title {
    -webkit-line-clamp: 1;
    font-size: 0.75rem;
  }
}

@media (max-width: 720px) {
  .day-add {
    display: none;
  }
}

/* ---------- Live links (editor) ---------- */
.link-fields {
  display: grid;
  gap: 6px;
}

.link-row {
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: center;
  gap: 10px;
}

/* ---------- Notes view: a notebook, not a dashboard ----------
   Same paper, ink and coral as the planner, but no heads or boxes: a checklist on ruled
   lines beside a notepad. --line is the ruling every writing surface shares. */
.notebook {
  --line: 1.625rem;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.4fr);
  gap: 32px;
  align-items: start;
}

.pad-body {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 0;
  border-bottom-width: 2px;
  padding: 2px 16px 12px;
}

/* Ruled paper: a dotted line at the bottom of every text line. */
.ruled,
.note-compose textarea,
.note-text {
  background-image: linear-gradient(to bottom, transparent calc(var(--line) - 1px), var(--rule-cell) calc(var(--line) - 1px));
  background-size: 100% var(--line);
  line-height: var(--line);
}

/* To-do */
.todo-add {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px dotted var(--rule-cell);
  color: var(--fg-muted);
}

.todo-add input {
  flex: 1;
  height: var(--line);
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 1rem;
}

.todo-add input:focus-visible {
  outline: none;
}

.todo-add:focus-within {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.todo {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-bottom: 1px dotted var(--rule-cell);
}

.todo-label {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  cursor: pointer;
  min-width: 0;
  overflow-wrap: anywhere;
}

.todo-check {
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  flex: none;
  border: 1.5px solid var(--fg);
  background: transparent;
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: background-color 0.12s;
}

.todo-check::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 2px solid var(--accent-fg);
  border-bottom: 2px solid var(--accent-fg);
  transform: rotate(-45deg) translate(1px, -1px);
  opacity: 0;
}

.todo-check:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.todo-check:checked::after {
  opacity: 1;
}

.todo.is-done .todo-label span {
  color: var(--fg-muted);
  text-decoration: line-through;
  text-decoration-color: var(--accent);
}

.sheets .empty {
  padding: 12px 16px;
  border-top: 1px solid var(--rule);
}

.checklist .empty {
  padding: 12px 0;
  color: var(--fg-muted);
  font-style: normal;
  border-bottom: 1px dotted var(--rule-cell);
}

.done-list {
  margin-top: 12px;
}

.done-list summary {
  cursor: pointer;
  padding: 6px 0;
  font-weight: 700;
  list-style-position: inside;
}

.row-delete {
  width: 32px;
  height: 32px;
  margin-top: 6px;
  color: var(--fg-muted);
  opacity: 0;
  transition: opacity 0.1s;
}

.todo:hover .row-delete,
.sheet:hover .row-delete,
.row-delete:focus-visible {
  opacity: 1;
}

.row-delete:hover {
  color: var(--danger);
  background: transparent;
}

/* Notes */
.note-compose {
  padding-top: 8px;
}

.note-compose textarea,
.note-text {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background-color: transparent;
  font-size: 1rem;
  resize: none;
  overflow: hidden;
  min-height: calc(var(--line) * 2);
}

.note-compose textarea {
  min-height: calc(var(--line) * 3);
}

.note-compose textarea:focus-visible,
.note-text:focus-visible {
  outline: none;
  background-image: linear-gradient(to bottom, transparent calc(var(--line) - 1px), var(--accent-ring) calc(var(--line) - 1px));
}

.compose-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 6px;
}

.sheets {
  list-style: none;
  margin: 12px -16px 0;
  padding: 0;
}

.sheet {
  padding: 12px 16px 2px;
  border-top: 1px solid var(--rule);
}

.note-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
}

@media (max-width: 1100px) {
  .notebook {
    grid-template-columns: 1fr;
    gap: 40px;
  }
}

@media (max-width: 720px) {
  .row-delete {
    opacity: 1;
  }
  .link-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

[hidden] {
  display: none !important;
}

/* ---------- Who made it: a small mark, no text ---------- */
.src-mark {
  width: 14px;
  height: 14px;
  flex: none;
}

.icon.src-codex {
  color: var(--fg);
  stroke-width: 2.5;
}

.icon.src-claude {
  color: var(--accent);
  stroke-width: 2.2;
}

.icon.src-gemini {
  color: #4285f4;
  stroke-width: 2.2;
}

:root[data-mode="dark"] .icon.src-gemini {
  color: #7baaf7;
}

.chip-marks {
  display: flex;
  gap: 3px;
  align-items: center;
  margin-top: 2px;
}

.chip-marks .icon {
  width: 13px;
  height: 13px;
}

.chip:hover .src-mark,
.row:hover .src-mark {
  color: inherit;
}

#editor-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---------- MCP presence (topbar) ----------
   Each tool is a small square tile, like the status badges. Connected: solid in the tool's own
   colour (Claude terracotta, Codex/OpenAI green, Gemini blue) with the mark cut out. Away: a
   dashed outline. */
.topbar-start {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.presence {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#presence-claude {
  --brand: #d97757;
}

#presence-codex {
  --brand: #10a37f;
}

#presence-gemini {
  --brand: #4285f4;
}

:root[data-mode="dark"] #presence-codex {
  --brand: #19c37d;
}

:root[data-mode="dark"] #presence-gemini {
  --brand: #7baaf7;
}

.presence-item {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: var(--fg-muted);
  border: 1.5px dashed var(--fg-muted);
  cursor: default;
}

.presence-item .icon {
  width: 12px;
  height: 12px;
  color: inherit;
  stroke-width: 2.6;
}

.presence-item[data-state="on"] {
  color: var(--bg);
  background: var(--brand);
  border: 1.5px solid var(--brand);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
