:root {
  color-scheme: light;
  --canvas: #f4f3ef;
  --surface: #faf9f6;
  --surface-raised: #ffffff;
  --text: #242825;
  --text-soft: #68706a;
  --text-faint: #929891;
  --line: #dfdfd9;
  --line-soft: #e9e8e3;
  --accent: #617c6a;
  --accent-soft: #dfe8e1;
  --shadow: 0 20px 60px rgba(39, 47, 41, 0.06);
  --radius-large: 24px;
  --radius-medium: 15px;
  --ease: 180ms ease;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #171917;
  --surface: #1d201e;
  --surface-raised: #232724;
  --text: #eceeea;
  --text-soft: #a7afa8;
  --text-faint: #737b75;
  --line: #333834;
  --line-soft: #2b302c;
  --accent: #9bb6a2;
  --accent-soft: #2e3c32;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; }

html { background: var(--canvas); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--text);
  transition: background var(--ease), color var(--ease);
}

button, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; }

.topbar {
  height: 72px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  color: var(--text);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.topbar-actions { display: flex; align-items: center; gap: 15px; }

.save-state { color: var(--text-faint); font-size: 12px; }
.ai-button { min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); color: var(--text-soft); cursor: pointer; font-size: 12px; }
.ai-button:hover { color: var(--text); border-color: var(--text-faint); }
.data-button { min-height: 34px; padding: 0 7px; border: 0; background: transparent; color: var(--text-faint); cursor: pointer; font-size: 11px; }
.data-button:hover { color: var(--text); }
.logout-link { display: inline-flex; align-items: center; text-decoration: none; }

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease);
}

.icon-button:hover { background: var(--surface); border-color: var(--text-faint); }

.workspace {
  width: min(1370px, calc(100% - 48px));
  min-height: calc(100vh - 104px);
  margin: 0 auto 32px;
  display: grid;
  grid-template-columns: 220px minmax(430px, 1fr) 280px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-large);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.area-nav, .capture-panel { padding: 34px 26px; }
.area-nav { border-right: 1px solid var(--line-soft); }
.capture-panel { border-left: 1px solid var(--line-soft); }
.area-list { display: grid; gap: 5px; }

.area-tab {
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 11px;
  background: transparent;
  color: var(--text-soft);
  text-align: left;
  cursor: pointer;
  transition: color var(--ease), background var(--ease);
}

.area-tab:hover { color: var(--text); background: var(--line-soft); }
.area-tab[data-active="true"] { color: var(--text); background: var(--accent-soft); }

.area-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.area-tab[data-tone="sage"] .area-dot { background: #769580; }
.area-tab[data-tone="sky"] .area-dot { background: #7692a5; }
.area-tab[data-tone="sand"] .area-dot { background: #a28d6c; }
.area-tab[data-tone="lilac"] .area-dot { background: #8c83a1; }

.quiet-button {
  border: 0;
  padding: 9px 11px;
  border-radius: 9px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
}

.quiet-button:hover { color: var(--text); background: var(--line-soft); }
.add-area-button { margin-top: 22px; font-size: 13px; }

.focus-panel { width: min(100%, 680px); padding: clamp(52px, 7vw, 92px) clamp(42px, 7vw, 92px); }
.eyebrow, .section-label { color: var(--text-faint); font-size: 12px; letter-spacing: .03em; }
.eyebrow { margin-bottom: 50px; text-transform: uppercase; letter-spacing: .1em; }
.section-label { margin: 0 0 12px; }

.goal-block h1 {
  max-width: 590px;
  margin: 0;
  font-size: clamp(31px, 4.3vw, 52px);
  font-weight: 470;
  letter-spacing: -0.045em;
  line-height: 1.08;
}

.progress-track { width: min(100%, 390px); height: 3px; margin-top: 30px; overflow: hidden; border-radius: 99px; background: var(--line); }
.progress-track span { display: block; width: 25%; height: 100%; border-radius: inherit; background: var(--accent); transition: width 500ms ease; }
.progress-copy { margin: 10px 0 0; color: var(--text-faint); font-size: 12px; }
.recent-progress { margin-top: 24px; }
.recent-progress .section-label { margin-bottom: 8px; }
.recent-progress ul { max-width: 440px; margin: 0; padding: 0; display: grid; gap: 6px; list-style: none; }
.recent-progress li { color: var(--text-soft); font-size: 12px; line-height: 1.45; }
.recent-progress li::before { content: "✓"; margin-right: 8px; color: var(--accent); }
.priority-block { margin-top: 67px; }
.priority-title { margin: 0; color: var(--text-soft); font-size: 16px; }

.next-step-card {
  margin: 26px 0 20px;
  padding: 22px 22px 21px;
  border: 1px solid var(--line);
  border-radius: var(--radius-medium);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  background: var(--surface-raised);
}

.next-step-card h2 { margin: 0; font-size: 21px; font-weight: 520; letter-spacing: -.025em; line-height: 1.25; }
.estimate { flex: none; padding: 6px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }

.primary-button {
  min-height: 43px;
  padding: 0 18px;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.primary-button:disabled { opacity: .48; cursor: default; }
.stage-note { color: var(--text-faint); font-size: 11px; }
.focus-actions { display: flex; align-items: center; gap: 7px; }
.completion-note { min-height: 18px; margin: 12px 0 0; color: var(--text-soft); font-size: 12px; }
.next-step-card[data-empty="true"] { background: transparent; border-style: dashed; }
.capture-copy { margin: 0 0 22px; color: var(--text-soft); font-size: 14px; line-height: 1.55; }

.capture-form textarea {
  width: 100%;
  min-height: 78px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  resize: vertical;
  background: var(--surface-raised);
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

.capture-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.capture-form-footer { margin-top: 8px; display: flex; gap: 7px; }
.capture-form select, .inbox-controls select { min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-raised); color: var(--text-soft); font-size: 11px; }
.capture-form select { flex: 1; padding: 0 7px; }
.small-primary-button { min-height: 34px; padding: 0 11px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; font-size: 12px; }
.inbox-heading { margin-top: 36px; display: flex; align-items: baseline; justify-content: space-between; }
.inbox-heading-actions { display: flex; align-items: center; gap: 8px; }
.inbox-heading-actions button { padding: 3px 0; border: 0; background: transparent; color: var(--text-faint); cursor: pointer; font-size: 11px; }
.inbox-heading-actions button:hover { color: var(--text); }
.inbox-count { color: var(--text-faint); font-size: 11px; }
.inbox-list { display: grid; gap: 9px; max-height: 55vh; overflow-y: auto; padding-right: 2px; }
.inbox-empty { margin: 4px 0; color: var(--text-faint); font-size: 12px; line-height: 1.5; }
.inbox-item { padding: 12px; border: 1px solid var(--line-soft); border-radius: 11px; background: var(--surface-raised); }
.inbox-item p { margin: 0 0 11px; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.inbox-controls { display: flex; flex-wrap: wrap; gap: 5px; }
.inbox-controls select { flex: 1 1 100%; padding: 5px 7px; }
.inbox-controls button { padding: 5px 7px; border: 0; border-radius: 6px; background: var(--surface); color: var(--text-faint); cursor: pointer; font-size: 10px; }
.inbox-controls button:hover { color: var(--text); background: var(--line-soft); }

.undo-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  color: var(--text-soft);
  font-size: 12px;
}
.undo-toast[hidden] { display: none; }
.undo-toast button { border: 0; background: transparent; color: var(--accent); cursor: pointer; font-weight: 600; }

.ai-dialog { width: min(660px, calc(100% - 28px)); height: min(760px, calc(100vh - 40px)); padding: 0; border: 1px solid var(--line); border-radius: 22px; background: var(--surface-raised); color: var(--text); box-shadow: 0 28px 100px rgba(0,0,0,.22); }
.ai-dialog::backdrop { background: rgba(20,22,20,.38); backdrop-filter: blur(4px); }
.ai-shell { height: 100%; padding: 28px; display: flex; flex-direction: column; }
.ai-heading { margin-bottom: 18px; }
.ai-messages { flex: 1; min-height: 180px; overflow-y: auto; padding: 8px 2px 18px; }
.ai-message { width: fit-content; max-width: 86%; margin: 0 0 10px; padding: 10px 12px; border-radius: 12px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.ai-message.assistant { background: var(--surface); color: var(--text-soft); }
.ai-message.user { margin-left: auto; background: var(--accent-soft); color: var(--text); }
.ai-preview { margin: 0 0 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.ai-preview #ai-operations { display: grid; gap: 6px; }
.ai-preview #ai-operations p { margin: 0; padding: 8px 9px; border-radius: 8px; background: var(--surface-raised); color: var(--text-soft); font-size: 12px; }
.ai-preview .dialog-actions { margin-top: 12px; }
.ai-form { display: flex; align-items: flex-end; gap: 8px; }
.ai-form textarea { flex: 1; min-height: 74px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; resize: none; outline: none; background: var(--surface); color: var(--text); font: inherit; line-height: 1.4; }
.ai-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.work-dialog { width: 100vw; max-width: none; height: 100vh; max-height: none; margin: 0; padding: 0; border: 0; background: var(--canvas); color: var(--text); }
.work-shell { width: min(760px, calc(100% - 44px)); min-height: 100%; margin: 0 auto; padding: 38px 0; display: flex; flex-direction: column; }
.work-topline { display: flex; justify-content: space-between; align-items: baseline; }
.work-topline .eyebrow { margin: 0; }
.work-elapsed { color: var(--text-faint); font-size: 11px; }
.work-focus { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: 64px 0; }
.work-focus h2 { max-width: 700px; margin: 0 0 24px; font-size: clamp(38px, 7vw, 70px); font-weight: 460; letter-spacing: -.05em; line-height: 1.06; }
.work-note { margin-bottom: 28px; }
.work-note > label, .shrink-form label { display: block; margin-bottom: 8px; color: var(--text-faint); font-size: 11px; }
.work-note > div { display: flex; gap: 7px; }
.work-note input, .shrink-form input { min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: var(--surface); color: var(--text); }
.work-note input { flex: 1; }
.work-note input:focus, .shrink-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.work-note button { padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--text-soft); cursor: pointer; }
.work-running-actions { display: flex; justify-content: flex-end; }
.work-finish { padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.work-finish > p { margin: 0 0 14px; color: var(--text-soft); font-size: 13px; }
.work-finish-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.shrink-form { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.shrink-form .form-row { align-items: stretch; }
.shrink-form #shrink-title { flex: 1; }
.shrink-form #shrink-estimate { width: 80px; }

.data-dialog { width: min(590px, calc(100% - 32px)); max-height: calc(100vh - 40px); }
.data-shell { padding: 28px; }
.data-section { padding: 20px 0; border-top: 1px solid var(--line-soft); }
.data-section h3 { margin: 0 0 6px; font-size: 15px; font-weight: 560; }
.data-section p { margin: 0 0 14px; color: var(--text-soft); font-size: 12px; line-height: 1.5; }
.data-download { display: inline-flex; align-items: center; text-decoration: none; font-size: 12px; }
.data-section input[type="file"] { display: block; width: 100%; margin-bottom: 9px; padding: 10px; border: 1px dashed var(--line); border-radius: 9px; color: var(--text-soft); font-size: 11px; }
.backup-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }
.backup-list { display: grid; gap: 7px; max-height: 210px; overflow-y: auto; color: var(--text-faint); font-size: 11px; }
.backup-row { padding: 9px 10px; border: 1px solid var(--line-soft); border-radius: 9px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.backup-row div { display: grid; gap: 2px; }
.backup-row strong { color: var(--text-soft); font-size: 11px; font-weight: 550; }
.backup-row button { border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: 10px; }

.capture-field {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-raised);
  color: var(--text-faint);
}

kbd { padding: 2px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); font: 11px inherit; }

.area-dialog {
  width: min(520px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: 0 24px 90px rgba(0,0,0,.18);
}

.area-dialog::backdrop { background: rgba(20, 22, 20, .35); backdrop-filter: blur(3px); }
.area-dialog form { padding: 28px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 30px; }
.dialog-heading h2 { margin: 0; font-size: 24px; font-weight: 500; letter-spacing: -.03em; }
.area-dialog label { display: block; margin: 18px 0 8px; color: var(--text-soft); font-size: 13px; }
.area-dialog input[type="text"], .area-dialog input:not([type]) { width: 100%; }
.area-dialog input:not([type="radio"]), .area-dialog textarea { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: var(--surface); color: var(--text); resize: vertical; }
.area-dialog input:not([type="radio"]):focus, .area-dialog textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.plan-dialog { width: min(620px, calc(100% - 32px)); }
.form-row { display: flex; align-items: flex-end; gap: 12px; }
.form-grow { flex: 1; }
.estimate-field { width: 95px; }
.label-note { color: var(--text-faint); font-weight: 400; }
.field-help { margin: 7px 0 0; color: var(--text-faint); font-size: 11px; }
.area-dialog .new-goal-option { margin-top: 24px; display: flex; align-items: center; gap: 9px; cursor: pointer; }
.area-dialog .new-goal-option input { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
.tone-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tone-options label { margin: 0; }
.tone-options input { position: absolute; opacity: 0; pointer-events: none; }
.tone { min-height: 38px; border: 1px solid var(--line); border-radius: 9px; display: grid; place-items: center; cursor: pointer; font-size: 12px; }
.tone-options input:checked + .tone { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--text); }
.tone.sage { background: color-mix(in srgb, #769580 13%, var(--surface)); }
.tone.sky { background: color-mix(in srgb, #7692a5 13%, var(--surface)); }
.tone.sand { background: color-mix(in srgb, #a28d6c 13%, var(--surface)); }
.tone.lilac { background: color-mix(in srgb, #8c83a1 13%, var(--surface)); }
.dialog-actions { margin-top: 30px; display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 180px 1fr; }
  .capture-panel { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line-soft); }
  .inbox-list { max-height: none; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .topbar { height: 60px; padding: 0 18px; }
  .save-state { display: none; }
  .ai-button { font-size: 11px; }
  .workspace { width: 100%; min-height: calc(100vh - 60px); margin: 0; grid-template-columns: 1fr; border: 0; border-radius: 0; }
  .area-nav { padding: 14px 18px; border: 0; border-bottom: 1px solid var(--line-soft); overflow-x: auto; }
  .area-list { display: flex; }
  .area-tab { width: auto; flex: none; padding: 9px 11px; }
  .add-area-button { margin: 5px 0 0; }
  .focus-panel { padding: 45px 22px; }
  .capture-panel { padding: 30px 22px 42px; }
  .inbox-list { grid-template-columns: 1fr; }
  .eyebrow { margin-bottom: 36px; }
  .goal-block h1 { font-size: 35px; }
  .priority-block { margin-top: 52px; }
  .tone-options { grid-template-columns: repeat(2, 1fr); }
  .work-shell { width: calc(100% - 36px); padding: 24px 0; }
  .work-focus h2 { font-size: 42px; }
  .work-finish-actions { display: grid; }
  .shrink-form .form-row { flex-wrap: wrap; }
}

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

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--canvas); color: var(--text); }
.login-card { width: min(430px, 100%); padding: 42px; border: 1px solid var(--line-soft); border-radius: 24px; background: var(--surface-raised); box-shadow: 0 24px 80px rgba(31, 38, 33, .08); }
.login-card .wordmark { display: block; margin-bottom: 72px; }
.login-card h1 { margin: 10px 0 16px; font-size: clamp(32px, 6vw, 46px); font-weight: 500; line-height: 1.05; letter-spacing: -.04em; }
.login-card > p:not(.section-label, .login-status) { color: var(--text-soft); line-height: 1.6; }
.login-button { width: 100%; margin-top: 30px; min-height: 48px; }
.login-status { min-height: 20px; margin: 14px 0 0; color: var(--text-faint); font-size: 13px; text-align: center; }

.access-page { min-height: 100vh; background: var(--canvas); color: var(--text); }
.access-shell { width: min(760px, calc(100% - 40px)); margin: 0 auto; padding: 36px 0 80px; }
.access-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 110px; }
.access-intro { margin-bottom: 48px; }
.access-intro h1 { margin: 10px 0 14px; font-size: clamp(40px, 7vw, 64px); font-weight: 500; letter-spacing: -.05em; }
.access-intro > p:last-child { max-width: 560px; color: var(--text-soft); line-height: 1.6; }
.access-panel { padding: 28px; border: 1px solid var(--line-soft); border-radius: 20px; background: var(--surface-raised); }
.credential-list { display: grid; gap: 2px; }
.credential-item { min-height: 74px; padding: 15px 4px; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.credential-item > div { display: grid; gap: 6px; }
.credential-item strong { font-size: 14px; font-weight: 550; }
.credential-item span { color: var(--text-faint); font-size: 12px; }
.credential-item button { border: 0; background: transparent; color: var(--text-faint); cursor: pointer; font-size: 12px; }
.credential-item button:hover:not(:disabled) { color: var(--text); }
.credential-item button:disabled { opacity: .35; cursor: default; }
.credential-actions { display: flex; gap: 12px; }
.credential-form { margin-top: 34px; }
.credential-form label { display: block; margin-bottom: 9px; color: var(--text-soft); font-size: 13px; }
.credential-form input { flex: 1; min-width: 0; padding: 12px 13px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: var(--surface); color: var(--text); }
.credential-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

@media (max-width: 560px) {
  .access-header { margin-bottom: 70px; }
  .access-panel { padding: 20px; }
  .credential-form .form-row { align-items: stretch; flex-direction: column; }
  .credential-form .primary-button { min-height: 46px; }
}
