:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  color: #182033;
  background: #f5f7fb;
  font-synthesis: none;
  --primary: #1f5eff;
  --primary-soft: #e9efff;
  --danger: #df3b45;
  --warning: #b56a00;
  --surface: #ffffff;
  --muted: #6e778b;
  --border: #e4e8f0;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  background: #f5f7fb;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background: #f5f7fb;
}

button,
a {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(31, 94, 255, 0.28);
  outline-offset: 2px;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: #f5f7fb;
  position: relative;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 58px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  font-size: 15px;
  font-weight: 700;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  color: white;
  background: var(--primary);
  font-size: 15px;
}

#page-content {
  min-height: calc(100dvh - 58px);
  padding-bottom: calc(116px + var(--safe-bottom));
  outline: none;
}

.page {
  padding: 24px 18px 32px;
}

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

.page-heading--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-heading h1 {
  margin: 3px 0 7px;
  font-size: clamp(26px, 8vw, 34px);
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.page-heading p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

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

.overview-card {
  min-height: 104px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(26, 38, 70, 0.05);
}

.overview-card:first-child {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #1f5eff, #467cff);
  border-color: transparent;
  color: white;
}

.overview-card span {
  display: block;
  font-size: 14px;
  color: var(--muted);
}

.overview-card:first-child span {
  color: rgba(255, 255, 255, 0.85);
}

.overview-card strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  line-height: 1;
}

.overview-card--warning strong {
  color: var(--warning);
}

.overview-card--danger strong {
  color: var(--danger);
}

.today-sections {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.today-section {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}

.today-section__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.today-section__heading h2 {
  margin: 0;
  font-size: 17px;
}

.today-section__heading span {
  color: var(--muted);
  font-size: 13px;
}

.today-section__empty {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.today-task-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.today-task {
  width: 100%;
  padding: 14px;
  border: 1px solid #e8ecf3;
  border-radius: 14px;
  color: inherit;
  background: #fafbfe;
  cursor: pointer;
  text-align: left;
}

.today-task:active {
  transform: scale(0.99);
}

.today-task strong {
  display: block;
  font-size: 16px;
  line-height: 1.45;
}

.today-task__tags,
.today-task__meta {
  display: flex;
  flex-wrap: wrap;
}

.today-task__tags {
  gap: 6px;
  margin-top: 9px;
}

.today-task__tags span {
  padding: 3px 8px;
  border-radius: 999px;
  color: #405171;
  background: #edf1f7;
  font-size: 12px;
  font-weight: 700;
}

.today-task__tags span:last-child {
  color: var(--primary);
  background: var(--primary-soft);
}

.category-sections {
  display: grid;
  gap: 14px;
}

.category-section {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}

.category-task-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.category-task {
  display: grid;
  width: 100%;
  gap: 5px;
  padding: 13px;
  border: 1px solid #e8ecf3;
  border-radius: 13px;
  color: inherit;
  background: #fafbfe;
  cursor: pointer;
  text-align: left;
}

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

.category-task span,
.category-task small,
.task-card__repeat {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.task-card__repeat {
  margin-top: 6px;
}

.today-task__meta {
  gap: 5px 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.empty-state,
.placeholder-panel {
  margin-top: 16px;
  padding: 34px 22px;
  border: 1px dashed #ccd3e2;
  border-radius: 18px;
  text-align: center;
  background: rgba(255, 255, 255, 0.55);
}

.empty-state__icon,
.placeholder-panel__icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  place-items: center;
  border-radius: 16px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 24px;
  font-weight: 800;
}

.empty-state h2,
.placeholder-panel h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.empty-state p,
.placeholder-panel p {
  max-width: 420px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.settings-list {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.settings-item:last-child {
  border-bottom: 0;
}

.settings-item strong,
.settings-item span {
  display: block;
}

.settings-item div > span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface);
}

.task-count {
  color: var(--muted);
  font-size: 14px;
}

.task-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-card {
  width: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  color: inherit;
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(26, 38, 70, 0.04);
  cursor: pointer;
  text-align: left;
}

.task-card:active {
  transform: scale(0.99);
}

.task-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.task-tag,
.status-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.task-tag {
  color: #405171;
  background: #eef2f8;
}

.status-tag {
  color: var(--primary);
  background: var(--primary-soft);
}

.status-tag--done {
  color: #187a52;
  background: #e4f7ee;
}

.task-card strong {
  display: block;
  font-size: 17px;
  line-height: 1.45;
}

.task-card p {
  display: -webkit-box;
  overflow: hidden;
  margin: 6px 0 0;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 14px;
  line-height: 1.55;
}

.task-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.quick-add {
  position: fixed;
  z-index: 20;
  right: max(18px, calc((100vw - 720px) / 2 + 18px));
  bottom: calc(76px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 18px 0 14px;
  border: 0;
  border-radius: 24px;
  color: white;
  background: var(--primary);
  box-shadow: 0 10px 24px rgba(31, 94, 255, 0.34);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.quick-add span:first-child {
  font-size: 23px;
  font-weight: 400;
}

.bottom-nav {
  position: fixed;
  z-index: 15;
  bottom: 0;
  left: 50%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 720px);
  min-height: calc(64px + var(--safe-bottom));
  padding: 7px 8px var(--safe-bottom);
  transform: translateX(-50%);
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(14px);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 12px;
  color: #7c8497;
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
}

.nav-item__icon {
  font-size: 22px;
  line-height: 1;
}

.nav-item--active {
  color: var(--primary);
  background: var(--primary-soft);
}

.notice {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: calc(138px + var(--safe-bottom));
  max-width: calc(100vw - 36px);
  padding: 10px 15px;
  transform: translate(-50%, 12px);
  border-radius: 10px;
  color: white;
  background: #202838;
  box-shadow: 0 8px 22px rgba(12, 19, 35, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  white-space: nowrap;
  font-size: 13px;
}

.notice--visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(18, 28, 49, 0.44);
}

.task-modal {
  width: min(100%, 720px);
  max-height: min(92dvh, 860px);
  overflow: auto;
  padding: 10px 18px calc(24px + var(--safe-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  box-shadow: 0 -12px 40px rgba(16, 28, 56, 0.18);
}

.task-modal__handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: #d6dce8;
}

.task-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.task-modal__header h2,
.confirm-modal h2 {
  margin: 3px 0 0;
  font-size: 22px;
}

.modal-close {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #56617a;
  background: #edf1f7;
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}

.task-form {
  display: grid;
  gap: 16px;
}

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

.form-field {
  display: grid;
  gap: 7px;
}

.form-field label {
  color: #2b3548;
  font-size: 14px;
  font-weight: 700;
}

.form-field--required label::after {
  margin-left: 3px;
  color: var(--danger);
  content: "*";
}

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #cfd7e5;
  border-radius: 12px;
  color: #182033;
  background: #fff;
  font: inherit;
  font-size: 16px;
}

.form-field textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.5;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(31, 94, 255, 0.15);
}

.form-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.weekday-picker {
  margin: 0;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.weekday-picker legend {
  padding: 0 5px;
  color: #2b3548;
  font-size: 14px;
  font-weight: 700;
}

.weekday-picker__options {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 5px;
}

.weekday-picker__options label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  color: #405171;
  font-size: 14px;
}

.weekday-picker__options input {
  width: 17px;
  height: 17px;
  min-height: 0;
  padding: 0;
}

.recurrence-note {
  padding: 13px;
  border-radius: 12px;
  background: var(--primary-soft);
}

.recurrence-note strong {
  color: var(--primary);
  font-size: 14px;
}

.recurrence-note p {
  margin: 5px 0 8px;
  color: #53617b;
  font-size: 13px;
  line-height: 1.55;
}

.text-button {
  padding: 0;
  border: 0;
  color: var(--primary);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.task-form__actions,
.task-form__actions-right,
.confirm-modal__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.task-form__actions {
  justify-content: space-between;
  margin-top: 4px;
}

.task-form__actions-right {
  margin-left: auto;
}

.button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
}

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

.settings-item--notification {
  align-items: center;
  gap: 12px;
}

.settings-item--notification .button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.notification-status {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.button--secondary {
  border-color: var(--border);
  color: #3c465b;
  background: #fff;
}

.button--danger,
.button--danger-quiet {
  color: #fff;
  background: var(--danger);
}

.button--danger-quiet {
  color: var(--danger);
  background: #fff0f1;
}

.modal-backdrop--confirm {
  align-items: center;
  padding: 18px;
}

.confirm-modal {
  width: min(100%, 390px);
  padding: 24px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 16px 48px rgba(16, 28, 56, 0.24);
}

.confirm-modal p {
  margin: 12px 0 22px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.confirm-modal__actions {
  justify-content: flex-end;
}

@media (min-width: 720px) {
  body {
    background: #e9edf5;
  }

  .app-shell {
    min-height: 100vh;
    box-shadow: 0 0 40px rgba(24, 32, 51, 0.08);
  }
}

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

  .task-form__actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .task-form__actions-right {
    width: 100%;
    margin-left: 0;
  }

  .task-form__actions-right .button,
  .task-form__actions > .button {
    flex: 1;
  }
}

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