/* UpTo
   A compact field-log look: condensed signage type (Barlow), cool concrete greys, and one
   hi-vis amber signal reserved for things that need you (due today, overdue, your turn). */

:root{
  /* Scales every font size; 1.2 = 20% larger than the original compact design. */
  --font-scale: 1.2;
  --font-ui: "Barlow Semi Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --font-text: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;

  --bg: #dce2e7;
  --surface: #f6f8f9;
  --surface-2: #ecf0f3;
  --surface-3: #e1e7ec;
  --ink: #16212b;
  --text: var(--ink);
  --muted: #4f5e6b;
  --muted2: #6e7c88;
  --line: #c8d1d8;
  --line-strong: #aeb9c2;
  --accent: #1f5fbf;
  --accent-soft: rgba(31,95,191,.12);
  --signal: #f2a50c;
  --signal-ink: #231800;
  --danger: #b8362a;
  --card: #ffffff;
  --list-bg: #e8edf1;
  --card-shadow: 0 1px 0 var(--line-strong);
  --lift-shadow: 0 12px 28px rgba(22,33,43,.28);
  --panel-alpha: 1;

  --r-panel: 6px;
  --r-list: 10px;
  --r-card: 6px;
  --r-chip: 3px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg: #12181e;
    --surface: #1b232b;
    --surface-2: #222c35;
    --surface-3: #2b3640;
    --ink: #e2e8ed;
    --muted: #a3b0bb;
    --muted2: #7d8a96;
    --line: #2f3b46;
    --line-strong: #42505c;
    --accent: #6fa3f0;
    --accent-soft: rgba(111,163,240,.16);
    --signal: #f5b53f;
    --signal-ink: #1f1500;
    --danger: #ef7a6c;
    --card: #26313b;
    --list-bg: #161d24;
    --card-shadow: 0 1px 0 rgba(0,0,0,.45);
    --lift-shadow: 0 14px 32px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"]{
  --bg: #12181e;
  --surface: #1b232b;
  --surface-2: #222c35;
  --surface-3: #2b3640;
  --ink: #e2e8ed;
  --muted: #a3b0bb;
  --muted2: #7d8a96;
  --line: #2f3b46;
  --line-strong: #42505c;
  --accent: #6fa3f0;
  --accent-soft: rgba(111,163,240,.16);
  --signal: #f5b53f;
  --signal-ink: #1f1500;
  --danger: #ef7a6c;
  --card: #26313b;
  --list-bg: #161d24;
  --card-shadow: 0 1px 0 rgba(0,0,0,.45);
  --lift-shadow: 0 14px 32px rgba(0,0,0,.55);
  color-scheme: dark;
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  font-family: var(--font-ui);
  font-size: calc(13px * var(--font-scale));
  line-height: 1.35;
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
body.has-bg{
  background: var(--bg) var(--bg-image) center / cover no-repeat fixed;
}
button, input, select, textarea{ font: inherit; color: inherit; }
:focus-visible{ outline: 2px solid var(--accent); outline-offset: 1px; }
.visually-hidden{
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.hidden{ display: none !important; }
.icon{ display: block; flex: none; }
.dim{ color: var(--muted2); }

.app{ height: 100%; display: flex; flex-direction: column; }

/* --- Top bar */
.topbar{
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 8px;
  flex: none;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand{ display: flex; align-items: center; gap: 7px; margin-right: 6px; }
.brand__mark{
  width: 12px; height: 12px;
  background: var(--signal);
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
}
.brand__title{ font-size: calc(17px * var(--font-scale)); font-weight: 700; letter-spacing: -.01em; }
.topbar__controls{ display: flex; align-items: center; gap: 2px; margin-left: auto; }

.segmented{
  display: inline-flex;
  padding: 2px;
  background: var(--surface-3);
  border-radius: 5px;
}
.segmented__btn{
  border: 0;
  background: transparent;
  padding: 3px 12px;
  border-radius: 4px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.segmented__btn[aria-selected="true"]{
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 0 var(--line-strong);
}

.search{
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 320px;
  max-width: 440px;
  height: 30px;
  margin-left: 6px;
  padding: 0 9px;
  color: var(--muted2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
}
.search:focus-within{ border-color: var(--accent); background: var(--surface); }
.search__input{ flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }

/* --- Buttons */
.btn{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover{ background: var(--surface-2); }
.btn--primary{ background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn--primary:hover{ background: var(--ink); opacity: .9; }
.btn--ghost{ background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover{ background: var(--surface-3); color: var(--ink); }
.btn--danger{ color: var(--danger); }
.btn--sm{ height: 24px; padding: 0 8px; }

.iconBtn{
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.iconBtn:hover{ background: var(--surface-3); color: var(--ink); }
.iconBtn--bar{ width: 30px; height: 30px; }
.iconBtn--bar[aria-pressed="false"]{ color: var(--muted2); }

/* --- Layout */
.layout{
  display: grid;
  grid-template-columns: var(--sidebar-w, 260px) 6px 1fr 6px var(--detail-w, 420px);
  flex: 1;
  min-height: 0;
  padding: 6px;
}
.layout--sidebarCollapsed{ grid-template-columns: 0 0 1fr 6px var(--detail-w, 420px); }
.layout--noDetail{ grid-template-columns: var(--sidebar-w, 260px) 6px 1fr 0 0; }
.layout--sidebarCollapsed.layout--noDetail{ grid-template-columns: 0 0 1fr 0 0; }
.layout--sidebarCollapsed .sidebar,
.layout--sidebarCollapsed #splitterSidebar,
.layout--noDetail .detail,
.layout--noDetail #splitterDetail{ display: none; }
/* Pin each panel to its column, so hiding the sidebar doesn't shift the
   content into the sidebar's zero-width column. */
.layout > .sidebar{ grid-column: 1; }
.layout > #splitterSidebar{ grid-column: 2; }
.layout > .content{ grid-column: 3; }
.layout > #splitterDetail{ grid-column: 4; }
.layout > .detail{ grid-column: 5; }

.sidebar, .content, .detail{
  min-height: 0;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  overflow: hidden;
}
.has-bg .sidebar, .has-bg .detail{ background: color-mix(in srgb, var(--surface) 94%, transparent); }

.splitter{ cursor: col-resize; position: relative; }
.splitter::after{
  content: "";
  position: absolute;
  inset: 40% 2px;
  border-radius: 2px;
}
.splitter:hover::after{ background: var(--line-strong); }

/* --- Sidebar tree */
.sidebar{ display: flex; flex-direction: column; }
.sidebar__header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 34px;
  padding: 0 6px 0 10px;
  border-bottom: 1px solid var(--line);
}
.sidebar__title{ font-weight: 700; font-size: calc(13px * var(--font-scale)); }
.tree{ flex: 1; overflow: auto; padding: 4px; }
.treeRow{
  display: grid;
  grid-template-columns: 14px 1fr auto 22px;
  align-items: center;
  gap: 2px;
  height: 26px;
  padding: 0 2px 0 4px;
  border-radius: 4px;
  cursor: pointer;
}
.treeRow:hover{ background: var(--surface-2); }
.treeRow--active{ background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.treeRow--active .treeRow__count{ color: var(--accent); }
.treeRow__caret{ color: var(--muted2); font-size: calc(11px * var(--font-scale)); text-align: center; }
.treeRow__name{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.treeRow__count{ color: var(--muted2); font-size: calc(12px * var(--font-scale)); padding: 0 2px; }
.treeRow__actions .iconBtn{ width: 22px; height: 22px; opacity: 0; }
.treeRow:hover .treeRow__actions .iconBtn,
.treeRow__actions .iconBtn:focus-visible{ opacity: 1; }
.treeChildren{ padding-left: 12px; }

/* --- Content toolbar */
.content{ display: flex; flex-direction: column; }
.layout--board .content{
  background: transparent;
  border-color: transparent;
}
.toolbar{
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.layout--board .toolbar{ border: 1px solid var(--line); border-radius: var(--r-panel); }
.has-bg .layout--board .toolbar{ background: color-mix(in srgb, var(--surface) 92%, transparent); }

.quickAdd{
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 260px;
  height: 28px;
  padding: 0 8px;
  color: var(--muted2);
  border: 1px dashed var(--line-strong);
  border-radius: 5px;
}
.quickAdd:focus-within{ border-style: solid; border-color: var(--accent); color: var(--accent); }
.quickAdd__input{ flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }

.pickField{ display: flex; align-items: center; gap: 5px; color: var(--muted); }
.pickField__label{ font-weight: 600; }
.pickField__select{
  height: 26px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
}

.toggle{ display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); font-weight: 600; }
.toggle input{ position: absolute; opacity: 0; pointer-events: none; }
.toggle__track{
  position: relative;
  width: 26px; height: 14px;
  border-radius: 7px;
  background: var(--line-strong);
}
.toggle__track::after{
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform .12s ease;
}
.toggle input:checked + .toggle__track{ background: var(--accent); }
.toggle input:checked + .toggle__track::after{ transform: translateX(12px); }
.toggle input:focus-visible + .toggle__track{ outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Fields and inputs (detail panel, modals) */
.field{ display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field__label{ font-size: calc(12px * var(--font-scale)); font-weight: 600; color: var(--muted); }
.field__hint{ margin-top: 10px; font-size: calc(12px * var(--font-scale)); color: var(--muted2); }
.input{
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
}
textarea.input{ height: auto; padding: 6px 7px; }
.input:focus{ outline: 0; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.input--wide{ width: 100%; }
.input--bare{ width: auto; height: 22px; padding: 0 3px; border-color: transparent; background: transparent; color: var(--muted); }
.input--bare:hover{ border-color: var(--line); }

/* --- Views */
.views{ flex: 1; min-height: 0; position: relative; }
.view{ display: none; height: 100%; }
.view--active{ display: block; }

/* --- Outline table */
.tableWrap{ height: 100%; overflow: auto; }
.table{ width: 100%; border-collapse: collapse; table-layout: fixed; }
.table thead th{
  position: sticky;
  top: 0;
  z-index: 1;
  height: 30px;
  padding: 0 10px;
  text-align: left;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.table thead th:nth-child(1){ width: 36%; }
.table thead th:nth-child(2){ width: 20%; }
.table thead th:nth-child(3){ width: 14%; }
.thBtn{
  display: inline-flex; gap: 4px; align-items: center;
  padding: 0; border: 0; background: none;
  font-weight: 700; color: var(--muted); cursor: pointer;
}
.thBtn:hover{ color: var(--ink); }
.thBtn__arrow{ color: var(--accent); }
.table tbody td{
  padding: 5px 10px;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.table .th--handle{ display: none; width: 34px; }
.table--reorder .th--handle{ display: table-cell; }
.table tbody td.dragCell{ width: 34px; padding: 3px 4px; vertical-align: middle; text-align: center; }
.dragHandle{
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted2);
  cursor: grab;
  touch-action: none;
  opacity: .55;
}
.row:hover .dragHandle, .dragHandle:focus-visible{ opacity: 1; }
.dragHandle:hover{ background: var(--surface-3); color: var(--ink); }
.row--dragging, .row--dragging:hover{ background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.row--dragging .dragHandle{ opacity: 1; color: var(--accent); }
.table__empty{ padding: 24px 10px !important; color: var(--muted2); }
.row{ cursor: pointer; }
.row:hover{ background: var(--surface-2); }
.row--selected, .row--selected:hover{ background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.taskTitle{ font-size: calc(14px * var(--font-scale)); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta{ display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 3px; }
.waiting{ display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: calc(12px * var(--font-scale)); }
.lastNote__row{ display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.lastNote__date{ flex: none; color: var(--muted2); font-size: calc(12px * var(--font-scale)); }
.lastNote__text{
  font-family: var(--font-text);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Agenda */
.agenda{ height: 100%; overflow: auto; padding-bottom: 16px; }
.agendaSection__header{
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.agendaSection__title{ margin: 0; font-size: calc(13px * var(--font-scale)); font-weight: 700; color: var(--muted); }
.agendaSection__count{ color: var(--muted2); font-size: calc(12px * var(--font-scale)); font-weight: 600; }
/* Only the sections that need you now get the signal colour. */
.agendaSection--overdue .agendaSection__header{ box-shadow: inset 3px 0 0 var(--signal); }
.agendaSection--overdue .agendaSection__title,
.agendaSection--today .agendaSection__title{ color: var(--ink); }
.agendaSection--done .agendaRow .taskTitle{ color: var(--muted2); }
.agendaSection__empty, .agenda__empty{ padding: 10px; color: var(--muted2); border-bottom: 1px solid var(--line); }
.agenda__empty{ padding: 24px 10px; border: 0; }
.agendaRow{
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px 128px;
  align-items: start;
  gap: 10px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.agendaRow:hover{ background: var(--surface-2); }
.agendaRow:focus-visible{ outline: 2px solid var(--accent); outline-offset: -2px; }
.agendaRow--selected, .agendaRow--selected:hover{ background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.agendaRow__main{ min-width: 0; }
.agendaRow > .badge{ justify-self: start; }
.agendaRow__due{ display: flex; justify-content: flex-end; }

/* --- Badges, labels, chips */
.badge{
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-chip);
  background: var(--surface-3);
  color: var(--muted);
  font-size: calc(12px * var(--font-scale));
  font-weight: 600;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge[style*="--badge-color"]::before{
  flex: none;
  content: "";
  width: 8px; height: 8px;
  border-radius: 2px;
  background: var(--badge-color);
}
.badge--overdue{ background: var(--signal); color: var(--signal-ink); }

.label{
  display: inline-block;
  max-width: 100%;
  padding: 0 6px;
  border-radius: var(--r-chip);
  background: color-mix(in srgb, var(--label) 22%, var(--card));
  color: color-mix(in srgb, var(--label) 70%, var(--ink));
  box-shadow: inset 3px 0 0 var(--label);
  font-size: calc(11.5px * var(--font-scale));
  font-weight: 600;
  line-height: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Due chips. Overdue carries the hazard stripe: the one loud thing in the interface. */
.due{
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-chip);
  color: var(--muted);
  font-size: calc(12px * var(--font-scale));
  font-weight: 600;
  white-space: nowrap;
}
.due .icon{ width: 13px; height: 13px; }
.due--today{ color: var(--signal-ink); background: var(--signal); }
.due--overdue{
  color: var(--signal-ink);
  background:
    repeating-linear-gradient(-45deg, var(--signal-ink) 0 3px, transparent 3px 6px) left / 7px 100% no-repeat,
    var(--signal);
  padding-left: 11px;
}
.due--done{ color: var(--muted2); text-decoration: line-through; }

.avatar{
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
  font-size: calc(10.5px * var(--font-scale));
  font-weight: 700;
  letter-spacing: .02em;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.avatar--sm{ width: 17px; height: 17px; font-size: calc(9px * var(--font-scale)); }

/* --- Board (Trello-style lists) */
.board{
  display: flex;
  align-items: flex-start;
  gap: 8px;
  height: 100%;
  padding: 8px 2px 4px;
  overflow-x: auto;
  overflow-y: hidden;
}
.board__empty{ padding: 24px; color: var(--muted2); }
.list{
  display: flex;
  flex-direction: column;
  flex: 0 0 272px;
  max-height: 100%;
  background: var(--list-bg);
  border-radius: var(--r-list);
  box-shadow: inset 0 3px 0 var(--lane-color);
}
.has-bg .list{ background: color-mix(in srgb, var(--list-bg) 90%, transparent); }
.list__header{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 6px;
}
.list__title{ margin: 0; font-size: calc(14px * var(--font-scale)); font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list__count{ color: var(--muted2); font-weight: 600; }
.list__cards{
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 8px;
  padding: 2px 8px 4px;
  overflow-y: auto;
}
.list__footer{ padding: 2px 8px 8px; }
.list__add{
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: 30px;
  padding: 0 6px;
  border: 0;
  border-radius: var(--r-card);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.list__add:hover{ background: color-mix(in srgb, var(--ink) 9%, transparent); color: var(--ink); }
.composer__input{ resize: none; background: var(--card); box-shadow: var(--card-shadow); border-color: transparent; font-family: var(--font-text); }
.composer__actions{ display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.composer__actions .btn{ background: var(--accent); border-color: var(--accent); color: #fff; }

.card{
  position: relative;
  padding: 7px 9px 8px;
  border-radius: var(--r-card);
  background: var(--card);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  user-select: none;
}
@media (pointer: fine){ .card{ touch-action: none; } }
.card:hover{ box-shadow: var(--card-shadow), inset 0 0 0 1px var(--line-strong); }
.card--selected{ box-shadow: var(--card-shadow), inset 0 0 0 2px var(--accent); }
.card__labels{ display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 5px; }
.card__title{ font-size: calc(14px * var(--font-scale)); font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.card__footer{ display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; margin-top: 6px; }
.card__badges{ display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-left: -4px; }
.cardBadge{ display: inline-flex; align-items: center; gap: 3px; padding: 0 4px; color: var(--muted2); font-size: calc(12px * var(--font-scale)); font-weight: 600; }
.cardBadge .icon{ width: 13px; height: 13px; }

.card--placeholder{
  background: color-mix(in srgb, var(--ink) 12%, transparent);
  box-shadow: none;
}
.card--ghost{
  position: fixed;
  z-index: 50;
  pointer-events: none;
  box-shadow: var(--lift-shadow);
  transform-origin: 30% 50%;
  opacity: .96;
}
body.is-dragging, body.is-dragging *{ cursor: grabbing !important; }
body.is-dragging{ user-select: none; }

/* --- Detail panel */
.detail{ display: flex; flex-direction: column; }
.detail__empty{ padding: 18px; color: var(--muted2); }
.detail__emptyTitle{ font-weight: 700; color: var(--muted); }
.detail__panel{ display: flex; flex-direction: column; min-height: 0; height: 100%; }
.detail__header{
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 10px;
  border-bottom: 1px solid var(--line);
}
.detail__title{
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 4px;
  margin-left: -4px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-size: calc(17px * var(--font-scale));
  font-weight: 700;
}
.detail__title:hover{ border-color: var(--line); }
.detail__title:focus{ outline: 0; border-color: var(--accent); background: var(--surface); }
.detail__headerBtns{ display: flex; align-items: center; gap: 2px; }
.detail__meta{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
.detail__notes{ flex: 1; min-height: 0; display: flex; flex-direction: column; }
.detail__sectionHeader{ display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 4px 10px; }
.detail__sectionTitle{ font-weight: 700; font-size: calc(13px * var(--font-scale)); }
.notes{ flex: 1; overflow: auto; padding: 0 10px 12px; }
.notes__empty{ padding: 8px 0; color: var(--muted2); }
.note{ padding: 6px 0 8px; border-top: 1px solid var(--line); }
.note:first-child{ border-top: 0; }
.note__top{ display: flex; align-items: center; gap: 2px; margin: 0 -3px 2px; }
.note__state{ flex: 1; text-align: right; padding-right: 4px; color: var(--muted2); font-size: calc(11.5px * var(--font-scale)); }
.note__top .iconBtn{ width: 22px; height: 22px; opacity: .55; }
.note:hover .note__top .iconBtn, .note__top .iconBtn:focus-visible{ opacity: 1; }
.note__body{
  display: block;
  min-height: 52px;
  padding: 4px 6px;
  margin: 0 -6px;
  width: calc(100% + 12px);
  border-color: transparent;
  background: transparent;
  font-family: var(--font-text);
  font-size: calc(14px * var(--font-scale));
  line-height: 1.5;
  resize: vertical;
}
.note__body:hover{ border-color: var(--line); }
.note__body:focus{ background: var(--surface); }

/* --- Modals */
.modal{
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--lift-shadow);
  width: min(560px, calc(100vw - 32px));
}
.modal::backdrop{ background: rgba(10,16,22,.45); }
.modal__card{ display: flex; flex-direction: column; max-height: calc(100vh - 64px); }
.modal__title{ padding: 12px 14px 0; font-size: calc(17px * var(--font-scale)); font-weight: 700; }
.modal__body{ padding: 10px 14px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.modal__actions{ display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; padding: 10px 14px 12px; border-top: 1px solid var(--line); }
.modal__actions .btn:first-child:not(.btn--ghost){ background: var(--ink); border-color: var(--ink); color: var(--surface); }

.modalMenu{ display: flex; flex-direction: column; gap: 12px; }
.modalMenu__section{ display: flex; flex-direction: column; gap: 4px; }
.modalMenu__title{ font-weight: 700; color: var(--muted); font-size: calc(12px * var(--font-scale)); }
.menuBtn{
  display: block;
  width: 100%;
  padding: 7px 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
}
.menuBtn:hover{ background: var(--surface-2); border-color: var(--line-strong); }
.menuBtn__top{ display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; font-size: calc(14px * var(--font-scale)); }
.menuBtn__hint{ margin-top: 1px; color: var(--muted2); font-size: calc(12px * var(--font-scale)); }
.menuBtn--danger .menuBtn__top{ color: var(--danger); }
.menuBtn--ghost{ border-color: transparent; }
.menuBtn--selected{ border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }

.copyRow{ display: flex; gap: 6px; }
.copyRow .input{ font-size: calc(12px * var(--font-scale)); }
.steps{ margin: 4px 0 0; padding-left: 20px; color: var(--muted); }
.steps li{ margin: 3px 0; }

/* Background picker */
.bgPicker{ display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.modal:has(.bgPicker){ width: min(760px, calc(100vw - 32px)); }
@media (max-width: 640px){ .bgPicker{ grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.bgPicker__group{ grid-column: 1 / -1; margin-top: 6px; font-weight: 700; color: var(--muted); font-size: calc(12px * var(--font-scale)); }
.bgTile{
  display: grid;
  grid-template-rows: 78px auto auto;
  padding: 0 0 6px;
  overflow: hidden;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  cursor: pointer;
}
.bgTile img, .bgTile__swatch{ width: 100%; height: 78px; object-fit: cover; display: block; background: var(--surface-3); }
.bgTile__swatch{ background: linear-gradient(135deg, var(--bg) 50%, var(--surface) 50%); }
.bgTile__label{ padding: 5px 7px 0; font-weight: 600; }
.bgTile__credit{ padding: 0 7px; font-size: calc(11px * var(--font-scale)); color: var(--muted2); }
.bgTile:hover{ border-color: var(--line-strong); }
.bgTile--active{ border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* --- Responsive */
@media (max-width: 1100px){
  .layout, .layout--noDetail, .layout--sidebarCollapsed, .layout--sidebarCollapsed.layout--noDetail{
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(420px, 1fr) auto;
    gap: 6px;
    overflow: auto;
  }
  .layout > .sidebar, .layout > .splitter, .layout > .content, .layout > .detail{ grid-column: auto; }
  .splitter{ display: none; }
  .sidebar{ max-height: 220px; }
  .detail{ min-height: 360px; }
}
@media (max-width: 760px){
  .topbar{ flex-wrap: wrap; height: auto; padding: 6px 8px; }
  .search{ order: 5; flex-basis: 100%; max-width: none; margin-left: 0; }
  .brand__title{ font-size: calc(15px * var(--font-scale)); }
  .detail__meta{ grid-template-columns: 1fr; }
  .list{ flex-basis: 84vw; }
}

@media (prefers-reduced-motion: reduce){
  *{ transition: none !important; }
}
