/* Emerson Building Book. Brick, slate, plaster. */
:root {
  --ground: #EEF0EC;
  --surface: #FFFFFF;
  --surface-2: #F6F7F4;
  --ink: #1E2226;
  --ink-2: #454D55;
  --muted: #6B747C;
  --line: #D5D9D1;
  --line-2: #E6E9E3;
  --brick: #8E3A2B;
  --brick-ink: #FFFFFF;
  --slate: #2F5D7C;
  --slate-soft: #E3ECF2;
  --ok: #2C7A4B;
  --ok-soft: #E1F0E6;
  --warn: #9A6410;
  --warn-soft: #FBEFD6;
  --crit: #B3261E;
  --crit-soft: #F9E0DD;
  --shadow: 0 10px 30px rgba(30, 34, 38, 0.14);
  --radius: 6px;
  --font-display: "Zilla Slab", "Rockwell", "Roboto Slab", Georgia, serif;
  --font-body: "Source Sans 3", "Source Sans Pro", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #16191C;
    --surface: #1F2327;
    --surface-2: #262B30;
    --ink: #E9E7E1;
    --ink-2: #C9CBC6;
    --muted: #97A0A8;
    --line: #353C43;
    --line-2: #2B3136;
    --brick: #C9644F;
    --brick-ink: #16191C;
    --slate: #8BB8D8;
    --slate-soft: #23323D;
    --ok: #6CC48A;
    --ok-soft: #1E3327;
    --warn: #E4B04A;
    --warn-soft: #3A2E12;
    --crit: #F07A6A;
    --crit-soft: #40201D;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --ground: #16191C; --surface: #1F2327; --surface-2: #262B30; --ink: #E9E7E1; --ink-2: #C9CBC6; --muted: #97A0A8;
  --line: #353C43; --line-2: #2B3136; --brick: #C9644F; --brick-ink: #16191C; --slate: #8BB8D8; --slate-soft: #23323D;
  --ok: #6CC48A; --ok-soft: #1E3327; --warn: #E4B04A; --warn-soft: #3A2E12; --crit: #F07A6A; --crit-soft: #40201D;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--slate); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; text-wrap: balance; margin: 0; }
h1 { font-size: 1.7rem; font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0; }
.wrap { max-width: 1080px; margin-inline: auto; padding-inline: 16px; }
main.wrap { padding-block: 20px 48px; display: grid; gap: 22px; }
.lede { color: var(--ink-2); max-width: 65ch; }
.label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.hidden { display: none !important; }

/* top bar */
.top { background: var(--surface); border-bottom: 1px solid var(--line); border-top: 4px solid var(--brick); position: sticky; top: 0; z-index: 20; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 10px 6px; }
.mark { text-decoration: none; color: inherit; display: flex; flex-direction: column; line-height: 1.05; }
.mark-name { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; color: var(--brick); letter-spacing: 0.01em; }
.mark-sub { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-top: 3px; }
.me { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; white-space: nowrap; }
.me select { max-width: 160px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: 0 0 auto; padding: 8px 12px 10px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: 0.95rem; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--brick); border-bottom-color: var(--brick); }
.tabs a:hover { color: var(--ink); }

/* sections and surfaces */
section { display: grid; gap: 12px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card.flat { background: var(--surface-2); border-color: var(--line-2); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 2px; }
.tile .big { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; line-height: 1.1; }
.tile.brick { border-color: var(--brick); }
.tile.brick .big { color: var(--brick); }

/* chips */
.chip { display: inline-block; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.03em; padding: 2px 8px; border-radius: 999px; background: var(--slate-soft); color: var(--slate); white-space: nowrap; vertical-align: middle; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.crit { background: var(--crit-soft); color: var(--crit); }
.chip.plain { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-2); }
.chip.brick { background: var(--brick); color: var(--brick-ink); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: middle; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.crit { background: var(--crit); } .dot.slate { background: var(--slate); }

/* forms */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px; min-width: 0; width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--slate); outline-offset: 1px; }
textarea { min-height: 64px; resize: vertical; }
label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--ink-2); font-weight: 600; }
label > span.hint { font-weight: 400; color: var(--muted); }
.form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); align-items: end; }
.form .wide { grid-column: 1 / -1; }
.btn { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 7px 12px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--brick); border-color: var(--brick); color: var(--brick-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.slate { background: var(--slate); border-color: var(--slate); color: #fff; }
.btn.sm { padding: 4px 9px; font-size: 0.85rem; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--slate); }
.btn:disabled { opacity: 0.55; cursor: default; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; white-space: nowrap; }
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--ink); }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tr.dim td { color: var(--muted); }

/* hours board */
.board { display: grid; gap: 8px; }
.hrow { display: grid; grid-template-columns: minmax(80px, 140px) 1fr 64px; gap: 10px; align-items: center; }
.hrow .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { position: relative; height: 18px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 3px; overflow: hidden; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: var(--slate); }
.bar > i.met { background: var(--ok); }
.bar > i.over { background: var(--ok); opacity: 0.45; }
.bar > b { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.bar > b.req { background: var(--ink-2); width: 2px; }
.hrow .val { text-align: right; font-weight: 600; }
.hrow .val.met { color: var(--ok); }

/* upkeep */
.task { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); align-items: start; }
.task:last-child { border-bottom: 0; }
.task .t-title { font-weight: 600; }
.task .t-meta { font-size: 0.86rem; color: var(--muted); }
.task .t-detail { font-size: 0.9rem; color: var(--ink-2); margin-top: 2px; }
.task .t-status { justify-self: end; display: grid; gap: 6px; justify-items: end; }
.task-form { grid-column: 1 / -1; }
.group-title { display: flex; align-items: center; gap: 10px; }
.group-title h3 { flex: 0 0 auto; }
.group-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* board */
.kan { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.col { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 10px; display: grid; gap: 8px; align-content: start; }
.col h3 { display: flex; justify-content: space-between; align-items: baseline; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 9px 10px; display: grid; gap: 4px; cursor: pointer; }
.pcard:hover { border-color: var(--ink-2); }
.pcard .p-title { font-weight: 600; }
.pcard .p-meta { font-size: 0.84rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.pcard .p-note { font-size: 0.9rem; color: var(--ink-2); }
.pcard.done { opacity: 0.8; }

/* chains */
.chain { display: grid; gap: 0; }
.step { display: grid; grid-template-columns: 26px 1fr; gap: 10px; }
.step .rail { position: relative; }
.step .rail::before { content: ""; position: absolute; left: 11px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.step:first-child .rail::before { top: 12px; }
.step:last-child .rail::before { bottom: auto; height: 12px; }
.step .rail i { position: absolute; left: 6px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--brick); border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--brick); }
.step .body { padding: 0 0 16px; display: grid; gap: 5px; }
.step .s-label { font-weight: 700; }
.step .s-note { color: var(--ink-2); font-size: 0.93rem; max-width: 65ch; }
.step .s-items { display: flex; flex-wrap: wrap; gap: 6px; }
.ichip { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 4px; padding: 3px 8px; font-size: 0.85rem; cursor: pointer; }
.ichip:hover { border-color: var(--ink-2); }
.ichip .cost { color: var(--muted); }
.ichip.done { text-decoration: line-through; color: var(--muted); }
.ichip.partly { border-color: var(--ok); }

/* filters */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; align-items: end; }
.filters .wide { grid-column: 1 / -1; }
.count { font-size: 0.9rem; color: var(--muted); }

/* photos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.photos img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 3px; background: var(--surface-2); cursor: zoom-in; }
.photos img.wide { aspect-ratio: 4 / 3; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.plans figure { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: grid; gap: 6px; }
.plans img { width: 100%; height: auto; border-radius: 3px; cursor: zoom-in; background: #fff; }
.plans figcaption { font-size: 0.88rem; color: var(--ink-2); }
.aerial { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.aerial figure { margin: 0; display: grid; gap: 4px; }
.aerial img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 3px; cursor: zoom-in; background: var(--surface-2); }
.aerial figcaption { font-size: 0.84rem; color: var(--ink-2); }

/* drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow); z-index: 40; overflow-y: auto; padding: 18px 18px 40px; display: grid; gap: 14px; align-content: start; }
.scrim { position: fixed; inset: 0; background: rgba(20, 22, 24, 0.35); z-index: 30; }
.drawer .d-head { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 0.93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.9); display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 96vw; max-height: 94vh; }

/* misc */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--ground); padding: 9px 14px; border-radius: 4px; z-index: 70; font-weight: 600; box-shadow: var(--shadow); }
.gate { position: fixed; inset: 0; background: var(--ground); z-index: 80; display: grid; place-items: center; padding: 16px; }
.gate-card { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--brick); border-radius: var(--radius); padding: 24px; width: min(380px, 100%); display: grid; gap: 12px; }
.gate-lede { color: var(--ink-2); }
.gate-err { color: var(--crit); font-weight: 600; }
.foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); padding-block: 12px 28px; border-top: 1px solid var(--line-2); }
.dates { display: grid; gap: 8px; }
.date { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: start; }
.date .d { font-family: var(--font-display); font-weight: 600; line-height: 1.1; color: var(--brick); }
.date .d small { display: block; font-family: var(--font-body); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.date.past .d { color: var(--muted); }
.feed { display: grid; gap: 6px; font-size: 0.92rem; }
.feed li { list-style: none; display: grid; grid-template-columns: 84px 1fr; gap: 8px; }
.feed ul, ul.feed { padding: 0; margin: 0; }
.check { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: start; padding: 5px 0; }
.check input { width: 18px; height: 18px; margin-top: 3px; }
.quote { border-left: 3px solid var(--brick); padding: 4px 12px; color: var(--ink-2); font-style: italic; }
ul.plain { padding-left: 18px; margin: 0; display: grid; gap: 4px; }
.two { columns: 2; column-gap: 24px; }
@media (max-width: 640px) {
  .two { columns: 1; }
  .hrow { grid-template-columns: 90px 1fr 56px; }
  .drawer { width: 100vw; }
  .top-row { padding-block: 8px 4px; }
  .mark-name { font-size: 1.3rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .bar > i { transition: width 0.4s ease; }
}
@media print {
  .top, .foot, .me, .btn, .filters, .gate, .scrim, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border-color: #999; break-inside: avoid; }
  main.wrap { padding-block: 0; }
}

[hidden] { display: none !important; }
