:root {
  color-scheme: light;
  --ink: #152432;
  --muted: #64717a;
  --soft-ink: #344651;
  --bg: #f2f4f1;
  --paper: #fffefb;
  --line: #d9ded9;
  --line-strong: #c5ccc6;
  --orange: #f45d35;
  --orange-dark: #d94621;
  --mint: #dcefe8;
  --green: #28785e;
  --blue: #3168ac;
  --amber: #b67616;
  --red: #b33a3a;
  --violet: #725795;
  --shadow: 0 10px 28px rgba(21, 36, 50, 0.07);
  font-family: "DM Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  min-width: 320px;
}

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

button,
.button-like {
  align-items: center;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 750;
  gap: 6px;
  justify-content: center;
  letter-spacing: 0;
  min-height: 42px;
  padding: 0 14px;
  text-decoration: none;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

button:hover,
.button-like:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.button-like:focus-visible {
  outline: 3px solid rgba(244, 93, 53, 0.28);
  outline-offset: 2px;
}

button.secondary,
.button-like.secondary {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--ink);
}

button.danger {
  background: var(--red);
  border-color: var(--red);
}

.icon-button {
  font-size: 22px;
  height: 42px;
  min-height: 42px;
  padding: 0;
  width: 42px;
}

.text-button {
  background: transparent;
  border-color: transparent;
  color: var(--ink);
  min-height: 40px;
  padding: 0 8px;
}

.danger-text {
  color: var(--red);
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  letter-spacing: 0;
  min-height: 42px;
  padding: 10px 11px;
  width: 100%;
}

textarea {
  line-height: 1.6;
  min-height: 110px;
  resize: vertical;
}

.app-header {
  align-items: center;
  background: rgba(255, 254, 251, 0.96);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  min-height: 72px;
  padding: 10px clamp(18px, 4vw, 56px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  gap: 11px;
  justify-self: start;
  text-decoration: none;
}

.brand-mark {
  background: var(--orange);
  border: 6px solid var(--ink);
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px #fff;
  height: 28px;
  width: 28px;
}

.brand span:last-child {
  display: grid;
  gap: 1px;
}

.brand strong {
  font-size: 18px;
}

.brand small,
.save-state {
  color: var(--muted);
  font-size: 12px;
}

.view-tabs,
.segmented {
  background: #e8ece7;
  border: 1px solid #dde3dd;
  border-radius: 7px;
  display: flex;
  gap: 2px;
  padding: 3px;
}

.view-tab,
.segment {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  min-height: 38px;
}

.view-tab.active,
.segment.active {
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 2px 8px rgba(21, 36, 50, 0.08);
  color: var(--ink);
}

.header-actions {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-self: end;
}

.reminder-toggle {
  background: #fff7e3;
  border-color: #d6a644;
  color: #8a5c00;
}

.reminder-toggle.is-ready {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.app-main {
  margin: 0 auto;
  max-width: 1320px;
  padding: 32px clamp(18px, 4vw, 48px) 80px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.day-heading,
.page-heading,
.section-heading {
  align-items: end;
  display: flex;
  gap: 20px;
  justify-content: space-between;
}

.day-heading,
.page-heading {
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--orange-dark);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  margin: 0 0 5px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: clamp(32px, 4.2vw, 54px);
  line-height: 1.05;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 17px;
}

.date-title-row {
  align-items: baseline;
  display: flex;
  gap: 12px;
}

.date-title-row span {
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
}

.date-controls,
.month-controls {
  align-items: center;
  display: flex;
  gap: 8px;
}

.date-controls input {
  width: 150px;
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 28px;
}

.summary-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 5px;
  min-height: 130px;
  padding: 18px;
}

.summary-card span,
.summary-card small {
  color: var(--muted);
}

.summary-card strong {
  font-size: 32px;
  line-height: 1.2;
}

.summary-primary {
  background: var(--orange);
  border-color: var(--orange-dark);
  color: #fff;
}

.summary-primary span,
.summary-primary small {
  color: rgba(255, 255, 255, 0.84);
}

.summary-focus {
  border-top: 5px solid var(--green);
}

.capacity-section,
.quick-add-section,
.tasks-section,
.day-review-section,
.result-feed-section {
  border-top: 1px solid var(--line-strong);
  padding: 24px 0 28px;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading.compact span,
.section-heading > span {
  color: var(--muted);
  font-size: 13px;
}

.capacity-list {
  display: grid;
  gap: 14px;
}

.capacity-row {
  align-items: center;
  display: grid;
  gap: 14px;
  grid-template-columns: 110px minmax(160px, 1fr) 190px;
}

.capacity-label {
  align-items: center;
  display: flex;
  font-weight: 800;
  gap: 9px;
}

.category-swatch {
  background: var(--category-color, var(--green));
  border-radius: 3px;
  flex: 0 0 9px;
  height: 24px;
  width: 9px;
}

.capacity-track {
  background: #dfe5df;
  border: 1px solid #d5dbd5;
  border-radius: 4px;
  height: 30px;
  overflow: hidden;
  position: relative;
}

.capacity-plan,
.capacity-actual {
  bottom: 0;
  left: 0;
  position: absolute;
  top: 0;
}

.capacity-plan {
  background: color-mix(in srgb, var(--category-color, var(--green)) 24%, #fff);
}

.capacity-actual {
  background: var(--category-color, var(--green));
  bottom: 4px;
  top: 4px;
}

.capacity-values {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: right;
}

.capacity-values strong {
  color: var(--ink);
}

.quick-add-form {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(240px, 1fr) 120px 120px 138px auto;
}

.quick-add-form #taskNoteInput {
  grid-column: 1 / -1;
  min-height: 76px;
}

.primary-action {
  background: var(--orange);
  border-color: var(--orange-dark);
}

.task-list-heading {
  align-items: center;
}

.task-list {
  display: grid;
  gap: 12px;
}

.task-card {
  --category-color: var(--green);
  align-items: start;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 6px solid var(--category-color);
  border-radius: 8px;
  box-shadow: 0 5px 18px rgba(21, 36, 50, 0.05);
  display: grid;
  gap: 18px;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  padding: 17px 17px 17px 14px;
}

.task-card.is-recorded {
  background: #fbfefc;
}

.task-card.is-timing {
  box-shadow: 0 0 0 2px rgba(244, 93, 53, 0.2), 0 8px 22px rgba(21, 36, 50, 0.08);
}

.task-time {
  display: grid;
  gap: 3px;
}

.task-time strong {
  font-size: 18px;
}

.task-time span,
.task-time small,
.task-meta,
.task-note,
.result-meta {
  color: var(--muted);
  font-size: 13px;
}

.task-body {
  min-width: 0;
}

.task-title-line {
  align-items: flex-start;
  display: flex;
  gap: 9px;
  justify-content: space-between;
}

.category-tag,
.recorded-tag,
.score-tag {
  background: color-mix(in srgb, var(--category-color, var(--green)) 14%, #fff);
  border: 1px solid color-mix(in srgb, var(--category-color, var(--green)) 28%, #fff);
  border-radius: 999px;
  color: var(--category-color, var(--green));
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 6px 8px;
}

.task-note {
  line-height: 1.6;
  margin: 8px 0 0;
}

.check-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.check-item {
  background: #f0f3ef;
  border-radius: 4px;
  color: var(--soft-ink);
  font-size: 12px;
  padding: 5px 7px;
}

.result-preview {
  background: var(--mint);
  border-left: 3px solid var(--green);
  border-radius: 0 6px 6px 0;
  margin-top: 12px;
  padding: 10px 12px;
}

.result-preview strong {
  color: var(--green);
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

.result-preview p {
  line-height: 1.55;
  margin: 0;
}

.task-actions {
  align-items: center;
  display: flex;
  gap: 7px;
}

.task-tools {
  display: grid;
  gap: 9px;
  min-width: 310px;
}

.task-timer {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 7px;
  padding-bottom: 10px;
}

.timer-sessions {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding-top: 10px;
}

.timer-sessions-heading {
  align-items: baseline;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.timer-sessions-heading strong {
  color: var(--ink);
  font-size: 13px;
}

.timer-sessions-heading span {
  color: var(--muted);
  font-size: 12px;
}

.timer-session-list {
  display: grid;
}

.timer-session-history {
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
}

.timer-session-history > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  list-style: none;
  min-height: 42px;
  padding: 8px 2px;
}

.timer-session-history > summary::-webkit-details-marker {
  display: none;
}

.timer-session-history > summary > span:first-child {
  align-items: baseline;
  display: flex;
  gap: 8px;
}

.timer-session-history > summary strong {
  color: var(--ink);
  font-size: 13px;
}

.timer-session-history > summary small,
.timer-history-toggle {
  color: var(--muted);
  font-size: 12px;
}

.timer-history-toggle::before {
  content: "展开";
}

.timer-session-history[open] .timer-history-toggle::before {
  content: "收起";
}

.timer-session-history[open] > summary {
  border-bottom: 1px solid var(--line);
}

.timer-session-history[open] .timer-session-list {
  padding-bottom: 2px;
}

.timer-session {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: 128px 130px minmax(180px, 1fr) auto;
  padding: 9px 0;
}

.timer-session:first-child {
  border-top: 1px solid var(--line);
}

.timer-session-history .timer-session:first-child {
  border-top: 0;
}

.timer-session.is-active {
  background: #fff7f2;
  box-shadow: inset 3px 0 0 var(--orange);
  padding-left: 10px;
  padding-right: 8px;
}

.timer-session.is-paused {
  background: #fff9e8;
  box-shadow: inset 3px 0 0 #d79a22;
  padding-left: 10px;
  padding-right: 8px;
}

.timer-session-number {
  align-items: baseline;
  display: flex;
  gap: 7px;
}

.timer-session-number span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.timer-session-number strong {
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.timer-session.is-active .timer-session-number strong,
.timer-session.is-active .timer-session-window small {
  color: var(--orange-dark);
}

.timer-session.is-paused .timer-session-number strong,
.timer-session.is-paused .timer-session-window small {
  color: #966411;
}

.timer-session-window {
  display: grid;
  gap: 2px;
}

.timer-session-window span,
.timer-session-window small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.timer-session-note {
  min-width: 0;
}

.session-completion {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  font: inherit;
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

.session-completion:focus {
  border-color: var(--orange);
  outline: 2px solid color-mix(in srgb, var(--orange) 22%, transparent);
  outline-offset: 1px;
}

.timer-session-actions {
  display: flex;
  justify-content: flex-end;
}

.session-edit-button,
.timer-add-segment {
  min-height: 38px;
  padding: 7px 11px;
  white-space: nowrap;
}

.timer-add-segment {
  justify-self: start;
}

.segment-duration-preview {
  background: var(--mint);
  border-left: 4px solid var(--green);
  border-radius: 0 6px 6px 0;
  color: #1d674e;
  font-size: 13px;
  font-weight: 800;
  padding: 10px 12px;
}

.segment-duration-preview.is-error {
  background: #fff0ec;
  border-left-color: var(--red);
  color: var(--red);
}

.timer-heading {
  align-items: baseline;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.timer-heading span,
.timer-status {
  color: var(--muted);
  font-size: 12px;
}

.timer-heading strong {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  white-space: nowrap;
}

.task-card.is-timing .timer-status {
  color: var(--orange-dark);
}

.timer-controls {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.timer-button {
  font-size: 12px;
  min-height: 38px;
  padding: 0 8px;
  white-space: nowrap;
}

.timer-start {
  background: var(--green);
  border-color: var(--green);
}

.record-result-button {
  background: var(--ink);
  min-width: 104px;
}

.task-edit-button {
  font-size: 13px;
  padding: 0 10px;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  padding: 40px 20px;
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  display: block;
  margin-bottom: 6px;
}

.calendar-layout {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr) 300px;
}

.calendar-panel {
  min-width: 0;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
  text-align: center;
}

.calendar-day {
  align-items: stretch;
  aspect-ratio: 1 / 0.88;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 82px;
  padding: 9px;
  text-align: left;
}

.calendar-day.outside {
  background: transparent;
  color: #a3aba5;
}

.calendar-day.selected {
  border: 2px solid var(--orange);
}

.calendar-day.today {
  box-shadow: inset 0 4px 0 var(--ink);
}

.calendar-day small {
  color: var(--muted);
  display: grid;
  font-size: 11px;
  line-height: 1.35;
}

.calendar-day .day-progress {
  background: #dfe5df;
  border-radius: 3px;
  height: 5px;
  overflow: hidden;
}

.calendar-day .day-progress span {
  background: var(--green);
  display: block;
  height: 100%;
}

.calendar-detail {
  border-left: 1px solid var(--line-strong);
  min-width: 0;
  padding-left: 24px;
}

.calendar-detail h2 {
  margin-bottom: 8px;
}

.calendar-detail-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.calendar-detail-item {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
}

.calendar-detail-item span {
  color: var(--muted);
  font-size: 12px;
}

.day-review-form {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.day-review-form label,
.modal-panel label {
  color: var(--soft-ink);
  display: grid;
  font-size: 13px;
  font-weight: 800;
  gap: 7px;
}

.day-review-form textarea {
  min-height: 132px;
}

.review-actions {
  display: flex;
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.result-feed {
  display: grid;
  gap: 10px;
}

.result-entry {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 14px;
  grid-template-columns: 82px minmax(0, 1fr) auto;
  padding: 4px 0 16px;
}

.result-entry-time {
  color: var(--muted);
  font-weight: 800;
}

.result-entry h3 {
  margin-bottom: 6px;
}

.result-entry p {
  line-height: 1.65;
  margin: 0 0 7px;
}

.result-details {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 4px;
}

.modal {
  background: transparent;
  border: 0;
  max-height: 100vh;
  max-width: 100vw;
  padding: 18px;
  width: 100%;
}

.modal::backdrop {
  background: rgba(13, 24, 32, 0.56);
}

.modal-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(11, 20, 27, 0.28);
  display: grid;
  gap: 16px;
  margin: auto;
  max-height: calc(100vh - 36px);
  max-width: 720px;
  overflow: auto;
  padding: 22px;
  width: 100%;
}

.modal-head {
  align-items: start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.result-task-context {
  background: #eef1ed;
  border-left: 4px solid var(--orange);
  border-radius: 0 6px 6px 0;
  color: var(--soft-ink);
  line-height: 1.6;
  padding: 10px 12px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-columns {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.full-field small,
.modal-panel label small {
  color: var(--muted);
  font-weight: 500;
}

.modal-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.action-spacer {
  flex: 1;
}

.settings-dialog-panel {
  max-width: 560px;
}

.settings-block {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.settings-block p {
  color: var(--muted);
  line-height: 1.6;
  margin: 7px 0 14px;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sync-settings {
  border-top: 0;
  padding-top: 0;
}

.settings-title-row {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.settings-title-row p {
  margin-bottom: 10px;
}

.sync-badge {
  background: var(--mint);
  border: 1px solid #9fcabc;
  border-radius: 999px;
  color: #1d674e;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 8px;
}

.sync-token-field,
.modal-panel label.sync-token-field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.sync-token-field > span {
  color: var(--soft-ink);
  font-size: 13px;
  font-weight: 800;
}

.toggle-row,
.modal-panel label.toggle-row {
  align-items: center;
  background: #f3f5f1;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  display: grid;
  gap: 12px;
  grid-template-columns: 22px minmax(0, 1fr);
  margin: 0 0 12px;
  padding: 12px;
}

.toggle-row input {
  accent-color: var(--green);
  height: 20px;
  margin: 0;
  min-height: 20px;
  padding: 0;
  width: 20px;
}

.toggle-row span {
  display: grid;
  gap: 2px;
}

.toggle-row small,
.settings-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.settings-block .settings-note {
  margin-bottom: 0;
}

.alarm {
  align-items: center;
  background: var(--ink);
  border: 1px solid #3d4d57;
  border-left: 6px solid var(--orange);
  border-radius: 8px;
  bottom: 18px;
  box-shadow: 0 20px 52px rgba(10, 18, 24, 0.28);
  color: #fff;
  display: grid;
  gap: 13px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  left: 50%;
  max-width: calc(100vw - 28px);
  padding: 13px 14px;
  position: fixed;
  transform: translateX(-50%);
  width: 560px;
  z-index: 50;
}

.alarm-icon {
  align-items: center;
  background: var(--orange);
  border-radius: 50%;
  display: inline-flex;
  font-size: 19px;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.alarm-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.alarm-copy small,
.alarm-copy span {
  color: #c9d2d7;
  font-size: 12px;
}

.alarm-copy strong {
  overflow-wrap: anywhere;
}

.alarm button {
  background: #fff;
  border-color: #fff;
  color: var(--ink);
}

body:has(.alarm:not([hidden])) .toast {
  bottom: 104px;
}

.toast {
  background: var(--ink);
  border: 1px solid #3d4d57;
  border-radius: 6px;
  bottom: 22px;
  box-shadow: 0 16px 40px rgba(10, 18, 24, 0.22);
  color: #fff;
  left: 50%;
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 40;
}

.sr-only,
.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

@media (max-width: 980px) {
  .app-header {
    gap: 12px;
    grid-template-columns: 1fr auto;
  }

  .view-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .view-tab {
    flex: 1;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-add-form {
    grid-template-columns: minmax(220px, 1fr) repeat(2, 112px) 130px;
  }

  .quick-add-form .primary-action {
    grid-column: 1 / -1;
  }

  .calendar-layout {
    grid-template-columns: 1fr;
  }

  .calendar-detail {
    border-left: 0;
    border-top: 1px solid var(--line-strong);
    padding-left: 0;
    padding-top: 20px;
  }

  .timer-session {
    grid-template-columns: 118px minmax(0, 1fr);
  }

  .timer-session-note {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .app-header {
    min-height: 64px;
    padding: 9px 14px;
  }

  .brand small,
  .save-state {
    display: none;
  }

  .header-actions {
    gap: 4px;
  }

  .app-main {
    padding: 22px 14px 72px;
  }

  .day-heading,
  .page-heading,
  .section-heading.task-list-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .date-controls {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
  }

  .date-controls input {
    width: 100%;
  }

  .today-button {
    grid-column: 1 / -1;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-card {
    min-height: 118px;
    padding: 14px;
  }

  .summary-card strong {
    font-size: 26px;
  }

  .capacity-row {
    gap: 8px 10px;
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .capacity-values {
    grid-column: 1 / -1;
    text-align: left;
  }

  .quick-add-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-add-form #taskTitleInput,
  .quick-add-form #taskNoteInput,
  .quick-add-form #taskCategoryInput,
  .quick-add-form .primary-action {
    grid-column: 1 / -1;
  }

  .segmented {
    width: 100%;
  }

  .segment {
    flex: 1;
    padding: 0 8px;
  }

  .task-card {
    gap: 12px;
    grid-template-columns: 74px minmax(0, 1fr);
    padding: 14px 12px 14px 10px;
  }

  .task-time strong {
    font-size: 16px;
  }

  .task-title-line {
    display: block;
  }

  .category-tag {
    margin-top: 7px;
  }

  .task-actions {
    grid-column: 1 / -1;
  }

  .task-tools {
    grid-column: 1 / -1;
    min-width: 0;
    width: 100%;
  }

  .timer-sessions-heading,
  .timer-session-number,
  .timer-session-window {
    align-items: flex-start;
  }

  .timer-sessions-heading {
    flex-direction: column;
    gap: 2px;
  }

  .timer-session-history > summary {
    align-items: flex-start;
  }

  .timer-session-history > summary > span:first-child {
    align-items: flex-start;
    display: grid;
    gap: 2px;
  }

  .timer-session {
    gap: 6px;
    grid-template-columns: minmax(0, 1fr);
  }

  .timer-session-number {
    justify-content: space-between;
  }

  .timer-session-actions {
    justify-content: stretch;
  }

  .session-edit-button,
  .timer-add-segment {
    width: 100%;
  }

  .timer-session-window {
    display: flex;
    gap: 8px;
    justify-content: space-between;
  }

  .timer-session-note {
    grid-column: auto;
  }

  .record-result-button {
    flex: 1;
  }

  .calendar-day {
    aspect-ratio: auto;
    min-height: 72px;
    padding: 7px;
  }

  .calendar-day small {
    font-size: 10px;
  }

  .day-review-form,
  .two-columns,
  .three-columns {
    grid-template-columns: 1fr;
  }

  .result-entry {
    grid-template-columns: 1fr;
  }

  .result-entry-time {
    font-size: 13px;
  }

  .modal {
    padding: 0;
  }

  .modal-panel {
    border-radius: 0;
    max-height: 100vh;
    min-height: 100vh;
    padding: 18px 14px 28px;
  }

  .modal-actions {
    align-items: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-title-row {
    display: grid;
  }

  .sync-badge {
    justify-self: start;
  }

  .modal-actions .action-spacer {
    display: none;
  }

  .alarm {
    bottom: 12px;
    grid-template-columns: auto minmax(0, 1fr);
    left: 12px;
    max-width: none;
    right: 12px;
    transform: none;
    width: auto;
  }

  .alarm button {
    grid-column: 1 / -1;
    width: 100%;
  }

  body:has(.alarm:not([hidden])) .toast {
    bottom: 152px;
  }
}

@media (max-width: 390px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-card {
    min-height: 104px;
  }

  .calendar-grid,
  .calendar-weekdays {
    gap: 3px;
  }

  .calendar-day {
    min-height: 64px;
  }
}

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