:root {
  --bg: #f4f7ff;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-strong: #ffffff;
  --card: rgba(240, 245, 255, 0.96);
  --border: rgba(37, 99, 235, 0.12);
  --text: #163074;
  --muted: rgba(22, 48, 116, 0.68);
  --gold: #ffbf1f;
  --coral: #ff595e;
  --mint: #22c55e;
  --blue: #2563eb;
  --shadow: 0 22px 54px rgba(37, 99, 235, 0.12);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "DM Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(255, 191, 31, 0.24), transparent 22%),
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.16), transparent 24%),
    radial-gradient(circle at bottom left, rgba(255, 89, 94, 0.16), transparent 22%),
    linear-gradient(180deg, #f8fbff 0%, #eef4ff 52%, #f4f7ff 100%);
}

button, input, select {
  font: inherit;
}

#confettiCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

.app-shell,
.detail-shell {
  width: min(980px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 90px;
}

.topbar,
.brand-row,
.stats-grid,
.sync-row,
.section-head,
.board-title-row,
.task-main,
.task-actions,
.sync-left,
.sync-actions,
.setup-actions,
.daily-actions {
  display: flex;
  align-items: center;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar,
.sync-row,
.section-head {
  justify-content: space-between;
}

.brand-row {
  gap: 12px;
}

.brand,
.section-head h2,
.board-card h3,
.daily-card h2,
.detail-card h1,
.modal h1,
.modal h2 {
  font-family: "Syne", sans-serif;
}

.brand {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 3rem);
  line-height: 0.94;
  background: linear-gradient(120deg, #ff595e 0%, #ffbf1f 35%, #2563eb 70%, #22c55e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
}

.week-pill,
.progress-chip,
.icon-btn,
.ghost-btn,
.primary-btn,
.task-points,
.sync-row,
.daily-card,
.stat-card,
.board-card,
.detail-card,
.modal {
  border: 1px solid var(--border);
}

.week-pill,
.progress-chip,
.icon-btn,
.ghost-btn,
.primary-btn,
.task-points {
  border-radius: 999px;
}

.week-pill {
  padding: 8px 12px;
  color: var(--muted);
  background: rgba(37, 99, 235, 0.08);
  font-size: 0.78rem;
  font-weight: 700;
}

.progress-chip {
  padding: 11px 16px;
  background: linear-gradient(120deg, rgba(255, 89, 94, 0.18), rgba(255, 191, 31, 0.18), rgba(37, 99, 235, 0.14));
  color: var(--text);
  font-weight: 800;
  border: 1px solid rgba(37,99,235,0.12);
  box-shadow: var(--shadow);
}

.icon-btn,
.ghost-btn,
.primary-btn {
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.icon-btn:hover,
.ghost-btn:hover,
.primary-btn:hover {
  transform: translateY(-1px);
}

.icon-btn,
.ghost-btn {
  background: rgba(37, 99, 235, 0.08);
  color: var(--text);
}

.icon-btn {
  padding: 10px 14px;
}

.ghost-btn,
.primary-btn {
  padding: 12px 18px;
}

.ghost-btn.small,
.primary-btn.small {
  padding: 9px 13px;
  font-size: 0.86rem;
}

.primary-btn {
  background: linear-gradient(120deg, #ff595e, #ffbf1f, #2563eb);
  color: #ffffff;
  font-weight: 800;
  border-color: transparent;
}

.daily-card,
.stat-card,
.board-card,
.sync-row,
.detail-card,
.modal {
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.daily-card {
  margin-top: 22px;
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
}

.daily-card h2,
.detail-card h1,
.section-head h2,
.board-card h3,
.modal h1,
.modal h2 {
  margin: 0;
}

.daily-meta,
.stat-detail,
.board-card p,
.detail-body,
.lead,
.setup-note {
  color: var(--muted);
}

.daily-meta,
.stat-detail,
.board-card p,
.setup-note {
  line-height: 1.5;
}

.daily-body {
  margin: 14px 0 0;
  line-height: 1.7;
}

.clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.inline-link {
  color: var(--gold);
  text-decoration: none;
  font-weight: 700;
}

.inline-link:hover {
  text-decoration: underline;
}

.stats-grid {
  gap: 16px;
  margin-top: 18px;
}

.stat-card {
  flex: 1;
  gap: 18px;
  padding: 18px;
}

.progress-card {
  display: block;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff595e, #ffbf1f, #2563eb, #22c55e);
  transition: width 0.35s ease;
}

.points-ring {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: conic-gradient(var(--blue) 0% var(--progress, 0%), rgba(37,99,235,0.12) var(--progress, 0%) 100%);
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.points-ring::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--surface);
}

.points-ring span {
  position: relative;
  z-index: 1;
  font-family: "Syne", sans-serif;
  font-size: 1.25rem;
  color: var(--blue);
}

.sync-row {
  margin-top: 18px;
  padding: 14px 18px;
  gap: 12px;
}

.sync-left,
.sync-actions {
  gap: 10px;
  flex-wrap: wrap;
}

.sync-text {
  color: var(--muted);
}

.sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 16px rgba(92, 240, 187, 0.4);
}

.sync-dot.syncing {
  background: var(--gold);
  box-shadow: 0 0 16px rgba(247, 203, 93, 0.4);
}

.sync-dot.error {
  background: var(--coral);
  box-shadow: 0 0 16px rgba(255, 122, 109, 0.4);
}

.board-shell {
  margin-top: 26px;
}

.section-head {
  margin-bottom: 12px;
}

.section-head .eyebrow {
  margin-bottom: 10px;
}

.section-head h2 {
  font-size: clamp(1.7rem, 3.6vw, 2.3rem);
  line-height: 1.12;
}

.board-card {
  overflow: hidden;
}

.board-card + .board-card {
  margin-top: 14px;
}

.board-title-row {
  justify-content: space-between;
  padding: 22px 18px 14px;
  border-left: 5px solid var(--accent-color);
}

.board-card h3 {
  font-size: 1.35rem;
  line-height: 1.18;
}

.accent-admin {
  border-color: rgba(255, 122, 109, 0.24);
}

.board-card[data-color] h3 {
  color: var(--accent-color);
}

.task-list {
  display: grid;
}

.task-row {
  border-top: 1px solid rgba(37, 99, 235, 0.08);
  padding: 14px 18px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  width: 100%;
  background: linear-gradient(90deg, rgba(37,99,235,0.04), transparent);
  border-left: 5px solid transparent;
  cursor: pointer;
  text-align: left;
}

.task-row.not_done {
  border-left-color: rgba(37,99,235,0.18);
}

.task-row.started {
  border-left-color: #67bbff;
  background: linear-gradient(90deg, rgba(103, 187, 255, 0.12), transparent 72%);
}

.task-row.done {
  border-left-color: var(--row-accent);
  background: linear-gradient(90deg, color-mix(in srgb, var(--row-accent) 16%, transparent), transparent 72%);
}

.task-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.task-status-pill.not_done {
  background: rgba(37,99,235,0.08);
  color: var(--muted);
}

.task-status-pill.started {
  background: rgba(37, 99, 235, 0.12);
  color: #2563eb;
}

.task-status-pill.done {
  background: rgba(34, 197, 94, 0.14);
  color: #159947;
}

.task-main {
  justify-content: space-between;
  gap: 16px;
}

.task-title {
  font-weight: 700;
  line-height: 1.45;
}

.task-row.done .task-title {
  color: rgba(22,48,116,0.9);
}

.task-actions {
  gap: 10px;
}

.task-points {
  padding: 8px 12px;
  background: rgba(255, 191, 31, 0.16);
  color: #cb8500;
  font-weight: 800;
  border: none;
}

.task-edit {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.task-edit:hover {
  color: var(--text);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(140%);
  background: linear-gradient(120deg, #ff595e, #ffbf1f, #2563eb);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 800;
  box-shadow: var(--shadow);
  transition: transform 0.28s ease;
  z-index: 1200;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.modal-shell {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 16, 0.74);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 1300;
  overflow-y: auto;
}

.modal-shell.hidden {
  display: none;
}

.modal {
  width: min(560px, 100%);
  padding: 24px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

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

.setup-grid label {
  display: grid;
  gap: 6px;
}

.setup-grid label.full {
  grid-column: 1 / -1;
}

.setup-grid span {
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 700;
}

.setup-grid input,
.setup-grid select {
  width: 100%;
  border-radius: 14px;
  padding: 13px 14px;
  background: rgba(37, 99, 235, 0.05);
  border: 1px solid rgba(37, 99, 235, 0.12);
  color: var(--text);
}

.setup-actions {
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.setup-note,
.lead {
  margin-top: 12px;
}

.detail-page {
  min-height: 100vh;
}

.detail-card {
  padding: 26px;
}

.detail-body p {
  margin: 0 0 18px;
  line-height: 1.8;
}

.back-link {
  display: inline-block;
  margin-bottom: 18px;
}

.status-modal {
  max-width: 520px;
}

.status-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.status-option {
  border: 1px solid rgba(37,99,235,0.12);
  border-radius: 18px;
  padding: 18px 14px;
  background: rgba(37,99,235,0.05);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.status-option.not_done.active {
  background: rgba(255,255,255,0.95);
}

.status-option.started.active {
  background: rgba(37, 99, 235, 0.14);
  border-color: rgba(37, 99, 235, 0.38);
}

.status-option.done.active {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.38);
}

.status-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.complete-badge {
  display: inline-flex;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 191, 31, 0.16);
  color: #cb8500;
  font-weight: 800;
}

@media (max-width: 760px) {
  .daily-card,
  .stats-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .stats-grid {
    gap: 14px;
  }

  .sync-row,
  .section-head,
  .task-main,
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }

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

  .modal-shell {
    place-items: start center;
    padding: 14px;
  }

  .modal {
    margin: max(10px, env(safe-area-inset-top)) 0 max(10px, env(safe-area-inset-bottom));
    max-height: calc(100vh - 28px);
  }

  .setup-grid label.full {
    grid-column: auto;
  }

  .task-row {
    grid-template-columns: 1fr;
  }

  .task-actions {
    grid-column: 1;
    justify-content: space-between;
  }

  .status-actions {
    grid-template-columns: 1fr;
  }
}
