/* MVE Project Hub
   Colours sampled from the Magic Valley Electric logo. Page titles are set as
   engraved panel nameplates, the one decorative element; everything else
   stays plain so the boards and tools do the talking. */

@font-face { font-family: "Barlow"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 400; font-style: italic; font-display: swap; src: url("../fonts/barlow-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/barlow-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }

:root {
  --ink: #01000E;          /* "ELECTRIC" lettering */
  --blue: #00529B;         /* "MAGIC" lettering, bolt shadow */
  --blue-dark: #003F78;
  --blue-tint: #E3EEF8;
  --sky: #018CD1;          /* "VALLEY" plate */
  --bolt: #37C1F2;         /* bolt highlight: focus rings only */
  --silver: #878A8F;       /* plate outline */
  --silver-light: #D9DBD8; /* "MAGIC" plate */

  --bg: #ECEEED;
  --surface: #FFFFFF;
  --surface-sunk: #F5F6F5;
  --line: #D3D6D4;
  --line-strong: #9A9EA3;
  --text: var(--ink);
  --muted: #50555B;

  --danger: #B42318; --danger-tint: #FDECEA;
  --warn: #7A4A00;   --warn-tint: #FFF2D6;
  --ok: #1D6631;     --ok-tint: #E5F3E8;

  --font-ui: "Barlow", "Segoe UI", system-ui, sans-serif;
  --font-display: "Barlow Condensed", "Barlow", "Arial Narrow", sans-serif;

  --r-control: 3px;
  --r-panel: 6px;
  --sidebar-w: 15.5rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 1rem/1.5 var(--font-ui);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: var(--blue); text-underline-offset: .15em; }
a:hover { color: var(--blue-dark); }
h1, h2, h3 { margin: 0; line-height: 1.15; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }
:focus-visible { outline: 2px solid var(--bolt); outline-offset: 2px; }
::selection { background: #BEE7FB; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 1rem; top: -3rem; z-index: 100; padding: .5rem 1rem; background: var(--ink); color: #fff; border-radius: var(--r-control); }
.skip-link:focus { top: 1rem; color: #fff; }
.muted { color: var(--muted); }

/* --- Nameplate -------------------------------------------------------------- */
.plate {
  display: inline-flex;
  align-items: center;
  gap: .65em;
  margin: 0;
  padding: .28em .8em .3em;
  background: var(--ink);
  color: #F2F4F3;
  font: 600 1.4rem/1.1 var(--font-display);
  letter-spacing: .03em;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.plate::before, .plate::after {
  content: "";
  flex: none;
  width: .36em;
  height: .36em;
  border-radius: 50%;
  background:
    linear-gradient(135deg, transparent 43%, rgba(10, 12, 16, .85) 43% 57%, transparent 57%),
    radial-gradient(circle at 35% 30%, #D6DADE 0 15%, #80868D 55%, #3A3F45 100%);
}
.plate-lg { font-size: 2rem; letter-spacing: .07em; text-transform: uppercase; padding: .3em .85em; }

/* --- App shell -------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.brand { display: block; padding: 1.1rem 1.1rem .9rem; text-decoration: none; border-bottom: 1px solid var(--line); }
.brand img { display: block; width: 100%; max-width: 12.5rem; }
.brand-name { display: block; margin-top: .45rem; font: 600 1.1rem/1 var(--font-display); letter-spacing: .04em; color: var(--blue); }

.nav { padding: .6rem .6rem 1rem; }
.nav-group { margin: 1rem .6rem .25rem; font: 600 .95rem/1.2 var(--font-display); letter-spacing: .02em; color: var(--muted); }
.nav-link {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .36rem .6rem;
  border-radius: var(--r-control);
  color: var(--text);
  font-weight: 500;
  font-size: .95rem;
  text-decoration: none;
}
.nav-link:hover { background: var(--surface-sunk); color: var(--text); }
.nav-link.is-current { background: var(--blue-tint); color: var(--blue); box-shadow: inset 3px 0 0 var(--blue); }
.nav-soon { margin-left: auto; padding: 0 .4rem; font-size: .72rem; font-weight: 500; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; }
.sidebar-foot { margin: auto 0 0; padding: .75rem 1.2rem; font-size: .8rem; color: var(--muted); border-top: 1px solid var(--line); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 2rem .9rem; }
.topbar-title { flex: 1; min-width: 0; }
.content { flex: 1; width: 100%; max-width: 76rem; padding: .5rem 2rem 3rem; }
.content:focus { outline: none; }

.nav-toggle { display: none; width: 2.5rem; height: 2.5rem; border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface); cursor: pointer; }
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after { display: block; width: 1.1rem; height: 2px; margin: auto; background: var(--ink); position: relative; content: ""; }
.nav-toggle-bars::before { position: absolute; top: -6px; }
.nav-toggle-bars::after { position: absolute; top: 6px; }
.scrim { position: fixed; inset: 0; z-index: 39; background: rgba(1, 0, 14, .35); }

/* Account menu */
.account { position: relative; }
.account summary {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .75rem;
  list-style: none; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-control);
  font-weight: 600;
}
.account summary::-webkit-details-marker { display: none; }
.account-dept { font-weight: 500; color: var(--muted); padding-left: .5rem; border-left: 1px solid var(--line); }
.account-menu {
  position: absolute; right: 0; top: calc(100% + .35rem); z-index: 30;
  min-width: 12rem; padding: .35rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: 0 10px 28px rgba(1, 0, 14, .14);
}
.account-menu a, .account-menu button {
  display: block; width: 100%; padding: .45rem .65rem;
  text-align: left; font: inherit; font-weight: 500; color: var(--text); text-decoration: none;
  background: none; border: 0; border-radius: var(--r-control); cursor: pointer;
}
.account-menu a:hover, .account-menu button:hover { background: var(--surface-sunk); }
.account-menu form { margin: 0; }

/* --- Feedback --------------------------------------------------------------- */
.flashes { display: grid; gap: .5rem; padding: 0 2rem; margin-bottom: 1.25rem; max-width: 76rem; }
.flashes-inline { padding: 0; margin-bottom: 1rem; text-align: left; }
.flash, .form-error, .callout { margin: 0; padding: .65rem .9rem; border-radius: var(--r-control); border-left: 4px solid; }
.flash-success { background: var(--ok-tint); border-color: var(--ok); }
.flash-info, .callout { background: var(--blue-tint); border-color: var(--blue); }
.flash-error, .form-error { background: var(--danger-tint); border-color: var(--danger); }
.form-error { margin-bottom: .75rem; }
.callout { margin-bottom: 1rem; }

/* --- Panels ----------------------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 1.25rem 1.5rem 1.5rem; }
.panel-narrow { max-width: 34rem; }
.panel-title { font: 600 1.3rem/1.2 var(--font-display); letter-spacing: .01em; margin-bottom: .75rem; }
.panel-danger { border-color: #E9B4AE; }
.lede { font-size: 1.15rem; }
.section-title { font: 600 1.5rem/1.2 var(--font-display); letter-spacing: .01em; margin: 2.25rem 0 1rem; }
.breadcrumb { margin-bottom: 1rem; font-weight: 500; }
.breadcrumb a::before { content: "‹ "; }
.stack { display: grid; gap: 1rem; align-content: start; }
.form-columns { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.5rem; align-items: start; }

/* --- Forms ------------------------------------------------------------------ */
.field { display: grid; gap: .3rem; }
.field-label { font-weight: 600; font-size: .92rem; }
.field-hint { display: block; font-size: .85rem; color: var(--muted); font-weight: 400; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%; min-height: 2.6rem; padding: .45rem .75rem;
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-control);
}
textarea { min-height: 6rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--bolt); outline-offset: 0; border-color: var(--sky); }
input:disabled, select:disabled { background: var(--surface-sunk); color: var(--muted); }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: var(--blue); }
.check { display: flex; gap: .65rem; align-items: flex-start; font-weight: 600; }
.check input { margin-top: .2rem; }

.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: .25rem; }
.actions-sticky { position: sticky; bottom: 0; padding: .9rem 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 2.5rem; padding: .4rem 1.05rem;
  font: 600 .95rem/1.2 var(--font-ui); text-decoration: none; white-space: nowrap;
  border: 1px solid transparent; border-radius: var(--r-control); cursor: pointer;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); color: #fff; }
.btn-quiet { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn-quiet:hover { background: var(--surface-sunk); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8F1C13; color: #fff; }
.btn-block { width: 100%; }

/* --- Tables ----------------------------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.toolbar-note { margin: 0 0 1rem; color: var(--muted); }
.toolbar .toolbar-note { margin: 0; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: .6rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table thead th { font-size: .85rem; font-weight: 600; color: var(--muted); background: var(--surface-sunk); }
.table tbody th { font-weight: 600; }
.table tr.is-muted { color: var(--muted); }
.table-matrix td { text-align: center; }
.table-matrix thead th:not(:first-child) { text-align: center; }
.th-sub { display: block; font-weight: 400; font-size: .8rem; }
.row-group th { padding-top: 1rem; font: 600 1rem/1.2 var(--font-display); letter-spacing: .02em; color: var(--blue); background: var(--surface); }
.tag { display: inline-block; margin-left: .35rem; padding: 0 .4rem; font-size: .75rem; font-weight: 600; color: var(--blue); background: var(--blue-tint); border-radius: var(--r-control); }
.status { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; }
.status::before { content: ""; width: .55rem; height: .55rem; border-radius: 50%; background: currentColor; }
.status-ok { color: var(--ok); }
.status-warn { color: var(--warn); }
.status-off { color: var(--muted); }

/* --- Home ------------------------------------------------------------------- */
.home-boards { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.25rem; }
/* Board links are drawn like a whiteboard: aluminium frame and marker tray. */
.board-link {
  display: grid; grid-template-columns: 1fr auto; align-content: start; gap: .35rem 1rem;
  padding: 1.25rem 1.5rem 1.4rem;
  color: var(--text); text-decoration: none;
  background: var(--surface);
  border: 2px solid #C3C7CA;
  border-bottom: 8px solid #B9BDC1;
  border-radius: 4px;
}
.board-link:hover { color: var(--text); border-color: var(--sky); border-bottom-color: #9FB9CC; }
.board-link-name { font: 600 1.75rem/1.1 var(--font-display); letter-spacing: .01em; color: var(--blue); }
.board-link-dept { align-self: center; padding: .15rem .55rem; font-weight: 600; font-size: .85rem; color: var(--ink); background: var(--silver-light); border-radius: var(--r-control); }
.board-link-summary { grid-column: 1 / -1; color: var(--muted); }

.directory-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1.75rem 2.5rem; }
.directory-group h3 { padding-bottom: .4rem; margin-bottom: .25rem; font: 600 1.1rem/1.2 var(--font-display); letter-spacing: .02em; color: var(--muted); border-bottom: 1px solid var(--line-strong); }
.directory-group ul { margin: 0; padding: 0; list-style: none; }
.directory-group li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.directory-group a { font-weight: 600; text-decoration: none; }
.directory-group a:hover { text-decoration: underline; }
.directory-group li span { display: block; font-size: .9rem; color: var(--muted); }

/* --- Sign-in ---------------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-panel { width: min(25rem, 100%); padding: 2rem 2rem 1.75rem; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); }
.auth-logo { display: block; width: 15rem; margin: 0 auto 1.25rem; }
.auth-panel .plate { margin-bottom: 1.75rem; }
.auth-panel form { text-align: left; }
.auth-help { margin-top: 1.25rem; font-size: .88rem; color: var(--muted); }
.error-code { font: 600 1rem var(--font-display); color: var(--muted); letter-spacing: .03em; }

/* --- Small screens ---------------------------------------------------------- */
@media (max-width: 60rem) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: min(var(--sidebar-w), 85vw); transform: translateX(-100%); transition: transform .2s ease; }
  .nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(1, 0, 14, .25); }
  .nav-toggle { display: grid; place-items: center; flex: none; }
  .topbar { padding: .9rem 1rem .75rem; gap: .75rem; }
  .content { padding: .5rem 1rem 2.5rem; }
  .flashes { padding: 0 1rem; }
  .plate { font-size: 1.15rem; }
  .account-dept { display: none; }
  .home-boards, .form-columns { grid-template-columns: 1fr; }
}
@media (max-width: 30rem) {
  .field-row { grid-template-columns: 1fr; }
  .plate::before, .plate::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* =============================================================================
   Whiteboards
   ========================================================================== */

/* Row colours: a tint for the row and a stronger stripe down its left edge. */
.color-white  { --tint: #FFFFFF; --stripe: transparent; }
.color-red    { --tint: #FCE9E7; --stripe: #D64535; }
.color-orange { --tint: #FDEEDD; --stripe: #E07B1F; }
.color-yellow { --tint: #FBF4CF; --stripe: #CFA713; }
.color-green  { --tint: #E3F2E5; --stripe: #3C9450; }
.color-blue   { --tint: #E2EFF9; --stripe: #018CD1; }
.color-purple { --tint: #EFE8F8; --stripe: #7C55B8; }
.color-gray   { --tint: #EEEFEF; --stripe: #878A8F; }
.note-yellow  { --note: #FFF0A3; }
.note-blue    { --note: #CDE6F8; }
.note-green   { --note: #D2EFD1; }
.note-pink    { --note: #F9D6E5; }

.content-wide { max-width: none; }
.title-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.title-chip { padding: .2rem .6rem; font-weight: 600; background: var(--silver-light); border-radius: var(--r-control); }

.board-layout.has-chat { display: grid; grid-template-columns: minmax(0, 1fr) 21rem; gap: 1.5rem; align-items: start; }
.board-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.board-toolbar-end { margin-left: auto; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.dept-switch { margin: 0; }
.dept-switch select { width: auto; min-height: 2.5rem; }
.sync-status { font-size: .9rem; color: var(--muted); }
.sync-status[data-kind="error"] { color: var(--danger); font-weight: 600; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 2rem 0 .75rem; }
.section-head .section-title { margin: 0; }
.empty { margin: 0; padding: 1.25rem; color: var(--muted); }

/* --- Rows ------------------------------------------------------------------ */
.rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.rows-head, .row {
  display: grid;
  grid-template-columns: 2rem minmax(10rem, 1.25fr) minmax(8.5rem, .8fr) minmax(12rem, 2.3fr) auto;
  gap: .4rem;
  align-items: start;
  padding: .35rem .75rem .35rem .3rem;
}
.rows-head { font-size: .82rem; font-weight: 600; color: var(--muted); background: var(--surface-sunk); border-bottom: 1px solid var(--line); padding-top: .5rem; padding-bottom: .5rem; }
.rows-head span { padding-left: .55rem; }
.rows-list { margin: 0; padding: 0; list-style: none; }
.row { background: var(--tint); box-shadow: inset 5px 0 0 var(--stripe); border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row.is-dragging { position: relative; z-index: 2; box-shadow: inset 5px 0 0 var(--stripe), 0 8px 24px rgba(1, 0, 14, .18); }

.row-handle {
  width: 2rem; height: 2.3rem; display: grid; place-items: center;
  color: var(--line-strong); background: none; border: 0; border-radius: var(--r-control);
  cursor: grab; touch-action: none;
}
.row-handle svg { width: .6rem; fill: currentColor; }
.row-handle:hover { color: var(--ink); background: rgba(1, 0, 14, .05); }
.row.is-dragging .row-handle { cursor: grabbing; }

.cell {
  display: block; width: 100%; min-height: 2.3rem; margin: 0; padding: .4rem .55rem;
  font: inherit; line-height: 1.4; color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: var(--r-control);
  resize: none; overflow: hidden;
}
input.cell:not([type]) { min-height: 2.3rem; padding: .4rem .55rem; background: transparent; border-color: transparent; }
.cell:hover { border-color: var(--line); }
.cell:focus, input.cell:not([type]):focus { background: var(--surface); border-color: var(--sky); outline: 2px solid var(--bolt); outline-offset: 0; }
.cell::placeholder { color: #9A9EA3; }
.cell-title { font-weight: 600; }
.cell-notes { max-height: 9.6rem; overflow-y: auto; }
.cell-wrap-title { display: flex; align-items: center; gap: .25rem; }
.unread { flex: none; width: .6rem; height: .6rem; border-radius: 50%; background: #D64535; box-shadow: 0 0 0 2px var(--surface); }

/* Status reads as a coloured tag until you click into it. */
input.cell-status:not(:focus).st-done     { background: #DCF0E0; color: #1D6631; }
input.cell-status:not(:focus).st-progress { background: #DCEBF8; color: var(--blue); }
input.cell-status:not(:focus).st-hold     { background: #FBE1DE; color: #A5281B; }
input.cell-status:not(:focus).st-queue    { background: #ECEDEC; color: #3F4349; }
input.cell-status:not(:focus).st-other    { background: rgba(1, 0, 14, .05); }
input.cell-status:not(:focus):not(:placeholder-shown) { font-weight: 600; border-radius: 999px; }

.row-actions { display: flex; align-items: center; gap: .3rem; padding-top: .15rem; }
.row-open {
  min-height: 2rem; padding: .25rem .65rem;
  font: 600 .88rem/1 var(--font-ui); color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-control); cursor: pointer;
}
.row-open:hover { border-color: var(--blue); color: var(--blue); }
.row-count { font-weight: 500; color: var(--muted); }
.swatch {
  flex: none; width: 1.5rem; height: 1.5rem; padding: 0;
  background: var(--tint); border: 2px solid var(--stripe); border-radius: 50%; cursor: pointer;
}
.swatch.color-white, .row.color-white .row-swatch { border-color: var(--line-strong); }
.swatch[class*="note-"], .note-swatch { background: var(--note); border-color: rgba(1, 0, 14, .28); }
.swatch.is-selected { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--blue); }
.swatches { display: flex; flex-wrap: wrap; gap: .45rem; }
.icon-btn {
  flex: none; width: 2rem; height: 2rem; display: grid; place-items: center; padding: 0;
  font-size: 1.25rem; line-height: 1; color: var(--muted);
  background: none; border: 0; border-radius: var(--r-control); cursor: pointer;
}
.icon-btn svg { width: 1.15rem; height: 1.15rem; }
.icon-btn:hover { color: var(--danger); background: rgba(1, 0, 14, .06); }

.color-popover {
  position: absolute; z-index: 60; padding: .6rem; max-width: 13rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: 0 10px 28px rgba(1, 0, 14, .16);
}

/* --- Sticky notes: drawn on a whiteboard with a frame and marker tray ------ */
.notes-board {
  position: relative; overflow: auto; min-height: 20rem;
  background-color: #FBFCFC;
  background-image: linear-gradient(#ECEFEE 1px, transparent 1px), linear-gradient(90deg, #ECEFEE 1px, transparent 1px);
  background-size: 24px 24px;
  border: 2px solid #C3C7CA; border-bottom: 8px solid #B9BDC1; border-radius: 4px;
}
.note {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column;
  min-width: 120px; min-height: 100px; overflow: hidden; resize: both;
  background: var(--note);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(1, 0, 14, .14), 0 4px 12px rgba(1, 0, 14, .08);
}
.note.is-dragging { z-index: 5; box-shadow: 0 2px 4px rgba(1, 0, 14, .14), 0 14px 30px rgba(1, 0, 14, .2); }
.note-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .25rem .3rem; background: rgba(1, 0, 14, .05); cursor: grab; touch-action: none;
}
.note.is-dragging .note-bar { cursor: grabbing; }
.note-bar .swatch { width: 1.15rem; height: 1.15rem; }
.note-bar .icon-btn { width: 1.6rem; height: 1.6rem; }
.note-text {
  flex: 1; width: 100%; min-height: 0 !important; margin: 0; padding: .45rem .65rem .75rem;
  font: inherit; line-height: 1.4; color: var(--ink);
  background: transparent; border: 0; border-radius: 0; resize: none;
}
.note-text:focus-visible { outline: 2px solid var(--bolt); outline-offset: -2px; }

/* --- Chat ------------------------------------------------------------------- */
.chat {
  position: sticky; top: 1rem;
  display: flex; flex-direction: column;
  height: min(calc(100vh - 2rem), 52rem);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
}
.chat-head { position: relative; display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem .2rem; }
.chat-head h2 { font: 600 1.35rem/1.2 var(--font-display); letter-spacing: .01em; }
.chat-settings summary { list-style: none; cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--blue); padding: .2rem .4rem; border-radius: var(--r-control); }
.chat-settings summary::-webkit-details-marker { display: none; }
.chat-settings-menu {
  position: absolute; right: .75rem; top: 2.6rem; z-index: 20; width: 15rem;
  display: grid; gap: .6rem; padding: .85rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: 0 10px 28px rgba(1, 0, 14, .14);
}
.online { display: flex; align-items: center; gap: .45rem; margin: 0; padding: 0 1rem .65rem; font-size: .85rem; color: var(--muted); border-bottom: 1px solid var(--line); }
.online-dot { flex: none; width: .5rem; height: .5rem; border-radius: 50%; background: #2FA24A; }
.chat-log { flex: 1; overflow-y: auto; margin: 0; padding: .5rem .75rem 1rem; list-style: none; }
.msg { position: relative; margin-top: .6rem; padding: .35rem .6rem; background: var(--surface-sunk); border-radius: var(--r-panel); }
.msg.is-mine { background: var(--blue-tint); }
.msg.is-continued { margin-top: .2rem; }
.msg.is-continued .msg-meta { display: none; }
.msg-meta { margin: 0; font-size: .8rem; color: var(--muted); }
.msg-author { font-weight: 600; color: var(--text); }
.msg-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-body textarea { min-height: 3.5rem; }
.msg-actions { position: absolute; top: .25rem; right: .3rem; display: none; gap: .2rem; }
.msg:hover .msg-actions:not([hidden]), .msg:focus-within .msg-actions:not([hidden]) { display: flex; }
.msg.is-editing .msg-actions { display: none !important; }
.msg-actions button { padding: .1rem .4rem; font: 600 .75rem var(--font-ui); color: var(--blue); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-control); cursor: pointer; }
.msg-actions [hidden] { display: none; }
@media (hover: none) { .msg-actions:not([hidden]) { position: static; display: flex; margin-top: .3rem; } }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: end; padding: .75rem; border-top: 1px solid var(--line); }
.chat-form textarea { min-height: 2.6rem; resize: none; }

/* --- Row details dialog ---------------------------------------------------- */
.dialog {
  width: min(58rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-panel);
  box-shadow: 0 24px 64px rgba(1, 0, 14, .32);
}
.dialog[open] { display: flex; flex-direction: column; }
.dialog::backdrop { background: rgba(1, 0, 14, .45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 0; padding: .9rem 1.25rem; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font: 600 1.45rem/1.2 var(--font-display); letter-spacing: .01em; overflow-wrap: anywhere; }
.dialog-close { flex: none; width: 2.25rem; height: 2.25rem; font-size: 1.6rem; line-height: 1; color: var(--muted); background: none; border: 0; border-radius: var(--r-control); cursor: pointer; }
.dialog-close:hover { background: var(--surface-sunk); color: var(--text); }
.dialog-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.75rem; padding: 1.25rem; overflow: auto; }
.dialog-fields { display: grid; gap: 1rem; align-content: start; }
.dialog-fields textarea { min-height: 10rem; }
.comments h3 { margin-bottom: .6rem; font: 600 1.2rem/1.2 var(--font-display); letter-spacing: .01em; }
.comment-list { display: grid; gap: .55rem; max-height: 22rem; overflow-y: auto; margin: 0 0 .9rem; padding: 0; list-style: none; }
.comment { padding: .5rem .7rem; background: var(--surface-sunk); border-radius: 4px; }
.comment-empty { color: var(--muted); }
.comment-meta { margin: 0 0 .1rem; font-size: .82rem; color: var(--muted); }
.comment-meta strong { color: var(--text); }
.comment-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.link-btn { padding: 0; font: inherit; font-size: .82rem; color: var(--blue); text-decoration: underline; background: none; border: 0; cursor: pointer; }
.dialog-foot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 1.25rem; background: var(--surface-sunk); border-top: 1px solid var(--line); }
.dialog-foot form { margin: 0; }

/* --- Archive page ---------------------------------------------------------- */
.count-muted { margin-left: .35rem; font: 500 1rem var(--font-ui); color: var(--muted); }
.color-mark { display: inline-block; width: .7rem; height: .7rem; margin-right: .55rem; vertical-align: .05em; background: var(--stripe); border: 1px solid var(--line-strong); border-radius: 2px; }
.color-mark.color-white { background: var(--surface); }
.archive-table .archive-notes { max-width: 32rem; font-size: .9rem; color: var(--muted); }
.archive-actions { display: flex; justify-content: flex-end; gap: .35rem; }
.archive-actions form, .archived-note form { margin: 0; }
.btn-text-danger { min-height: 2.5rem; padding: .4rem .7rem; font: 600 .95rem var(--font-ui); color: var(--danger); background: none; border: 0; border-radius: var(--r-control); cursor: pointer; }
.btn-text-danger:hover { background: var(--danger-tint); }
.archive-notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 1rem; margin: 0; padding: 0; list-style: none; }
.archived-note { display: flex; flex-direction: column; justify-content: space-between; gap: .75rem; padding: .9rem 1rem; background: var(--note); border-radius: 2px; box-shadow: 0 1px 2px rgba(1, 0, 14, .14); }
.archived-note p { white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 75rem) {
  .board-layout.has-chat { grid-template-columns: 1fr; }
  .chat { position: static; height: 30rem; margin-top: 2rem; }
}
@media (max-width: 48rem) {
  .rows-head { display: none; }
  .row { grid-template-columns: 2rem minmax(0, 1fr); grid-template-areas: "handle title" ". status" ". notes" ". actions"; padding: .6rem .75rem .6rem .3rem; }
  .row-handle { grid-area: handle; }
  .row > .cell-wrap-title { grid-area: title; }
  .row > .cell-wrap:nth-of-type(2) { grid-area: status; }
  .row > .cell-wrap:nth-of-type(3) { grid-area: notes; }
  .row-actions { grid-area: actions; justify-content: flex-start; }
  .notes-board { display: grid; gap: .75rem; padding: .75rem; min-height: auto !important; }
  .note { position: static; transform: none !important; width: auto !important; height: auto !important; resize: none; }
  .note-bar { cursor: default; }
  .note-text { min-height: 7rem !important; field-sizing: content; }
  .dialog-body { grid-template-columns: 1fr; }
  .board-toolbar-end { margin-left: 0; }
}
.notes-section { margin-top: .5rem; }
