:root {
  --ink: #1d2327;
  --muted: #68727d;
  --paper: #fbfaf7;
  --sheet: #ffffff;
  --line: #d7d2c8;
  --line-strong: #9fa7ad;
  --code: #15191d;
  --code-soft: #252b31;
  --blue: #3858e9;
  --blue-soft: #eef2ff;
  --green: #087f5b;
  --green-soft: #e8f7ef;
  --yellow: #f3d55b;
  --yellow-soft: #fff7d4;
  --red: #b42318;
  --red-soft: #fff0ed;
  --teal: #0f766e;
  --radius: 8px;
  --shadow: 0 22px 60px rgba(29, 35, 39, 0.14);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(29, 35, 39, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, #f6f0e5 0, #edf3f0 360px, #f7f7f4 100%);
  background-size: 28px 28px, auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(56, 88, 233, 0.28);
  outline-offset: 2px;
}

.workspace {
  min-height: 100vh;
}

.document-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(210px, 0.8fr) minmax(280px, 1.2fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px clamp(14px, 3vw, 34px);
  background: rgba(251, 250, 247, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.doc-title,
.path-strip,
.header-actions,
.title-row,
.clause-head,
.section-title,
.button-line,
.browser-bar,
.register-head,
.table-actions,
.manager-tabs,
.tree-actions,
.code-head,
.filter-row,
.chip-row {
  display: flex;
  align-items: center;
}

.doc-title {
  min-width: 0;
  gap: 10px;
}

.wp-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  color: #fff;
  background: var(--ink);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line-strong);
  font-family: Georgia, serif;
  font-size: 25px;
  font-weight: 800;
}

.doc-title p,
.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.doc-title h1 {
  margin: 0;
  overflow: hidden;
  font-size: 18px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.path-strip {
  min-width: 0;
  gap: 8px;
}

.path-strip label,
.route-form label,
.inline-clause label,
.settings-grid label,
.search-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.path-strip label {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

input,
select {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.path-strip input {
  padding: 0;
  border: 0;
}

.header-actions {
  justify-content: flex-end;
  gap: 8px;
}

.status,
.doc-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.status.unsaved,
.doc-tag.warning {
  color: #694800;
  background: var(--yellow-soft);
  border-color: #e5c955;
}

.status.saved {
  color: var(--green);
  background: var(--green-soft);
  border-color: #a8dac0;
}

button {
  min-height: 36px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.small-button,
.icon-button,
.quiet,
.primary,
.danger-button,
.table-actions button,
.tree-actions button,
.handoff-card button,
.filter-row button,
.manager-tabs button {
  padding: 8px 11px;
  font-weight: 750;
}

.icon-button {
  width: 36px;
  padding: 0;
}

.primary {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.quiet {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: #c8d1ff;
}

.danger-button,
.danger button {
  color: var(--red);
  background: var(--red-soft);
  border-color: #f0b7ad;
}

.wide {
  width: 100%;
}

.document {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 70px;
}

.paper-section {
  margin: 0 0 18px;
  padding: clamp(16px, 2.6vw, 28px);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.first-fold {
  min-height: calc(100vh - 90px);
}

.section-kicker,
.fact-grid,
.proof-flow,
.clause-grid,
.brief-grid,
.register-table,
.settings-grid,
.file-workbench,
.database-grid,
.logs-grid,
.gallery-layout,
.handoff-grid {
  display: grid;
}

.section-kicker {
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 20px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 750;
}

.brief-grid {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.82fr);
  gap: 18px;
  align-items: stretch;
}

.brief-copy,
.route-row,
.destination,
.paper-section,
.inline-clause,
.register-row,
.manager-panel,
.handoff-card {
  min-width: 0;
}

.title-row,
.section-title,
.clause-head {
  justify-content: space-between;
  gap: 14px;
}

h2,
h3,
p,
dl,
ol,
ul {
  margin-top: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(30px, 5vw, 56px);
  line-height: 1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.paper-section:not(.first-fold) h2 {
  font-size: clamp(24px, 3.6vw, 38px);
}

h3 {
  margin-bottom: 10px;
  font-size: 20px;
  line-height: 1.16;
  overflow-wrap: anywhere;
}

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

.fact-grid div,
.inline-clause,
.evidence-card,
.register-row,
.manager-panel,
.blueprint-detail,
.handoff-card,
.db-notice,
.logs-grid article {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.fact-grid div {
  padding: 11px;
}

dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 4px 0 0;
  font-weight: 750;
}

.proof-flow {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  list-style: none;
}

.proof-flow li {
  min-width: 0;
  padding: 12px;
  background: #f4f5f6;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.proof-flow li.complete {
  background: var(--green-soft);
  border-color: #a8dac0;
}

.proof-flow li.active {
  background: var(--blue-soft);
  border-color: #c8d1ff;
}

.proof-flow strong,
.proof-flow span {
  display: block;
}

.proof-flow span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.evidence-card {
  min-width: 0;
  overflow: hidden;
}

.mini-browser {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--code);
}

.browser-bar {
  justify-content: space-between;
  gap: 10px;
  padding: 9px;
  color: #dbe2e8;
  background: var(--code-soft);
  font-size: 12px;
}

.browser-bar button {
  min-height: 28px;
  padding: 4px 8px;
  color: #fff;
  background: #3b4148;
  border-color: #4a525a;
}

.wp-preview {
  margin: 8px;
  overflow: hidden;
  background: #fff;
  border-radius: 4px;
}

.wp-preview header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  font-size: 12px;
  border-bottom: 1px solid #ececec;
}

.wp-preview nav {
  color: #555;
}

.wp-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 18px;
  align-items: center;
  min-height: 275px;
  padding: 28px 18px;
}

.wp-body h3 {
  font-family: Georgia, serif;
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 500;
}

.wp-body h3 span {
  color: var(--blue);
}

mark {
  background: #fff2a8;
}

.preview-logo {
  display: grid;
  place-items: center;
  width: 154px;
  aspect-ratio: 1;
  color: #111;
  border: 14px solid #30e879;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 82px;
  font-weight: 900;
}

.clause-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
  margin-top: 18px;
}

.inline-clause {
  min-width: 0;
  padding: 16px;
}

.route-list,
.destination-stack,
.button-stack {
  display: grid;
  gap: 8px;
}

.route-list {
  margin: 14px 0;
}

.route-row,
.destination {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 11px 12px;
  text-align: left;
}

.route-row span,
.destination span {
  color: var(--muted);
  font-size: 12px;
}

.route-row.selected,
.destination.selected {
  background: var(--blue-soft);
  border-color: var(--blue);
  box-shadow: inset 4px 0 0 var(--blue);
}

.route-row.danger {
  border-color: #f0b7ad;
}

.route-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #f7f8f8;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.button-line {
  flex-wrap: wrap;
  gap: 8px;
}

.result-line,
.destructive-note,
.action-note {
  padding: 11px 12px;
  color: #3d3420;
  background: var(--yellow-soft);
  border: 1px solid #e5c955;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.45;
}

.save-progress {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 12px;
  background: #f7f8f8;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.save-progress div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  background: #dfe4e8;
  border-radius: 99px;
}

.progress-track span {
  display: block;
  width: 81%;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--teal));
}

.section-title {
  margin-bottom: 16px;
}

.register-table {
  gap: 6px;
}

.register-head,
.register-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 0.65fr) minmax(190px, 0.8fr) auto;
  gap: 12px;
  align-items: center;
}

.register-head {
  padding: 0 12px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.register-row {
  padding: 12px;
}

.register-row.selected {
  border-color: var(--blue);
  box-shadow: inset 4px 0 0 var(--blue);
}

.register-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.table-actions {
  gap: 6px;
}

.destructive-note {
  margin-top: 12px;
}

.manager-tabs {
  gap: 6px;
  padding-bottom: 10px;
  overflow-x: auto;
}

.manager-tabs button {
  white-space: nowrap;
}

.manager-tabs button.active,
.filter-row button.active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.manager-panel {
  display: none;
  padding: 16px;
}

.manager-panel.active {
  display: block;
}

.settings-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.checkline {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  align-content: center;
  min-height: 44px;
  padding: 10px;
  color: var(--ink);
  background: #f7f8f8;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.checkline input {
  width: auto;
}

.file-workbench {
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.file-tree {
  min-width: 0;
  background: #f7f8f8;
  border-right: 1px solid var(--line);
}

.tree-actions {
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.tree-actions button,
.button-stack button {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
}

.file-tree ul {
  margin: 0;
  padding: 8px;
  list-style: none;
}

.file-tree li {
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 13px;
}

.file-tree li.selected {
  background: #fff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.file-tree li.open {
  font-weight: 800;
}

.button-stack {
  padding: 10px;
}

.code-card {
  min-width: 0;
  background: var(--code);
  color: #e9edf2;
}

.code-head {
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--code-soft);
  border-bottom: 1px solid #3c444c;
  font-size: 13px;
}

pre {
  margin: 0;
  overflow: auto;
}

.code-card pre,
.logs-grid pre {
  padding: 14px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.database-grid {
  grid-template-columns: minmax(0, 1fr) minmax(270px, 0.72fr);
  gap: 14px;
}

.db-notice {
  padding: 16px;
  border-left: 4px solid var(--teal);
  background: #ecf8f6;
}

.database-grid dl {
  padding: 0;
  margin: 0;
}

.database-grid dl div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.logs-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.logs-grid article {
  overflow: hidden;
}

.logs-grid strong {
  display: block;
  padding: 10px 12px;
  background: #f7f8f8;
  border-bottom: 1px solid var(--line);
}

.logs-grid pre {
  min-height: 130px;
  color: #dce4ea;
  background: var(--code);
}

.gallery-tools {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.filter-row {
  flex-wrap: wrap;
  gap: 7px;
}

.filter-row button {
  min-height: 32px;
  padding: 6px 10px;
}

.gallery-layout {
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.blueprint-detail {
  position: sticky;
  top: 92px;
  padding: 14px;
}

.detail-shot {
  height: 150px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(56, 88, 233, 0.86), rgba(8, 127, 91, 0.72)),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.35) 0 18px, transparent 18px 38px);
}

.chip-row {
  flex-wrap: wrap;
  gap: 6px;
}

.chip-row span {
  padding: 5px 8px;
  color: #42505c;
  background: #eef0f2;
  border-radius: 999px;
  font-size: 12px;
}

.blueprint-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.blueprint-card {
  display: grid;
  gap: 7px;
  min-height: 112px;
  padding: 11px;
  text-align: left;
  background: #fff;
  border-color: var(--line);
}

.blueprint-card.selected {
  border-color: var(--blue);
  box-shadow: inset 4px 0 0 var(--blue);
}

.blueprint-card strong {
  line-height: 1.2;
}

.blueprint-card small {
  color: var(--muted);
  line-height: 1.35;
}

.handoff-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.handoff-card {
  padding: 16px;
}

.handoff-card.danger {
  background: var(--red-soft);
  border-color: #f0b7ad;
}

@media (max-width: 980px) {
  .document-header {
    grid-template-columns: 1fr auto;
  }

  .path-strip {
    grid-column: 1 / -1;
    order: 3;
  }

  .brief-grid,
  .clause-grid,
  .gallery-layout,
  .database-grid,
  .handoff-grid {
    grid-template-columns: 1fr;
  }

  .blueprint-detail {
    position: static;
  }

  .proof-flow,
  .settings-grid,
  .logs-grid,
  .blueprint-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .register-head,
  .register-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .table-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .document {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

  .document-header {
    position: static;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  .header-actions {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .path-strip {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .path-strip .small-button {
    width: 100%;
  }

  .first-fold {
    min-height: auto;
  }

  .paper-section {
    padding: 14px;
  }

  .section-kicker,
  .title-row,
  .section-title,
  .clause-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .fact-grid,
  .proof-flow,
  .settings-grid,
  .logs-grid,
  .blueprint-list {
    grid-template-columns: 1fr;
  }

  .wp-preview header,
  .wp-body,
  .register-head,
  .register-row,
  .file-workbench {
    grid-template-columns: 1fr;
  }

  .wp-preview header {
    display: grid;
  }

  .preview-logo {
    width: 112px;
    font-size: 58px;
  }

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

  .database-grid dl div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  h2 {
    font-size: clamp(26px, 7.8vw, 31px);
    line-height: 1.04;
  }

  .doc-title h1,
  .route-row strong,
  .destination strong {
    overflow-wrap: anywhere;
    white-space: normal;
  }
}
