:root {
  color-scheme: light;
  --ink: #15201e;
  --ink-soft: #56615e;
  --paper: #fbfaf6;
  --surface: #ffffff;
  --surface-soft: #f3f1ea;
  --line: #dedfd8;
  --line-strong: #c5c9bf;
  --green: #163832;
  --green-light: #e3ece8;
  --accent: #e8783d;
  --accent-dark: #c85926;
  --danger: #b23a37;
  --shadow: 0 22px 55px rgba(26, 41, 37, 0.09);
  --radius-lg: 24px;
  --radius-md: 14px;
  --radius-sm: 9px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(227, 236, 232, 0.9), transparent 26rem),
    var(--paper);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  transform: translateY(-150%);
  padding: 10px 14px;
  border-radius: 8px;
  color: white;
  background: var(--green);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 12px clamp(18px, 4vw, 64px);
  border-bottom: 1px solid rgba(197, 201, 191, 0.72);
  background: rgba(251, 250, 246, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  color: #f6f5ef;
  background: var(--green);
}

.brand-mark svg {
  width: 25px;
  stroke-width: 1.65;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.08rem;
  letter-spacing: -0.025em;
}

.brand small {
  margin-top: 1px;
  color: var(--ink-soft);
  font-size: 0.73rem;
}

.topbar-actions,
.editor-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.button,
.icon-button,
.modal-close,
.text-button,
.row-action {
  border: 0;
  cursor: pointer;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  transition: 160ms ease;
}

.button svg {
  width: 18px;
  height: 18px;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.button-primary {
  color: white;
  background: var(--green);
  box-shadow: 0 8px 18px rgba(22, 56, 50, 0.16);
}

.button-primary:hover {
  background: #214a42;
}

.button-secondary {
  border-color: var(--line-strong);
  background: var(--surface);
}

.button-secondary:hover,
.button-quiet:hover {
  border-color: #aeb5aa;
  background: var(--surface-soft);
}

.button-quiet {
  border-color: transparent;
  background: transparent;
}

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: 4px;
  color: var(--ink-soft);
  font-size: 0.76rem;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4d8a62;
  box-shadow: 0 0 0 4px rgba(77, 138, 98, 0.11);
}

.page-shell {
  width: min(1460px, calc(100% - clamp(28px, 6vw, 96px)));
  margin: 34px auto 48px;
}

.project-card {
  overflow: hidden;
  padding: clamp(24px, 3vw, 42px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.91);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.71rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.title-input {
  width: min(900px, 100%);
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4.2vw, 3.65rem);
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.title-input::placeholder {
  color: #a5aba5;
}

.project-help {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.metadata-grid {
  display: grid;
  grid-template-columns: minmax(150px, 0.75fr) minmax(250px, 1.7fr) minmax(150px, 0.8fr) minmax(110px, 0.55fr);
  gap: 14px;
  margin-top: 30px;
}

.field {
  display: grid;
  gap: 7px;
}

.field > span:first-child {
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 750;
}

.field em {
  color: #8c928e;
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 500;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--ink);
  background: #fdfdfb;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field input,
.field select {
  height: 43px;
  padding: 0 12px;
}

.field select {
  appearance: auto;
  cursor: pointer;
}

.field textarea {
  min-height: 86px;
  padding: 11px 12px;
  resize: vertical;
  line-height: 1.45;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.title-input:focus-visible {
  border-color: #4e7b70;
  box-shadow: 0 0 0 3px rgba(78, 123, 112, 0.13);
}

.title-input:focus-visible {
  border-radius: 4px;
}

.field small {
  color: #808783;
  font-size: 0.71rem;
  line-height: 1.35;
}

.input-suffix {
  display: flex;
  align-items: center;
  overflow: hidden;
  height: 43px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fdfdfb;
}

.input-suffix:focus-within {
  border-color: #4e7b70;
  box-shadow: 0 0 0 3px rgba(78, 123, 112, 0.13);
}

.input-suffix input {
  height: 41px;
  border: 0;
  box-shadow: none !important;
}

.input-suffix > span {
  padding: 0 12px;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 700;
}

.summary-strip {
  display: grid;
  grid-template-columns: minmax(210px, 1.35fr) repeat(4, minmax(115px, 1fr));
  margin: 34px calc(clamp(24px, 3vw, 42px) * -1) calc(clamp(24px, 3vw, 42px) * -1);
  border-top: 1px solid var(--line);
  background: #f6f5f0;
}

.summary-strip > div {
  min-height: 94px;
  padding: 20px clamp(18px, 2.3vw, 32px);
  border-right: 1px solid var(--line);
}

.summary-strip > div:last-child {
  border-right: 0;
}

.summary-strip span,
.summary-strip strong {
  display: block;
}

.summary-strip span {
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 0.71rem;
  font-weight: 700;
}

.summary-strip strong {
  font-size: 1.12rem;
}

.summary-main {
  color: white;
  background: var(--green);
}

.summary-main span {
  color: #bdd0ca;
}

.summary-main strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.68rem;
  letter-spacing: -0.03em;
}

.workspace {
  display: grid;
  grid-template-columns: 295px minmax(0, 1fr);
  min-height: 520px;
  margin-top: 26px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 14px 38px rgba(26, 41, 37, 0.055);
}

.chapter-sidebar {
  padding: 25px 20px;
  border-right: 1px solid var(--line);
  background: #f6f5f0;
}

.section-heading,
.editor-heading,
.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.section-heading h2,
.editor-heading h2,
.modal-heading h2,
.editor-empty h2 {
  margin: 0;
  letter-spacing: -0.025em;
}

.section-heading h2 {
  font-size: 1.12rem;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  color: white;
  background: var(--green);
}

.icon-button svg {
  width: 18px;
}

.chapter-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 22px 0 0;
  list-style: none;
}

.chapter-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 12px;
  transition: 150ms ease;
}

.chapter-entry:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.75);
}

.chapter-entry.is-active {
  border-color: #bfd0ca;
  background: white;
  box-shadow: 0 8px 20px rgba(36, 59, 52, 0.07);
}

.chapter-select {
  min-width: 0;
  padding: 12px 8px 12px 13px;
  border: 0;
  cursor: pointer;
  text-align: left;
  background: transparent;
}

.chapter-select span,
.chapter-select strong,
.chapter-select small {
  display: block;
}

.chapter-select span {
  margin-bottom: 4px;
  color: var(--accent-dark);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
}

.chapter-select strong {
  overflow: hidden;
  font-size: 0.87rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-select small {
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.chapter-entry-actions {
  display: flex;
  padding-right: 6px;
  opacity: 0;
  transition: opacity 150ms ease;
}

.chapter-entry:hover .chapter-entry-actions,
.chapter-entry.is-active .chapter-entry-actions,
.chapter-entry:focus-within .chapter-entry-actions {
  opacity: 1;
}

.row-action {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  color: var(--ink-soft);
  background: transparent;
}

.row-action:hover {
  color: var(--green);
  background: var(--green-light);
}

.row-action.danger:hover {
  color: var(--danger);
  background: #f8e7e5;
}

.row-action svg {
  width: 16px;
  height: 16px;
}

.sidebar-empty,
.items-empty,
.editor-empty {
  text-align: center;
}

.sidebar-empty {
  padding: 42px 12px;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.empty-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  place-items: center;
  border-radius: 14px;
  color: #6c827b;
  background: var(--green-light);
}

.empty-icon svg {
  width: 25px;
}

.text-button {
  padding: 2px;
  color: var(--accent-dark);
  background: transparent;
  font-size: 0.8rem;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.chapter-editor {
  min-width: 0;
  padding: clamp(24px, 3vw, 40px);
}

.editor-empty {
  display: grid;
  min-height: 440px;
  max-width: 530px;
  align-content: center;
  justify-items: center;
  margin: auto;
}

.editor-empty-illustration {
  width: 150px;
  margin-bottom: 20px;
  color: #789087;
}

.editor-empty-illustration svg {
  width: 100%;
  fill: rgba(227, 236, 232, 0.5);
  stroke-width: 1.2;
}

.editor-empty h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 3vw, 2.25rem);
}

.editor-empty > p:not(.eyebrow) {
  max-width: 460px;
  margin: 12px 0 22px;
  color: var(--ink-soft);
  line-height: 1.55;
}

.editor-heading {
  align-items: center;
  padding-bottom: 24px;
}

.chapter-kicker {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
  color: var(--accent-dark);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.code-chip {
  padding: 3px 7px;
  border-radius: 999px;
  color: #4a6760;
  background: var(--green-light);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.64rem;
  letter-spacing: 0;
}

.editor-heading h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 2.7vw, 2.3rem);
}

.editor-heading p {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.editor-heading p strong {
  color: var(--ink);
}

.table-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.items-table th,
.items-table td {
  padding: 14px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.items-table th {
  color: var(--ink-soft);
  background: #f6f5f0;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.items-table th:nth-child(1) { width: 12%; }
.items-table th:nth-child(2) { width: 30%; }
.items-table th:nth-child(3) { width: 8%; }
.items-table th:nth-child(4) { width: 12%; }
.items-table th:nth-child(5) { width: 13%; }
.items-table th:nth-child(6) { width: 15%; }
.items-table th:nth-child(7) { width: 10%; }

.items-table tbody tr:last-child td {
  border-bottom: 0;
}

.items-table tbody tr:hover {
  background: #fdfcf9;
}

.items-table td {
  font-size: 0.83rem;
}

.items-table .numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.item-code {
  color: #4d6b63;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  font-weight: 700;
}

.item-summary {
  display: block;
  overflow: hidden;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-detail-indicator {
  display: block;
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.67rem;
}

.item-source-path {
  color: var(--green);
  font-weight: 650;
}

.item-cell-value,
.item-cell-source {
  display: block;
}

.item-cell-source {
  margin-top: 4px;
  color: #6b7874;
  font-size: 0.65rem;
  font-weight: 650;
  white-space: nowrap;
}

.item-actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
}

.items-empty {
  padding: 56px 20px;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.format-note {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 18px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.format-badge {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: var(--accent);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.format-note strong {
  font-size: 0.86rem;
}

.format-note p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.local-note {
  margin-left: auto;
  color: #68726f;
  font-size: 0.72rem;
  white-space: nowrap;
}

.modal {
  width: min(560px, calc(100% - 28px));
  max-height: calc(100vh - 36px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(17, 31, 27, 0.27);
}

.modal-wide {
  width: min(720px, calc(100% - 28px));
}

.report-dialog {
  width: min(640px, calc(100% - 28px));
}

.report-options {
  grid-template-columns: 1fr;
  gap: 14px;
}

.report-description {
  min-height: 68px;
  padding: 14px 16px;
  border: 1px solid #cfdcd7;
  border-radius: 10px;
  color: #36534c;
  background: var(--green-light);
  font-size: 0.78rem;
  line-height: 1.5;
}

.report-format-description {
  min-height: 20px;
  margin: -5px 0 0;
  color: var(--ink-soft);
  font-size: 0.73rem;
  line-height: 1.45;
}

.modal-item {
  width: min(1180px, calc(100% - 28px));
}

.modal::backdrop {
  background: rgba(14, 29, 25, 0.55);
  backdrop-filter: blur(4px);
}

.modal form {
  padding: 26px;
}

.modal-heading {
  margin-bottom: 24px;
}

.modal-heading h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
}

.modal-close {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  color: var(--ink-soft);
  background: var(--surface-soft);
  font-size: 1.45rem;
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: 0.75fr 1.25fr;
  gap: 17px;
}

.item-form-grid {
  grid-template-columns: 1fr 1fr;
}

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

.field.is-calculated input[readonly] {
  color: #244f45;
  background: var(--green-light);
  font-weight: 750;
}

.item-detail-section {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.detail-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 13px;
}

.detail-title-line {
  display: flex;
  align-items: center;
  gap: 9px;
}

.detail-section-heading h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.015em;
}

.detail-section-heading p {
  max-width: 680px;
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
  line-height: 1.45;
}

.count-badge {
  display: inline-grid;
  min-width: 23px;
  height: 23px;
  padding: 0 7px;
  place-items: center;
  border-radius: 999px;
  color: #365e55;
  background: var(--green-light);
  font-size: 0.68rem;
  font-weight: 800;
}

.button-small {
  min-height: 36px;
  flex: 0 0 auto;
  padding: 7px 11px;
  font-size: 0.76rem;
}

.button-small svg {
  width: 16px;
  height: 16px;
}

.detail-empty {
  padding: 16px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--ink-soft);
  background: #faf9f5;
  font-size: 0.76rem;
  text-align: center;
}

.detail-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
  overscroll-behavior-inline: contain;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.measurement-table {
  min-width: 800px;
}

.component-table {
  min-width: 1090px;
}

.detail-table th,
.detail-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.detail-table th {
  color: var(--ink-soft);
  background: #f6f5f0;
  font-size: 0.63rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.detail-table td {
  background: #fff;
}

.detail-table .numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.detail-table tbody tr:last-child td {
  border-bottom: 1px solid var(--line);
}

.detail-table tfoot th,
.detail-table tfoot td {
  border-bottom: 0;
  color: var(--ink);
  background: #f6f5f0;
  font-size: 0.72rem;
}

.detail-table tfoot th {
  text-align: right;
}

.detail-table output {
  font-weight: 800;
  white-space: nowrap;
}

.detail-readonly,
.detail-base {
  display: block;
  color: var(--ink-soft);
  font-size: 0.7rem;
  line-height: 1.3;
}

.detail-base {
  color: #244f45;
  font-weight: 750;
  text-align: right;
  white-space: normal;
}

.measurement-table th:nth-child(1) { width: 30%; }
.measurement-table th:nth-child(n + 2):nth-child(-n + 5) { width: 12%; }
.measurement-table th:nth-child(6) { width: 14%; }
.measurement-table th:nth-child(7) { width: 8%; }

.component-table th:nth-child(1) { width: 12%; }
.component-table th:nth-child(2) { width: 14%; }
.component-table th:nth-child(3) { width: 7%; }
.component-table th:nth-child(4) { width: 21%; }
.component-table th:nth-child(5) { width: 8%; }
.component-table th:nth-child(6) { width: 10%; }
.component-table th:nth-child(7) { width: 10%; }
.component-table th:nth-child(8) { width: 11%; }
.component-table th:nth-child(9) { width: 7%; }

.detail-input {
  width: 100%;
  height: 34px;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  color: var(--ink);
  background: #fdfdfb;
  font-size: 0.73rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.detail-input:focus {
  border-color: #4e7b70;
  box-shadow: 0 0 0 3px rgba(78, 123, 112, 0.13);
}

.detail-input.numeric-input {
  padding-inline: 5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.detail-input.code-input {
  color: #416259;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
}

.detail-total {
  color: #304b44;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.detail-table .row-action {
  margin-inline: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.toast {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100% - 44px));
  padding: 13px 16px;
  border-radius: 11px;
  color: white;
  background: var(--green);
  box-shadow: 0 16px 38px rgba(14, 29, 25, 0.25);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.42;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  background: #8f302f;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(232, 120, 61, 0.42);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1080px) {
  .save-status {
    display: none;
  }

  .metadata-grid {
    grid-template-columns: 1fr 1.5fr 1fr;
  }

  .field-compact {
    grid-column: 3;
  }

  .summary-strip {
    grid-template-columns: 1.4fr repeat(2, 1fr);
  }

  .summary-strip > div:nth-child(4),
  .summary-strip > div:nth-child(5) {
    min-height: 72px;
    border-top: 1px solid var(--line);
  }

  .summary-strip > div:nth-child(4) {
    grid-column: 2;
  }

  .workspace {
    grid-template-columns: 245px minmax(0, 1fr);
  }

  .editor-heading {
    align-items: flex-start;
  }

  .editor-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .items-table th:nth-child(3),
  .items-table td:nth-child(3) {
    display: none;
  }
}

@media (max-width: 820px) {
  .topbar {
    position: static;
    align-items: flex-start;
    padding: 14px 18px;
  }

  .topbar-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .topbar-actions .button {
    min-height: 38px;
    padding: 7px 10px;
    font-size: 0.78rem;
  }

  .topbar-actions .button-quiet {
    display: none;
  }

  .page-shell {
    width: min(100% - 24px, 720px);
    margin-top: 18px;
  }

  .metadata-grid {
    grid-template-columns: 1fr 1fr;
  }

  .field-wide,
  .field-compact {
    grid-column: auto;
  }

  .summary-strip {
    grid-template-columns: 1fr 1fr;
  }

  .summary-main {
    grid-column: 1 / -1;
  }

  .summary-strip > div {
    min-height: 76px;
    border-top: 1px solid var(--line);
  }

  .summary-strip > div:nth-child(2),
  .summary-strip > div:nth-child(3) {
    border-top: 0;
  }

  .summary-strip > div:nth-child(4) {
    grid-column: auto;
  }

  .workspace {
    display: block;
  }

  .chapter-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chapter-list {
    grid-auto-columns: minmax(210px, 75%);
    grid-auto-flow: column;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
  }

  .chapter-entry {
    scroll-snap-align: start;
  }

  .sidebar-empty {
    padding: 22px 12px 6px;
  }

  .empty-icon {
    display: none;
  }

  .local-note {
    display: none;
  }
}

@media (max-width: 620px) {
  .brand small,
  .topbar-actions .button-secondary svg,
  .topbar-actions .button-primary svg {
    display: none;
  }

  .topbar {
    gap: 12px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .project-card {
    padding: 22px 18px;
    border-radius: 18px;
  }

  .title-input {
    font-size: 2rem;
  }

  .metadata-grid {
    grid-template-columns: 1fr;
  }

  .summary-strip {
    margin: 28px -18px -22px;
  }

  .summary-strip > div {
    padding: 16px 18px;
  }

  .workspace {
    border-radius: 18px;
  }

  .chapter-editor {
    padding: 24px 16px;
  }

  .editor-heading {
    display: block;
  }

  .editor-actions {
    flex-direction: row;
    margin-top: 18px;
  }

  .editor-actions .button {
    flex: 1;
    padding-inline: 10px;
    font-size: 0.75rem;
  }

  .items-table,
  .items-table tbody,
  .items-table tr,
  .items-table td {
    display: block;
    width: 100%;
  }

  .items-table thead {
    display: none;
  }

  .items-table tr {
    position: relative;
    padding: 16px 54px 16px 15px;
    border-bottom: 1px solid var(--line);
  }

  .items-table tbody tr:last-child {
    border-bottom: 0;
  }

  .items-table td {
    padding: 3px 0;
    border: 0;
    text-align: left !important;
  }

  .items-table td:nth-child(3) {
    display: block;
  }

  .items-table td:nth-child(n + 3):nth-child(-n + 6) {
    display: inline-block;
    width: auto;
    margin: 8px 13px 0 0;
    color: var(--ink-soft);
    font-size: 0.74rem;
  }

  .items-table td:nth-child(n + 3):nth-child(-n + 6)::before {
    content: attr(data-label) ": ";
    font-weight: 700;
  }

  .items-table td:last-child {
    position: absolute;
    top: 13px;
    right: 10px;
  }

  .format-note {
    align-items: flex-start;
  }

  .format-note p {
    line-height: 1.45;
  }

  .form-grid,
  .item-form-grid {
    grid-template-columns: 1fr;
  }

  .field-span-2 {
    grid-column: auto;
  }

  .modal form {
    padding: 22px 18px;
  }

  .modal-item {
    width: calc(100% - 12px);
    max-height: calc(100vh - 12px);
    border-radius: 15px;
  }

  .detail-section-heading {
    display: block;
  }

  .detail-section-heading .button-small {
    width: 100%;
    margin-top: 12px;
  }

  .item-detail-section {
    margin-top: 20px;
    padding-top: 19px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
