:root {
  color-scheme: light dark;
  --page: #f5f4f1;
  --panel: #ffffff;
  --panel-soft: #f7f8f6;
  --ink: #1d2921;
  --muted: #59665d;
  --quiet: #6d786f;
  --line: #7a887e;
  --line-soft: #c4cdc5;
  --accent: #31593f;
  --accent-strong: #254a32;
  --accent-soft: #e7eee8;
  --focus: #7b3fe4;
  --danger: #a12e2e;
  --danger-soft: #fff0ef;
  --high: #a43131;
  --high-soft: #fff0ee;
  --medium: #755000;
  --medium-soft: #fff5dc;
  --low: #315b3c;
  --low-soft: #eaf3eb;
  --shadow: 0 16px 42px rgb(34 47 37 / 7%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 28px 20px 24px;
  background:
    radial-gradient(ellipse at 10% 0%, rgb(230 235 226 / 72%), transparent 36rem),
    var(--page);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button,
select {
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

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

.skip-link {
  position: fixed;
  z-index: 20;
  top: 10px;
  left: 10px;
  padding: 12px 16px;
  transform: translateY(-160%);
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 700;
}

.skip-link:focus {
  transform: translateY(0);
}

.shell {
  display: grid;
  grid-template-columns: minmax(300px, 0.83fr) minmax(0, 1.17fr);
  gap: 24px;
  width: min(1120px, 100%);
  min-height: 680px;
  margin: 0 auto;
  align-items: start;
}

.deck,
.board {
  border: 1px solid var(--line-soft);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.deck {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  min-height: 620px;
  padding: 30px;
  background:
    linear-gradient(155deg, rgb(255 255 255 / 90%), rgb(247 249 246 / 94%)),
    var(--panel);
}

.brand-row,
.board-heading,
.add-fields,
.field-meta,
.progress-copy,
.stats,
.toolbar,
.task-row,
.task-meta,
.task-actions,
.edit-actions,
.undo-notice {
  display: flex;
  align-items: center;
}

.brand-row,
.board-heading {
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 19px;
  font-weight: 760;
  letter-spacing: -0.5px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: var(--accent);
  color: white;
  font-size: 19px;
  font-weight: 800;
}

.today-date {
  color: var(--muted);
  font-size: 14px;
  font-weight: 620;
}

.welcome {
  margin: 38px 0 27px;
}

.eyebrow,
.card-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 1.35px;
}

.welcome h1 {
  max-width: 360px;
  margin: 10px 0 9px;
  font-size: clamp(29px, 3vw, 39px);
  line-height: 1.12;
  letter-spacing: -1.5px;
}

.welcome > p:last-child {
  max-width: 330px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.progress-card {
  padding: 19px 20px;
  border: 1px solid var(--line-soft);
  border-radius: 15px;
  background: var(--panel);
}

.progress-copy {
  justify-content: space-between;
  gap: 12px;
}

.progress-summary {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.progress-summary strong {
  color: var(--accent);
  font-size: 20px;
  letter-spacing: -0.5px;
}

.progress-track {
  height: 9px;
  margin: 16px 0 18px;
  overflow: hidden;
  border-radius: 20px;
  background: var(--line-soft);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.stats {
  justify-content: space-between;
  gap: 12px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat strong {
  font-size: 19px;
  line-height: 1.1;
}

.stat span {
  color: var(--muted);
  font-size: 14px;
}

.add-card {
  margin-top: 25px;
}

.add-fields {
  align-items: stretch;
  gap: 8px;
  margin-top: 11px;
}

.title-field {
  min-width: 0;
  flex: 1;
}

.add-fields input,
.add-fields select,
.search-wrap input,
.priority-filter,
.edit-form input,
.edit-form select {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
}

.add-fields input,
.search-wrap input,
.edit-form input {
  width: 100%;
  padding: 0 13px;
}

.add-fields input::placeholder,
.search-wrap input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.add-fields select,
.edit-form select {
  min-width: 116px;
  padding: 0 28px 0 10px;
}

.button {
  min-height: 46px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.button-primary {
  background: var(--accent);
  color: white;
}

.button-primary:hover {
  background: var(--accent-strong);
}

.add-button {
  padding-inline: 13px;
}

.add-button span {
  margin-right: 4px;
  font-size: 18px;
}

.button-quiet {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

.button-quiet:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.button-small {
  min-height: 44px;
}

.field-meta {
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.field-error,
.edit-error {
  min-height: 0;
  margin: 0;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
}

.field-error:not(:empty) {
  margin-top: 7px;
}

.save-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding-top: 25px;
  color: var(--muted);
  font-size: 13px;
}

.save-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
}

.storage-warning {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 650;
}

.board {
  min-height: 620px;
  padding: 30px;
}

.board-heading {
  margin-bottom: 22px;
}

.board-heading h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 7px 0 0;
  font-size: 27px;
  letter-spacing: -0.7px;
}

.count-pill {
  display: inline-grid;
  min-width: 27px;
  height: 27px;
  padding: 0 7px;
  place-items: center;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  letter-spacing: 0;
}

.clear-button {
  min-height: 44px;
}

.toolbar {
  flex-wrap: wrap;
  gap: 9px;
  padding-bottom: 17px;
  border-bottom: 1px solid var(--line-soft);
}

.search-wrap {
  position: relative;
  min-width: 180px;
  flex: 1 1 200px;
}

.search-wrap input {
  padding-left: 40px;
}

.search-icon {
  position: absolute;
  top: 16px;
  left: 14px;
  width: 15px;
  height: 15px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  pointer-events: none;
}

.search-icon::after {
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: 7px;
  height: 2px;
  transform: rotate(45deg);
  background: var(--muted);
  content: "";
}

.filters {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.filter-button {
  min-height: 44px;
  padding: 0 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.filter-button.is-selected {
  background: var(--accent);
  color: white;
}

.priority-filter {
  min-height: 46px;
  padding: 0 28px 0 10px;
  font-size: 13px;
}

.result-summary {
  margin: 15px 0 4px;
  color: var(--muted);
  font-size: 14px;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-row {
  gap: 12px;
  min-height: 80px;
  padding: 13px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.check-label {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
}

.check-label input {
  position: absolute;
  width: 44px;
  height: 44px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.check-visual {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  pointer-events: none;
}

.check-label input:checked + .check-visual {
  border-color: var(--accent);
  background: var(--accent);
}

.check-label input:checked + .check-visual::after {
  width: 7px;
  height: 12px;
  transform: translateY(-1px) rotate(45deg);
  border-right: 2px solid white;
  border-bottom: 2px solid white;
  content: "";
}

.check-label input:focus-visible + .check-visual {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.task-content {
  min-width: 0;
  flex: 1;
}

.task-title {
  display: block;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 630;
  line-height: 1.45;
}

.is-completed .task-title {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.task-meta {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
}

.priority-badge,
.next-label {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid currentColor;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 650;
}

.priority-high {
  background: var(--high-soft);
  color: var(--high);
}

.priority-medium {
  background: var(--medium-soft);
  color: var(--medium);
}

.priority-low {
  background: var(--low-soft);
  color: var(--low);
}

.priority-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: currentColor;
}

.next-label {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--muted);
}

.task-actions {
  gap: 4px;
}

.icon-button {
  min-width: 44px;
  min-height: 44px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.icon-button:hover {
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--ink);
}

.task-actions [data-control="delete"]:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.edit-form {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(120px, auto);
  gap: 8px;
}

.edit-form input {
  grid-column: 1 / -1;
}

.edit-count {
  color: var(--muted);
  font-size: 13px;
}

.edit-form input,
.edit-form select {
  min-height: 44px;
}

.edit-form select {
  padding: 0 25px 0 9px;
}

.edit-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
  gap: 7px;
}

.edit-error {
  grid-column: 1 / -1;
}

.empty-state {
  padding: 60px 20px 40px;
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 13px;
  place-items: center;
  border-radius: 17px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 25px;
}

.empty-state h3 {
  margin: 0;
  font-size: 18px;
}

.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.list-error {
  padding: 14px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
}

.page-footer {
  padding: 23px 10px 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.undo-notice {
  position: fixed;
  z-index: 10;
  right: 20px;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 20px;
  width: max-content;
  max-width: calc(100% - 40px);
  min-height: 60px;
  justify-content: center;
  gap: 12px;
  margin: 0 auto;
  padding: 8px 10px 8px 17px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--ink);
  box-shadow: 0 8px 30px rgb(0 0 0 / 22%);
  color: white;
}

.undo-notice[hidden] {
  display: none;
}

.undo-notice p {
  max-width: 400px;
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}

.undo-notice .button-quiet {
  border-color: #9aa79d;
  background: transparent;
  color: white;
}

.undo-notice .button-quiet:hover {
  background: #39483d;
}

.undo-notice .icon-button {
  color: white;
}

.undo-notice .icon-button:hover {
  border-color: white;
  background: #39483d;
  color: white;
}

@media (hover: hover) and (pointer: fine) {
  .check-label:hover .check-visual {
    transform: scale(1.06);
  }

  .task-row:hover {
    background: var(--panel-soft);
  }
}

@media (max-width: 1000px) {
  .shell {
    grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
    gap: 16px;
  }

  .deck,
  .board {
    padding: 24px;
  }

  .add-fields {
    flex-wrap: wrap;
  }

  .title-field {
    flex-basis: 100%;
  }
}

@media (max-width: 760px) {
  body {
    padding: 16px 14px 90px;
  }

  .shell {
    grid-template-columns: 1fr;
    gap: 14px;
    min-height: 0;
  }

  .deck {
    position: static;
    min-height: 0;
    padding: 23px;
  }

  .welcome {
    margin: 25px 0 20px;
  }

  .welcome h1 {
    max-width: 500px;
    font-size: clamp(30px, 8vw, 40px);
  }

  .save-note {
    padding-top: 20px;
  }

  .board {
    min-height: 430px;
    padding: 23px;
  }

  .toolbar {
    align-items: stretch;
  }

  .search-wrap {
    flex-basis: 100%;
  }

  .filters {
    flex: 1;
    justify-content: space-around;
  }

  .filter-button {
    flex: 1;
    padding: 0 7px;
  }
}

@media (max-width: 420px) {
  body {
    padding-inline: 10px;
  }

  .deck,
  .board {
    padding: 19px 16px;
    border-radius: 18px;
  }

  .add-fields select {
    flex: 1;
  }

  .add-button {
    flex: 1;
  }

  .board-heading {
    align-items: flex-start;
  }

  .clear-button {
    max-width: 130px;
    white-space: normal;
  }

  .task-row {
    gap: 7px;
    padding-inline: 3px;
  }

  .task-actions {
    gap: 0;
  }

  .icon-button {
    min-width: 42px;
    padding-inline: 6px;
  }

  .undo-notice {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    max-width: calc(100% - 20px);
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 3px 8px;
    padding: 8px 10px;
  }

  .undo-notice p {
    width: 100%;
  }
}

@media (max-height: 700px) and (min-width: 761px) {
  .deck {
    position: static;
  }

  .shell {
    min-height: 0;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #151a16;
    --panel: #202821;
    --panel-soft: #28332b;
    --ink: #edf2ed;
    --muted: #c0cbc2;
    --quiet: #aab8ad;
    --line: #899a8d;
    --line-soft: #536157;
    --accent: #a3c5a9;
    --accent-strong: #c0dcc5;
    --accent-soft: #304337;
    --focus: #d3a6ff;
    --danger: #ffaaa5;
    --danger-soft: #432b2a;
    --high: #ffaaa5;
    --high-soft: #432b2a;
    --medium: #f0cd76;
    --medium-soft: #453b24;
    --low: #a9d2ae;
    --low-soft: #2d4032;
    --shadow: 0 16px 42px rgb(0 0 0 / 24%);
  }

  .deck {
    background: linear-gradient(155deg, #242e26, #202821);
  }

  .button-primary,
  .filter-button.is-selected {
    background: #a3c5a9;
    color: #17231a;
  }

  .button-primary:hover {
    background: #c0dcc5;
  }

  .progress-track {
    background: #536157;
  }

  .check-label input:checked + .check-visual {
    border-color: #a3c5a9;
    background: #a3c5a9;
  }

  .check-label input:checked + .check-visual::after {
    border-color: #17231a;
  }
}

@media (forced-colors: active) {
  :focus-visible,
  .check-label input:focus-visible + .check-visual {
    outline: 3px solid Highlight;
    outline-offset: 3px;
  }

  .button-primary,
  .filter-button.is-selected,
  .check-label input:checked + .check-visual {
    border: 2px solid ButtonText;
    background: ButtonFace;
    color: ButtonText;
  }

  .priority-badge,
  .next-label {
    border: 1px solid ButtonText;
    background: Canvas;
    color: CanvasText;
  }

  .priority-dot,
  .save-dot {
    border: 1px solid currentColor;
    background: transparent;
  }

  .progress-track span {
    border: 2px solid Highlight;
    background: Highlight;
  }
}

@media print {
  body {
    padding: 0;
    background: white;
    color: black;
  }

  .shell {
    display: block;
    width: 100%;
  }

  .deck,
  .board {
    min-height: 0;
    margin-bottom: 16px;
    padding: 16px;
    border: 1px solid #777;
    box-shadow: none;
  }

  .add-card,
  .toolbar,
  .task-actions,
  .clear-button,
  .undo-notice,
  .page-footer,
  .skip-link {
    display: none !important;
  }

  .deck {
    position: static;
  }
}

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