:root {
  color-scheme: light;
  --bg: #f7f7f7;
  --sidebar: #f3f3f3;
  --panel: #ffffff;
  --ink: #171717;
  --muted: #5e5e5e;
  --line: #e2e2e2;
  --soft: #efefef;
  --fill: #171717;
  --on-fill: #ffffff;
  --shadow: #0000001a;
  --open: #9f2d2d;
  --radius: 8px;
  --sidebar-width: 236px;
  --topbar: 52px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1b1b;
  --sidebar: #141414;
  --panel: #242424;
  --ink: #f0f0f0;
  --muted: #a6a6a6;
  --line: #3a3a3a;
  --soft: #303030;
  --fill: #f0f0f0;
  --on-fill: #171717;
  --shadow: #00000080;
  --open: #ffb4b4;
}

* { box-sizing: border-box; }

html {
  overflow-x: clip;
  max-width: 100%;
}

body {
  margin: 0;
  max-width: 100%;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI", "Liberation Sans", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

::selection {
  background: var(--ink);
  color: var(--bg);
}

button, input, select, textarea { font: inherit; color: inherit; accent-color: var(--fill); }

button, a, summary { touch-action: manipulation; }

a { color: inherit; }

h1, h2, h3, p { overflow-wrap: break-word; }

h1 { font-size: 1.5rem; font-weight: 650; line-height: 1.25; margin: 0; }

h2 { font-size: 1.05rem; font-weight: 650; margin: 0 0 12px; }

h3 { font-size: 0.98rem; font-weight: 650; margin: 0 0 8px; }

p { margin: 0; }

.app { min-height: 100vh; max-width: 100%; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  min-height: var(--topbar);
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  align-items: stretch;
  min-height: calc(100vh - var(--topbar));
  max-width: 100%;
}

.sidebar {
  position: sticky;
  top: var(--topbar);
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: var(--sidebar-width);
  height: calc(100vh - var(--topbar));
  min-width: 0;
  overflow: auto;
  padding: 16px 10px 12px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.nav-links a, .nav-aux {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius);
  text-decoration: none;
}

.nav-sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 4px;
  padding-left: 12px;
  min-width: 0;
}

.nav-sub a {
  padding: 7px 12px;
  color: var(--muted);
}

.nav-note {
  margin: 0;
  padding: 0 12px 8px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.3;
}

.workspace-search { align-items: center; }
.workspace-search input[type="search"] { flex: 1 1 16rem; min-width: 12rem; }
#mine-toggle[aria-pressed="true"] { font-weight: 700; background: var(--soft); }
.fact-link { display: inline; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }

.nav-links > a.is-current,
.nav-links a[aria-current="page"],
.nav-aux[aria-current="page"] {
  background: var(--soft);
  color: var(--ink);
  font-weight: 650;
}

.nav-aux {
  margin-top: auto;
  color: var(--muted);
}

.identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 14px 6px 2px;
  border-top: 1px solid var(--line);
}

.identity-card { min-width: 0; }

.identity-card div { overflow-wrap: anywhere; }

main {
  min-width: 0;
  max-width: 100%;
  padding: 20px 22px 40px;
}

.page-head, .row, .actions, .tabs, .toolbar, .footer, .identity, .picker-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.page-head {
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.page-head p { margin-top: 6px; }

.tabs {
  gap: 4px 16px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.tabs a {
  padding: 8px 0;
  border-bottom: 2px solid transparent;
  text-decoration: none;
  color: var(--muted);
}

.tabs a[aria-current="page"],
.tabs button[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
  font-weight: 650;
}

.tabs button {
  padding: 8px 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
}

.button, .nav-links a, .nav-aux, .tabs a, .tabs button, .text-button {
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  white-space: normal;
}

.button.primary {
  background: var(--fill);
  color: var(--on-fill);
  border-color: var(--fill);
}

.button:disabled { opacity: 0.5; cursor: not-allowed; }

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.panel, .empty, .notice, .upload {
  min-width: 0;
  max-width: 100%;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.notice { background: var(--soft); }

.empty { text-align: center; padding: 36px 16px; }

.empty p { max-width: 36rem; margin: 8px auto 16px; }

.muted { color: var(--muted); }

.small { font-size: 0.84rem; }

.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--soft);
  color: var(--ink);
  font-size: 0.84rem;
  white-space: normal;
}

.description { white-space: pre-wrap; overflow-wrap: anywhere; }

.fields, .summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 22px;
}

.summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.summary > div { min-width: 0; padding: 12px 14px; }

.summary > div + div { border-left: 1px solid var(--line); }

.span-2 { grid-column: 1 / -1; }

label, .field { display: grid; gap: 6px; min-width: 0; font-size: 0.84rem; color: var(--muted); }

input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
}

textarea { resize: vertical; min-height: 88px; }

.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 0.95rem; }

.check input { width: 16px; height: 16px; }

.field-error, .error { color: var(--ink); font-size: 0.9rem; }

.field-error { margin: 0; }

.error { font-weight: 650; }

.toolbar { justify-content: space-between; position: relative; margin-bottom: 12px; }

.filter-wrap { margin-left: auto; }

.filter-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  max-width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 8px 24px var(--shadow);
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.3rem;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--soft);
  color: var(--ink);
  font-size: 0.8rem;
}

.table-wrap, .table-scroll { max-width: 100%; overflow-x: auto; }

.workspace-table { width: 100%; }
.workspace-table th { white-space: nowrap; }

.workspace-table th.num,
.workspace-table td.num,
.workspace-table th.actions,
.workspace-table td.actions {
  white-space: nowrap;
  width: 1%;
}

.workspace-table td:first-child,
.workspace-table th:first-child {
  min-width: 12rem;
  white-space: normal;
}

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }

th, td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: break-word;
  word-break: normal;
}

th { color: var(--muted); font-size: 0.8rem; font-weight: 500; background: var(--bg); }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

tr.clickable { cursor: pointer; }

tr.clickable:hover, tr.clickable:focus-within { background: var(--soft); }

.name-link { font-weight: 650; }

.subrow td { background: var(--bg); }

.subrow td:first-child { padding-left: 22px; }

dl { margin: 0; }

dt { color: var(--muted); font-size: 0.8rem; margin-bottom: 4px; }

dd { margin: 0; }

.upload { border-style: dashed; text-align: center; }

.queue { display: grid; gap: 10px; }

.queue-item { padding-bottom: 10px; border-bottom: 1px solid var(--line); }

progress { width: min(100%, 220px); height: 8px; accent-color: var(--fill); }

.picker-results, .choice-list { display: grid; gap: 4px; margin-top: 6px; }

.picker-option, .choice {
  width: 100%;
  text-align: left;
  background: var(--panel);
}

.categories { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

.categories button[aria-pressed="true"] {
  background: var(--soft);
  border-color: var(--ink);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 280px);
  gap: 14px;
  align-items: start;
}

.evidence {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

blockquote {
  margin: 10px 0;
  padding-left: 10px;
  border-left: 2px solid var(--line);
  overflow-wrap: anywhere;
}

.crumb { margin-bottom: 10px; font-size: 0.84rem; color: var(--muted); }

.crumb a { color: var(--ink); }

.history-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.history-item:last-child { border-bottom: 0; }
.quote-file-summary, .history-item[role="button"] { cursor: pointer; }

.history-item p { margin-top: 4px; }

.noscript { padding: 16px; }

@media (min-width: 560px) {
  .filter-panel { left: auto; width: min(22rem, 100%); }
}

@media (max-width: 800px) {
  .layout { display: block; min-height: 0; }
  .sidebar {
    position: static;
    display: block;
    width: auto;
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 8px 12px 10px;
  }
  .nav-links {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
  }
  .nav-links > a { min-width: 0; }
  .nav-sub {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-direction: row;
    flex-wrap: wrap;
    margin: 0;
    padding: 4px 0 0;
    border-top: 1px solid var(--line);
  }
  .nav-sub a { width: auto; }
  .nav-aux { margin-top: 8px; }
  .identity { margin-top: 8px; }
  main { padding: 16px 12px 28px; }
  .split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 480px) {
  .fields, .summary { grid-template-columns: minmax(0, 1fr); }
  .summary > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .topbar, .sidebar { padding-inline: 10px; }
  main { padding-inline: 10px; }
  h1 { font-size: 1.3rem; }
}

@media (pointer: coarse) {
  .button, .nav-links a, .nav-aux { min-height: 44px; }
  input, select, textarea { font-size: 16px; }
}

.stack { display: grid; gap: 12px; min-width: 0; }

.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 20px;
  margin: 0;
}

.fact-grid div { min-width: 0; }

.fact-grid dt { margin: 0; }

.fact-grid dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.text-view {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
}

.text-frame {
  margin: 8px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  background: var(--soft);
  padding: 12px;
  max-height: 24rem;
  overflow: auto;
}

.text-frame.is-open { max-height: none; overflow: visible; }

.action-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  padding: 10px 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.choice-on { font-weight: 650; }

@media (max-width: 800px) {
  .fact-grid { grid-template-columns: minmax(0, 1fr); }
  .workspace-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .workspace-table,
  .workspace-table tbody,
  .workspace-table tr,
  .workspace-table td { display: block; width: 100%; }
  .workspace-table tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .workspace-table td { border: 0; padding: 4px 0; }
  .workspace-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
  }
}

.banner { margin-bottom: 14px; }

.kv {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 22px;
}

.kv > div { min-width: 0; }

.filter-panel .fields,
.filter-panel .kv { grid-template-columns: minmax(0, 1fr); }

.button[aria-expanded="true"] {
  background: var(--soft);
  border-color: var(--ink);
}

.choice-row, .chip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.chip {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}

.item-block, .group {
  min-width: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.group summary { cursor: pointer; }

.req-list, .plain-list { margin: 8px 0 0; padding-left: 1.2em; }
.plain-list li { margin: 2px 0; }
.prep-table .button { white-space: normal; }
.req-group td { background: var(--soft); font-weight: 600; }
.qty-input { width: 6rem; }

.excerpt {
  max-height: 12rem;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.form-errors { display: grid; gap: 4px; }

.login { max-width: 28rem; }

body { overflow-wrap: break-word; }

.button { white-space: normal; text-align: center; }

.page-head > * { min-width: 0; max-width: 100%; }

.filter-panel { max-height: calc(100vh - 8rem); overflow: auto; }

.scroll-box { max-height: 18rem; overflow: auto; }

.choice-row { align-items: flex-start; }

@media (max-width: 480px) {
  .kv { grid-template-columns: minmax(0, 1fr); }
  .crumb { margin-bottom: 4px; }
  .page-head { margin-bottom: 6px; }
  .page-head p { margin-top: 2px; }
  .tabs { margin-bottom: 8px; }
  .stage-scale { margin: 2px 0 6px; }
  .stage-work { gap: 8px; }
  .kz-jump-bar { padding: 4px 0; gap: 4px 8px; }
}

.stage-scale {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 16px;
}

.stage-step {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 7.5rem;
  max-width: 12rem;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-decoration: none;
  line-height: 1.25;
}

.stage-word {
  color: var(--muted);
  font-size: 0.75rem;
}

.stage-step.is-current {
  border-color: var(--ink);
  font-weight: 650;
}

.stage-step.is-viewing {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.stage-step.is-past { background: var(--soft); }

.stage-step.is-inactive { opacity: 0.72; }

.stage-actions {
  position: sticky;
  top: var(--topbar);
  z-index: 5;
  display: grid;
  gap: 8px;
  padding: 8px 0;
  background: var(--bg);
}

.stage-work { display: grid; gap: 12px; }

.stage-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.stage-card-head { display: grid; gap: 4px; }

.stage-lead { margin: 0; }

.stage-list-action {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 6px;
}

.stage-list-action p { margin: 0; }

.stage-list-action .panel-edit {
  width: 1.5rem;
  height: 1.5rem;
}

.stage-card h2 { margin: 0; }

.stage-status { margin: 0; }

.stage-gate, .stage-doing { display: grid; gap: 8px; }

.stage-doing {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.gate-list { display: grid; gap: 4px; }

.gate-list .is-open { color: var(--open); font-weight: 650; }

.gate-list .is-pending { color: var(--muted); }

.gate-list .is-failed { font-weight: 650; }

.gate-note { margin: 0; }

.stage-moves {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}

.stage-moves-back,
.stage-moves-side,
.stage-moves-within,
.stage-clarify {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.stage-moves-side { margin-left: auto; }

.stage-back::before { content: "←\00a0"; }

.stage-next::after,
.stage-within::after { content: "\00a0→"; }

.stage-card h3 { margin: 0 0 6px; font-size: 0.95rem; }

.stage-card ul { margin: 0; padding-left: 1.2rem; }

.file-picked { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.file-native {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.file-picker {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  max-width: 100%;
}

.file-names { min-width: 0; overflow-wrap: anywhere; }

.kz-jump-bar {
  position: sticky;
  top: var(--topbar);
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  padding: 8px 0;
  background: var(--bg);
}

.kz-jump { display: flex; flex-wrap: wrap; gap: 8px 12px; }

.diagnostics { color: var(--muted); font-size: 0.85rem; }

.file-input { position: relative; }

.file-links { margin: 0; padding-left: 1.2rem; }

.file-input input[type="file"] { padding-right: 2.6rem; }

.file-input .file-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: var(--panel);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 { margin: 0; }

.panel-edit {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.panel-edit:hover { color: var(--ink); }

.icon-button {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  line-height: 1;
}

.quiet-moves { color: var(--muted); }

@media (max-width: 800px) {
  .stage-moves { flex-direction: column-reverse; align-items: stretch; }
  .stage-moves-side { margin-left: 0; flex-direction: column-reverse; align-items: stretch; }
  .stage-next { width: 100%; }
}

.file-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.transition-dialog {
  width: min(28rem, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 16px;
}

.transition-dialog::backdrop { background: #0006; }

.workspace-board td { vertical-align: top; }

@media (max-width: 800px) {
  .sidebar { padding: 6px 10px 8px; }
  .workspace-page .page-head { margin-bottom: 4px; }
  .workspace-page .page-head p { margin-top: 2px; }
  .stage-scale { margin: 4px 0 8px; gap: 4px; }
  .stage-step { min-width: 0; flex: 1 1 4.6rem; padding: 4px 6px; }
  .stage-card { padding: 12px; }
}

.workspace-page .page-head { margin-bottom: 8px; }
.workspace-page h1 { font-size: 1.35rem; }
.workspace-page .toolbar { margin-bottom: 8px; }

.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.matrix-legend > span { display: inline-flex; align-items: center; gap: 6px; }

.matrix-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: clip;
}

.matrix-head, .matrix-row {
  display: grid;
  grid-template-columns: minmax(156px, 1.2fr) 7.6rem minmax(28rem, 2.4fr) minmax(168px, 1.15fr) minmax(176px, 1.25fr);
  column-gap: 12px;
  align-items: center;
}

.matrix-head {
  position: sticky;
  /* Отступ считается от .matrix-scroll, а не от окна: top: var(--topbar) наезжал на первую строку. */
  top: 0;
  z-index: 4;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.2;
  background: var(--bg);
}

.matrix-row {
  min-height: 80px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
}

.matrix-row:hover, .matrix-row:focus-within { background: var(--soft); }

.matrix-project, .matrix-now, .matrix-next { min-width: 0; overflow-wrap: anywhere; }
.matrix-due { min-width: 0; }
.matrix-due-lines { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; max-width: 100%; }
.matrix-due-date, .matrix-due-state { white-space: nowrap; }

.matrix-project { position: sticky; left: 0; z-index: 1; background: var(--bg); }
.matrix-row:hover .matrix-project, .matrix-row:focus-within .matrix-project { background: var(--soft); }
.matrix-head .matrix-project, .matrix-head > span:first-child { position: sticky; left: 0; background: var(--bg); }

.matrix-project .name-link { font-weight: 650; text-decoration: underline; text-underline-offset: 2px; }
.matrix-project .small, .matrix-facts p { margin-top: 2px; }
.matrix-due { font-variant-numeric: tabular-nums; }

.matrix-stages {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: center;
  position: relative;
  min-width: 0;
}

.matrix-row .matrix-stages::before {
  content: "";
  position: absolute;
  left: 7%;
  right: 7%;
  top: 50%;
  height: 1px;
  background: var(--line);
}

.stage-head {
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
}

.stage-short { white-space: nowrap; }

.stage-tip {
  position: fixed;
  z-index: 40;
  max-width: 16rem;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 8px 24px #0002;
  font-size: 0.85rem;
  line-height: 1.3;
  pointer-events: none;
}

.stage-mark {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1;
}

.stage-mark.is-past { background: var(--soft); }
.stage-mark.is-current { background: var(--fill); color: var(--on-fill); border-color: var(--fill); font-weight: 700; }
.stage-mark.is-future { background: var(--panel); }
.stage-mark.is-inactive { background: var(--panel); color: var(--muted); }

.matrix-kicker, .matrix-current-label { display: none; color: var(--muted); font-size: 0.75rem; }
.more-facts { display: inline-block; margin-top: 2px; font-size: 0.84rem; text-decoration: underline; text-underline-offset: 2px; }
.matrix-facts p { user-select: text; }

@media (max-width: 800px) {
  .matrix-head { display: none; }
  .matrix-scroll { overflow: visible; }
  .matrix-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    min-height: 0;
  }
  .matrix-project { position: static; background: transparent; }
  .matrix-current-label, .matrix-kicker { display: block; }
  .matrix-stages { display: flex; gap: 6px; overflow-x: auto; max-width: 100%; }
  .matrix-row .matrix-stages::before { display: none; }
  .stage-mark { flex: 0 0 32px; margin: 0; }
}

.quote-status {
  display: grid;
  gap: 8px;
}
.quote-status article, .version-card, .diary-entry, .task-row {
  min-width: 0;
  overflow-wrap: anywhere;
}
.diary-entry, .version-card, .task-row {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.diary-entry p, .version-card p { white-space: pre-wrap; }
@media (min-width: 768px) {
  .quote-status { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
