:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --bg-soft: #ebeef3;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --surface-raised: #ffffff;
  --border: rgba(23, 28, 38, 0.11);
  --border-strong: rgba(23, 28, 38, 0.18);
  --text: #151821;
  --muted: #687083;
  --muted-strong: #40485a;
  --blue: #2f6fed;
  --green: #2a9d6f;
  --orange: #d97706;
  --red: #d44848;
  --purple: #7c5cff;
  --shadow: 0 18px 45px rgba(22, 28, 45, 0.12), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  --shadow-soft: 0 10px 28px rgba(22, 28, 45, 0.08);
  --radius: 18px;
  --radius-sm: 11px;
  --chrome: rgba(255, 255, 255, 0.72);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "ss01";
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1117;
  --bg-soft: #171a23;
  --surface: rgba(28, 31, 41, 0.78);
  --surface-solid: #1b1e28;
  --surface-raised: #222632;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f2f4f8;
  --muted: #9aa3b5;
  --muted-strong: #c4cad6;
  --blue: #7ba7ff;
  --green: #5cc99a;
  --orange: #ffb45a;
  --red: #ff7777;
  --purple: #a591ff;
  --shadow: 0 22px 55px rgba(0, 0, 0, 0.42), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --shadow-soft: 0 14px 34px rgba(0, 0, 0, 0.28);
  --chrome: rgba(17, 19, 27, 0.72);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), transparent 280px),
    radial-gradient(circle at 20% -10%, rgba(47, 111, 237, 0.13), transparent 32rem),
    radial-gradient(circle at 88% 8%, rgba(42, 157, 111, 0.10), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow-x: hidden;
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at 18% -8%, rgba(123, 167, 255, 0.15), transparent 32rem),
    radial-gradient(circle at 88% 8%, rgba(92, 201, 154, 0.10), transparent 28rem),
    var(--bg);
}

button,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.sf {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.app-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(190px, auto) minmax(260px, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--chrome);
  backdrop-filter: blur(22px) saturate(1.25);
}

.app-top > * {
  min-width: 0;
}

.brand,
.actions,
.brand > div,
.card-top,
.project-title > div,
.drawer-panel button,
.dialog-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 11px;
  min-width: 0;
}

.brand-dot,
.column-icon,
.project-orb,
.icon-btn,
.drag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-dot {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: white;
  background: linear-gradient(145deg, var(--blue), #5aa4ff);
  box-shadow: var(--shadow-soft);
}

.brand h1,
.brand p,
.project-title h2,
.project-title p {
  margin: 0;
}

.brand > div {
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
}

.brand h1 {
  font-size: 17px;
  line-height: 1.1;
  font-weight: 700;
}

.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.header-projects {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-solid) 68%, transparent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.42) inset;
  overflow-x: auto;
  scrollbar-width: none;
}

.header-projects::-webkit-scrollbar {
  display: none;
}

.header-projects button {
  border: 0;
  border-radius: 999px;
  padding: 6px 10px 6px 7px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

.header-projects .project-orb {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  font-size: 11px;
}

.header-projects button span {
  display: grid;
}

.header-projects button small {
  display: none;
}

.header-projects button.selected {
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

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

.btn,
.icon-btn,
dialog button {
  border: 1px solid var(--border);
  background: var(--surface-solid);
  border-radius: 999px;
  min-height: 36px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
}

.btn.primary {
  border-color: color-mix(in srgb, var(--blue) 50%, transparent);
  color: white;
  background: linear-gradient(180deg, color-mix(in srgb, var(--blue) 88%, white), var(--blue));
}

.icon-btn {
  width: 38px;
  height: 38px;
  color: var(--muted-strong);
}

.icon-btn.danger,
.card-action {
  color: var(--red);
}

.btn:hover,
.icon-btn:hover,
.header-projects button:hover,
dialog button:hover {
  transform: translateY(-1px);
}

.menu-btn {
  display: none;
}

.banner {
  margin: 18px auto 0;
  max-width: 1440px;
  width: calc(100% - 48px);
  padding: 11px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--muted-strong);
  background: var(--surface);
}

.workspace {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  padding: 26px 0 56px;
}

.workspace > *,
.project-board,
.project-shell {
  min-width: 0;
}

.project-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(250px, 1fr));
  gap: 16px;
  min-height: 620px;
}

.board-column {
  display: flex;
  flex-direction: column;
  min-height: 560px;
  max-height: calc(100vh - 260px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.board-column header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 15px 15px 13px;
  border-bottom: 1px solid var(--border);
}

.column-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 12%, transparent);
}

.board-column:nth-child(1) .column-icon { color: var(--red); background: color-mix(in srgb, var(--red) 12%, transparent); }
.board-column:nth-child(3) .column-icon { color: var(--orange); background: color-mix(in srgb, var(--orange) 14%, transparent); }
/* "Recent" (Last touched) is a thin state log — de-emphasized vs the work columns. */
.board-column:nth-child(4) .column-icon { color: var(--muted); background: color-mix(in srgb, var(--muted) 12%, transparent); }
.board-column:nth-child(4) .task-card p { color: var(--muted-strong); }

.board-column h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 760;
  letter-spacing: 0;
}

.board-column header strong {
  min-width: 28px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted-strong);
  text-align: center;
  font-size: 12px;
}

.column-scroll {
  flex: 1;
  overflow: auto;
  padding: 10px;
  scrollbar-width: thin;
}

.task-card {
  margin: 0 0 10px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-raised);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset, 0 7px 18px rgba(20, 26, 40, 0.06);
}

:root[data-theme="dark"] .task-card {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 9px 22px rgba(0, 0, 0, 0.2);
}

.task-card[draggable="true"] {
  cursor: grab;
}

.task-card.dragging {
  opacity: 0.45;
  transform: rotate(1deg) scale(0.99);
}

.board-column.is-over {
  outline: 2px solid color-mix(in srgb, var(--blue) 45%, transparent);
  outline-offset: -6px;
}

.task-card.is-flagged {
  border-color: color-mix(in srgb, var(--orange) 36%, var(--border));
}

.card-top {
  gap: 7px;
  flex-wrap: wrap;
}

.drag {
  width: 20px;
  height: 20px;
  color: var(--muted);
}

.drag .sf {
  width: 16px;
  height: 16px;
  stroke-width: 2.4;
}

.project-label,
.micro {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted-strong);
  background: var(--bg-soft);
  white-space: nowrap;
}

.micro {
  color: var(--muted);
  font-weight: 650;
}

.micro.idea { color: var(--green); }
.micro.decide { color: var(--orange); }

.alert {
  margin-left: auto;
  color: var(--orange);
}

.card-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-solid);
  cursor: pointer;
}

.alert + .card-action {
  margin-left: 0;
}

.card-action .sf {
  width: 14px;
  height: 14px;
}

.alert .sf {
  width: 17px;
  height: 17px;
}

.task-card p {
  margin: 10px 0 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.empty {
  margin: 0;
  padding: 18px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-solid) 50%, transparent);
}

/* Ideas / Open questions — the "overarching thinking" pane under each board. */
.project-thinking {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

html[data-focus="1"] .project-thinking {
  display: none;
}

.thinking-col {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-solid);
  overflow: hidden;
}

.thinking-col header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 15px 15px 13px;
  border-bottom: 1px solid var(--border);
}

.thinking-col:nth-child(1) .column-icon { color: var(--green); background: color-mix(in srgb, var(--green) 13%, transparent); }
.thinking-col:nth-child(2) .column-icon { color: var(--orange); background: color-mix(in srgb, var(--orange) 14%, transparent); }

.thinking-col h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 760;
}

.thinking-col header strong {
  min-width: 28px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted-strong);
  text-align: center;
  font-size: 12px;
}

.thinking-list {
  list-style: none;
  margin: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.thinking-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.thinking-item .micro {
  flex: 0 0 auto;
  margin-top: 1px;
}

.thinking-item > span:last-child {
  overflow-wrap: anywhere;
}

.thinking-col .empty {
  margin: 12px;
}

.project-orb {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  color: white;
  background: linear-gradient(145deg, #29384f, #5c6f91);
  font-size: 17px;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
  flex: 0 0 auto;
}

.project-title p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.raw-link {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dotted var(--border-strong);
}

.raw-link:hover {
  color: var(--text);
}

.project-title .project-tagline {
  margin-top: 6px;
  color: var(--muted-strong);
  font-size: 14px;
  font-style: italic;
  max-width: 64ch;
}

.project-shell {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* Overview is the default landing; the project board is the drill-down. */
.project-shell { display: none; }
html[data-view="project"] .overview { display: none; }
html[data-view="project"] .project-shell { display: block; }

.project-shell-top {
  padding: 14px 16px 0;
}

.overview {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.overview-header {
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.overview-header-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.overview-header-top > span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.overview-header-name {
  font-size: 22px;
  font-weight: 650;
}

.overview-header-tagline {
  margin-top: 2px;
  color: var(--muted-strong);
  font-style: italic;
  font-size: 14px;
}

.overview-header .overview-focus {
  margin-top: 16px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.overview-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease;
}

.overview-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.overview-card-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.overview-card-name {
  font-size: 16px;
  font-weight: 650;
}

.overview-card-tagline {
  color: var(--muted-strong);
  font-style: italic;
  font-size: 13px;
}

.overview-card .sep {
  color: var(--muted);
}

.overview-focus {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.overview-focus li {
  position: relative;
  padding-left: 18px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}

.overview-focus li::before {
  content: "\25B8";
  position: absolute;
  left: 0;
  color: var(--muted);
}

.overview-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.drawer-panel button {
  width: 100%;
  gap: 10px;
  margin: 0 0 8px;
  padding: 9px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.drawer-panel .project-orb {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  font-size: 14px;
}

.drawer-panel span {
  display: grid;
  min-width: 0;
}

.drawer-panel strong,
.drawer-panel small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-panel small {
  color: var(--muted);
  font-size: 11px;
}

.drawer-panel button.selected,
.drawer-panel button:hover {
  border-color: var(--border);
  background: var(--surface-solid);
}

.drawer-panel .drawer-action {
  border-color: var(--border);
  background: color-mix(in srgb, var(--blue) 9%, var(--surface-solid));
}

.project-drawer[hidden] {
  display: none;
}

.project-drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.32);
  cursor: default;
}

.drawer-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(330px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
}

.project-main {
  padding: 22px;
  overflow: auto;
}

.project-panel {
  display: none;
}

.project-panel.is-active {
  display: block;
}

.project-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.project-title > div {
  gap: 12px;
  min-width: 0;
}

.project-title h2 {
  font-size: 26px;
  line-height: 1.05;
}

.project-title-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

dialog {
  width: min(500px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(10px);
}

dialog form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

dialog h3 {
  margin: 0;
  font-size: 20px;
}

dialog label {
  display: grid;
  gap: 7px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.capture-types {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.capture-types legend {
  grid-column: 1 / -1;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.capture-types label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 760;
  text-transform: none;
  cursor: pointer;
}

.capture-types input {
  width: 0;
  height: 0;
  opacity: 0;
  position: absolute;
}

.capture-types label:has(input:checked) {
  border-color: color-mix(in srgb, var(--blue) 42%, var(--border));
  background: color-mix(in srgb, var(--blue) 13%, var(--surface-solid));
  color: var(--text);
}

dialog input,
dialog select,
dialog textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
  color: var(--text);
  padding: 11px 12px;
  resize: vertical;
}

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

dialog button {
  padding: 8px 14px;
  font-weight: 700;
}

.hint {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.hint.ok { color: var(--green); }
.hint.error { color: var(--red); }

html[data-focus="1"] .board-column:nth-child(4),
html[data-focus="1"] .project-title {
  display: none;
}

html[data-focus="1"] .workspace {
  padding-top: 18px;
}

html[data-focus="1"] .project-board {
  grid-template-columns: repeat(3, minmax(260px, 1fr));
}

@media (max-width: 1180px) {
  .app-top {
    grid-template-columns: minmax(180px, 1fr) auto;
  }

  .header-projects {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .actions {
    justify-self: end;
  }

  .project-board,
  html[data-focus="1"] .project-board {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }

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

@media (max-width: 720px) {
  html, body {
    font-size: 14px;
  }

  .app-top {
    padding: 12px;
    gap: 12px;
    grid-template-columns: 1fr auto;
  }

  .brand {
    width: 100%;
  }

  .brand p {
    display: none;
  }

  .header-projects {
    display: none;
  }

  .menu-btn {
    display: inline-flex;
  }

  .actions {
    width: auto;
    justify-content: flex-end;
  }

  .actions .btn {
    display: none;
  }

  .actions [data-action="toggle-theme"] {
    display: none;
  }

  .workspace,
  .banner {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }

  .project-board,
  html[data-focus="1"] .project-board {
    grid-template-columns: 1fr;
    overflow: hidden;
  }

  .project-thinking {
    grid-template-columns: 1fr;
  }

  .board-column {
    width: 100%;
    max-width: calc(100vw - 56px);
    min-height: 260px;
    max-height: none;
  }

  .project-title {
    flex-wrap: wrap;
    min-width: 0;
    overflow: hidden;
  }

  .project-title > div {
    flex: 1 1 100%;
  }

  .project-title-actions {
    width: 100%;
  }

  .project-title-actions .btn {
    flex: 0 0 calc(100vw - 80px);
    min-width: 0;
    max-width: calc(100vw - 80px);
  }

  .project-main {
    padding: 14px;
  }
}
