:root {
  --bg: #f5f8f8;
  --surface: #ffffff;
  --surface-2: #eef5f5;
  --ink: #18313d;
  --muted: #6e8189;
  --line: #dce7e8;
  --blue: #629dc4;
  --blue-soft: #dcecf5;
  --green: #78bfb2;
  --green-soft: #dff1ed;
  --orange: #e6a27e;
  --orange-soft: #f9e9df;
  --red: #b4232d;
  --red-soft: #fae6e7;
  --shadow: 0 10px 30px rgba(35, 72, 82, .08);
  --sidebar: 252px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: transparent; color: var(--ink); border-radius: 6px; }
.icon-button:hover { background: var(--surface-2); }
.icon-button svg, button svg { width: 18px; height: 18px; flex: none; }
.mobile-only { display: none; }
.login-screen { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 20px; background: #edf4f4; }
.login-screen.hidden { display: none; }
.login-panel { width: min(410px, 100%); padding: 34px; background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.login-mark { width: 46px; height: 46px; margin-bottom: 24px; }
.login-panel h1 { margin-bottom: 8px; }
.login-form { display: grid; margin-top: 28px; }
.login-form .primary { width: 100%; min-height: 44px; }
.login-form > span { text-align: center; color: var(--muted); font-size: 11px; margin-top: 12px; }

.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: #fbfdfd; border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand-mark { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; background: var(--blue); color: white; font-weight: 700; }
.brand strong, .brand span, .profile strong, .profile span { display: block; }
.brand strong { font-size: 15px; }
.brand span, .profile span { color: var(--muted); font-size: 12px; margin-top: 3px; }
.side-nav { display: grid; gap: 4px; }
.side-nav button, .side-footer > button { border: 0; background: transparent; color: #48616a; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 6px; text-align: left; }
.side-nav button:hover, .side-nav button.active, .side-footer > button:hover { color: #245979; background: var(--blue-soft); }
.side-footer { margin-top: auto; display: grid; gap: 14px; }
.profile { border-top: 1px solid var(--line); padding: 16px 8px 0; display: flex; gap: 10px; align-items: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--green-soft); color: #357f73; font-weight: 700; }
.avatar.has-image { background-size: cover; background-position: center; color: transparent; }

.main-shell { margin-left: var(--sidebar); min-height: 100vh; }
.topbar { height: 66px; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(245,248,248,.9); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10; }
#menuButton, .mobile-title { display: none; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.notification-dot { position: absolute; width: 7px; height: 7px; background: var(--red); border-radius: 50%; margin: -14px -14px 0 0; }
.page-root { padding: 30px 34px 80px; max-width: 1460px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.eyebrow { color: var(--muted); font-size: 13px; margin-bottom: 7px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 26px; margin-bottom: 6px; letter-spacing: 0; }
h2 { font-size: 17px; margin-bottom: 0; letter-spacing: 0; }
h3 { font-size: 15px; margin-bottom: 10px; letter-spacing: 0; }
.subtitle { color: var(--muted); margin: 0; font-size: 14px; }

.grid { display: grid; gap: 16px; }
.grid.home { grid-template-columns: 1.45fr 1fr; align-items: start; }
.stack { display: grid; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; box-shadow: 0 2px 10px rgba(35,72,82,.03); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-head .meta { color: var(--muted); font-size: 12px; }
.metric-row { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.metric { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.metric span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.metric strong { font-size: 23px; }
.metric.blue { border-top: 3px solid var(--blue); }
.metric.green { border-top: 3px solid var(--green); }
.metric.orange { border-top: 3px solid var(--orange); }
.metric.red { border-top: 3px solid var(--red); }

.primary, .secondary, .danger, .ghost { border: 0; min-height: 38px; border-radius: 6px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.primary { color: white; background: #357ea7; }
.primary:hover { background: #286d94; }
.secondary { color: #2c6f68; background: var(--green-soft); }
.ghost { color: #49636c; background: var(--surface-2); }
.danger { color: white; background: var(--red); }
.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.text-button { border: 0; background: transparent; color: #347fa5; padding: 4px; }

.task-list { display: grid; gap: 8px; }
.task { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 6px; padding: 11px 12px; background: white; transition: .2s ease; }
.task:hover { border-color: #b9d0d5; transform: translateY(-1px); }
.task.dragging { opacity: .55; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.check { width: 20px; height: 20px; border: 1.5px solid #9bb1b7; border-radius: 5px; display: grid; place-items: center; background: white; padding: 0; }
.task.done .check { background: var(--green); border-color: var(--green); color: white; }
.task-title { font-size: 14px; margin-bottom: 5px; }
.task-meta { color: var(--muted); font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.handle { color: #9fb0b5; cursor: grab; }
.tag { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 4px; font-size: 11px; background: var(--blue-soft); color: #2f6c8e; }
.tag.green { background: var(--green-soft); color: #2d756b; }
.tag.orange { background: var(--orange-soft); color: #955c3e; }
.tag.red { background: var(--red-soft); color: var(--red); }
.deadline { border-left: 3px solid var(--orange); padding: 11px 12px; background: #fffaf7; border-radius: 4px; margin-bottom: 8px; }
.deadline.urgent { border-color: var(--red); background: #fff7f7; }
.deadline strong { display: block; font-size: 14px; margin-bottom: 4px; }
.deadline span { color: var(--muted); font-size: 12px; }

.progress { height: 8px; background: #e7eff0; border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--blue); border-radius: inherit; }
.research-card { border: 1px solid var(--line); border-radius: 7px; padding: 15px; margin-bottom: 10px; }
.research-card .title-row { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.research-card h3 { margin-bottom: 4px; }
.research-card p { color: var(--muted); font-size: 12px; margin: 0; }
.research-card .progress-line { display: grid; grid-template-columns: 1fr 42px; gap: 10px; align-items: center; }

.timeline-mini { display: grid; gap: 12px; }
.schedule-item { display: grid; grid-template-columns: 54px 4px 1fr; gap: 10px; min-height: 52px; }
.schedule-item time { color: var(--muted); font-size: 12px; padding-top: 2px; }
.schedule-item .bar { background: var(--blue); border-radius: 4px; }
.schedule-item .bar.green { background: var(--green); }
.schedule-item .bar.orange { background: var(--orange); }
.schedule-item strong { display: block; font-size: 13px; margin-bottom: 4px; }
.schedule-item span { color: var(--muted); font-size: 12px; }

.segmented { display: inline-flex; padding: 3px; border-radius: 7px; background: #e9f0f1; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 7px 12px; color: var(--muted); border-radius: 5px; }
.segmented button.active { background: white; color: var(--ink); box-shadow: 0 1px 4px rgba(30,60,70,.1); }
.calendar-layout { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; }
.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 4px; }
.weekday { text-align: center; color: var(--muted); font-size: 11px; padding: 8px 0; }
.day { min-height: 72px; border: 1px solid transparent; background: #f9fbfb; border-radius: 6px; padding: 7px; text-align: left; color: var(--ink); position: relative; }
.day:hover, .day.selected { border-color: var(--blue); background: var(--blue-soft); }
.day.muted { color: #afbdc0; }
.dots { display: flex; gap: 3px; position: absolute; left: 8px; bottom: 7px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--blue); }
.dots i:nth-child(2) { background: var(--orange); }
.week-board { display: grid; grid-template-columns: 48px repeat(7, 1fr); overflow-x: auto; min-width: 760px; }
.week-board > div { min-height: 54px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; font-size: 11px; }
.week-event { background: var(--blue-soft); border-left: 3px solid var(--blue); border-radius: 4px; }
.week-agenda { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.week-day { min-height: 330px; border: 1px solid var(--line); border-radius: 6px; padding: 10px; background: #fbfdfd; }
.week-day-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.week-day .week-event { padding: 8px; margin-bottom: 7px; }
.week-day .week-event strong, .week-day .week-event span { display: block; font-size: 11px; }
.week-day .week-event span { color: var(--muted); margin-top: 4px; }

.plan-tree { display: grid; gap: 10px; }
.plan-workspace { grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); align-items: start; }
.plan-level { display: grid; grid-template-columns: 120px 1fr auto; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 7px; padding: 14px; }
.level-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.level-name i { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 5px; font-style: normal; background: var(--blue-soft); color: #32749a; }
.plan-copy strong { font-size: 14px; display: block; margin-bottom: 6px; }
.plan-copy span { color: var(--muted); font-size: 12px; }

.stage-list { display: grid; gap: 8px; }
.stage { border: 1px solid var(--line); border-radius: 7px; padding: 12px; display: grid; grid-template-columns: 12px 1fr auto; gap: 12px; align-items: start; }
.stage-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: #c8d4d6; }
.stage.in-progress .stage-dot { background: var(--orange); box-shadow: 0 0 0 4px var(--orange-soft); }
.stage.done .stage-dot { background: var(--green); }
.stage strong { display: block; font-size: 14px; margin-bottom: 5px; }
.stage p { margin: 0; color: var(--muted); font-size: 12px; }

.chart { height: 180px; display: flex; align-items: end; gap: 10px; padding-top: 15px; border-bottom: 1px solid var(--line); }
.bar-col { flex: 1; background: var(--blue-soft); border-radius: 5px 5px 0 0; position: relative; min-width: 20px; }
.bar-col::after { content: attr(data-label); position: absolute; left: 50%; bottom: -24px; transform: translateX(-50%); color: var(--muted); font-size: 10px; }
.bar-col:last-child { background: var(--green); }
.line-chart { width: 100%; height: auto; overflow: visible; }
.line-chart .grid-line { stroke: #dfe9ea; stroke-width: 1; }
.line-chart .trend-line { fill: none; stroke: var(--blue); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.line-chart .point { fill: white; stroke: var(--blue); stroke-width: 3; }
.line-chart text { fill: var(--muted); font-size: 10px; }
.profile-editor { display: grid; grid-template-columns: 82px 1fr; gap: 18px; align-items: center; margin-top: 16px; }
.profile-preview { width: 78px; height: 78px; border-radius: 50%; display: grid; place-items: center; background: var(--green-soft); color: #357f73; font-size: 24px; font-weight: 700; background-size: cover; background-position: center; }
.profile-preview.has-image { color: transparent; }

.chat-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 590px; padding: 0; overflow: hidden; }
.chat-history { border-right: 1px solid var(--line); padding: 16px; background: #fbfdfd; }
.chat-history button { display: block; width: 100%; border: 0; background: transparent; padding: 10px; border-radius: 5px; text-align: left; margin-bottom: 5px; }
.chat-history button.active { background: var(--blue-soft); }
.chat-history small { display: block; color: var(--muted); margin-top: 4px; }
.chat-main { display: flex; flex-direction: column; }
.messages { padding: 22px; display: grid; gap: 14px; flex: 1; align-content: start; }
.message { max-width: 76%; padding: 12px 14px; border-radius: 7px; line-height: 1.65; font-size: 14px; white-space: pre-line; }
.message.ai { background: var(--surface-2); }
.message.user { justify-self: end; background: #dbeef7; }
.composer { border-top: 1px solid var(--line); padding: 14px; display: flex; gap: 10px; }
.composer textarea { flex: 1; min-height: 54px; resize: none; }

.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); }
input, textarea, select { width: 100%; border: 1px solid #cbdadd; border-radius: 6px; background: white; color: var(--ink); padding: 10px 11px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.toggle-row strong { font-size: 14px; display: block; margin-bottom: 4px; }
.toggle-row span { color: var(--muted); font-size: 12px; }
.switch { width: 42px; height: 24px; border: 0; border-radius: 99px; background: #cad7d9; padding: 3px; }
.switch::after { content: ""; display: block; width: 18px; height: 18px; background: white; border-radius: 50%; transition: .2s; }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(18px); }
.empty { text-align: center; padding: 70px 20px; }
.empty-icon { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-soft); color: #357ea7; margin: 0 auto 18px; }
.empty-icon svg { width: 28px; height: 28px; }
.empty p { max-width: 420px; margin: 10px auto 20px; color: var(--muted); line-height: 1.7; }

.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(12,31,38,.38); z-index: 50; place-items: center; padding: 18px; }
.modal-backdrop.open { display: grid; }
.modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; background: white; border-radius: 8px; box-shadow: var(--shadow); padding: 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: #17323d; color: white; border-radius: 6px; padding: 11px 16px; opacity: 0; pointer-events: none; z-index: 90; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.bottom-nav, .sidebar-scrim { display: none; }

@media (max-width: 900px) {
  :root { --sidebar: 278px; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim.open { display: block; position: fixed; inset: 0; background: rgba(16,39,46,.34); z-index: 19; }
  .mobile-only { display: grid; margin-left: auto; }
  .main-shell { margin-left: 0; }
  .topbar { height: 58px; padding: 0 14px; }
  #menuButton { display: grid; }
  .mobile-title { display: block; font-weight: 700; font-size: 14px; }
  .top-actions .primary span { display: none; }
  .top-actions .primary { width: 36px; padding: 0; }
  .page-root { padding: 20px 16px 96px; }
  .grid.home, .calendar-layout, .plan-workspace { grid-template-columns: 1fr; }
  .metric-row { grid-template-columns: repeat(2, 1fr); }
  .chat-shell { grid-template-columns: 1fr; }
  .chat-history { display: none; }
  .bottom-nav { position: fixed; display: grid; grid-template-columns: repeat(3,1fr); left: 0; right: 0; bottom: 0; min-height: 66px; padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); z-index: 16; backdrop-filter: blur(12px); }
  .bottom-nav button { border: 0; background: transparent; color: var(--muted); display: grid; justify-items: center; align-content: center; gap: 4px; font-size: 11px; }
  .bottom-nav button.active { color: #2c789e; }
  .bottom-nav button svg { width: 20px; height: 20px; }
}

@media (max-width: 560px) {
  h1 { font-size: 23px; }
  .page-head { align-items: center; }
  .page-head .primary span, .page-head .ghost span { display: none; }
  .metric strong { font-size: 20px; }
  .panel { padding: 15px; }
  .task { grid-template-columns: 26px 1fr 18px; padding: 10px; }
  .plan-level { grid-template-columns: 1fr auto; }
  .plan-copy { grid-column: 1 / -1; }
  .form-row { grid-template-columns: 1fr; }
  .calendar-grid { gap: 2px; }
  .day { min-height: 55px; padding: 5px; }
  .message { max-width: 90%; }
  .login-panel { padding: 26px 22px; }
  .profile-editor { grid-template-columns: 64px 1fr; }
  .profile-preview { width: 60px; height: 60px; }
}
