:root {
  color-scheme: dark;
  --background: #101014;
  --panel: #191920;
  --raised: #23232e;
  --text: #e8e8ef;
  --muted: #b1b1c3;
  --soft: #9292a6;
  --accent: #b6a1f4;
  --accent-text: #21182e;
  --accent-panel: #30273f;
  --complete: #91beb6;
  --warning: #d9a285;
  --error: #e9a1ad;
  --line: #3b3b4b;
  --outline: #747489;
  --space: 24px;
  --nav-height: 68px;
  --content-width: 1224px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }
button, select { color: inherit; }
a { color: var(--accent); text-underline-offset: .18em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
svg { flex: none; width: 18px; height: 18px; }
h1, h2, h3 { margin: 0 0 10px; font-weight: 550; line-height: 1.35; overflow-wrap: anywhere; }
h1 { font-size: 29px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0 0 12px; overflow-wrap: anywhere; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 9px 0 18px; padding-inline-start: 24px; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; background: var(--background); padding: 12px; border-radius: 6px; }
blockquote { margin: 0 0 18px; padding: 10px 15px; border-inline-start: 3px solid var(--accent); background: var(--background); overflow-wrap: anywhere; }
progress { accent-color: var(--complete); }
summary { cursor: pointer; padding-block: 9px; }
.preserve { white-space: pre-wrap; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.accent-warn { color: var(--warning); }

.app-shell { display: flex; flex-direction: column; min-height: 100dvh; }
.app-header { border-bottom: 1px solid var(--line); }
.header-inner { max-width: calc(var(--content-width) + var(--space) * 2); margin-inline: auto; padding: 7px var(--space); min-height: 65px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: inline-flex; align-items: center; gap: 11px; min-height: 44px; color: var(--text); text-decoration: none; font-size: 19px; font-weight: 600; white-space: nowrap; }
.brand-mark { display: inline-grid; place-items: center; width: 37px; height: 37px; border: 1px solid #6f5f99; border-radius: 9px; color: var(--accent); background: var(--accent-panel); flex: none; }
.brand-mark svg { width: 21px; height: 21px; }
.brand-mark.large { width: 54px; height: 54px; border-radius: 13px; margin-bottom: 14px; }
.brand-mark.large svg { width: 29px; height: 29px; }
.connection { display: flex; min-width: 0; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); }
.connection-state, .warn { color: var(--warning); }
.last-sync { white-space: nowrap; }

main { flex: 1; width: 100%; max-width: calc(var(--content-width) + var(--space) * 2); margin-inline: auto; padding: 26px var(--space) calc(var(--nav-height) + 34px + env(safe-area-inset-bottom)); }
.page-head, .section-head, .row, .dialog-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.page-head { margin-bottom: 17px; }
.page-head h1, .section-head h2, .dialog-head h2 { margin: 0; }
.section-head { margin-bottom: 12px; }
.actions { display: flex; min-width: 0; flex-wrap: wrap; align-items: center; gap: 8px; }
.section-toolbar { margin-block: 12px 18px; }
.row { padding-block: 9px; border-top: 1px solid var(--line); }
.row > span { min-width: 0; overflow-wrap: anywhere; }

.button, .segmented button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-width: 0; min-height: 44px; padding: 7px 12px;
  background: transparent; color: var(--muted); border: 1px solid var(--outline);
  border-radius: 6px; text-decoration: none; text-align: center; line-height: 1.35;
  overflow-wrap: anywhere;
}
.button:hover, .segmented button:hover { color: var(--text); border-color: var(--accent); background: var(--accent-panel); }
.button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 650; }
.button.primary:hover { background: #c8b8f7; color: var(--accent-text); }
.button.text-button { border-color: transparent; color: var(--muted); padding-inline: 8px; }
.button.icon-button { padding-inline: 9px; min-width: 44px; }
.connection .button { border-color: transparent; }
.button.need-action { justify-content: space-between; color: var(--text); width: 100%; margin-top: 7px; }

.overview { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.goal-card, .need-card, .section-panel, .note, .login-card {
  min-width: 0; padding: 21px 23px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.goal-card { border-inline-start: 3px solid var(--accent); }
.need-card { border-inline-start: 3px solid var(--warning); }
.eyebrow { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--accent); margin-bottom: 8px; }
.need-card .eyebrow { color: var(--warning); }
.eyebrow span { color: var(--muted); margin-inline-start: 6px; }
.goal-card h2 { font-size: 26px; }
.goal-footer { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.goal-meter { width: min(100%, 400px); }
.goal-meter > .muted { display: block; margin-top: 3px; font-size: 13px; }
.meter { width: 100%; min-width: 0; }
.meter > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.meter > div span { color: var(--muted); font-size: 13px; }
.meter strong { color: var(--text); font-size: 23px; font-weight: 530; font-variant-numeric: tabular-nums; }
.meter progress, .meter-unknown { display: block; appearance: none; height: 4px; width: 100%; border: 0; border-radius: 5px; background: var(--line); overflow: hidden; }
.meter progress::-webkit-progress-bar { background: var(--line); }
.meter progress::-webkit-progress-value { background: var(--complete); }
.meter progress::-moz-progress-bar { background: var(--complete); }
.status-badge { display: inline-flex; align-items: center; min-height: 26px; max-width: 100%; padding: 2px 8px; color: var(--muted); background: var(--raised); border-radius: 4px; font-size: 13px; overflow-wrap: anywhere; }
.status-badge.complete { color: var(--complete); background: #21342f; }
.priority-badge { color: var(--warning); }

.projects-section { margin-block-start: 27px; }
.project-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.project-card { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 16px 17px 9px; }
.project-card.parent-card { grid-column: 1 / -1; padding-inline-start: 21px; border-inline-start: 3px solid #76678e; background: #1e1e26; }
.project-body { display: grid; grid-template-columns: minmax(0, 1fr); }
.parent-card .project-body { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 22px; align-items: end; }
.project-copy { min-width: 0; }
.project-copy p { margin-bottom: 8px; color: var(--muted); }
.project-title { display: flex; min-height: 44px; justify-content: space-between; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.project-title:hover { color: var(--accent); }
.project-title svg { color: var(--muted); width: 15px; height: 15px; }
.project-badges { min-height: 32px; display: flex; flex-wrap: wrap; gap: 5px; align-items: start; }
.parent-card .project-badges { justify-content: end; }
.project-actions { min-width: 0; display: flex; justify-content: flex-end; gap: 4px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 5px; margin-top: 10px; }
.project-actions .button { border-color: transparent; padding-inline: 6px; font-size: 13px; }
.priority-list { padding-inline-start: 24px; }
.priority-list li { padding: 9px 0; border-top: 1px solid var(--line); }
.priority-list li li { padding: 0; border: 0; }
.priority-prerequisites { color: var(--warning); font-size: 14px; }
.priority-prerequisites ul { margin-bottom: 7px; }
.priority-row { display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.priority-row > div:first-child { display: grid; min-width: 0; overflow-wrap: anywhere; }
.priority-row .button { min-width: 44px; }
.priority-scope { color: var(--muted); font-size: 13px; }
.project-updated { min-width: 0; margin-inline-end: auto; align-self: center; color: var(--soft); font-size: 12px; }

#navigation { position: fixed; inset: auto 0 0; z-index: 3; min-height: var(--nav-height); padding-bottom: env(safe-area-inset-bottom); background: var(--background); border-top: 1px solid var(--line); }
.nav-inner { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; max-width: calc(var(--content-width) + var(--space) * 2); margin-inline: auto; padding: 7px var(--space); }
.nav-inner a { display: flex; min-height: 52px; gap: 4px; flex-flow: column; align-items: center; justify-content: center; color: var(--muted); text-decoration: none; border-radius: 5px; font-size: 13px; }
.nav-inner a:hover { background: var(--panel); color: var(--text); }
.nav-inner a[aria-current="page"] { color: var(--accent); background: var(--accent-panel); }
.mobile-nav { display: none; }

.loading, .empty { padding: 19px 21px; margin: 10px 0; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow-wrap: anywhere; }
.login-card { max-width: 450px; margin: clamp(12px, 8vh, 100px) auto 0; padding: clamp(19px, 4vw, 32px); }
.login-card h1 { font-size: 26px; }
.login-card .form { margin-top: 20px; }
.section-panel { margin-top: 17px; }
.section-panel > .meter { max-width: 400px; margin-block: 8px 16px; }
.form { display: grid; min-width: 0; gap: 8px; }
.form .actions { margin-top: 6px; }
.form label { color: var(--muted); }
.form textarea, .form input:not([type=checkbox]), select {
  min-width: 0; min-height: 44px; padding: 8px 11px; border: 1px solid var(--outline);
  background: var(--background); color: var(--text); border-radius: 5px;
}
.form input::placeholder, .form textarea::placeholder { color: var(--soft); }
.form textarea { width: 100%; resize: vertical; }
.form input[type=file] { width: 100%; }
.form fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 5px; margin: 0; padding: 0 10px 3px; }
.form .check { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px; overflow-wrap: anywhere; }
.goal-scope + .goal-scope { border-top: 1px solid var(--line); }
.form .goal-criterion { margin-inline-start: 18px; }
.form .check input { min-width: 17px; min-height: 17px; accent-color: var(--accent); }
.form-status { color: var(--error); }
.form-status:empty { display: none; }
.filter { display: flex; align-items: center; gap: 10px; }
.discussion-form { margin-top: 14px; }
.note { padding: 12px; margin-block: 9px; background: var(--background); }
.note p { white-space: pre-wrap; }
.note-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 11px; margin-bottom: 7px; }
.note-head time { color: var(--soft); font-size: 12px; }
.note-status { color: var(--accent); font-size: 13px; }
.quoted { margin-bottom: 8px; border-left: 2px solid var(--outline); padding-left: 8px; color: var(--muted); overflow-wrap: anywhere; }
.note .button { border-color: transparent; }
.bible-section { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line); }
.bible-section .actions:not(:empty) { margin-top: 14px; }

.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px; margin-bottom: 7px; }
.breadcrumbs a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); }
.breadcrumbs svg { width: 14px; }
.map-section { margin-top: 23px; }
.map-head { align-items: flex-start; }
.segmented { display: inline-flex; border: 1px solid var(--line); padding: 2px; border-radius: 6px; }
.segmented button { border: 0; color: var(--muted); }
.segmented button[aria-pressed=true] { color: var(--accent); background: var(--accent-panel); }
.map-canvas {
  height: clamp(370px, 54vh, 650px); position: relative; overflow: hidden;
  border: 1px solid var(--line); border-radius: 8px; background: #14141a;
  background-image: radial-gradient(#2f2e3b 1px, transparent 1px); background-size: 24px 24px;
  touch-action: pan-y; cursor: grab;
}
.map-canvas.moving, .map-canvas .node-handle { touch-action: none; }
.map-canvas.dragging { cursor: grabbing; }
.map-stage { position: absolute; inset: 0 auto auto 0; transform-origin: 0 0; }
.map-stage .map-lines { position: absolute; width: 1px; height: 1px; overflow: visible; pointer-events: none; stroke: var(--outline); stroke-width: 1.4px; fill: none; }
.map-lines .dependency-line { stroke: var(--warning); stroke-dasharray: 5 4; }
.map-node { position: absolute; width: 190px; height: 74px; }
.map-node-main { display: flex; align-items: center; gap: 9px; width: 100%; height: 100%; padding: 11px 21px 11px 10px; text-align: start; background: var(--panel); border: 1px solid var(--outline); border-radius: 6px; color: var(--text); }
.map-node.current .map-node-main, .map-node-main:hover { color: var(--text); background: var(--accent-panel); border-color: var(--accent); }
.map-node-content { display: grid; gap: 2px; min-width: 0; }
.map-node-content strong, .map-node-content small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-node-content small { font-size: 13px; color: var(--muted); }
.map-ring { display: inline-grid; flex: none; place-items: center; width: 36px; height: 36px; font-size: 12px; border: 1px solid var(--outline); border-radius: 100%; color: var(--muted); font-variant-numeric: tabular-nums; }
.map-ring.complete { color: var(--complete); border-color: var(--complete); }
.node-marker { position: absolute; top: -22px; right: 0; color: var(--accent); font-size: 12px; }
.node-fold, .node-handle { position: absolute; display: grid; place-items: center; background: var(--raised); border: 1px solid var(--outline); border-radius: 4px; color: var(--muted); }
.node-fold { left: calc(50% - 19px); bottom: -21px; min-width: 38px; height: 33px; }
.node-handle { right: -13px; top: 17px; width: 30px; height: 40px; cursor: move; }
.node-fold:hover, .node-handle:hover { border-color: var(--accent); color: var(--accent); }
.node-fold svg, .node-handle svg { width: 15px; height: 15px; }
.map-controls { display: flex; justify-content: space-between; align-items: start; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
[data-zoom-level] { color: var(--muted); font-size: 13px; min-width: 37px; text-align: center; font-variant-numeric: tabular-nums; }

dialog {
  width: min(94vw, 620px); max-height: calc(100dvh - 38px);
  padding: 0; color: var(--text); background: var(--panel);
  border: 1px solid var(--outline); border-radius: 12px; overscroll-behavior: contain;
}
dialog::backdrop { background: #08080bbf; }
.dialog-content { padding: 19px 22px 22px; }
.dialog-head { align-items: flex-start; gap: 10px; flex-wrap: nowrap; margin-bottom: 10px; }
.dialog-head h2 { flex: 1; padding-top: 7px; }
.dialog-section { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.notice {
  position: fixed; inset: auto var(--space) calc(var(--nav-height) + 12px + env(safe-area-inset-bottom)) auto;
  max-width: min(460px, calc(100% - var(--space) * 2)); z-index: 5; display: none;
  padding: 9px 14px; color: var(--text); background: var(--raised); border: 1px solid var(--outline); border-radius: 6px;
  overflow-wrap: anywhere; pointer-events: none;
}
.notice.visible { display: block; }
.notice.error { color: var(--error); }

@media (max-width: 600px) {
  :root { --space: 16px; --nav-height: 66px; }
  body { font-size: 16px; }
  main { padding-top: 18px; }
  .header-inner { min-height: 58px; padding-top: 5px; padding-bottom: 5px; }
  .connection { gap: 4px; }
  .last-sync { max-width: 94px; white-space: normal; font-size: 11px; line-height: 1.2; }
  .connection .button span { font-size: 13px; }
  .brand { font-size: 18px; gap: 7px; }
  .brand-mark { width: 33px; height: 33px; }
  h1 { font-size: 24px; }
  h2 { font-size: 19px; }
  .goal-card h2 { font-size: 23px; }
  .goal-card, .need-card, .section-panel { padding: 15px; }
  .goal-footer { align-items: start; flex-flow: column; }
  .goal-meter { width: 100%; }
  .project-card { padding: 11px 12px 6px; }
  .project-card.parent-card { padding-inline-start: 13px; }
  .parent-card .project-body { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .parent-card .project-badges { justify-content: start; }
  .project-updated { display: block; flex: 0 0 100%; align-self: flex-start; }
  .project-actions .button { font-size: 14px; }
  .projects-section { margin-block-start: 20px; }
  .desktop-nav { display: none; }
  .mobile-nav { display: grid; padding-inline: 9px; }
  .nav-inner a { min-height: 51px; }
  .form textarea, .form input:not([type=checkbox]), select { font-size: 16px; }
  .map-canvas { height: min(53dvh, 480px); min-height: 315px; }
  .map-head .actions { gap: 5px; }
  .map-controls .actions { gap: 5px; }
  .node-fold { height: 50px; width: 50px; bottom: -31px; left: calc(50% - 25px); }
  .node-handle { width: 50px; height: 50px; top: 12px; right: -26px; }
  .node-fold:focus-visible { outline-offset: 1px; }
  .map-node-main { padding-right: 28px; }
  dialog { width: 100%; max-width: 100%; max-height: calc(100dvh - 15px); margin: auto 0 0; border-radius: 13px 13px 0 0; }
  .dialog-content { padding: 13px var(--space) calc(18px + env(safe-area-inset-bottom)); }
}
@media (max-width: 480px) { .project-grid { grid-template-columns: minmax(0, 1fr); } }

.workflow-record { padding: 12px 0; border-top: 1px solid var(--line); }
.workflow-record h3 { margin: 0; }
.workflow-record > summary, .workflow-history > summary { min-height: 44px; }
.workflow-record .section-head { margin-bottom: 5px; }
.workflow-links .row { gap: 7px; }
.workflow-links .actions { justify-content: start; }
.workflow-participants { margin-block: 8px 14px; }
.workflow-participants small { display: block; color: var(--muted); }
.workflow-resolution { margin-top: 10px; padding: 10px 13px; border-inline-start: 2px solid var(--complete); background: var(--background); }
.workflow-resolution p { margin: 1px 0 4px; }
