:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.64);
  --text: #1d1d1f;
  --muted: #767680;
  --hairline: rgba(60, 60, 67, 0.15);
  --shadow: 0 18px 55px rgba(23, 23, 26, 0.08);
  --blue: #4a90e2;
  --blue-soft: #e9f3ff;
  --green: #47a66b;
  --green-soft: #e9f8ef;
  --amber: #b8892c;
  --amber-soft: #fff5dc;
  --red: #d85d5d;
  --red-soft: #fff0f0;
  --lane: rgba(247, 247, 249, 0.82);
  --selected: rgba(74, 144, 226, 0.13);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-pill: 999px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111113;
  --surface: rgba(31, 31, 35, 0.78);
  --surface-strong: #1f1f23;
  --surface-soft: rgba(255, 255, 255, 0.08);
  --text: #f5f5f7;
  --muted: #a1a1aa;
  --hairline: rgba(255, 255, 255, 0.13);
  --shadow: 0 20px 65px rgba(0, 0, 0, 0.32);
  --blue: #8ec5ff;
  --blue-soft: rgba(104, 166, 255, 0.16);
  --green: #7bd99a;
  --green-soft: rgba(86, 190, 122, 0.15);
  --amber: #f1c66f;
  --amber-soft: rgba(232, 179, 79, 0.16);
  --red: #ff9d9d;
  --red-soft: rgba(255, 117, 117, 0.14);
  --lane: rgba(255, 255, 255, 0.055);
  --selected: rgba(142, 197, 255, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(74, 144, 226, 0.08), transparent 28rem),
    radial-gradient(circle at 90% 10%, rgba(71, 166, 107, 0.08), transparent 26rem),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(1500px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0 32px;
}

.calendar-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(26px);
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.8rem);
  font-weight: 750;
  letter-spacing: 0;
}

.header-actions,
.tool-row,
.segmented-control,
.priority-picker,
.search-box,
.stat-pill {
  display: flex;
  align-items: center;
}

.header-actions,
.tool-row {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tool-row {
  grid-column: 1 / -1;
  justify-content: space-between;
}

.soft-button,
.segmented-control,
.search-box,
.stat-pill,
.priority-picker {
  min-height: 42px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.46);
}

.soft-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.soft-button:hover,
.segmented-control button:hover,
.priority-choice:hover,
.add-button:hover {
  transform: translateY(-1px);
  border-color: rgba(74, 144, 226, 0.35);
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 1.55rem;
  line-height: 1;
}

.today-button {
  color: var(--blue);
  font-weight: 700;
}

.segmented-control {
  padding: 4px;
  gap: 4px;
}

.segmented-control button,
.priority-choice {
  min-width: 48px;
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  cursor: pointer;
}

.segmented-control button.active,
.priority-choice.selected {
  background: var(--surface-strong);
  border-color: var(--hairline);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  font-weight: 750;
}

.search-box {
  flex: 1 1 260px;
  max-width: 520px;
  gap: 8px;
  padding: 0 14px;
}

.search-box span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.search-box input {
  width: 100%;
  min-width: 80px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.stat-pill {
  gap: 5px;
  padding: 0 16px;
  color: var(--muted);
}

.stat-pill strong {
  color: var(--green);
}

.calendar-area {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(24px);
}

.calendar-scroll {
  overflow: auto;
}

.week-head,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(172px, 1fr));
  min-width: 1180px;
}

.week-head {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-strong);
}

.week-head div {
  padding: 14px 14px 12px;
  border-right: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
  text-align: center;
}

.week-head div:last-child {
  border-right: 0;
}

.calendar-grid {
  align-items: stretch;
}

.day-cell {
  min-height: 520px;
  padding: 12px;
  border-right: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.28);
  transition: background 160ms ease, box-shadow 160ms ease;
}

.month-mode .day-cell {
  min-height: 430px;
}

.week-mode .day-cell {
  min-height: calc(100vh - 230px);
}

.day-cell:nth-child(7n) {
  border-right: 0;
}

.day-cell.today {
  background: linear-gradient(180deg, var(--blue-soft), rgba(255, 255, 255, 0.26));
}

:root[data-theme="dark"] .day-cell.today {
  background: linear-gradient(180deg, var(--blue-soft), rgba(255, 255, 255, 0.04));
}

.day-cell.selected {
  box-shadow: inset 0 0 0 2px rgba(74, 144, 226, 0.34);
  background: var(--selected);
}

.day-cell.outside-month {
  opacity: 0.48;
}

.day-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.weekday-mobile {
  display: none;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.date-number {
  width: 34px;
  height: 34px;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: var(--surface-strong);
  cursor: pointer;
  font-weight: 760;
}

.today .date-number {
  border-color: rgba(74, 144, 226, 0.45);
  background: var(--blue);
  color: #ffffff;
}

.day-count {
  min-width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.periods {
  display: grid;
  gap: 10px;
}

.period-lane {
  min-height: 132px;
  padding: 10px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--lane);
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.week-mode .period-lane {
  min-height: 176px;
}

.period-lane.active,
.period-lane.drop-ready {
  border-color: rgba(74, 144, 226, 0.5);
  background: var(--blue-soft);
}

.period-lane.drop-ready {
  transform: scale(0.992);
}

.period-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.period-label small {
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-soft);
  font-size: 0.72rem;
}

.task-list {
  display: grid;
  gap: 7px;
  max-height: 184px;
  overflow: auto;
  scrollbar-width: thin;
}

.week-mode .task-list {
  max-height: 232px;
}

.task-card {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 12px 26px;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 6px 7px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--surface-strong);
  box-shadow: 0 9px 18px rgba(0, 0, 0, 0.045);
  cursor: grab;
}

.task-card.dragging {
  opacity: 0.58;
}

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

.task-check,
.task-delete,
.task-title {
  border: 0;
  background: transparent;
}

.task-check {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  color: var(--blue);
  cursor: pointer;
}

.task-check span {
  display: inline-flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 900;
}

.task-title {
  min-width: 0;
  padding: 0;
  color: var(--text);
  text-align: left;
  cursor: text;
  overflow-wrap: anywhere;
}

.task-card.completed .task-title {
  color: var(--muted);
  text-decoration: line-through;
}

.task-delete {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 140ms ease, background 140ms ease;
}

.task-card:hover .task-delete,
.task-card:focus-within .task-delete {
  opacity: 1;
}

.task-delete:hover {
  background: var(--red-soft);
  color: var(--red);
}

.priority-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.priority-low .priority-dot,
.priority-choice.priority-low.selected {
  background: var(--green-soft);
  color: var(--green);
}

.priority-medium .priority-dot,
.priority-choice.priority-medium.selected {
  background: var(--amber-soft);
  color: var(--amber);
}

.priority-high .priority-dot,
.priority-choice.priority-high.selected {
  background: var(--red-soft);
  color: var(--red);
}

.task-card.priority-low {
  border-color: rgba(71, 166, 107, 0.28);
}

.task-card.priority-medium {
  border-color: rgba(184, 137, 44, 0.3);
}

.task-card.priority-high {
  border-color: rgba(216, 93, 93, 0.34);
}

.priority-low .priority-dot {
  background: var(--green);
}

.priority-medium .priority-dot {
  background: var(--amber);
}

.priority-high .priority-dot {
  background: var(--red);
}

.quick-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.quick-add input,
.edit-task-form input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  outline: 0;
  background: var(--surface-strong);
  color: var(--text);
}

.quick-add input {
  padding: 0 12px;
}

.edit-task-form input {
  min-height: 28px;
  padding: 0 10px;
}

.priority-picker {
  justify-content: space-between;
  padding: 3px;
  gap: 4px;
}

.priority-choice {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.add-button {
  min-height: 36px;
  border: 1px solid rgba(74, 144, 226, 0.22);
  border-radius: var(--radius-pill);
  background: var(--blue-soft);
  color: var(--blue);
  cursor: pointer;
  font-weight: 760;
}

@media (max-width: 1060px) {
  .calendar-header {
    grid-template-columns: 1fr;
  }

  .header-actions,
  .tool-row {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 18px, 720px);
    padding: 10px 0 18px;
  }

  .calendar-header {
    gap: 12px;
    padding: 14px;
    border-radius: 24px;
  }

  .tool-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }

  .search-box {
    grid-column: 1 / -1;
    max-width: none;
  }

  .stat-pill,
  .soft-button,
  .segmented-control {
    justify-content: center;
  }

  .calendar-area {
    border-radius: 24px;
  }

  .week-head,
  .calendar-grid {
    grid-template-columns: repeat(7, minmax(255px, 1fr));
    min-width: 1785px;
  }

  .day-cell,
  .month-mode .day-cell,
  .week-mode .day-cell {
    min-height: calc(100vh - 220px);
  }

  .weekday-mobile {
    display: block;
    margin-bottom: 2px;
  }

  .period-lane,
  .week-mode .period-lane {
    min-height: 158px;
  }
}

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