:root {
  --paper: #e9eef3;
  --paper-deep: #dce4eb;
  --ink: #17222d;
  --muted: #667583;
  --line: #c8d2dc;
  --white: #f9fbfc;
  --blue: #2463eb;
  --blue-dark: #174cc0;
  --amber: #d18a19;
  --red: #c8423a;
  --green: #2d7d68;
  --shadow: 0 18px 55px rgba(23, 34, 45, 0.12);
  --radius: 18px;
  --display: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --utility: ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(200, 210, 220, 0.32) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 52px;
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }

button { cursor: pointer; }

button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(36, 99, 235, 0.28);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font: 700 11px/1 var(--utility);
  letter-spacing: 0.14em;
}

h1, h2, h3, p { margin-top: 0; }

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 700;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 470px);
  padding: 44px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--blue);
  border-radius: 6px 6px var(--radius) var(--radius);
  background: rgba(249, 251, 252, 0.94);
  box-shadow: var(--shadow);
}

.login-card h1 { margin-bottom: 12px; font-size: clamp(34px, 8vw, 56px); letter-spacing: -0.06em; }
.login-copy { color: var(--muted); line-height: 1.75; }
.login-card label, .dialog label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
.login-card input { margin-bottom: 18px; }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: var(--white);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input, select { height: 46px; padding: 0 13px; }
textarea { padding: 14px; line-height: 1.65; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(36, 99, 235, 0.09); }

.form-error { min-height: 18px; margin: 12px 0 0; color: var(--red); font-size: 13px; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 0 max(24px, calc((100vw - 1160px) / 2));
  border-bottom: 1px solid rgba(153, 170, 184, 0.55);
  background: rgba(233, 238, 243, 0.89);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--ink);
}

.top-actions { display: flex; align-items: center; gap: 20px; }
.date-label { color: var(--muted); font: 12px/1 var(--utility); }
.text-button { padding: 5px; border: 0; color: var(--muted); background: none; }

.workspace {
  width: min(1160px, calc(100% - 48px));
  margin: 0 auto;
  padding: 66px 0 100px;
}

.capture {
  position: relative;
  padding: 36px;
  border: 1px solid #aebdca;
  border-radius: var(--radius);
  background: rgba(249, 251, 252, 0.95);
  box-shadow: var(--shadow);
}

.capture::before {
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: -1px;
  width: 7px;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--blue);
  content: "";
}

.capture-heading, .capture-footer, .section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.capture h1 {
  margin-bottom: 22px;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.12;
  letter-spacing: -0.055em;
}

.privacy-note, .mode-chip {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--green);
  background: rgba(45, 125, 104, 0.09);
  font-size: 12px;
}

.capture textarea {
  min-height: 126px;
  border: 0;
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font-family: var(--display);
  font-size: clamp(19px, 2.5vw, 27px);
}

.capture textarea::placeholder { color: #8996a2; }
.capture textarea:focus { box-shadow: none; }

.capture-footer { align-items: center; margin-top: 20px; }
.capture-footer p { margin: 0; color: var(--muted); font-size: 13px; }

.button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 650;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button.primary { color: white; background: var(--blue); }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { border-color: var(--line); color: var(--ink); background: transparent; }
.button.ink { color: white; background: var(--ink); }
.button.full { width: 100%; }
.button.danger-button { border-color: rgba(200, 66, 58, 0.25); color: var(--red); background: transparent; }

.draft-panel, .record-board, .day-board { margin-top: 56px; }
.draft-panel { padding: 30px; border: 1px solid var(--blue); border-radius: var(--radius); background: rgba(246, 249, 252, 0.94); }
.section-head { align-items: flex-end; margin-bottom: 26px; }
.section-head h2 { margin-bottom: 0; font-size: clamp(26px, 3.4vw, 39px); letter-spacing: -0.045em; }
.mode-chip { color: var(--blue); background: rgba(36, 99, 235, 0.08); }

.draft-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.draft-form label { display: grid; gap: 8px; color: var(--muted); font-size: 12px; }
.draft-form .wide { grid-column: 1 / -1; }
.entry-type-field select { border: 2px solid var(--blue); color: var(--blue-dark); font-weight: 700; }
.entry-type-field small { margin-top: 2px; color: var(--muted); line-height: 1.5; }
.todo-fields, .record-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.record-fields[hidden], .todo-fields[hidden] { display: none; }
.record-fields .wide { grid-column: 1 / -1; }
.draft-actions { display: flex; justify-content: flex-end; gap: 12px; }
.draft-questions { padding: 12px 14px; border-left: 3px solid var(--amber); color: #6e531f; background: rgba(209, 138, 25, 0.08); font-size: 14px; }
.next-actions { padding: 15px; border: 1px solid #b7c7ee; border-radius: 10px; background: #f4f7fd; }
.next-actions > strong { color: var(--blue-dark); font-size: 14px; }
.next-actions > p { margin: 5px 0 10px; color: var(--muted); font-size: 12px; }
.next-actions label { display: flex; align-items: flex-start; gap: 9px; padding: 7px 0; color: var(--ink); font-size: 14px; }
.next-actions input { flex: 0 0 auto; width: 17px; height: 17px; margin-top: 2px; }

.metrics { display: flex; gap: 24px; color: var(--muted); font-size: 12px; }
.metrics strong { margin-right: 4px; color: var(--ink); font: 700 20px/1 var(--utility); }
.metrics .danger strong { color: var(--red); }

.notifications { display: grid; gap: 8px; margin: -4px 0 20px; }
.notification { padding: 12px 14px; border-left: 3px solid var(--amber); background: rgba(209, 138, 25, 0.1); font-size: 13px; }
.notification strong { margin-right: 8px; }

.record-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.record-card { min-height: 142px; padding: 20px; border: 1px solid var(--line); border-top: 4px solid var(--green); border-radius: 10px; background: rgba(249, 251, 252, .78); }
.record-card.progress { border-top-color: var(--blue); }
.record-card.note { border-top-color: var(--amber); }
.record-type { color: var(--muted); font: 700 10px/1 var(--utility); letter-spacing: .1em; }
.record-card h3 { margin: 16px 0 8px; font-family: var(--body); font-size: 15px; }
.record-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.record-empty { padding: 28px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }

.task-tabs { display: flex; gap: 24px; margin-bottom: 0; border-bottom: 1px solid var(--line); }
.tab { padding: 13px 1px 11px; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: none; }
.tab.active { border-color: var(--blue); color: var(--ink); font-weight: 700; }

.task-list { position: relative; }
.task-list::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 108px;
  width: 1px;
  background: var(--line);
  content: "";
}

.task-row {
  position: relative;
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 28px;
  align-items: center;
  min-height: 108px;
  border-bottom: 1px solid var(--line);
}

.task-time { color: var(--muted); font: 12px/1.4 var(--utility); text-align: right; }
.task-time strong { display: block; color: var(--ink); font-size: 16px; }
.task-row::before {
  position: absolute;
  left: 103px;
  width: 9px;
  height: 9px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 1px var(--blue);
  content: "";
}

.task-main { min-width: 0; }
.task-main h3 { margin: 0 0 9px; overflow: hidden; font-family: var(--body); font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.task-meta { display: flex; flex-wrap: wrap; gap: 7px; color: var(--muted); font-size: 12px; }
.chip { padding: 4px 7px; border-radius: 5px; background: rgba(103, 117, 131, 0.09); }
.chip.priority-P0 { color: var(--red); background: rgba(200, 66, 58, 0.09); }
.chip.priority-P1 { color: #9c6510; background: rgba(209, 138, 25, 0.11); }
.task-open { padding: 8px 11px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: transparent; }
.task-row.completed { opacity: 0.62; }
.task-row.completed .task-main h3 { text-decoration: line-through; }

.empty-state { padding: 66px 20px; text-align: center; }
.empty-state span { display: grid; width: 50px; height: 50px; margin: 0 auto 14px; place-items: center; border: 1px solid var(--green); border-radius: 50%; color: var(--green); font-size: 24px; }
.empty-state h3 { margin-bottom: 6px; font-size: 24px; }
.empty-state p { color: var(--muted); }

.summary-center {
  margin-top: 72px;
  padding: 34px;
  border-radius: var(--radius);
  background: var(--ink);
}

.summary-center .eyebrow { color: #86a8ff; }
.summary-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; color: white; }
.summary-head h2 { margin-bottom: 0; font-size: clamp(26px, 3.4vw, 39px); letter-spacing: -0.045em; }
.text-report-button { padding: 7px 0; border: 0; border-bottom: 1px solid #7898e9; color: #c7d6ff; background: transparent; }
.monthly-ledger { display: grid; grid-template-columns: 190px 1fr; margin-top: 30px; overflow: hidden; border-radius: 12px; background: var(--white); }
.month-stamp { display: flex; flex-direction: column; justify-content: space-between; min-height: 230px; padding: 24px; color: white; background: var(--blue); }
.month-stamp span { font: 700 11px/1 var(--utility); letter-spacing: .12em; writing-mode: vertical-rl; }
.month-stamp strong { font: 700 27px/1.1 var(--utility); white-space: pre-line; }
.ledger-body { display: flex; flex-direction: column; justify-content: space-between; padding: 28px 30px; }
.ledger-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.ledger-metrics span { color: var(--muted); font-size: 12px; }
.ledger-metrics strong { display: block; margin-bottom: 6px; color: var(--ink); font: 700 25px/1 var(--utility); }
.month-evidence { margin: 26px 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.month-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.month-actions label { color: var(--muted); font-size: 12px; }
.month-actions input { width: 155px; background: var(--paper); }

.dialog { width: min(680px, calc(100% - 28px)); padding: 0; border: 0; border-radius: var(--radius); color: var(--ink); background: var(--white); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(16, 25, 34, 0.55); backdrop-filter: blur(4px); }
.dialog-card { position: relative; display: grid; gap: 18px; padding: 34px; }
.dialog-card h2 { margin: -4px 38px 0 0; font-size: 30px; }
.dialog-close { position: absolute; top: 18px; right: 20px; width: 34px; height: 34px; border: 0; border-radius: 50%; color: var(--muted); background: var(--paper); font-size: 22px; }
.dialog-meta { margin: -8px 0 4px; color: var(--muted); font-size: 13px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 5px; }
.report-dialog pre { max-height: 56vh; overflow: auto; padding: 18px; border-radius: 9px; white-space: pre-wrap; color: var(--ink); background: var(--paper); font: 14px/1.75 var(--body); }

.toast { position: fixed; z-index: 50; right: 24px; bottom: 24px; max-width: 380px; padding: 13px 16px; border-radius: 8px; color: white; background: var(--ink); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(10px); transition: 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.mobile-capture { display: none; }

@media (max-width: 760px) {
  body { background-size: 100% 44px; }
  .topbar { min-height: 60px; padding: 0 18px; }
  .date-label { display: none; }
  .workspace { width: min(100% - 28px, 600px); padding: 30px 0 96px; }
  .capture { padding: 25px 20px 22px; }
  .capture-heading, .capture-footer, .section-head { display: block; }
  .privacy-note { display: inline-block; margin-bottom: 16px; }
  .capture-heading { display: flex; flex-direction: column-reverse; gap: 0; }
  .capture h1 { margin-bottom: 16px; font-size: 34px; }
  .capture textarea { min-height: 120px; font-size: 19px; }
  .capture-footer p { margin-bottom: 14px; line-height: 1.5; }
  .capture-footer .button { width: 100%; }
  .draft-panel { margin-top: 34px; padding: 22px 18px; }
  .draft-form { grid-template-columns: 1fr; }
  .draft-form .wide { grid-column: auto; }
  .todo-fields, .record-fields { grid-template-columns: 1fr; }
  .record-fields .wide { grid-column: auto; }
  .mode-chip { display: inline-block; margin-top: 13px; }
  .draft-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .day-board { margin-top: 44px; }
  .record-board { margin-top: 44px; }
  .record-list { grid-template-columns: 1fr; }
  .section-head { margin-bottom: 18px; }
  .metrics { margin-top: 18px; gap: 13px; justify-content: space-between; }
  .metrics span { display: grid; gap: 4px; }
  .task-tabs { gap: 20px; }
  .task-list::before { left: 60px; }
  .task-row { grid-template-columns: 44px 1fr; gap: 26px; min-height: 116px; }
  .task-row::before { left: 55px; }
  .task-time { font-size: 10px; }
  .task-time strong { font-size: 13px; }
  .task-open { grid-column: 2; justify-self: start; margin-top: -16px; }
  .summary-center { padding: 26px 18px 18px; }
  .summary-head { display: block; }
  .summary-head .text-report-button { margin-top: 18px; }
  .monthly-ledger { grid-template-columns: 1fr; }
  .month-stamp { flex-direction: row; align-items: center; min-height: auto; padding: 18px 20px; }
  .month-stamp span { writing-mode: initial; }
  .month-stamp strong { font-size: 20px; white-space: normal; }
  .ledger-body { padding: 22px 18px; }
  .ledger-metrics { grid-template-columns: 1fr 1fr; gap: 20px; }
  .month-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .month-actions label { grid-column: 1 / -1; }
  .month-actions input { width: 100%; }
  .dialog-card { padding: 28px 20px 22px; }
  .dialog-actions { display: grid; grid-template-columns: 1fr; }
  .mobile-capture {
    position: fixed;
    z-index: 19;
    right: 19px;
    bottom: calc(19px + env(safe-area-inset-bottom));
    display: grid;
    width: 56px;
    height: 56px;
    place-items: center;
    border: 0;
    border-radius: 50%;
    color: white;
    background: var(--blue);
    box-shadow: 0 10px 28px rgba(36, 99, 235, 0.32);
    font-size: 28px;
  }
  .toast { right: 14px; bottom: 86px; left: 14px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
