:root {
  --ink: #171714;
  --muted: #73736b;
  --line: #d9d9cf;
  --paper: #f5f4ee;
  --surface: #fbfaf6;
  --white: #ffffff;
  --acid: #c9f54a;
  --acid-dark: #a6d628;
  --coral: #ff8d73;
  --lavender: #bca8ff;
  --blue: #82c7ff;
  --shadow: 0 20px 60px rgba(28, 28, 24, 0.14);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(201, 245, 74, 0.11), transparent 26rem),
    var(--paper);
  font-family: "Manrope", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
textarea,
select {
  font: inherit;
}

button,
.canvas-cell,
.sticky-note {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.app-shell {
  max-width: 1680px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 32px 48px;
}

.topbar {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  position: relative;
  display: inline-flex;
  overflow: hidden;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  transform: rotate(-32deg);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 0 50% 0 auto;
  border-right: 1.5px solid var(--ink);
}

.brand-mark span:first-child {
  width: 50%;
  background: var(--acid);
}

.brand-mark span:last-child {
  width: 50%;
  background: var(--ink);
}

.topbar-actions,
.form-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button {
  min-height: 44px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

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

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

.button--primary {
  color: var(--white);
  background: var(--ink);
}

.button--primary:hover {
  background: #34342f;
}

.button--ghost {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.48);
}

.button--ghost:hover {
  border-color: var(--ink);
  background: var(--white);
}

.button--small {
  min-height: 38px;
  padding-inline: 14px;
}

.button--danger {
  color: #b83c2e;
  border-color: #efb8b0;
  background: #fff6f4;
}

.button--danger-solid {
  color: var(--white);
  background: #c8493a;
}

.intro {
  min-height: 255px;
  padding: 52px 0 44px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 48px;
}

.intro-copy {
  max-width: 760px;
}

.eyebrow,
.section-index,
.modal-kicker {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
}

.eyebrow span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--acid-dark);
  box-shadow: 0 0 0 4px rgba(201, 245, 74, 0.3);
}

h1 {
  margin: 14px 0 10px;
  font-size: clamp(44px, 5vw, 76px);
  line-height: 0.98;
  letter-spacing: -0.065em;
}

h1 em {
  color: var(--muted);
  font-family: Georgia, serif;
  font-weight: 400;
}

.intro-copy > p {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.project-meta {
  width: min(520px, 42vw);
  margin: 0;
  display: grid;
  grid-template-columns: 1.15fr 1.1fr 1.35fr 0.65fr;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.project-meta div {
  min-width: 0;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.project-meta div:last-child {
  border-right: 0;
}

.project-meta dt {
  margin-bottom: 7px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.project-meta dd {
  margin: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--acid-dark);
}

.canvas-section {
  padding-top: 22px;
}

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

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

.section-heading h2 {
  margin: 7px 0 0;
  font-size: 24px;
  letter-spacing: -0.04em;
}

.legend {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

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

.legend-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 2px;
}

.legend-dot--hypothesis { background: var(--acid); }
.legend-dot--evidence { background: var(--blue); }
.legend-dot--decision { background: var(--lavender); }

.canvas-board {
  min-height: 730px;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(260px, 1fr)) minmax(215px, 0.82fr);
  overflow: hidden;
  border: 1px solid var(--ink);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(42, 42, 36, 0.06);
}

.canvas-cell {
  min-width: 0;
  min-height: 0;
  padding: 19px;
  position: relative;
  overflow: hidden;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 180ms ease;
}

.canvas-cell:hover {
  background: #fff;
}

.canvas-cell:focus-visible,
.icon-button:focus-visible,
.button:focus-visible,
.sticky-note:focus-visible {
  outline: 3px solid rgba(130, 199, 255, 0.7);
  outline-offset: -3px;
}

.canvas-cell[data-block="partners"] { grid-area: 1 / 1 / 3 / 3; }
.canvas-cell[data-block="activities"] { grid-area: 1 / 3 / 2 / 5; }
.canvas-cell[data-block="resources"] { grid-area: 2 / 3 / 3 / 5; }
.canvas-cell[data-block="value"] { grid-area: 1 / 5 / 3 / 7; }
.canvas-cell[data-block="relationships"] { grid-area: 1 / 7 / 2 / 9; }
.canvas-cell[data-block="channels"] { grid-area: 2 / 7 / 3 / 9; }
.canvas-cell[data-block="segments"] { grid-area: 1 / 9 / 3 / 11; border-right: 0; }
.canvas-cell[data-block="costs"] { grid-area: 3 / 1 / 4 / 6; border-bottom: 0; }
.canvas-cell[data-block="revenue"] { grid-area: 3 / 6 / 4 / 11; border-right: 0; border-bottom: 0; }

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

.cell-number {
  margin-bottom: 7px;
  display: block;
  color: #99998f;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
}

.cell-header h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.cell-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
}

.cell-icon svg {
  width: 17px;
  height: 17px;
}

.cell-description {
  margin: 8px 0 15px;
  color: #929289;
  font-size: 10px;
  line-height: 1.45;
}

.note-stack {
  display: grid;
  gap: 8px;
}

.sticky-note {
  width: 100%;
  padding: 11px 12px 12px;
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 7px 7px 10px 7px;
  color: var(--ink);
  background: var(--acid);
  box-shadow: 0 3px 8px rgba(31, 31, 26, 0.08);
  text-align: left;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.sticky-note::after {
  content: "";
  width: 11px;
  height: 11px;
  position: absolute;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.45);
  clip-path: polygon(100% 0, 0 100%, 100% 100%);
}

.sticky-note:hover {
  z-index: 2;
  transform: translateY(-2px) rotate(-0.3deg);
  box-shadow: 0 7px 15px rgba(31, 31, 26, 0.13);
}

.sticky-note[data-type="evidence"] { background: var(--blue); }
.sticky-note[data-type="decision"] { background: var(--lavender); }

.sticky-note small {
  margin-bottom: 5px;
  display: block;
  font-family: "DM Mono", monospace;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.08em;
  opacity: 0.63;
  text-transform: uppercase;
}

.sticky-note p {
  margin: 0;
  display: -webkit-box;
  overflow: hidden;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.38;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.more-notes {
  width: 100%;
  padding: 5px 0 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.more-notes:hover {
  color: var(--ink);
}

.canvas-footer {
  padding: 12px 2px 0;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.canvas-footer p {
  margin: 0;
}

body.modal-open {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

.modal-backdrop,
.confirm-backdrop {
  padding: 24px;
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(23, 23, 20, 0.58);
  backdrop-filter: blur(8px);
  animation: fade-in 160ms ease both;
}

.modal-backdrop--front {
  z-index: 40;
}

.modal {
  width: min(100%, 930px);
  max-height: min(86vh, 860px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: modal-in 220ms ease both;
}

.modal--note {
  width: min(100%, 610px);
}

.modal-header {
  padding: 28px 30px 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 25px;
  border-bottom: 1px solid var(--line);
}

.modal-header--compact {
  padding-bottom: 24px;
}

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

.modal-header h2 {
  margin: 7px 0 5px;
  font-size: 28px;
  letter-spacing: -0.045em;
}

.modal-header p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease;
}

.icon-button:hover {
  border-color: var(--ink);
  transform: rotate(4deg);
}

.modal-toolbar {
  padding: 16px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
}

.modal-note-grid {
  padding: 28px 30px 34px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.modal-note-grid .sticky-note {
  min-height: 150px;
  padding: 16px;
}

.modal-note-grid .sticky-note p {
  font-size: 14px;
  -webkit-line-clamp: 6;
}

.modal-note-grid .sticky-note small {
  font-size: 9px;
}

.empty-state {
  padding: 70px 30px 84px;
  color: var(--muted);
  text-align: center;
}

.empty-state > span {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border: 1px dashed #aaa99e;
  border-radius: 50%;
}

.empty-state svg {
  width: 24px;
}

.empty-state h3 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 17px;
}

.empty-state p {
  margin: 0;
  font-size: 12px;
}

#note-form {
  padding: 28px 30px 30px;
}

.field {
  margin-bottom: 22px;
  display: block;
}

.field > span,
.fieldset legend {
  margin-bottom: 8px;
  display: block;
  font-size: 12px;
  font-weight: 700;
}

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

.field select {
  height: 48px;
  padding: 0 14px;
}

.field textarea {
  min-height: 134px;
  padding: 14px;
  line-height: 1.5;
  resize: vertical;
}

.field select:focus,
.field textarea:focus {
  border-color: #9ec927;
  box-shadow: 0 0 0 4px rgba(201, 245, 74, 0.22);
}

.field small {
  margin-top: 5px;
  display: block;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  text-align: right;
}

.fieldset {
  padding: 0;
  border: 0;
}

.type-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.type-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-option span {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.type-option i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--acid);
}

.type-option--evidence i { background: var(--blue); }
.type-option--decision i { background: var(--lavender); }

.type-option input:checked + span {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.form-actions {
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
}

.confirm-backdrop {
  z-index: 60;
}

.confirm-card {
  width: min(100%, 390px);
  padding: 30px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
  animation: modal-in 180ms ease both;
}

.confirm-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #b83c2e;
  background: #fee7e2;
}

.confirm-icon svg {
  width: 22px;
}

.confirm-card h2 {
  margin: 0 0 7px;
  font-size: 21px;
}

.confirm-card p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
}

.confirm-card > div {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.toast {
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: 24px;
  border-radius: 999px;
  color: var(--white);
  background: var(--ink);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(15px) scale(0.985); }
}

@media (max-width: 1050px) {
  .intro {
    align-items: flex-start;
    flex-direction: column;
    gap: 30px;
  }

  .project-meta {
    width: 100%;
  }

  .canvas-board {
    min-height: 650px;
    grid-template-rows: repeat(2, minmax(230px, 1fr)) minmax(200px, 0.82fr);
  }

  .canvas-cell {
    padding: 14px;
  }

  .cell-icon {
    width: 29px;
    height: 29px;
  }

  .cell-description {
    display: none;
  }

  .note-stack {
    margin-top: 15px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding-inline: 16px;
  }

  .topbar {
    height: 70px;
  }

  .button {
    min-height: 40px;
    padding-inline: 14px;
  }

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

  .intro {
    min-height: 0;
    padding: 38px 0 32px;
  }

  h1 {
    font-size: 45px;
  }

  .project-meta {
    grid-template-columns: repeat(2, 1fr);
  }

  .project-meta div:nth-child(2) {
    border-right: 0;
  }

  .project-meta div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .legend {
    flex-wrap: wrap;
  }

  .canvas-board {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    gap: 10px;
  }

  .canvas-cell,
  .canvas-cell[data-block] {
    min-height: 210px;
    padding: 18px;
    grid-area: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
  }

  .cell-description {
    display: block;
  }

  .note-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .canvas-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .modal-backdrop,
  .confirm-backdrop {
    padding: 10px;
    align-items: end;
  }

  .modal {
    max-height: 92vh;
    border-radius: 20px 20px 12px 12px;
  }

  .modal-header,
  .modal-toolbar,
  #note-form {
    padding-left: 20px;
    padding-right: 20px;
  }

  .modal-note-grid {
    padding: 20px;
    grid-template-columns: 1fr 1fr;
  }

  .type-options {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 470px) {
  .brand {
    font-size: 18px;
  }

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

  .button span[data-icon] {
    display: none;
  }

  .note-stack,
  .modal-note-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column-reverse;
    gap: 10px;
  }

  .form-actions-right {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
  }
}

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