:root {
  --ink: #19322d;
  --muted: #6b7a75;
  --line: #dbe4df;
  --paper: #f5f3ed;
  --card: #fffefa;
  --green: #176b54;
  --green-dark: #104a3c;
  --amber: #a45d05;
  --red: #b23a35;
  --shadow: 0 12px 32px rgba(21, 56, 47, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-width: 0; max-width: 100%; overflow-x: hidden; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  line-height: 1.5;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(23, 107, 84, .26);
  outline-offset: 2px;
}

.shell { width: min(720px, 100%); margin: 0 auto; padding: max(22px, env(safe-area-inset-top)) 16px 72px; }
.app-view { min-width: 0; }
.hero, .section-heading, .task-topline, .actions, .filters, .form-row {
  display: flex;
  align-items: center;
}
.hero, .section-heading { justify-content: space-between; gap: 12px; }
.header-actions { display: flex; align-items: center; gap: 2px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: clamp(26px, 8vw, 38px); line-height: 1.12; letter-spacing: -.04em; }
h2 { margin: 0; font-size: 22px; }
h3 { margin: 10px 0; font-size: 18px; line-height: 1.35; overflow-wrap: anywhere; }
.eyebrow { margin-bottom: 5px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.quiet-button { border: 0; background: transparent; color: var(--muted); padding: 8px; }
.quiet-button.active { color: var(--green); font-weight: 800; }

.section { margin-top: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 22px; background: var(--card); box-shadow: var(--shadow); min-width: 0; }
.section-note { flex: none; font-size: 12px; color: var(--muted); }
.daily-section { margin-top: 24px; }

.controls-heading { align-items: flex-end; }
.primary { width: 100%; border: 0; border-radius: 12px; padding: 12px 16px; background: var(--green); color: white; font-weight: 750; }
.primary:hover { background: var(--green-dark); }
.primary.compact { width: auto; flex: none; padding: 9px 12px; }
.create-form { margin: 16px 0; padding: 14px; border-radius: 15px; background: #f1f6f3; }
.create-form label, .filters label, .login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); min-width: 0; }
.create-form input, .create-form select, .create-form textarea, .filters select, .login-card input {
  min-width: 0; width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: white; color: var(--ink);
}
.create-form textarea { resize: vertical; min-height: 70px; line-height: 1.5; }
.create-form > * + * { margin-top: 12px; }
.quick-create-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.quick-create-footer small { color: var(--muted); font-size: 11px; line-height: 1.45; }
.quick-create-footer .primary { min-width: 76px; }
.subpage-header { display: grid; gap: 22px; }
.subpage-header h1 { margin-bottom: 0; }
.back-button { justify-self: start; border: 0; padding: 6px 2px; background: transparent; color: var(--green); font-weight: 750; }
.create-view { min-height: calc(100svh - 96px); }
.create-page-card { margin-top: 24px; }
.create-form-page { margin: 0; padding: 0; background: transparent; }
.create-form-page textarea { min-height: 132px; font-size: 16px; }
.voice-controls { display: flex; align-items: center; gap: 12px; }
.voice-input-button {
  flex: none; border: 1px solid #9bc9b7; border-radius: 999px; padding: 10px 16px;
  background: #edf6f1; color: var(--green-dark); font-weight: 750;
}
.voice-input-button::before { content: "●"; margin-right: 7px; color: var(--green); font-size: 11px; }
.voice-input-button[aria-pressed="true"] { border-color: #dc8d87; background: #fff0ef; color: var(--red); }
.voice-input-button[aria-pressed="true"]::before { color: var(--red); animation: voice-pulse 1s ease-in-out infinite; }
#voice-status { color: var(--muted); font-size: 12px; line-height: 1.45; }
@keyframes voice-pulse { 50% { opacity: .25; } }
.urgent-toggle { display: flex !important; align-items: center; gap: 10px; width: fit-content; cursor: pointer; }
.urgent-toggle input { width: 22px; height: 22px; margin: 0; accent-color: var(--red); }
.urgent-toggle span { color: var(--ink); font-size: 15px; font-weight: 750; }
.create-form-page .quick-create-footer { align-items: stretch; flex-direction: column; }
.create-form-page .quick-create-footer .primary { width: 100%; }
@media (max-width: 420px) {
  .voice-controls { align-items: stretch; flex-direction: column; gap: 7px; }
  .voice-input-button { width: 100%; }
}
.form-row { align-items: flex-start; gap: 10px; }
.form-row label { flex: 1 1 0; }

.board-status { min-height: 20px; margin: 10px 0 4px; color: var(--muted); font-size: 13px; }
.task-list { display: grid; gap: 12px; min-width: 0; }
.day-group { min-width: 0; padding-top: 8px; }
.day-group + .day-group { margin-top: 10px; border-top: 1px solid var(--line); }
.urgent-group { padding: 10px 0 14px; }
.urgent-group + .day-group { margin-top: 8px; }
.urgent-group .day-heading h3 { color: var(--red); }
.aging-group .day-heading h3 { color: #9a5709; }
.completed-group { margin-top: 18px !important; padding-top: 16px; border-top: 1px solid var(--line); }
.completed-group .day-heading h3 { color: var(--muted); }
.cancelled-group { margin-top: 14px !important; padding-top: 14px; border-top: 1px solid var(--line); }
.cancelled-group > summary { cursor: pointer; list-style: none; }
.cancelled-group > summary::-webkit-details-marker { display: none; }
.cancelled-group > summary h3 { color: #8a6666; }
.cancelled-group[open] > summary { margin-bottom: 8px; }
.day-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 5px 2px 10px; }
.day-heading h3 { margin: 0; font-size: 17px; color: var(--green-dark); }
.day-heading span { flex: none; color: var(--muted); font-size: 12px; }
.day-tasks { display: grid; gap: 10px; }
.task-card { min-width: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.task-card.aging { border-color: #e7bd82; background: #fffbf3; box-shadow: inset 4px 0 #c87817; }
.task-card.overdue { border-color: #e5a6a1; box-shadow: inset 4px 0 var(--red); }
.task-card.urgent { border-color: #df8e88; box-shadow: inset 4px 0 var(--red); }
.task-card.completed { border-color: #b9d8cb; background: #edf6f1; opacity: 1; }
.task-card.completed .task-title { color: #55736a; text-decoration: line-through; text-decoration-color: #7ca597; text-decoration-thickness: 1px; }
.task-card.completed .task-row-time { color: #789087; }
.task-card.cancelled { border-color: #decaca; background: #f8f1f1; }
.task-card.cancelled .task-title { color: #866d6d; text-decoration: line-through; text-decoration-color: #b99b9b; }
.task-card.cancelled .task-row-time { color: #927f7f; }
.task-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 68px; }
.task-row h3 { margin: 0; font-size: 15px; line-height: 1.35; }
.task-row-main { min-width: 0; }
.task-row-time { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.task-row-time span + span::before { content: " · "; }
.task-plan-time { display: inline-flex; flex-wrap: wrap; gap: 5px 10px; align-items: center; width: fit-content; margin: 6px 0 0; padding: 6px 9px; border-left: 4px solid #cf433d; border-radius: 6px; background: #fff0ed; color: #a72f2a; font-size: 12px; font-weight: 800; }
.task-plan-time[hidden] { display: none; }
.task-schedule { color: #a72f2a; }
.task-countdown { color: #c24136; }
.task-countdown.overdue { color: #9d1712; }
.task-row-labels { display: flex; max-width: 190px; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.complete-action { border: 1px solid #a9c8bd; border-radius: 999px; padding: 5px 12px; background: white; color: var(--green); font-size: 12px; font-weight: 800; }
.complete-action:hover { background: #e9f3ef; }
.edit-action, .reopen-action { border: 0; padding: 5px 7px; background: transparent; color: var(--green); font-size: 12px; font-weight: 750; }
.edit-action:hover, .reopen-action:hover { background: #edf6f1; border-radius: 999px; }
.cancel-action { border: 0; padding: 5px 7px; background: transparent; color: #9a6666; font-size: 12px; font-weight: 700; }
.cancel-action:hover { color: var(--red); }
.urgent-mark { padding: 3px 8px; border-radius: 999px; background: #fce7e5; color: var(--red); font-size: 11px; font-weight: 800; }
.aging-mark { padding: 3px 8px; border-radius: 999px; background: #fff0d8; color: #9a5709; font-size: 11px; font-weight: 800; }
.badges { display: flex; min-width: 0; flex-wrap: wrap; gap: 5px; }
.badge { display: inline-flex; max-width: 100%; padding: 3px 8px; border-radius: 999px; background: #e9f3ef; color: var(--green-dark); font-size: 11px; font-weight: 750; overflow-wrap: anywhere; }
.badge.status.completed { background: #dfeee7; color: var(--green-dark); }
.badge.status.pending_clarification, .badge.status.scheduled_suggested { background: #fff0da; color: var(--amber); }
.badge.hard { background: #fff0da; color: var(--amber); }
.badge.override { background: #eee9fb; color: #5b408c; }
.badge.risk { background: #fce7e5; color: var(--red); }
.badge.overdue { background: #fce7e5; color: var(--red); }
.priority-score { flex: none; color: var(--muted); font-size: 12px; }
.task-meta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 9px; margin: 0; font-size: 13px; }
.task-meta dt { color: var(--muted); }
.task-meta dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.importance { margin-top: 10px; color: var(--muted); font-size: 13px; }
.importance summary { color: var(--green); cursor: pointer; font-weight: 700; }
.importance p { margin: 8px 0 0; overflow-wrap: anywhere; }
.schedule-note { margin: 10px 0 0; padding: 9px; border-radius: 9px; background: #fff4e3; color: #774a12; font-size: 12px; overflow-wrap: anywhere; }
.schedule-note:empty { display: none; }
.actions { flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.actions button { flex: 1 1 82px; min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 8px 6px; background: white; color: var(--ink); font-size: 12px; }
.actions .complete { border-color: #b8d9cd; color: var(--green); }
.actions .danger { color: var(--red); }
.actions .confirm { background: var(--green); color: white; border-color: var(--green); }

.login-screen { min-height: 100svh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(390px, 100%); padding: 24px; border: 1px solid var(--line); border-radius: 22px; background: var(--card); box-shadow: var(--shadow); }
.login-card p:not(.eyebrow):not(.error) { color: var(--muted); }
.login-card button { margin-top: 16px; }
.error { min-height: 22px; margin: 10px 0 0; color: var(--red); font-size: 13px; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.stats-view { min-height: calc(100svh - 96px); }
.stats-card { margin-top: 24px; }
.stats-overview { padding: 22px; border-radius: 18px; background: linear-gradient(145deg, var(--green-dark), var(--green)); color: white; }
.stats-overview-copy { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.stats-overview-copy span { font-size: 14px; opacity: .82; }
.stats-overview-copy strong { font-size: 48px; line-height: .9; letter-spacing: -.05em; }
.stats-progress { height: 8px; margin-top: 22px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, .22); }
.stats-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: white; transition: width .35s ease; }
.stats-overview p { margin: 10px 0 0; font-size: 12px; opacity: .76; }
.stats-today { display: grid; grid-template-columns: auto 1fr 1fr; align-items: center; gap: 12px; margin-top: 14px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcfb; }
.stats-today-label { color: var(--green); font-size: 13px; font-weight: 800; }
.stats-today div { display: flex; align-items: baseline; justify-content: flex-end; gap: 6px; }
.stats-today div span { color: var(--muted); font-size: 12px; }
.stats-today div strong { color: var(--ink); font-size: 22px; }
.stats-primary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.stats-metric { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 5px 8px; padding: 18px; border-radius: 16px; }
.stats-metric span { grid-column: 1 / -1; font-size: 13px; font-weight: 700; }
.stats-metric strong { font-size: 36px; line-height: 1; }
.stats-metric small { padding-bottom: 2px; color: var(--muted); font-size: 11px; }
.completed-metric { border: 1px solid #b9d8cb; background: #edf6f1; color: #2f6958; }
.created-metric { border: 1px solid #c9dcd5; background: #f3f8f6; color: var(--green-dark); }
.stats-secondary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 14px; border: 1px solid var(--line); border-radius: 14px; }
.stats-secondary div { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 13px 15px; }
.stats-secondary div + div { border-left: 1px solid var(--line); }
.stats-secondary span { color: var(--muted); font-size: 12px; }
.stats-secondary strong { color: var(--ink); font-size: 20px; }
.stats-note { margin: 12px 2px 0; color: var(--muted); font-size: 11px; }

@media (max-width: 390px) {
  .shell { padding-left: 12px; padding-right: 12px; }
  .section { padding: 14px; border-radius: 18px; }
  .form-row { align-items: stretch; flex-direction: column; }
  .actions button { flex-basis: calc(50% - 7px); }
  .task-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .task-row-labels { max-width: 112px; }
}
