:root {
  --ink: #172532;
  --ink-soft: #314352;
  --muted: #667789;
  --canvas: #f4f7f7;
  --surface: #ffffff;
  --surface-subtle: #f8fbfa;
  --line: #dce5e4;
  --line-strong: #c5d4d1;
  --primary: #176b5b;
  --primary-hover: #105347;
  --primary-soft: #e7f4f0;
  --warning: #a96813;
  --warning-soft: #fff4de;
  --export: #a85c28;
  --export-soft: #fff1e7;
  --export-line: #dfb18d;
  --danger: #b73d4b;
  --danger-soft: #fff0f1;
  --info: #356c9c;
  --info-soft: #eaf3fb;
  --radius-control: 10px;
  --radius-surface: 14px;
  --focus: 0 0 0 3px rgba(23, 107, 91, .2);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  scrollbar-color: #9ba9a7 var(--canvas);
  scrollbar-width: thin;
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
body { min-width: 320px; margin: 0; background: var(--canvas); color: var(--ink); }
body::-webkit-scrollbar, *::-webkit-scrollbar { width: 10px; height: 10px; }
body::-webkit-scrollbar-track, *::-webkit-scrollbar-track { background: var(--canvas); }
body::-webkit-scrollbar-thumb, *::-webkit-scrollbar-thumb { background: #a9b7b5; border: 3px solid var(--canvas); border-radius: 99px; }
body::-webkit-scrollbar-thumb:hover, *::-webkit-scrollbar-thumb:hover { background: #81918e; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: var(--focus); }
button:not(:disabled), [href] { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 14px; overflow-y: auto; background: #102d32; color: #e9f2ef; }
.brand { display: flex; align-items: baseline; gap: 10px; margin: 2px 12px 32px; color: #f3faf7; font-size: 18px; font-weight: 750; letter-spacing: -.25px; text-decoration: none; }
.brand-user { font-size: 22px; font-weight: 800; letter-spacing: -.35px; }
.brand-suffix { white-space: nowrap; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a, .logout button { display: block; width: 100%; border: 0; border-radius: 8px; padding: 11px 12px; background: transparent; color: #bed0cd; font-size: 14px; text-align: left; text-decoration: none; transition: background .16s ease, color .16s ease; }
.sidebar nav a:hover, .sidebar nav a.is-current, .logout button:hover { background: rgba(255, 255, 255, .11); color: #fff; }
.sidebar nav a.is-current { box-shadow: inset 3px 0 0 #7fcbb7; }
.logout { margin-top: auto; padding-top: 22px; }
.main-shell { min-width: 0; }
.topbar { position: sticky; z-index: 3; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 32px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); }
.search-form { position: relative; display: flex; width: min(430px, 48vw); min-width: 210px; }
.search-form input { width: 100%; min-width: 0; padding: 9px 76px 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface); color: var(--ink); }
.search-form input:focus { border-color: var(--primary); }
.search-form > button[type="submit"] { position: absolute; top: 4px; right: 4px; bottom: 4px; border: 0; border-radius: 7px; padding: 0 10px; background: var(--surface-subtle); color: var(--ink-soft); font-size: 13px; font-weight: 700; }
.search-form > button[type="submit"]:hover { background: var(--primary-soft); color: var(--primary-hover); }
.search-clear { position: absolute; top: 50%; right: 59px; z-index: 1; width: 26px; height: 26px; transform: translateY(-50%); border: 0; border-radius: 50%; background: transparent; color: var(--muted); line-height: 1; }
.search-clear:hover { background: #eef3f2; color: var(--ink); }
.quick-actions, .form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.quick-actions form, .task-actions form { margin: 0; }
.content { max-width: 1200px; margin: 0 auto; padding: 36px 32px 60px; }

.page-heading, .record-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-heading h1, .record-hero h1 { margin: 0; color: var(--ink); font-size: clamp(27px, 3vw, 34px); font-weight: 780; letter-spacing: -.75px; line-height: 1.25; overflow-wrap: anywhere; }
.page-heading p, .record-date { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.dashboard-heading { margin-bottom: 26px; }
.today-heading { display: flex; align-items: baseline; gap: 16px; }
.today-heading p { margin: 0; font-size: 14px; font-weight: 400; }
.button, .small-button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; border: 1px solid var(--line-strong); border-radius: var(--radius-control); padding: 8px 13px; background: var(--surface); color: var(--ink-soft); font-weight: 700; line-height: 1.2; text-decoration: none; white-space: nowrap; transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease; }
.button:hover, .small-button:hover { border-color: #97aaa6; background: var(--surface-subtle); color: var(--ink); }
.button:active, .small-button:active { transform: translateY(1px); }
.button.primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.button.primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); color: #fff; }
.button.success, .action-complete { border-color: #97c7ba; background: var(--primary-soft); color: var(--primary-hover); }
.button.success:hover, .action-complete:hover { border-color: var(--primary); background: var(--primary); color: #fff; }
.button.warning, .action-postpone { border-color: #e7c77f; background: var(--warning-soft); color: #815109; }
.button.warning:hover, .action-postpone:hover { border-color: #c89131; background: #ffeec8; color: #6f4305; }
.button.export { border-color: var(--export-line); background: var(--export-soft); color: var(--export); }
.button.export:hover { border-color: #bd7848; background: #fee5d4; color: #824117; }
button:disabled { cursor: not-allowed; opacity: .55; }
.small-button { min-height: 36px; padding: 7px 10px; font-size: 13px; }
.notice { margin: 0 0 18px; border: 1px solid #b8d9cf; border-radius: var(--radius-control); padding: 11px 13px; background: var(--primary-soft); color: var(--primary-hover); font-size: 14px; }

.module { margin-bottom: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-surface); background: var(--surface); }
.module > header { display: flex; align-items: center; justify-content: space-between; min-height: 62px; gap: 14px; padding: 13px 20px; border-bottom: 1px solid var(--line); background: var(--surface-subtle); }
.module h2 { margin: 0; color: var(--ink); font-size: 17px; font-weight: 760; letter-spacing: -.2px; }
.count-badge { display: inline-grid; min-width: 23px; height: 23px; place-items: center; margin-left: 7px; border-radius: 6px; padding: 0 6px; background: var(--primary-soft); color: var(--primary-hover); font-size: 12px; font-weight: 800; vertical-align: 2px; }
.view-switch { border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px; background: var(--surface); color: var(--ink-soft); font-size: 13px; font-weight: 700; text-decoration: none; transition: border-color .16s ease, background .16s ease; }
.view-switch:hover { border-color: #96b7ae; background: var(--primary-soft); color: var(--primary-hover); }
.empty { margin: 0; padding: 20px; color: var(--muted); font-size: 14px; }

.home-task-row { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(315px, 1fr) auto; align-items: center; gap: 18px; padding: 17px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.home-task-row:last-child, .task-row:last-child { border-bottom: 0; }
.home-task-row:hover, .task-row:hover { background: #fbfdfc; }
.task-main { min-width: 0; }
.task-title-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.task-title-line > a { min-width: 0; color: var(--ink); font-size: 16px; font-weight: 760; line-height: 1.45; text-decoration: none; overflow-wrap: anywhere; }
.task-title-line > a:hover { color: var(--primary); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.task-main p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.task-main p i { padding: 0 3px; color: #aab7b8; font-style: normal; }
.home-task-title { display: block; color: var(--ink); font-size: 16px; font-weight: 760; line-height: 1.45; text-decoration: none; overflow-wrap: anywhere; }
.home-task-title:hover { color: var(--primary); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.home-task-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 10px; margin-top: 7px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.home-task-meta i { padding: 0 3px; color: #aab7b8; font-style: normal; }
.list-record-title { display: block; color: var(--ink); font-size: 16px; font-weight: 760; line-height: 1.45; text-decoration: none; overflow-wrap: anywhere; }
.list-record-title:hover { color: var(--primary); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.list-record-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 10px; margin-top: 7px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.list-record-meta i { padding: 0 3px; color: #aab7b8; font-style: normal; }
.task-badges { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.badge { display: inline-flex; align-items: center; min-height: 22px; border-radius: 6px; padding: 3px 7px; background: #eff3f3; color: #5d6c72; font-size: 12px; font-weight: 720; line-height: 1.15; white-space: nowrap; }
.badge-status-todo { background: var(--info-soft); color: #285b86; }
.badge-status-done, .badge-done { background: var(--primary-soft); color: var(--primary-hover); }
.badge-important, .badge-postponed { background: var(--warning-soft); color: #85530b; }
.badge-overdue { background: var(--danger-soft); color: var(--danger); }
.badge-project { background: #edf0fb; color: #4d6195; }
.home-progress { display: flex; min-width: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface); transition: border-color .16s ease, box-shadow .16s ease; }
.home-progress:focus-within { border-color: var(--primary); box-shadow: var(--focus); }
.home-progress input { width: 100%; min-width: 0; border: 0; padding: 10px 12px; background: transparent; color: var(--ink); }
.home-progress .action-progress { min-height: auto; border: 0; border-left: 1px solid var(--line); border-radius: 0; background: var(--surface-subtle); color: var(--primary-hover); }
.home-progress .action-progress:hover { background: var(--primary-soft); }
.task-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: -5px 0 18px; }
.filters a { border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 700; text-decoration: none; }
.filters a:hover, .filters a.is-active { border-color: #8bbcaf; background: var(--primary-soft); color: var(--primary-hover); }
.task-row { position: relative; display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.task-row--todo::before, .task-row--overdue::before { position: absolute; top: 15px; bottom: 15px; left: 0; width: 3px; border-radius: 0 3px 3px 0; background: var(--info); content: ""; }
.task-row--overdue::before { background: var(--danger); }
.list-module .task-actions { flex: 0 0 auto; margin-left: auto; }

.record-hero { margin: 0 0 22px; }
.record-hero > div:first-child { min-width: 0; }
.record-badges { margin-top: 10px; }
.form-hero { margin-bottom: 18px; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(245px, .39fr); align-items: start; gap: 20px; margin-bottom: 20px; }
.detail-content { padding: 0; }
.content-block { padding: 20px; border-bottom: 1px solid var(--line); }
.content-block:last-child { border-bottom: 0; }
.content-block h2 { margin: 0 0 10px; color: var(--ink-soft); font-size: 14px; font-weight: 750; }
.detail-text { color: var(--ink); font-size: 15px; line-height: 1.75; overflow-wrap: anywhere; }
.detail-aside { display: grid; gap: 10px; }
.facts { display: grid; gap: 0; margin: 0; }
.facts > div { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 12px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; color: var(--ink-soft); font-size: 14px; overflow-wrap: anywhere; }
.facts dd a { color: var(--primary); text-decoration: none; }
.postpone-panel { margin: 0; }
.postpone-panel .button { width: 100%; }
.timeline { list-style: none; margin: 0; padding: 20px 20px 20px 35px; }
.timeline li { position: relative; display: grid; grid-template-columns: 178px minmax(0, 1fr); gap: 15px; padding: 0 0 18px 18px; border-left: 1px solid var(--line-strong); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { position: absolute; top: 4px; left: -5px; width: 9px; height: 9px; border: 2px solid var(--surface); border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); content: ""; }
.timeline time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.timeline span { color: var(--ink-soft); font-size: 14px; line-height: 1.55; }

.record-form { display: grid; gap: 20px; }
.record-form .module { margin: 0; overflow: visible; }
.form-section { padding: 20px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; }
.field-grid--primary { grid-template-columns: minmax(0, 1.3fr) minmax(210px, .7fr); }
.field { display: grid; gap: 7px; min-width: 0; }
.field-label { color: var(--ink-soft); font-size: 14px; font-weight: 750; }
.required, .errorlist { color: var(--danger); }
.errorlist { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.record-form > .module > .field { margin: 0 0 18px; }
.record-form input, .record-form select, .record-form textarea, .resource-form textarea, .login-form input { width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius-control); padding: 10px 11px; background: var(--surface); color: var(--ink); }
.record-form input:focus, .record-form select:focus, .record-form textarea:focus, .resource-form textarea:focus, .login-form input:focus { border-color: var(--primary); }
.record-form textarea, .resource-form textarea { min-height: 90px; resize: none; }
.source-heading { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.button.parse-trigger { min-height: 30px; border-color: #d6bba7; border-radius: 7px; padding: 4px 9px; background: #faf4ef; color: #905e39; font-size: 14px; font-weight: 750; }
.button.parse-trigger:hover { border-color: #bc8b69; background: #f3e1d4; color: #784626; }
.parse-trigger:active { transform: translateY(1px); }
.source-section > textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius-control); padding: 10px 11px; background: var(--surface); color: var(--ink); min-height: 90px; resize: none; }
.source-section > textarea:focus { border-color: var(--primary); }
.inline-help { padding: 0 0 17px; }
.parse-feedback { display: block; margin-top: 8px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.parse-feedback:empty { display: none; }
.parse-feedback.is-error { color: var(--danger); }
.help { margin: 0; color: var(--muted); font-size: 13px; }
.recurrence-option[hidden] { display: none !important; }
.recurrence-picker { display: grid; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.recurrence-choice-grid { display: grid; gap: 9px; }
.recurrence-choice-grid--week { grid-template-columns: repeat(7, 46px); }
.recurrence-choice-grid--month { grid-template-columns: repeat(14, 42px); }
.recurrence-token { position: relative; display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: var(--ink-soft); font-size: 13px; font-weight: 730; cursor: pointer; transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease; }
.recurrence-choice-grid--week .recurrence-token { width: 46px; border-radius: 50%; }
.recurrence-token input { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.recurrence-token:hover { border-color: #8bbcaf; background: var(--primary-soft); color: var(--primary-hover); }
.recurrence-token:has(input:checked) { border-color: var(--primary); background: var(--primary); color: #fff; }
.recurrence-token:has(input:focus-visible) { box-shadow: var(--focus); }
.form-actions { position: sticky; z-index: 2; bottom: 12px; justify-content: flex-end; padding: 11px; border: 1px solid var(--line); border-radius: var(--radius-surface); background: rgba(255, 255, 255, .96); box-shadow: 0 5px 16px rgba(20, 42, 45, .08); }

.upload-form, .resource-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; padding: 16px 20px; }
.drop-zone { display: flex; flex: 1; min-width: 280px; align-items: center; justify-content: space-between; gap: 12px; border: 1px dashed #a5b9b5; border-radius: var(--radius-control); padding: 12px; background: var(--surface-subtle); color: var(--muted); cursor: pointer; }
.drop-zone.dragging { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-hover); }
.drop-zone input[type=file] { max-width: 265px; }
.resource-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.resource-form .field { min-width: 0; }

.mobile-nav { display: none; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0, #e7f4f0 0, var(--canvas) 44rem); }
.login-card { width: min(410px, 100%); border: 1px solid var(--line); border-radius: var(--radius-surface); padding: 32px; background: var(--surface); box-shadow: 0 16px 42px rgba(15, 45, 50, .10); }
.login-card h1 { margin: 0 0 25px; color: var(--ink); font-size: 28px; letter-spacing: -.5px; }
.login-form { display: grid; gap: 16px; }
.login-form .button { width: 100%; margin-top: 5px; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 196px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .topbar { padding-inline: 20px; }
  .content { padding-inline: 22px; }
  .home-task-row { grid-template-columns: 1fr; gap: 12px; }
  .home-task-row .task-actions { justify-content: flex-start; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-aside { grid-template-columns: minmax(0, 1fr) minmax(180px, .5fr); }
}

@media (max-width: 700px) {
  html { scroll-padding-bottom: 78px; }
  .app-shell { display: block; }
  .sidebar { display: none; }
  .topbar { position: static; flex-wrap: wrap; gap: 10px; padding: 12px; }
  .search-form { order: 2; width: 100%; }
  .quick-actions { width: 100%; }
  .quick-actions .button { flex: 1; }
  .content { padding: 22px 12px 92px; }
  .page-heading, .record-hero { gap: 12px; margin-bottom: 18px; }
  .page-heading h1, .record-hero h1 { font-size: 27px; }
  .today-heading { gap: 12px; }
  .page-heading .button { min-height: 38px; padding-inline: 10px; }
  .module { border-radius: 12px; margin-bottom: 16px; }
  .module > header { min-height: 56px; padding: 11px 14px; }
  .module h2 { font-size: 16px; }
  .view-switch { padding: 6px 8px; font-size: 12px; }
  .home-task-row, .task-row { align-items: flex-start; padding: 15px 14px; }
  .task-row { flex-direction: column; gap: 12px; }
  .task-actions { width: 100%; justify-content: flex-start; }
  .list-module .task-actions { margin-left: 0; }
  .task-actions .small-button { flex: 1; }
  .task-actions form { flex: 1; }
  .task-actions form .small-button { width: 100%; }
  .task-title-line > a { font-size: 15px; }
  .home-progress { width: 100%; }
  .field-grid, .field-grid--primary { grid-template-columns: 1fr; gap: 15px; }
  .recurrence-choice-grid--week { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
  .recurrence-choice-grid--month { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; }
  .recurrence-token, .recurrence-choice-grid--week .recurrence-token { width: 100%; max-width: 48px; height: 40px; justify-self: center; font-size: 12px; }
  .recurrence-choice-grid--week .recurrence-token { border-radius: 50%; }
  .form-section { padding: 16px 14px; }
  .form-actions { position: static; margin-top: -2px; box-shadow: none; }
  .detail-aside { grid-template-columns: 1fr; }
  .facts > div { grid-template-columns: 88px minmax(0, 1fr); }
  .timeline { padding: 16px 14px 16px 28px; }
  .timeline li { grid-template-columns: 1fr; gap: 4px; padding-left: 15px; }
  .upload-form, .resource-form { padding: 14px; }
  .drop-zone { min-width: 0; align-items: flex-start; flex-direction: column; }
  .resource-form { grid-template-columns: 1fr; }
  .mobile-nav { position: fixed; z-index: 4; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(4, 1fr); padding: 7px 5px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.98); box-shadow: 0 -4px 16px rgba(15, 35, 40, .05); }
  .mobile-nav a { min-height: 42px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 700; text-decoration: none; }
  .mobile-nav a.is-current { background: var(--primary-soft); color: var(--primary-hover); }
}

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

@media (forced-colors: active) { :root { scrollbar-color: auto; } }
