/* Growth Assistant: a quiet field notebook organized around one useful next step. */
:root {
  --canvas: #f1f4ef;
  --surface: #fffefa;
  --ink: #1d3027;
  --muted: #52665b;
  --accent: #28634e;
  --accent-hover: #1d503e;
  --accent-soft: #e4eee5;
  --line: #d5dfd7;
  --danger: #963e37;
  --highlight: #d6ed81;
  --sidebar: #183b30;
  --sidebar-muted: #c0d1c7;
  --radius: 14px;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.65;
  font-size: 16px;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0 0 12px; font-size: clamp(30px, 3.2vw, 42px); line-height: 1.2; font-weight: 720; letter-spacing: -.045em; }
h2 { margin: 0 0 16px; font-size: 21px; line-height: 1.4; font-weight: 680; letter-spacing: -.025em; }
h3 { margin: 0 0 7px; font-size: 17px; line-height: 1.45; font-weight: 650; }
p { margin: 10px 0 16px; }
.ui-icon { width: 20px; height: 20px; flex: none; vertical-align: middle; }
.hint, .eyebrow { color: var(--muted); }
.eyebrow { margin: 0 0 8px; font-size: 13px; }
.lead { margin: 5px 0 0; color: var(--muted); font-size: 16px; }

/* Desktop navigation is a quiet, grouped rail; the active destination is explicit. */
.workspace .app-sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 30;
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;
  gap: 30px; width: 244px; min-height: 0; padding: 30px 18px 20px;
  overflow-y: auto; color: white; background: var(--sidebar); border: 0;
}
.app-sidebar .brand {
  display: flex; align-items: center; min-height: 42px; padding: 0 10px;
  color: white; font-size: 19px; font-weight: 700; letter-spacing: -.035em;
  text-decoration: none; white-space: nowrap;
}
.app-nav { display: flex; flex-direction: column; align-items: stretch; gap: 26px; }
.nav-group { display: grid; gap: 5px; }
.nav-group-title { padding: 0 12px 5px; color: var(--sidebar-muted); font-size: 12px; }
.app-nav a {
  position: relative; display: flex; align-items: center; gap: 13px; min-height: 46px;
  padding: 9px 12px; color: var(--sidebar-muted); border-radius: 8px;
  font-size: 14px; text-decoration: none; transition: color .16s, background-color .16s;
}
.app-nav a:hover { color: white; background: #ffffff12; }
.app-nav a[aria-current="page"] { color: white; background: #ffffff17; font-weight: 650; }
.app-nav a[aria-current="page"]::before {
  position: absolute; top: 10px; bottom: 10px; left: -18px; width: 3px;
  background: var(--highlight); border-radius: 0 3px 3px 0; content: "";
}
.app-nav a[aria-current="page"] .ui-icon { color: var(--highlight); }
.logout-form { margin: auto 0 0; }
.logout-form button { width: 100%; justify-content: flex-start; gap: 12px; color: var(--sidebar-muted); border-color: #ffffff32; background: transparent; }
.logout-form button:hover { color: white; border-color: #ffffff70; background: #ffffff12; }

.workspace main {
  min-height: calc(100dvh - 64px); max-width: none; margin: 0 0 0 244px;
  padding: 48px clamp(28px, 5vw, 76px) 40px;
}
.workspace .page-shell { width: 100%; max-width: 1600px; min-width: 0; margin: 0; }
.workspace .page-shell > .narrow { max-width: 720px; margin-left: 0; margin-right: 0; }
.workspace .app-footer { margin-left: 244px; padding: 20px 32px 28px; color: var(--muted); font-size: 13px; text-align: center; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; min-height: 0; margin-bottom: 34px; padding: 0; border: 0; background: transparent; }
.page-heading h1 { margin-bottom: 7px; }
.page-date { margin: 0; color: var(--muted); font-size: 14px; }
.page-heading > .button { flex: none; margin-top: 3px; }
.page-heading .links { justify-content: flex-end; margin: 0; }

/* Sections use whitespace and dividers first. Reserve framed surfaces for working areas. */
.panel { margin: 34px 0; padding: 24px 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; box-shadow: none; }
.panel h2 { margin-bottom: 17px; }
.panel:has(> form), .panel:has(> details) {
  padding: 26px 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
form.panel { padding: 26px 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.subtle { background: var(--accent-soft); box-shadow: none; }
.intro { margin-bottom: 34px; }
.intro .lead { max-width: 680px; }
.goal-toolbar { justify-content: space-between; margin: 0 0 20px !important; }
.goal-primary-action { flex: none; }
.destructive-panel { color: var(--ink); }
.journal-date-tools { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: -10px 0 22px; }
.date-picker { display: grid; grid-template-columns: auto minmax(170px, 220px) auto; align-items: center; gap: 10px; margin: 0; }
.date-picker label { margin: 0; white-space: nowrap; }
.date-picker input { width: 100%; }
.date-picker button { min-height: 46px; margin: 0; }
.date-navigation { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 14px; color: var(--muted); font-size: 13px; }
.date-navigation span { white-space: nowrap; }
.day-detail-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 0; margin: 30px 0 18px; padding: 0; border: 0; background: transparent; }
.day-detail-heading .eyebrow { margin-bottom: 2px; }
.day-detail-heading h2 { margin: 0; }
.calendar-log-marker { color: var(--accent-hover) !important; font-weight: 700; }
.two-columns { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr); align-items: start; gap: clamp(30px, 5vw, 72px); }
.two-columns > * { min-width: 0; }
.two-columns .panel { margin-top: 0; }
.task-row { border-color: var(--line); }
.task-title { color: var(--ink); }

/* Today keeps the action list as the main surface; supporting habits stay secondary. */
.today-layout { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(260px, .8fr); align-items: start; gap: 28px; }
.today-layout > * { min-width: 0; }
.today-layout .panel { margin: 0; }
.today-layout .daily-tasks { padding: 26px 30px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.today-layout .daily-habits { padding: 8px 0 0 24px; border-top: 0; border-left: 1px solid var(--line); }
.daily-tasks h2 { margin-bottom: 8px; }
.daily-task { display: grid; grid-template-columns: minmax(0, 1fr) 150px; align-items: start; gap: 12px 24px; padding: 21px 0; border-top: 1px solid var(--line); }
.daily-tasks article + article { margin-top: 0; padding-top: 21px; }
.task-copy { grid-column: 1; min-width: 0; }
.daily-task h3 a { color: var(--ink); text-decoration: none; }
.daily-task h3 a:hover { color: var(--accent); text-decoration: underline; }
.daily-task .hint { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.criterion { margin: 0; color: var(--muted); font-size: 14px; }
.task-completion { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; align-items: stretch; gap: 7px; margin: 0; }
.task-completion .task-complete { width: 100%; min-width: 0; margin: 0; }
.task-note { order: 2; }
.task-note summary { min-height: 40px; padding: 8px 0; color: var(--muted); font-size: 13px; font-weight: 450; }
.task-note label { margin: 7px 0; font-size: 13px; }
.task-edit { grid-column: 2; grid-row: 2; display: inline-flex; align-items: center; justify-self: end; min-height: 34px; color: var(--muted); font-size: 13px; }
.task-control { grid-column: 2; grid-row: 1; margin: 0; }
.task-control button { width: 100%; margin: 0; }
.is-complete h3 a { color: var(--muted); text-decoration: line-through; }
.list-footnote { margin: 0; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.empty-state { padding: 28px 4px 18px; color: var(--muted); }
.empty-state h3 { color: var(--ink); }
.empty-state a { display: inline-flex; align-items: center; min-height: 44px; margin-top: 4px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-heading h2 { margin: 0; }
.section-heading > a { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; }
.habit-item { padding: 16px 0; border-top: 1px solid var(--line); }
.habit-item h3 a { color: var(--ink); text-decoration: none; }
.habit-item .hint { margin: 4px 0 8px; font-size: 13px; }
.daily-habits .habit-item:last-child { padding-bottom: 0; }

/* Controls and feedback share the same plain, high-contrast vocabulary. */
.button, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; color: var(--accent); background: var(--surface);
  border: 1px solid #a8b9ad; border-radius: 8px; font: inherit; font-size: 14px; font-weight: 650;
  text-decoration: none; cursor: pointer; touch-action: manipulation;
  transition: color .16s, background-color .16s, border-color .16s;
}
.button:hover, button:hover { color: var(--accent-hover); border-color: var(--accent); background: var(--accent-soft); }
.primary, button.primary { color: white; background: var(--accent); border-color: var(--accent); }
.primary:hover, button.primary:hover { color: white; background: var(--accent-hover); border-color: var(--accent-hover); }
.quiet { color: var(--ink); background: transparent; border-color: #a8b9ad; }
.quiet:hover { background: var(--accent-soft); }
.danger, button[value="delete"] { color: var(--danger); border-color: #d8aaa5; background: var(--surface); }
.danger:hover, button[value="delete"]:hover { background: #fff0ed; }
button:disabled, [aria-disabled="true"] { opacity: .55; cursor: wait; }
input, textarea, select { max-width: 100%; min-height: 48px; color: var(--ink); background: var(--surface); border-color: #9caea2; border-radius: 8px; font: inherit; font-size: 16px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; }
label { margin: 20px 0 8px; font-size: 14px; font-weight: 650; }
input[type="checkbox"], input[type="radio"] { display: inline-block; width: 20px; height: 20px; min-height: 20px; margin: 0 8px 0 0; padding: 0; accent-color: var(--accent); vertical-align: middle; }
fieldset { min-width: 0; margin: 20px 0; padding: 20px; border: 1px solid var(--line); border-radius: 10px; }
legend { padding: 0 8px; font-weight: 650; }
form .primary { margin-top: 20px; }
.badge { display: inline-block; flex: none; padding: 4px 10px; color: var(--accent-hover); background: var(--accent-soft); border-radius: 999px; font-size: 13px; }
.success { padding: 12px 16px; color: var(--accent-hover); background: var(--accent-soft); border-radius: 8px; }
.error, [role="alert"] { padding: 12px 16px; color: var(--danger); background: #fff0ed; border-left: 3px solid var(--danger); border-radius: 5px; }
#sync-status { padding: 12px 16px; border: 1px solid #cdb777; border-radius: 8px; background: #fff6d9; }
#sync-status[hidden], #form-status[hidden], [hidden] { display: none !important; }
#form-status { padding: 12px 16px; color: var(--accent-hover); background: var(--accent-soft); border-radius: 8px; }
summary { min-height: 44px; padding: 8px 0; font-weight: 650; cursor: pointer; }
.record { padding: 16px 0; border-top: 1px solid var(--line); }
.record p { overflow-wrap: anywhere; }
.links { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 22px 0; }
.links a, nav a { display: inline-flex; align-items: center; min-height: 44px; }
main nav:not(.app-nav) { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; margin: 14px 0 20px; }
main nav:not(.app-nav) a { color: var(--accent); }

/* Calendar, review and records remain readable without turning every row into a card. */
main table { width: 100%; margin: 24px 0; table-layout: fixed; border-collapse: separate; border-spacing: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
main th, main td { padding: 8px 5px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: center; vertical-align: top; }
main th { padding: 12px 4px; color: var(--muted); background: #e8eee8; font-size: 13px; font-weight: 650; }
main th:last-child, main td:last-child { border-right: 0; }
main tr:last-child td { border-bottom: 0; }
main td a { display: block; min-height: 82px; padding: 10px 3px; border-radius: 7px; text-decoration: none; }
main td a:hover { background: var(--canvas); }
main td a[aria-current="date"] { color: var(--accent-hover); background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -2px; }
main td small { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
main article { overflow-wrap: anywhere; }
main article + article { border-color: var(--line); }
.simple .eyebrow { display: none; }
.simple .lead { display: none; }
.simple main { line-height: 1.85; }
.auth-page .app-sidebar { position: static; min-height: 74px; padding: 14px max(24px, calc((100vw - 1080px) / 2)); color: var(--ink); background: transparent; border-bottom: 1px solid var(--line); }
.auth-page .app-sidebar .brand { color: var(--ink); }
.auth-page main { max-width: 600px; margin: 48px auto; padding: 0 24px; }
.auth-page .page-shell > .panel { padding: 30px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.auth-page h1 { font-size: 30px; }
.auth-page .app-footer { margin: 0; }
.narrow { max-width: 640px; }
:focus-visible { outline: 3px solid #83a93c; outline-offset: 3px; }
.skip { z-index: 100; }

@media (max-width: 1100px) {
  .workspace .app-sidebar { width: 218px; padding-right: 14px; padding-left: 14px; }
  .workspace main { margin-left: 218px; padding: 36px 28px; }
  .workspace .app-footer { margin-left: 218px; }
  .today-layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .today-layout .daily-habits { padding: 24px 0 0; border-top: 1px solid var(--line); border-left: 0; }
}
@media (max-width: 920px) {
  .two-columns { grid-template-columns: minmax(0, 1fr); gap: 20px; }
}
@media (max-width: 760px) {
  .workspace .app-sidebar { position: relative; width: 100%; gap: 14px; padding: 12px 16px 10px; overflow: visible; border-bottom: 1px solid var(--line); }
  .workspace .app-sidebar .brand { min-height: 38px; padding: 0; color: #fff; font-size: 17px; }
  .app-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px 4px; }
  .nav-group { display: contents; }
  .nav-group-title { display: none; }
  .app-nav a { justify-content: center; gap: 7px; min-height: 44px; padding: 7px 3px; color: var(--muted); border-radius: 7px; font-size: 13px; }
  .app-nav a[aria-current="page"] { color: var(--accent-hover); background: var(--accent-soft); }
  .app-nav a[aria-current="page"]::before { top: 8px; bottom: 8px; left: 0; width: 2px; background: var(--accent); }
  .app-nav .ui-icon { width: 18px; height: 18px; }
  .logout-form { position: absolute; top: 10px; right: 14px; margin: 0; }
  .logout-form button { width: auto; min-height: 38px; padding: 5px 8px; color: var(--muted); border-color: transparent; background: transparent; font-size: 13px; }
  .logout-form button:hover { color: var(--ink); background: var(--accent-soft); }
  .logout-form .ui-icon { width: 17px; height: 17px; }
  .workspace main { min-height: calc(100dvh - 230px); margin: 0; padding: 28px 18px 34px; }
  .workspace .app-footer { margin: 0; padding: 16px; }
  .page-heading { flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 26px; }
  .page-heading h1 { font-size: 34px; }
  .page-heading .links { justify-content: flex-start; width: 100%; }
  .page-heading .links .button { flex: 1; }
  .journal-date-tools { align-items: stretch; flex-direction: column; gap: 8px; margin-top: -8px; }
  .date-picker { grid-template-columns: minmax(0, 1fr) auto; }
  .date-picker label { grid-column: 1 / -1; }
  .date-navigation { gap: 4px 14px; }
  .day-detail-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .lead { font-size: 14px; }
  .two-columns { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .today-layout { gap: 20px; }
  .today-layout .daily-tasks { padding: 22px 19px; border-radius: 12px; }
  .today-layout .daily-habits { padding-top: 18px; }
  .daily-task { grid-template-columns: minmax(0, 1fr) 120px; gap: 10px 14px; padding: 18px 0; }
  .daily-tasks article + article { padding-top: 18px; }
  .task-completion { grid-column: 2; }
  .task-edit { grid-column: 2; }
  .panel:has(> form), .panel:has(> details) { padding: 22px 19px; }
  main td a { min-height: 70px; padding: 8px 1px; }
  main th, main td { padding: 5px 2px; font-size: 13px; }
  main td small { font-size: 10px; }
}
@media (max-width: 430px) {
  .workspace main { padding-right: 14px; padding-left: 14px; }
  .app-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px 2px; }
  .app-nav a { gap: 4px; font-size: 12px; }
  .logout-form button { gap: 4px; }
  .daily-task { grid-template-columns: minmax(0, 1fr); }
  .task-copy, .task-completion, .task-control, .task-edit { grid-column: 1; }
  .task-completion { grid-row: auto; align-items: flex-start; }
  .task-completion .task-complete { width: auto; min-width: 112px; }
  .task-control { grid-row: auto; }
  .task-control button { width: auto; }
  .task-edit { grid-row: auto; justify-self: start; margin-top: 0; }
  .task-note { width: 100%; }
  .page-heading h1 { font-size: 31px; }
  .auth-page main { margin-top: 24px; padding: 0 16px; }
  .auth-page .page-shell > .panel { padding: 22px 18px; }
  main th, main td { font-size: 12px; }
  main td a { min-height: 62px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Keep generation, result and editing in the same working area. */
.review-workspace { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; gap: 24px; margin: 24px 0; }
.review-workspace > .panel, .review-editor > .panel, .goal-ai { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.review-editor { min-width: 0; }
.review-workspace .review-sources { margin: 16px 0; }
.review-sources > summary, .review-evidence > summary, .goal-ai > summary { min-height: 44px; padding: 10px 0; cursor: pointer; font-weight: 600; }
.review-evidence { margin-top: 24px; }
.review-evidence[open] > section { margin-top: 24px; }
.ai-inline-result:not(:empty) { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.ai-inline-result h1 { font-size: 24px; }
.ai-inline-result [data-ai-breadcrumb] { display: none; }
.workspace p[role="status"]:empty { display: none; }
.ai-shortcuts { display: flex; flex-wrap: wrap; gap: 10px 20px; margin: 16px 0 24px; }
.ai-shortcuts a { display: inline-flex; align-items: center; min-height: 44px; }
@media (max-width: 1100px) { .review-workspace { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .review-workspace { gap: 18px; } .review-workspace > .panel, .review-editor > .panel, .goal-ai { padding: 20px 18px; } }
