:root {
  --ink: #19231f;
  --muted: #68726d;
  --paper: #f6f4ee;
  --surface: #fffdf8;
  --line: #dcded6;
  --green: #17624a;
  --green-soft: #dcebe3;
  --amber: #a65d1b;
  --amber-soft: #faead6;
  --red: #a83b32;
  --red-soft: #f6dfdc;
  --gray-soft: #e8e9e5;
  --shadow: 0 18px 50px rgb(37 47 42 / 8%);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 20; padding: .7rem 1rem; background: var(--ink); color: white; }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 clamp(1rem, 4vw, 4rem); border-bottom: 1px solid var(--line); background: rgb(246 244 238 / 88%); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: white; background: var(--green); border-radius: 11px; font-family: Georgia, serif; font-size: 1.25rem; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: .62rem; letter-spacing: .14em; margin-top: .16rem; }
.identity { color: var(--muted); font-size: .88rem; }
.identity-disconnected { display: flex; align-items: center; gap: .55rem; color: var(--amber); }
.identity-login { padding: .34rem .55rem; border: 1px solid currentColor; border-radius: 7px; color: var(--green); font-size: .75rem; font-weight: 700; text-decoration: none; white-space: nowrap; }
.identity-login:hover { background: var(--green-soft); }
.session-summary { display: flex; align-items: center; justify-content: end; gap: .8rem; }
.connection { display: inline-flex; align-items: center; gap: .38rem; padding: .32rem .58rem; border-radius: 999px; color: var(--muted); background: var(--gray-soft); font-size: .72rem; font-weight: 700; white-space: nowrap; }
.connection span { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.connection-live { color: var(--green); background: var(--green-soft); }
.connection-readonly { color: var(--amber); background: var(--amber-soft); }
.connection-error { color: var(--red); background: var(--red-soft); }

main { min-height: calc(100vh - 76px); }
.hero { padding: clamp(3rem, 7vw, 6rem) clamp(1rem, 5vw, 5rem) clamp(2.5rem, 5vw, 4rem); background: radial-gradient(circle at 88% 18%, #d8e7dd 0, transparent 30%), linear-gradient(140deg, #f9f7f1, #eeeae0); border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 .7rem; color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.hero h1 { max-width: 760px; margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(2.15rem, 5vw, 4.7rem); font-weight: 500; letter-spacing: -.035em; line-height: 1.08; }
.hero-copy { max-width: 660px; margin: 1.25rem 0 2rem; color: var(--muted); line-height: 1.8; }
.search { max-width: 680px; display: grid; grid-template-columns: auto 1fr auto; gap: .7rem; align-items: center; padding: .45rem .45rem .45rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }
.search input { min-width: 0; border: 0; outline: 0; background: transparent; padding: .7rem 0; color: var(--ink); }
.search button, .primary-button { cursor: pointer; border: 0; border-radius: 9px; color: white; background: var(--green); padding: .75rem 1.15rem; font-weight: 700; }
.search button:hover, .primary-button:hover { background: #104e3b; }

.workspace { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); min-height: 680px; }
.project-panel { padding: 2rem clamp(1rem, 3vw, 2.5rem); border-right: 1px solid var(--line); }
.detail-panel { padding: clamp(1.5rem, 4vw, 3.5rem); background: var(--surface); }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 1.3rem; }
.section-heading h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 1.7rem; font-weight: 500; }
.count { color: var(--muted); font-size: .8rem; }
.project-list { display: grid; gap: .65rem; }
.project-card { width: 100%; text-align: left; cursor: pointer; border: 1px solid transparent; border-radius: 12px; background: transparent; padding: 1rem; color: var(--ink); }
.project-card:hover { background: #eeeee8; }
.project-card[aria-current="true"] { background: var(--surface); border-color: var(--line); box-shadow: 0 8px 24px rgb(35 44 39 / 7%); }
.project-card strong, .project-card span { display: block; }
.project-card strong { margin-bottom: .5rem; line-height: 1.35; }
.project-meta { color: var(--muted); font-size: .78rem; }
.project-card-footer { margin-top: .8rem; display: flex !important; justify-content: space-between; align-items: center; gap: .5rem; }

.status { display: inline-flex !important; width: fit-content; align-items: center; gap: .4rem; padding: .28rem .56rem; border-radius: 999px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-not_started { color: #5f6863; background: var(--gray-soft); }
.status-in_progress { color: var(--amber); background: var(--amber-soft); }
.status-completed { color: var(--green); background: var(--green-soft); }
.status-blocked { color: var(--red); background: var(--red-soft); }

.detail-header { padding-bottom: 1.8rem; border-bottom: 1px solid var(--line); }
.detail-header h2 { margin: .3rem 0 .8rem; font-family: Georgia, "Songti SC", serif; font-size: clamp(1.9rem, 4vw, 3.25rem); font-weight: 500; line-height: 1.12; }
.detail-summary { display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; color: var(--muted); font-size: .87rem; }
.material-link { color: var(--green); font-weight: 700; text-underline-offset: 3px; }
.timeline-title { margin: 2rem 0 1rem; font-size: .9rem; }
.timeline { display: flex; overflow-x: auto; padding: .25rem 0 1.25rem; scrollbar-width: thin; }
.node-step { position: relative; min-width: 150px; flex: 1; cursor: pointer; text-align: left; border: 0; background: transparent; padding: 0 1rem 0 0; color: var(--ink); }
.node-step:not(:last-child)::after { content: ""; position: absolute; left: 25px; right: 0; top: 12px; height: 1px; background: var(--line); }
.node-dot { position: relative; z-index: 1; display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: var(--gray-soft); border: 5px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.node-step.is-active .node-dot { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.node-step[data-status="completed"] .node-dot { background: var(--green); }
.node-step[data-status="in_progress"] .node-dot { background: var(--amber); }
.node-step[data-status="blocked"] .node-dot { background: var(--red); }
.node-name { display: block; margin-top: .65rem; font-size: .82rem; font-weight: 700; line-height: 1.35; }
.node-state { display: block; margin-top: .2rem; color: var(--muted); font-size: .7rem; }

.node-detail { margin-top: 1rem; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.node-detail-header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; padding: 1.5rem; background: #f3f1ea; border-bottom: 1px solid var(--line); }
.node-detail-header h3 { margin: .3rem 0 0; font-family: Georgia, "Songti SC", serif; font-size: 1.7rem; font-weight: 500; }
.detail-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.info-section { min-width: 0; padding: 1.4rem 1.5rem; border-bottom: 1px solid var(--line); }
.info-section:nth-child(odd) { border-right: 1px solid var(--line); }
.info-section h4 { display: flex; align-items: center; gap: .55rem; margin: 0 0 .8rem; font-size: .82rem; }
.info-section p { margin: 0; color: var(--muted); line-height: 1.65; }
.resource-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .65rem; }
.resource-link { display: block; padding: .75rem; border: 1px solid var(--line); border-radius: 9px; text-decoration: none; transition: border-color .15s, transform .15s; }
.resource-link:hover { border-color: var(--green); transform: translateY(-1px); }
.resource-link strong { display: block; font-size: .86rem; }
.resource-link small { display: block; margin-top: .25rem; color: var(--muted); line-height: 1.4; }
.resource-link .resource-action { margin-top: .55rem; color: var(--green); font-weight: 700; }
.empty-copy { color: var(--muted); font-size: .84rem; }
.operation { grid-column: 1 / -1; border-right: 0 !important; background: #fbfaf6; }
.operation-row { display: flex; flex-wrap: wrap; align-items: end; gap: .8rem; }
.field { display: grid; gap: .4rem; min-width: 220px; color: var(--muted); font-size: .75rem; }
.field select { padding: .72rem .8rem; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: white; }
.operation-note { margin-top: .75rem !important; font-size: .75rem; }

.welcome-state, .state-box { min-height: 380px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); }
.welcome-state h2, .state-box h3 { color: var(--ink); margin: 1rem 0 .45rem; }
.welcome-state p, .state-box p { margin: 0; max-width: 360px; line-height: 1.6; }
.welcome-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 1.6rem; }
.skeleton { height: 92px; border-radius: 12px; background: linear-gradient(90deg, #e9e7e0 25%, #f5f3ed 50%, #e9e7e0 75%); background-size: 200% 100%; animation: pulse 1.3s infinite; }
@keyframes pulse { to { background-position: -200% 0; } }
.toast { position: fixed; right: 1.25rem; bottom: 1.25rem; max-width: min(380px, calc(100vw - 2.5rem)); padding: .9rem 1rem; border-radius: 10px; color: white; background: var(--ink); box-shadow: var(--shadow); z-index: 20; }
.noscript { padding: 1rem; background: var(--red-soft); color: var(--red); text-align: center; }
:focus-visible { outline: 3px solid #dfa85f; outline-offset: 3px; }

@media (max-width: 760px) {
  .topbar { min-height: 64px; }
  .identity { max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .identity-disconnected > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .session-summary { gap: .45rem; }
  .connection { max-width: 132px; overflow: hidden; text-overflow: ellipsis; }
  .brand small { display: none; }
  .hero { padding-top: 2.5rem; }
  .workspace { display: block; }
  .project-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .project-list { display: flex; overflow-x: auto; padding-bottom: .6rem; scroll-snap-type: x proximity; }
  .project-card { flex: 0 0 245px; scroll-snap-align: start; }
  .detail-panel { padding: 1.25rem 1rem 3rem; }
  .detail-sections { display: block; }
  .info-section, .info-section:nth-child(odd) { border-right: 0; }
  .node-detail-header { display: block; }
  .node-detail-header .status { margin-top: .8rem; }
  .operation-row { display: grid; }
  .field { min-width: 0; }
}

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