:root {
  --ink: #f3efe8;
  --muted: #b7aea3;
  --faint: #8c8378;
  --paper: #2c2926;
  --card: #3a3531;
  --raised: #463f3a;
  --line: #524c46;
  --accent: #9ec4e4;
  --accent-soft: #3d4d5c;
  --todo: #9ec4e4;
  --doing: #e2b06a;
  --done: #7dccb4;
  --danger: #e39a9a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 12px 28px rgba(0, 0, 0, 0.18);
  --sans: "Segoe UI", "Helvetica Neue", sans-serif;
  --serif: "Palatino Linotype", Palatino, Georgia, serif;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

button, input, textarea { font: inherit; color: inherit; }

::placeholder { color: var(--faint); }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 28px;
  background: rgba(44, 41, 38, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  flex-direction: column;
  min-width: 148px;
  text-decoration: none;
  color: inherit;
}

.brand strong {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand span {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav {
  display: flex;
  gap: 6px;
}

.sign-out {
  margin-left: auto;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.sign-out:hover { color: var(--ink); }

.login-card {
  width: min(420px, 100%);
  margin: 48px auto 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px 22px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-family: var(--serif);
  font-size: 36px;
  letter-spacing: -0.03em;
  margin: 4px 0 18px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-form input {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.login-form button {
  margin-top: 4px;
  background: var(--raised);
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}

.nav a.is-on,
.nav a:hover {
  color: var(--ink);
  background: var(--raised);
}

.search {
  margin-left: auto;
  width: min(320px, 36vw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
}

.search:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.wrap {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 32px 0 80px;
}

.hero h1, .page-intro h1, .progress-head h1 {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 42px;
  line-height: 1.1;
  margin: 0 0 10px;
}

.lede {
  max-width: 62ch;
  color: var(--muted);
  font-size: 17px;
  margin: 0 0 28px;
}

.host-note {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  background: #35302c;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 28px;
}

.host-note p { margin: 4px 0 0; color: #d6d3d1; font-size: 14px; }
.host-note strong { font-size: 14px; letter-spacing: 0.04em; text-transform: uppercase; }
.host-note code {
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 8px;
  border-radius: 8px;
}

.area-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.area-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
  min-height: 148px;
}

.area-card:hover { border-color: #6e675f; }

.area-card em {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.area-card strong {
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: -0.02em;
}

.area-card span {
  color: var(--muted);
  font-size: 14px;
}

.page-block {
  margin: 0 0 22px 0;
  padding: 0 0 8px 22px;
  border-left: 2px solid #524c46;
}

.page-kicker {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.page-block h2 {
  font-family: var(--serif);
  font-size: 28px;
  margin: 2px 0 4px;
  letter-spacing: -0.02em;
}

.where {
  display: inline-block;
  margin: 0 0 8px;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 7px;
}

.page-block > .summary {
  margin: 0 0 12px;
  color: var(--muted);
  max-width: 70ch;
}

.script {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 0 0 8px;
  box-shadow: var(--shadow);
}

.script-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 12px 14px;
}

.script-toggle:hover { background: var(--raised); }

.chev {
  width: 14px;
  color: var(--faint);
  flex: none;
}

.file {
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 13.5px;
  font-weight: 700;
  flex: none;
  white-space: nowrap;
}

.script-summary {
  color: var(--muted);
  font-size: 14px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.script-body {
  padding: 0 14px 14px 38px;
}

.script-body p { margin: 0 0 8px; }

.script-body h3 {
  margin: 12px 0 4px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.script-body ul { margin: 0; padding-left: 18px; }
.script-body li { margin: 2px 0; }

.affects { display: flex; flex-wrap: wrap; gap: 6px; }

.affects a, .result-meta a {
  text-decoration: none;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 13px;
  font-weight: 650;
}

.child-list {
  margin-top: 8px;
  padding-left: 14px;
  border-left: 2px solid var(--line);
}

.child-list .script { box-shadow: none; }

.results { display: flex; flex-direction: column; gap: 8px; }

.result {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.result:hover { border-color: #6e675f; }

.result-meta { color: var(--muted); font-size: 13px; }

.empty {
  color: var(--muted);
  padding: 24px 0;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
}

.save-state {
  font-size: 13px;
  color: var(--muted);
  min-height: 1.2em;
}

.save-state.is-error { color: var(--danger); }
.save-state.is-ok { color: var(--done); }

.editor-gate {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: -8px 0 18px;
}

.editor-gate input {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.editor-gate button, .editor-state {
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  background: var(--raised);
  color: var(--ink);
}

.editor-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.card.is-readonly { cursor: default; }
.card-read {
  margin: 0;
  min-height: calc(1.4em * 2);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  overflow-wrap: break-word;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: start;
}

.column {
  background: #322e2b;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  min-height: 220px;
}

.column header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 2px 4px;
}

.column h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.column.todo h2 { color: var(--todo); }
.column.doing h2 { color: var(--doing); }
.column.done h2 { color: var(--done); }

.count {
  font-size: 12px;
  color: var(--muted);
  background: var(--raised);
  border-radius: 999px;
  padding: 2px 8px;
}

.cards { display: flex; flex-direction: column; gap: 6px; min-height: 40px; }

.card {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: none;
}

.card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mark {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  flex: none;
}

.mark-spin {
  border-radius: 50%;
  background: conic-gradient(from 0.25turn, transparent 0 55%, var(--doing) 88%, #fff6e8 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
  animation: mark-spin 0.75s linear infinite;
}

.mark-check {
  border-radius: 50%;
  background: rgba(125, 204, 180, 0.16);
  box-shadow: inset 0 0 0 1.5px var(--done);
}

.mark-check::after {
  content: "";
  display: block;
  width: 5px;
  height: 9px;
  margin: 2px 0 0 6px;
  border: solid var(--done);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

@keyframes mark-spin {
  to { transform: rotate(1turn); }
}

.card.is-dragging { opacity: 0.45; }
.cards.is-over { outline: 2px dashed #6e675f; outline-offset: 4px; border-radius: 10px; }

.card-title {
  width: 100%;
  min-width: 0;
  min-height: calc(1.4em * 2);
  box-sizing: border-box;
  border: 0;
  background: transparent;
  padding: 0;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
  resize: none;
  overflow: hidden;
  overflow-wrap: break-word;
}

.card-title:focus { outline: none; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.card-actions button, .adder button, .undo button {
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--raised);
}

.card-actions button:hover, .adder button:hover, .undo button:hover { color: var(--ink); }

.card-actions .remove:hover { color: var(--danger); }

.adder {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.adder input {
  flex: 1;
  border: 1px dashed #6a625a;
  background: transparent;
  border-radius: 10px;
  padding: 8px 10px;
}

.adder input:focus {
  outline: none;
  border-style: solid;
  border-color: var(--accent);
  background: var(--card);
}

.undo {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: #242220;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 8px 8px 14px;
  box-shadow: var(--shadow);
}

.undo button { background: var(--accent-soft); color: var(--ink); }

@media (max-width: 860px) {
  .top { flex-wrap: wrap; padding: 12px 16px; }
  .search { width: 100%; margin-left: 0; }
  .wrap { width: min(100% - 28px, 1120px); }
  .hero h1, .page-intro h1, .progress-head h1 { font-size: 32px; }
  .board { grid-template-columns: 1fr; }
  .script-summary { display: none; }
  .host-note { flex-direction: column; align-items: flex-start; }
}
