/* Spaces, pages, trackers and Start here (owner: portal-spaces). Loaded after styles.css; uses its tokens (--accent,
   --paper, --muted…), so dark mode comes with them. --space-accent is a space's own colour, set on the view. */

/* Things these pages show and hide with the hidden attribute (their own display rules would win otherwise). */
.tclear[hidden], .sp-project-new[hidden], .asset-filter[hidden] { display: none !important; }

/* ---------- the portal's markdown (js/markdown-dom.js) */

.md { display: grid; gap: 12px; line-height: 1.6; overflow-wrap: anywhere; min-width: 0; }
.md > * { margin: 0; min-width: 0; }
.md-h { line-height: 1.3; scroll-margin-top: 72px; }
.md-h1 { font-size: 20px; font-weight: 800; margin-top: 8px; }
.md-h2 { font-size: 17px; font-weight: 800; margin-top: 10px; padding-top: 4px; }
.md-h3 { font-size: 15px; font-weight: 700; margin-top: 4px; }
.md-h:first-child { margin-top: 0; }
.md-h:focus { outline: none; }
.md-hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; width: 100%; }
.md-a { overflow-wrap: anywhere; }
.md-ul { list-style: disc; padding-left: 1.4em; display: grid; gap: 4px; }
.md-ol { list-style: decimal; padding-left: 1.6em; display: grid; gap: 4px; }
.md-list li::marker { color: var(--muted); }
.md-checklist { list-style: none; padding-left: 0; }
.md-check { display: flex; align-items: flex-start; gap: 8px; }
.md-check input { margin-top: 4px; flex: none; }
.md-check-done > span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }

.md-table-wrap { overflow-x: auto; position: relative; border: 1px solid var(--line); border-radius: var(--radius-s); }
.md-table { width: 100%; border-collapse: collapse; font-size: 13.5px; line-height: 1.45; }
.md-table th, .md-table td { text-align: left; vertical-align: top; padding: 7px 10px; border-top: 1px solid var(--line); min-width: 90px; }
.md-table thead th { border-top: 0; background: var(--sunk); font-size: 12.5px; font-weight: 700; color: var(--muted); }
.md-table tbody tr:first-child td { border-top: 0; }
.md-table thead + tbody tr:first-child td { border-top: 1px solid var(--line); }
.md-al-center { text-align: center !important; }
.md-al-right { text-align: right !important; }

.md-figure { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; justify-items: start; min-width: 0; }
.md-figure img { display: block; max-width: 100%; height: auto; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--sunk); }
.md-zoom { display: block; max-width: 100%; }
.md-figure figcaption { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.md-missing-box { padding: 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius-s); color: var(--muted); font-size: 13px; background: var(--sunk); }
.md-download { display: block; }
.md-file { font-weight: 600; }
.md-file-note { color: var(--muted); font-size: 12.5px; }

.md-callout { border-radius: var(--radius-s); padding: 10px 12px; border-left: 4px solid var(--line-strong); background: var(--sunk); }
.md-callout-label { margin-right: 4px; }
.md-callout-do { background: var(--done-bg); border-left-color: var(--done-dot); }
.md-callout-do .md-callout-label { color: var(--done-ink); }
.md-callout-dont { background: var(--blocked-bg); border-left-color: var(--blocked-dot); }
.md-callout-dont .md-callout-label { color: var(--blocked-ink); }
.md-callout-note { background: var(--accent-soft); border-left-color: var(--accent); }
.md-callout-note .md-callout-label { color: var(--accent); }
.md-callout-rule { background: var(--warn-bg); border-left-color: var(--gold); }
.md-callout-rule .md-callout-label { color: var(--warn-ink); }

/* Side by side: one column on a phone, two from 480px, the asked-for count from 760px. */
.md-grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.md-grid-item { min-width: 0; display: grid; gap: 8px; }
@media (min-width: 480px) { .md-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 760px) {
  .md-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .md-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.md-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.md-swatch { margin: 0; display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--raised); font-size: 12.5px; min-width: 0; }
.md-swatch-chip { width: 26px; height: 26px; border-radius: 50%; flex: none; border: 1px solid var(--line-strong); background: var(--sunk); }
.md-swatch figcaption { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; }
.md-swatch-name { color: var(--muted); }

.md-spec { border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.md-spec-title { font-weight: 700; padding: 8px 12px; background: var(--sunk); border-bottom: 1px solid var(--line); }
.md-spec dl { margin: 0; display: grid; }
.md-spec-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px 16px; padding: 7px 12px; border-top: 1px solid var(--line); }
.md-spec-row:first-child { border-top: 0; }
.md-spec-row dt { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.md-spec-row dd { margin: 0; }
@media (min-width: 560px) { .md-spec-row { grid-template-columns: minmax(120px, 34%) minmax(0, 1fr); } }

/* ---------- spaces list */

.space-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); margin-bottom: 16px; }
/* Each space card carries its team's colour as a band across the top of the slab. */
.space-card {
  background: var(--surface); border: 2px solid var(--keyline); border-radius: var(--radius); padding: 20px 16px 16px; display: grid; gap: 8px;
  align-content: start; box-shadow: inset 0 7px 0 var(--space-accent, var(--accent)), var(--slab); min-width: 0;
}
.space-card.is-archived { opacity: .8; box-shadow: var(--slab); }
.space-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.space-name { font-weight: 800; font-size: 16px; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; margin-right: auto; }
.space-name:hover { color: var(--accent); text-decoration: underline; }
.space-pages { display: grid; }
.space-pages li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 0; border-top: 1px solid var(--line); min-width: 0; }
.space-pages li:first-child { border-top: 0; }
.space-pages li > a { font-weight: 600; overflow-wrap: anywhere; }
.space-card-foot { margin-top: auto; }
.space-archived-link { margin-top: 4px; }
.new-space { margin-bottom: 16px; }
.accent-input { width: 64px; height: 36px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--raised); cursor: pointer; }
.chip-kind-guide { --chip-face: var(--face-lav); }
.chip-kind-tracker { --chip-face: var(--face-sky); }

/* Progress bars are chunky slots filling with green plastic. */
.tp { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.tp progress, .sh-progress progress { appearance: none; -webkit-appearance: none; height: 8px; border: 1.5px solid var(--keyline); border-radius: 999px; background: var(--sunk); overflow: hidden; accent-color: var(--face-green); }
.tp progress { width: 64px; }
.tp progress::-webkit-progress-bar, .sh-progress progress::-webkit-progress-bar { background: var(--sunk); border-radius: 999px; }
.tp progress::-webkit-progress-value, .sh-progress progress::-webkit-progress-value { background: var(--face-green); border-radius: 999px; box-shadow: inset 0 -2px 0 #1DB267; }
.tp progress::-moz-progress-bar, .sh-progress progress::-moz-progress-bar { background: var(--face-green); border-radius: 999px; }

/* ---------- one space */

/* The space's colour runs along the bottom of its title plate. */
.has-accent > .page-head { box-shadow: inset 0 -7px 0 var(--space-accent), inset 0 3px 0 rgba(255, 255, 255, .16), 0 4px 0 var(--keyline); }
.space-page-list { display: grid; }
.space-page-list li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); min-width: 0; }
.space-page-list li:first-child { border-top: 0; }
.spl-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.spl-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.spl-title a { font-weight: 700; overflow-wrap: anywhere; }
.spl-move { display: flex; gap: 2px; flex: none; }
.space-note { margin-top: 8px; }
.assets-panel .asset-filter { margin-bottom: 6px; }
.asset-list li .btn { flex: none; }
.asset-drop { margin-bottom: 4px; }

/* ---------- a guide */

.page-meta { margin: -8px 0 12px; }
.guide-layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.guide-body { padding: 16px 18px; }
@media (min-width: 1100px) {
  .guide-layout.has-toc { grid-template-columns: minmax(0, 1fr) 260px; }
  .guide-layout.has-toc .guide-toc { grid-column: 2; grid-row: 1; position: sticky; top: 72px; max-height: calc(100vh - 96px); overflow-y: auto; }
  .guide-layout.has-toc .guide-body { grid-column: 1; grid-row: 1; }
}
.guide-toc > summary { cursor: pointer; font-weight: 700; }
.guide-toc[open] > summary { margin-bottom: 8px; }
.guide-toc ul { display: grid; gap: 2px; }
.toc-link { background: none; border: 0; padding: 3px 0; text-align: left; font: inherit; font-size: 13px; color: var(--accent); }
.page-nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 16px; }
.page-nav a { display: grid; gap: 2px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; min-width: 0; max-width: 100%; flex: 0 1 320px; overflow-wrap: anywhere; }
.page-nav a:hover { border-color: var(--accent); }
.page-nav-next { margin-left: auto; text-align: right; }

/* ---------- a tracker */

.tracker-intro { margin-bottom: 12px; }
.tracker-intro .md { margin-top: 4px; }
.tracker-tools { margin-bottom: 4px; }
.tracker-tools .toolbar { margin-bottom: 6px; }
.trait-filters { padding: 10px; background: var(--sunk); border-radius: var(--radius-s); }
.trait-filters select { max-width: 220px; }
.trait-chips { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin-bottom: 12px; }
.trait-chips-label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.trait-chip-list { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.trait-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer; }
.trait-chip:hover { border-color: var(--accent); }
.trait-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink, #fff); }
.quick-add { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.quick-add input { flex: 3 1 220px; width: auto; }
.quick-add select { flex: 1 1 140px; width: auto; }
.stage-tabs { margin-bottom: 10px; max-width: 100%; }
.stage-seg { max-width: 100%; }
.stage-seg .seg-btn { display: inline-flex; align-items: center; gap: 6px; }
.tab-count { font-size: 11.5px; font-weight: 700; opacity: .8; }
.tracker-board { grid-auto-columns: minmax(240px, 1fr); }
.tcol-done { background: var(--done-bg); }
.tcol-done .col-head h2 { color: var(--done-ink); }
.tcard:not([draggable="true"]) { cursor: default; }
.tcard-img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 4px; background: var(--sunk); }
.tcard .tags li { font-size: 11.5px; }
.tracker-table-wrap { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tracker-table th, .tracker-table td { vertical-align: top; }
.tracker-table thead th { position: sticky; top: 0; background: var(--surface); }
.tracker-table td.tt-title { white-space: normal; min-width: 220px; max-width: 360px; overflow-wrap: anywhere; }
.tracker-table tr.is-done .tt-link { color: var(--muted); }
.tt-link { font-weight: 600; }
.th-sort { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: inherit; cursor: pointer; white-space: nowrap; }
.th-sort:hover { color: var(--ink); }
.table-more { margin-top: 10px; }

/* The item drawer: a panel from the right on a wide screen, the whole screen on a phone. */
.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0; width: min(560px, 100%); max-width: 100%; height: 100%; max-height: 100%;
  padding: 0; border: 0; border-left: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lift);
  flex-direction: column;
}
.drawer[open] { display: flex; }
.drawer:not([open]) { display: none; }
.drawer::backdrop { background: rgba(5, 8, 60, .45); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 17px; overflow-wrap: anywhere; padding-top: 3px; }
.drawer-close { font-size: 20px; line-height: 1; flex: none; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 16px 28px; display: grid; gap: 14px; align-content: start; min-width: 0; }
.drawer-body h3 { font-size: 13.5px; margin-bottom: 4px; }
.drawer-picture { margin: 0; }
.drawer-picture img { display: block; width: 100%; max-height: 360px; object-fit: contain; border-radius: var(--radius-s); background: var(--sunk); border: 1px solid var(--line); }
.drawer-facts { border-top: 0; padding-top: 0; }
.drawer-task { border-top: 1px solid var(--line); padding-top: 12px; }
.drawer-task .form-body { margin-top: 8px; }
.drawer-history .activity { max-height: none; }
.drawer-danger { border-top: 1px solid var(--line); padding-top: 10px; }
.drawer-danger .btn { color: var(--danger); }

/* ---------- editing */

.editor-layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1200px) { .editor-layout { grid-template-columns: minmax(0, 1fr) 320px; } }
.editor { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.editor-tabs { justify-self: start; }
.editor-write, .editor-read { display: grid; gap: 6px; align-content: start; min-width: 0; }
.editor-bar { display: flex; align-items: end; justify-content: space-between; gap: 8px; }
.editor-bar label { font-size: 12px; font-weight: 600; color: var(--muted); }
.editor-bar select { width: auto; max-width: 60%; }
.md-source { font-family: var(--mono); font-size: 13px; line-height: 1.5; min-height: 220px; }
.editor-preview { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px 14px; background: var(--bg); max-height: 75vh; overflow-y: auto; min-width: 0; }
@media (max-width: 899px) {
  .editor[data-mode="write"] .editor-read { display: none; }
  .editor[data-mode="preview"] .editor-write { display: none; }
}
@media (min-width: 900px) {
  .editor { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .editor-tabs { display: none; }
  .md-source { min-height: 480px; }
}
.editor-help .md { font-size: 13px; }
.settings-sub { margin-top: 6px; }
.edit-rows { display: grid; gap: 8px; }
.edit-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--raised); min-width: 0; }
.edit-row > input { flex: 1 1 180px; width: auto; }
.edit-row-note { min-width: 56px; }
.edit-row-buttons { display: flex; gap: 2px; margin-left: auto; }
.edit-field { display: grid; gap: 8px; }
.edit-row-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ---------- history */

.version-list { display: grid; }
.version-list li { padding: 8px 0; border-top: 1px solid var(--line); display: grid; gap: 2px; min-width: 0; }
.version-list li:first-child { border-top: 0; }
.version-now { font-weight: 700; }
.version-btn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; text-align: left; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.version-btn[aria-pressed="true"] { color: var(--ink); text-decoration: none; box-shadow: inset 3px 0 0 var(--gold); padding-left: 8px; }
.version-reader .md { margin-top: 8px; }

/* ---------- Start here */

.sh-progress { display: grid; gap: 4px; margin-bottom: 6px; }
.sh-progress-text { font-weight: 700; font-size: 13.5px; }
.sh-progress progress { width: 100%; height: 14px; }
.sh-head { margin-bottom: 16px; }
.sh-list { display: grid; }
.sh-step { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); min-width: 0; }
.sh-step:first-child { border-top: 0; }
.sh-mark { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; border: 2px solid var(--line-strong); color: var(--muted); }
.sh-done .sh-mark { background: var(--face-green); border-color: var(--keyline); color: var(--face-ink); box-shadow: inset 0 -2px 0 #1DB267, 0 2px 0 var(--keyline); }
.sh-skipped .sh-mark { border-style: dashed; }
.sh-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.sh-title { font-weight: 700; overflow-wrap: anywhere; }
.sh-done .sh-title, .sh-skipped .sh-title { font-weight: 600; color: var(--muted); }
.sh-why { font-size: 13px; color: var(--muted); }
.sh-where { font-size: 12px; color: var(--faint); }
.sh-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; flex: none; max-width: 50%; }
.sh-foot { margin-top: 4px; }
.sh-all-done { font-weight: 600; color: var(--ok-ink); }
@media (max-width: 520px) {
  .sh-step { flex-wrap: wrap; }
  .sh-actions { max-width: none; width: 100%; justify-content: flex-start; padding-left: 32px; }
}
