/* ============================================================
   DEPARTURE BOARD — timetable data discipline, night desk.
   ONE TYPE SIZE (13px): rank is weight, case, reversal.
   State is a MARK in a fixed cell, never color alone.
   ============================================================ */
:root {
  --carbon: #101319;      /* ground            */
  --carbon-2: #14161d;    /* raised rail       */
  --cell: #1b1f28;        /* filled cell       */
  --rule: #2a2f3a;        /* hairline rule     */
  --rule-soft: #1b1f28;   /* soft row rule     */
  --ivory: #e8e4d8;       /* primary ink       */
  --dim: #8a8f9c;         /* secondary ink     */
  --gold: #d9a821;        /* selection / light */
  --green: #37997b;       /* exists / synced   */
  --cobalt: #5b85c9;      /* lookup / hashtag  */
  --verm: #e0523f;        /* missing / struck  */
  --sans: "Archivo", sans-serif;
  --mono: "IBM Plex Mono", monospace;
}
* { box-sizing: border-box; font-size: 13px; }
html, body { margin: 0; height: 100%; background: var(--carbon);
  color: var(--ivory); font-family: var(--mono); line-height: 1.55; }
#app { display: flex; height: 100vh; }
.hidden { display: none !important; }

/* browser surfaces ship with the design */
::selection { background: var(--gold); color: var(--carbon); }
* { scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px;
  border-radius: 2px; }

button { font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: .1em; background: transparent; color: var(--ivory);
  border: 1px solid var(--rule); padding: 5px 8px; cursor: pointer; }
button:hover { border-color: var(--ivory); }
button:disabled { color: var(--dim); border-color: var(--rule-soft);
  cursor: default; }

/* ---------- rail ---------- */
#sidebar { position: fixed; top: 0; left: 0; height: 100vh; width: 300px;
  background: var(--carbon-2); z-index: 10; border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; padding: 0; overflow: hidden; }
#brand { font-family: var(--sans); font-weight: 700; letter-spacing: .18em;
  padding: 14px 14px 12px; border-bottom: 1px solid var(--rule); }
#brand small { display: block; font-family: var(--mono); font-weight: 400;
  letter-spacing: .08em; color: var(--dim); margin-top: 3px; }
#topbar { display: flex; gap: 0; border-bottom: 1px solid var(--rule); }
#topbar button { flex: 1; border: none; border-right: 1px solid var(--rule-soft);
  padding: 8px 2px; font-size: 11px; }
#topbar button:last-child { border-right: none; }
#topbar button:hover { background: var(--cell); border-color: var(--rule-soft); }

#search { background: var(--carbon); border: none; border-bottom: 1px solid var(--rule);
  color: var(--ivory); padding: 9px 14px; outline: none; font-family: var(--mono);
  letter-spacing: .04em; }
#search::placeholder { color: var(--dim); }
#search:focus { border-bottom-color: var(--gold); }

#syncbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  border-bottom: 1px solid var(--rule); }
#sync-btn { min-width: 76px; border-color: var(--rule); }
#sync-status { color: var(--dim); font-size: 11px; letter-spacing: .04em; }
#sync-status.error { color: var(--verm); }

#remote-panel { display: flex; flex-direction: column; gap: 6px; padding: 10px 14px;
  border-bottom: 1px solid var(--rule); background: var(--carbon); }
#remote-panel input { background: var(--cell); border: 1px solid var(--rule);
  color: var(--ivory); padding: 7px 9px; outline: none; font-family: var(--mono); }
#remote-panel input:focus { border-color: var(--gold); }
#remote-panel button { border-color: var(--rule); font-size: 11px; }
#remote-error { color: var(--verm); font-size: 11px; }

#agent-link { font-size: 11px; padding: 6px 14px; border-bottom: 1px solid var(--rule); }
#agent-link a { color: var(--dim); text-decoration: none; letter-spacing: .04em; }
#agent-link a:hover { color: var(--gold); }

.pane-title { font-family: var(--sans); font-weight: 600; font-size: 11px;
  letter-spacing: .18em; color: var(--dim); padding: 10px 14px 6px;
  text-transform: uppercase; }
.pane-hint { font-weight: 400; letter-spacing: .1em; text-transform: none; }

/* routes — tags as transit lines */
#tag-list { overflow-y: auto; flex: 0 1 30%; padding-bottom: 4px; }
.tag-item { display: flex; align-items: center; gap: 10px; padding: 5px 14px;
  cursor: pointer; border-bottom: 1px solid var(--rule-soft); }
.tag-item:hover { background: var(--cell); }
.tag-item .line { width: 20px; height: 6px; flex-shrink: 0; }
.tag-item em { font-style: normal; color: var(--dim); margin-left: auto;
  font-size: 11px; }

/* ---------- the board ---------- */
#crumbs { font-family: var(--mono); font-weight: 400; letter-spacing: .04em;
  text-transform: none; margin-left: 6px; }
#board-wrap { flex: 1; position: relative; overflow: hidden;
  display: flex; flex-direction: column; }
#beam { position: absolute; left: 0; width: 100%; pointer-events: none;
  background: rgba(217, 168, 33, .07);
  border-left: 2px solid var(--gold);
  transition: top .3s cubic-bezier(.2, .8, .2, 1); z-index: 2; }
#note-list { overflow-y: auto; flex: 1; position: relative; z-index: 1; }
.board-cols { display: grid; grid-template-columns: 30px 1fr 62px 20px;
  gap: 8px; padding: 4px 14px; border-bottom: 1px solid var(--rule);
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  letter-spacing: .14em; color: var(--dim); }
.board-cols.sticky { position: sticky; top: 0; background: var(--carbon-2); z-index: 2; }

.note-item { display: grid; grid-template-columns: 30px 1fr 62px 20px;
  gap: 8px; align-items: center; padding: 6px 14px; cursor: pointer;
  border-bottom: 1px solid var(--rule-soft); }
.note-item:hover { background: var(--cell); }
.note-item.active { background: var(--ivory); color: var(--carbon); }
.note-item.active .tags, .note-item.active .no, .note-item.active .mark {
  color: var(--carbon); }
.note-item .no { color: var(--dim); font-size: 11px; }
.note-item .ttl { white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; font-weight: 500; }
.note-item .tags { color: var(--dim); font-size: 11px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.note-item .meta { display: none; color: var(--dim); font-size: 11px;
  grid-column: 2 / 5; }
.note-item.active .meta, .note-item:focus-within .meta { display: block; }
/* the mark — fixed cell, never color alone */
.mark { font-size: 11px; text-align: center; }
.mark.f::after { content: "●"; color: var(--green); }
.note-item.active .mark.f::after { color: var(--carbon); }
.mark.h::after { content: "○"; color: var(--dim); }
.mark.x::after { content: "⊗"; color: var(--verm); }
.note-actions { visibility: hidden; grid-column: 4; display: flex;
  gap: 2px; justify-self: end; }
.note-item:hover .note-actions, .note-item:focus-within .note-actions {
  visibility: visible; }
@media (hover: none) { .note-actions { visibility: visible; } }
.note-actions button { padding: 0 4px; font-size: 11px; line-height: 18px;
  border-color: var(--rule); background: var(--carbon-2); }
.note-actions button.danger:hover { border-color: var(--verm); color: var(--verm); }

.folder-item { display: flex; align-items: center; gap: 8px; padding: 6px 14px;
  cursor: pointer; user-select: none; border-bottom: 1px solid var(--rule-soft);
  font-family: var(--sans); font-weight: 600; letter-spacing: .1em;
  font-size: 11px; text-transform: uppercase; }
.folder-item:hover { background: var(--cell); }
.folder-item .count { color: var(--dim); font-family: var(--mono);
  font-weight: 400; margin-left: auto; }
.folder-arrow { color: var(--dim); font-size: 9px; width: 10px; }
.folder-children { border-left: 1px solid var(--rule); margin-left: 14px; }

/* ---------- sheet (reader/editor) ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0;
  margin-left: 300px; }
#content { flex: 1; position: relative; display: flex; }
.panel { flex: 1; overflow-y: auto; min-width: 0; }
#reader, #editor { padding: 0; }

/* ENTRY / STATUS / LINKS strip */
.strip { display: flex; border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; background: var(--carbon); z-index: 3; }
.strip .cell { padding: 8px 18px; border-right: 1px solid var(--rule-soft);
  flex: 1; min-width: 0; }
.strip .cell:last-child { border-right: none; }
.strip .k { display: block; font-family: var(--sans); font-size: 11px;
  font-weight: 600; letter-spacing: .16em; color: var(--dim);
  text-transform: uppercase; margin-bottom: 2px; }
.strip .v { font-size: 11px; letter-spacing: .02em; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.strip .v.ok { color: var(--green); }
.strip .v.warn { color: var(--verm); }

.sheet { padding: 26px 34px; max-width: 900px; }
#reader h1, .sheet h1 { font-family: var(--sans); font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; line-height: 1.3;
  border-bottom: 2px solid var(--ivory); padding-bottom: 10px;
  margin: 0 0 18px; }
#reader .tagline { margin: -8px 0 18px; }
#reader h2 { font-family: var(--sans); font-weight: 600; text-transform: uppercase;
  letter-spacing: .1em; border-bottom: 1px solid var(--rule);
  padding-bottom: 6px; margin: 24px 0 10px; }
#reader p { max-width: 72ch; margin: 0 0 12px; }
#reader a { color: var(--cobalt); }
#reader code { background: var(--cell); padding: 1px 5px; border-radius: 2px;
  font-family: var(--mono); }
#reader pre code { display: block; padding: 12px; overflow-x: auto;
  border: 1px solid var(--rule); }
#reader blockquote { border-left: 2px solid var(--gold); margin: 0 0 12px;
  padding: 2px 14px; color: var(--dim); }
#reader table { border-collapse: collapse; margin: 0 0 12px; }
#reader th, #reader td { border: 1px solid var(--rule); padding: 4px 10px; }
.wikilink { color: var(--green); cursor: pointer;
  border-bottom: 1px dotted var(--green); }
.wikilink.missing { color: var(--verm); border-bottom-color: var(--verm); }
.hashtag { color: var(--cobalt); cursor: pointer; }

#editor { background: var(--carbon); color: var(--ivory); border: none;
  outline: none; resize: none; font-family: var(--mono); line-height: 1.6;
  padding: 26px 34px; }
#save-btn.dirty { border-color: var(--gold); color: var(--gold); }

/* see also (backlinks) */
#backlinks-panel { border-top: 1px solid var(--rule); background: var(--carbon-2);
  padding: 4px 0 8px; max-height: 160px; overflow-y: auto; }
#backlinks .note-item { font-size: 12px; }

/* ---------- graph ---------- */
#graph-view { padding: 0; display: flex; flex-direction: column; }
#graph-controls { display: flex; gap: 16px; padding: 8px 14px;
  background: var(--carbon-2); border-bottom: 1px solid var(--rule);
  color: var(--dim); align-items: center; font-family: var(--sans);
  font-size: 11px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; flex-wrap: wrap; }
#graph-controls select, #graph-controls input[type=text] {
  background: var(--carbon); color: var(--ivory); border: 1px solid var(--rule);
  border-radius: 2px; padding: 3px 8px; font-family: var(--mono);
  font-size: 11px; letter-spacing: 0; text-transform: none; }
#graph-controls label { display: flex; align-items: center; gap: 6px; }
#graph-legend { font-family: var(--mono); font-weight: 400; letter-spacing: .02em;
  text-transform: none; font-size: 11px; }
#graph-legend .dot { font-size: 12px; }
#graph-svg { flex: 1; width: 100%; }
#graph-svg .node { cursor: pointer; }
#graph-svg .node text { fill: var(--ivory); font-size: 11px;
  font-family: var(--mono); pointer-events: none; }
#graph-svg .edge { stroke: var(--rule); stroke-opacity: .8; }
#graph-svg .node.dim { opacity: .15; }
#graph-svg .edge.dim { opacity: .05; }
/* starmap — nested world exception, keeps its dark sky */
#graph-svg.starmap { background: radial-gradient(ellipse at 50% 35%,
  #141a33 0%, #0a0d1c 55%, #05060f 100%); }
#graph-svg.starmap .edge { stroke: #3d466e; stroke-opacity: .5; stroke-width: .7; }
#graph-svg.starmap .node text { fill: #9aa5cc; font-size: 10px; }

/* atlas colors stay data-true */
#graph-svg .dot-visited { fill: var(--green); }
#graph-svg .dot-wishlist { fill: var(--cobalt); }

/* a struck ghost of a deleted note — cancellation is a mark, then it goes */
.note-item.struck { opacity: .55; }
.note-item.struck .ttl { text-decoration: line-through; color: var(--verm); }

/* toast — a departure announcement, vermilion when bad news */
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--carbon-2); border: 1px solid var(--gold); color: var(--ivory);
  padding: 8px 18px; opacity: 0; pointer-events: none; transition: opacity .25s;
  font-size: 12px; letter-spacing: .02em; z-index: 20; }
#toast.show { opacity: 1; }
#toast.error { border-color: var(--verm); color: var(--verm); }

@media (max-width: 720px) {
  #main { margin-left: 0; padding-top: 40px; }
  #sidebar.collapsed { display: none; }
  .sheet, #editor { padding: 14px 16px; }
}
/* rail toggle — the only chrome visible when the rail is parked */
#rail-toggle { display: none; position: fixed; top: 10px; left: 10px; z-index: 30;
  background: var(--carbon-2); font-size: 10px; padding: 6px 10px; }
@media (max-width: 720px) {
  #rail-toggle { display: block; }
  #rail-toggle.parked { left: auto; right: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  #beam { transition: none; }
}
/* split-flap discipline: board settles once, top to bottom */
@keyframes boardsettle {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: none; }
}
#note-list.cascade .note-item { animation: boardsettle .25s ease-out both; }
