:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --bg-2: #e9eef7;
  --panel: rgba(255, 255, 255, .88);
  --panel-solid: #ffffff;
  --panel-soft: #f1f4f8;
  --text: #17202a;
  --muted: #687384;
  --line: #d9e0ea;
  --accent: #2f6fed;
  --accent-2: #25a275;
  --danger: #c14545;
  --warning: #b56b22;
  --shadow: 0 20px 60px rgba(45, 57, 76, .13);
  --shadow-soft: 0 10px 30px rgba(45, 57, 76, .09);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101318;
    --bg-2: #151b23;
    --panel: rgba(27, 32, 40, .88);
    --panel-solid: #1b2028;
    --panel-soft: #222936;
    --text: #f4f7fb;
    --muted: #a8b1bf;
    --line: #323b49;
    --accent: #82aaff;
    --accent-2: #7bd9b3;
    --danger: #ff8e8e;
    --warning: #f1b36c;
    --shadow: 0 24px 68px rgba(0, 0, 0, .32);
    --shadow-soft: 0 10px 34px rgba(0, 0, 0, .24);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior-y: none;
}

body {
  overflow-x: hidden;
  min-height: 100svh;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cover-app {
  width: 100%;
  max-width: 1120px;
  min-height: 100svh;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top, 0px) + 18px)
    clamp(16px, 3vw, 26px)
    calc(env(safe-area-inset-bottom, 0px) + 28px);
  background:
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

.hero-panel,
.list-panel {
  background: transparent;
}

.hero-panel {
  padding: 2px 0 0;
}

.list-panel {
  margin-top: 14px;
  padding: 0;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.title-stack {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .06em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 5px;
  font-size: clamp(34px, 8vw, 52px);
  line-height: 1;
  letter-spacing: 0;
}

.subtitle,
#sectionMeta,
.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

.add-btn,
.icon-btn,
.primary-btn,
.secondary-btn,
.danger-btn,
.search-submit,
.summary-card,
.task-check,
.task-action {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 780;
}

.add-btn {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.add-btn span {
  transform: translateY(-1px);
  font-size: 34px;
  line-height: 1;
}

.search-card {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 6px;
  align-items: center;
  margin-top: 16px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-solid);
  box-shadow: var(--shadow-soft);
}

.search-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 22px;
}

.search-card input {
  width: 100%;
  min-width: 0;
  height: 40px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
}

.clear-search {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 22px;
}

.search-submit {
  min-height: 40px;
  padding: 0 14px;
  background: var(--text);
  color: var(--panel-solid);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.summary-card {
  display: grid;
  gap: 3px;
  min-height: 94px;
  padding: 13px;
  text-align: left;
  background: var(--panel-solid);
  color: var(--text);
  border-color: var(--line);
  box-shadow: var(--shadow-soft);
}

.summary-card span {
  font-size: 30px;
  line-height: 1;
  font-weight: 900;
}

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

.summary-card small {
  color: var(--muted);
  font-size: 12px;
}

.summary-card.active {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 17%, var(--panel-solid)), var(--panel-solid));
}

.list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 12px;
}

.list-toolbar h2 {
  margin-bottom: 4px;
  font-size: 24px;
}

.category-filter {
  display: grid;
  gap: 5px;
  min-width: 190px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.category-filter select,
.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-solid);
  color: var(--text);
  padding: 0 12px;
  outline: 0;
}

.field textarea {
  min-height: 98px;
  padding-top: 12px;
  resize: vertical;
}

.category-filter select:focus,
.field input:focus,
.field textarea:focus,
.field select:focus,
.search-card:focus-within {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

.reminder-list {
  display: grid;
  gap: 10px;
}

.date-group {
  display: grid;
  gap: 10px;
}

.date-heading {
  margin: 14px 2px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.task-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-solid);
  box-shadow: var(--shadow-soft);
}

.task-card.completed {
  opacity: .68;
}

.task-card.completed .task-title {
  text-decoration: line-through;
}

.task-check {
  width: 30px;
  height: 30px;
  min-height: 30px;
  margin-top: 1px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  color: var(--accent);
}

.task-check.done {
  background: var(--accent);
  color: #fff;
}

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

.task-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.task-note {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.chip.priority-alta {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
}

.chip.priority-media {
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 35%, var(--line));
}

.chip.overdue {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--panel-soft));
}

.task-menu {
  display: grid;
  gap: 8px;
}

.task-action {
  min-width: 72px;
  min-height: 36px;
  padding: 0 10px;
  background: var(--panel-soft);
  color: var(--text);
  border-color: var(--line);
}

.task-action.danger {
  color: var(--danger);
}

.task-action:focus-visible,
.task-check:focus-visible,
.summary-card:focus-visible,
.add-btn:focus-visible,
.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.danger-btn:focus-visible,
.icon-btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 48%, transparent);
  outline-offset: 2px;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 32px 18px;
  border: 1px dashed color-mix(in srgb, var(--line) 80%, var(--muted));
  border-radius: 22px;
  background: color-mix(in srgb, var(--panel-solid) 74%, transparent);
  text-align: center;
}

.empty-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: color-mix(in srgb, var(--accent-2) 18%, var(--panel-solid));
  color: var(--accent-2);
  font-size: 28px;
  font-weight: 900;
}

.primary-btn,
.secondary-btn,
.danger-btn {
  padding: 0 16px;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.secondary-btn {
  background: var(--panel-soft);
  color: var(--text);
  border-color: var(--line);
}

.danger-btn {
  background: color-mix(in srgb, var(--danger) 10%, var(--panel-solid));
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 32%, var(--line));
}

.task-sheet {
  width: min(620px, calc(100vw - 18px));
  max-height: min(760px, calc(100vh - 20px));
  padding: 0;
  border: 0;
  border-radius: 26px;
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: 0 32px 90px rgba(0, 0, 0, .26);
}

.task-sheet::backdrop {
  background: rgba(10, 14, 20, .42);
  backdrop-filter: blur(4px);
}

.task-sheet form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.sheet-header,
.sheet-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet-header h2 {
  margin: 0;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 24px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 780;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.sheet-actions > div {
  display: flex;
  gap: 8px;
}

@media (max-width: 760px) {
  html,
  body {
    background: var(--bg);
  }

  body {
    position: relative;
    min-height: 100svh;
    min-height: 100dvh;
  }

  .cover-app {
    width: 100%;
    max-width: none;
    min-height: 100svh;
    min-height: 100dvh;
    padding:
      calc(env(safe-area-inset-top, 0px) + 12px)
      0
      calc(env(safe-area-inset-bottom, 0px) + 18px);
  }

  .hero-panel,
  .list-panel {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
  }

  .hero-panel {
    padding: 0 14px;
  }

  .list-panel {
    margin-top: 12px;
    padding: 0 14px;
  }

  h1 {
    font-size: 32px;
  }

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

  .summary-card {
    min-height: 82px;
    padding: 11px 12px;
    border-radius: 16px;
  }

  .summary-card span {
    font-size: 25px;
  }

  .summary-card small {
    display: none;
  }

  .search-card {
    grid-template-columns: auto 1fr auto auto;
    margin-top: 14px;
    border-radius: 15px;
  }

  .search-icon,
  .clear-search {
    width: 34px;
    height: 34px;
  }

  .search-submit {
    min-height: 38px;
    padding: 0 12px;
    border-radius: 12px;
    font-size: 14px;
  }

  .list-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .category-filter {
    min-width: 0;
  }

  .task-card {
    grid-template-columns: auto 1fr;
    border-radius: 16px;
    box-shadow: 0 4px 18px rgba(45, 57, 76, .07);
  }

  .task-menu {
    grid-column: 2;
    grid-template-columns: repeat(2, minmax(0, auto));
    justify-content: start;
  }

  .task-sheet {
    width: 100vw;
    max-width: 100vw;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px));
    margin: auto 0 0;
    border-radius: 26px 26px 0 0;
  }

  .task-sheet form {
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 8px);
    overflow-y: auto;
    padding:
      18px
      16px
      calc(env(safe-area-inset-bottom, 0px) + 18px);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .sheet-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .sheet-actions > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 761px) {
  .cover-app {
    padding-top: calc(env(safe-area-inset-top, 0px) + 24px);
  }

  .hero-panel,
  .list-panel {
    border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
  }

  .hero-panel {
    border-radius: 28px;
    padding: 20px;
  }

  .list-panel {
    border-radius: 24px;
    padding: 18px;
  }
}

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