:root {
  color-scheme: light;
  --ink: #201b23;
  --muted: #6c6272;
  --paper: #fffaf2;
  --panel: #ffffff;
  --line: #e7ddcf;
  --coral: #ff6f61;
  --yellow: #ffcf4a;
  --green: #3bb273;
  --blue: #4d8df7;
  --pink: #f06aa6;
  --shadow: 0 18px 44px rgba(46, 29, 16, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 207, 74, 0.32), transparent 26rem),
    radial-gradient(circle at 85% 12%, rgba(240, 106, 166, 0.22), transparent 24rem),
    linear-gradient(135deg, #fffaf2 0%, #f1fff8 45%, #fff5fb 100%);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

#confettiCanvas {
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: 20;
}

.app-shell {
  min-height: 100vh;
  padding: 14px;
}

.planner-view {
  display: grid;
  gap: 14px;
  margin: 0 auto;
  max-width: 1220px;
}

.login-view {
  align-items: center;
  display: grid;
  min-height: calc(100vh - 44px);
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 0 auto;
  max-width: 560px;
  padding: 34px;
  width: min(100%, 560px);
}

.kicker {
  color: var(--coral);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(2.2rem, 6vw, 4.6rem);
  line-height: 0.92;
  margin-bottom: 18px;
}

h2 {
  font-size: 1.35rem;
  line-height: 1.1;
  margin-bottom: 0;
}

h3 {
  font-size: 1rem;
  line-height: 1.2;
  margin-bottom: 0;
}

.login-form label {
  color: var(--muted);
  display: block;
  font-size: 0.9rem;
  font-weight: 750;
  margin-bottom: 8px;
}

.password-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
}

input,
select {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  padding: 0 12px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(77, 141, 247, 0.35);
  outline-offset: 2px;
}

.primary-button,
.icon-button,
.ghost-button,
.mini-button,
.task-toggle,
.subtask-toggle {
  border: 0;
  border-radius: 8px;
  font-weight: 850;
}

.primary-button {
  background: var(--ink);
  color: white;
  min-height: 44px;
  padding: 0 16px;
}

.icon-button {
  align-items: center;
  background: var(--yellow);
  color: var(--ink);
  display: inline-grid;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.ghost-button,
.mini-button {
  background: #f6f0e7;
  color: var(--ink);
}

.mini-button {
  min-height: 32px;
  padding: 0 10px;
}

.form-error {
  color: #b42132;
  min-height: 1.4em;
  padding-top: 8px;
}

.topbar {
  align-items: center;
  display: block;
  gap: 10px;
  margin: 0;
  order: 0;
  width: 100%;
}

.topbar > div:first-child {
  min-width: 0;
}

.topbar h1 {
  font-size: clamp(1.32rem, 6vw, 3rem);
  letter-spacing: 0;
  margin: 0;
  overflow-wrap: normal;
  white-space: nowrap;
}

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

.top-actions .icon-button {
  flex: 0 0 auto;
  height: 38px;
  width: 38px;
}

.quiet-action {
  background: #fff5d8;
}

.progress-band {
  align-items: center;
  display: contents;
  gap: 14px;
  grid-template-columns: 1fr;
  margin: 0;
  max-width: none;
}

.progress-orbit,
.reward-stage,
.streak-panel,
.list-rail,
.task-zone,
.tadaa-zone {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.progress-orbit {
  aspect-ratio: auto;
  display: flex;
  justify-content: center;
  margin: 0 auto;
  max-width: none;
  order: 3;
  padding: 10px 14px;
  place-items: center;
  position: relative;
  width: 100%;
}

.progress-orbit svg {
  display: none;
  height: 78%;
  transform: rotate(-90deg);
  width: 78%;
}

.ring-bg,
.ring-fill {
  fill: none;
  stroke-width: 14;
}

.ring-bg {
  stroke: #efe3d4;
}

.ring-fill {
  stroke: var(--green);
  stroke-dasharray: 314;
  stroke-dashoffset: 314;
  stroke-linecap: round;
  transition: stroke-dashoffset 340ms ease, stroke 340ms ease;
}

.progress-number {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: center;
  place-items: center;
  position: static;
}

.progress-number strong {
  font-size: 1.35rem;
  line-height: 0.95;
}

.progress-number span {
  color: var(--muted);
  font-weight: 800;
}

.streak-panel {
  display: none;
  order: 4;
  min-height: 160px;
  padding: 18px;
}

.reward-stage {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  min-height: 0;
  order: 2;
  overflow: hidden;
  padding: 16px;
}

.stage-copy {
  align-self: center;
}

.stage-copy h2 {
  font-size: clamp(2.05rem, 10vw, 4.6rem);
  line-height: 0.95;
  margin-bottom: 10px;
}

.stage-copy p:not(.kicker) {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 750;
  line-height: 1.35;
  max-width: 34ch;
}

.stage-copy p:last-child {
  margin-bottom: 0;
}

.stage-nudge {
  background: #fff5d8;
  border: 1px solid #ffe0a0;
  border-radius: 999px;
  color: var(--ink) !important;
  display: inline-block;
  margin-top: 14px;
  padding: 10px 14px;
}

.stage-frame {
  --open: 0;
  align-self: stretch;
  background: #201b23;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  min-height: min(54vh, 460px);
  overflow: hidden;
  position: relative;
}

.stage-frame img {
  filter: saturate(calc(0.42 + var(--open) * 0.012)) brightness(calc(0.62 + var(--open) * 0.005));
  height: 100%;
  inset: 0;
  object-fit: cover;
  object-position: center 16%;
  position: absolute;
  transform: scale(calc(1.045 - var(--open) * 0.00025));
  transition: filter 360ms ease, transform 360ms ease;
  width: 100%;
}

.curtain {
  background:
    linear-gradient(90deg, rgba(120, 24, 54, 0.92), rgba(255, 111, 97, 0.88), rgba(255, 207, 74, 0.5)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 9px, transparent 9px 22px);
  height: 100%;
  position: absolute;
  top: 0;
  transition: transform 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
  width: 58%;
  z-index: 2;
}

.curtain-left {
  left: 0;
  transform: translateX(calc(var(--open) * -0.68%));
}

.curtain-right {
  right: 0;
  transform: scaleX(-1) translateX(calc(var(--open) * -0.68%));
}

.haze {
  background: rgba(255, 250, 242, calc(0.34 - var(--open) * 0.0034));
  inset: 0;
  position: absolute;
  z-index: 3;
}

.stage-lights {
  background:
    radial-gradient(circle at 50% 9%, rgba(255, 255, 255, calc(0.2 + var(--open) * 0.005)), transparent 28%),
    radial-gradient(circle at 24% 84%, rgba(255, 207, 74, 0.38), transparent 22%),
    radial-gradient(circle at 82% 78%, rgba(240, 106, 166, 0.34), transparent 26%);
  inset: 0;
  mix-blend-mode: screen;
  position: absolute;
  z-index: 4;
}

.stage-badge {
  align-items: center;
  background: rgba(32, 27, 35, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  bottom: 12px;
  color: #fff;
  display: inline-grid;
  font-size: 1.2rem;
  font-weight: 950;
  height: 48px;
  justify-content: center;
  min-width: 72px;
  padding: 0 14px;
  position: absolute;
  right: 12px;
  z-index: 5;
}

.reveal-steps {
  display: none;
  gap: 7px;
  grid-column: 1 / -1;
  grid-template-columns: 1fr;
}

.reveal-step {
  background: #f6f0e7;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  min-height: 28px;
  overflow: hidden;
  padding: 7px 8px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reveal-step.active {
  background: linear-gradient(135deg, var(--coral), var(--yellow));
  color: var(--ink);
}

.reward-stage.final-glow {
  animation: finalPulse 720ms ease-in-out 2;
}

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

.streak-head span {
  font-size: 1.15rem;
  font-weight: 900;
}

.streak-head button {
  background: var(--coral);
  border: 0;
  border-radius: 8px;
  color: white;
  font-weight: 850;
  min-height: 38px;
  padding: 0 14px;
}

.streak-track {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(5, minmax(42px, 1fr));
}

.streak-cell {
  align-items: center;
  aspect-ratio: 1.35;
  background: #fff4ee;
  border: 1px solid #ffd3c9;
  border-radius: 8px;
  display: grid;
  font-size: 1.6rem;
  font-weight: 900;
  justify-items: center;
}

.streak-cell.filled {
  background: linear-gradient(135deg, var(--coral), var(--yellow));
  color: white;
}

.workspace {
  display: contents;
  gap: 14px;
  grid-template-columns: 1fr;
  margin: 0;
  max-width: none;
}

.list-rail,
.task-zone,
.tadaa-zone {
  min-height: 0;
  padding: 16px;
}

.task-zone {
  order: 1;
  padding: 16px;
}

.tadaa-zone {
  order: 5;
}

.list-rail {
  display: none;
  order: 6;
}

.rail-head,
.zone-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
  min-width: 0;
}

.zone-head > div {
  min-width: 0;
}

.zone-head .primary-button {
  flex: 0 0 auto;
  min-width: 104px;
}

.zone-head.compact {
  margin-bottom: 12px;
}

.list-tabs {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.list-tab {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 46px;
  padding: 0 12px;
  text-align: left;
  width: 100%;
}

.list-tab.active {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
  font-weight: 900;
}

.task-list,
.tadaa-list {
  display: grid;
  gap: 10px;
}

.task-card,
.done-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.task-main {
  align-items: center;
  background: #fff9ee;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 10px;
  grid-template-columns: 42px minmax(0, 1fr) minmax(68px, auto);
  min-height: 96px;
  padding: 14px;
  text-align: left;
  width: 100%;
}

.task-main:focus-visible {
  outline: 3px solid rgba(77, 141, 247, 0.35);
  outline-offset: -3px;
}

.task-card.expanded .task-main {
  background: linear-gradient(135deg, #fff7e8, #fffdf7);
}

.task-toggle,
.subtask-toggle {
  align-items: center;
  background: #f0f7ff;
  border: 2px solid #bdd7ff;
  color: var(--blue);
  display: inline-grid;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.task-toggle.done,
.subtask-toggle.done {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.task-toggle {
  height: 42px;
  width: 42px;
}

.task-title {
  background: transparent;
  border: 0;
  color: var(--ink);
  display: block;
  font-size: 1.28rem;
  font-weight: 950;
  line-height: 1.12;
  min-height: 0;
  padding: 0;
  text-align: left;
  width: 100%;
}

.task-title-wrap {
  min-width: 0;
}

.task-label,
.subtask-label {
  color: var(--coral);
  font-size: 0.72rem;
  font-weight: 950;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.task-meta {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 750;
  margin-top: 5px;
}

.expand-button {
  background: #fff5d8;
  border: 1px solid #ffe0a0;
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  font-size: 1.9rem;
  font-weight: 950;
  min-height: 48px;
  padding: 0 10px;
  place-items: center;
  text-align: center;
}

.task-details {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  padding: 10px 12px 12px;
}

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

.subtask {
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 10px;
  grid-template-columns: 40px minmax(0, 1fr);
  padding-left: 10px;
}

.subtask:focus-visible {
  outline: 3px solid rgba(77, 141, 247, 0.35);
  outline-offset: 3px;
}

.subtask:active {
  background: #fff7e8;
}

.subtask-label {
  margin: 0 0 2px 50px;
}

.subtask span {
  color: #332d36;
  font-size: 1.05rem;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.subtask.done span {
  color: var(--muted);
  text-decoration: line-through;
}

.add-subtask,
.add-task-form {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.timer-row {
  align-items: center;
  display: grid;
  gap: 8px;
  display: none;
  grid-template-columns: 1fr;
}

.timer-readout {
  color: var(--pink);
  font-weight: 950;
  min-width: 6ch;
  text-align: left;
}

.count-pill {
  align-items: center;
  background: var(--green);
  border-radius: 999px;
  color: white;
  display: inline-grid;
  font-weight: 900;
  height: 32px;
  justify-content: center;
  min-width: 32px;
  padding: 0 10px;
}

.done-card {
  animation: tadaaIn 360ms ease both;
  border-color: #b8ebd1;
  padding: 12px;
}

.done-card strong {
  display: block;
  margin-bottom: 4px;
}

.done-card span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.empty {
  color: var(--muted);
  font-weight: 750;
  margin: 18px 0;
  text-align: center;
}

.toast {
  background: var(--ink);
  border-radius: 8px;
  bottom: 18px;
  color: white;
  font-weight: 900;
  left: 50%;
  opacity: 0;
  padding: 14px 18px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 16px);
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 30;
}

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

.tadaa-zone.pulse {
  animation: finalPulse 520ms ease-in-out 1;
}

.finale-overlay {
  align-items: center;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 207, 74, 0.42), transparent 26rem),
    rgba(32, 27, 35, 0.78);
  display: grid;
  inset: 0;
  justify-items: center;
  padding: 18px;
  position: fixed;
  z-index: 40;
}

.finale-card {
  background: #fffaf2;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.32);
  max-width: 680px;
  padding: clamp(28px, 5vw, 54px);
  text-align: center;
  width: min(100%, 680px);
}

.finale-card h2 {
  font-size: clamp(2.6rem, 12vw, 6.2rem);
  line-height: 0.92;
  margin-bottom: 14px;
}

.finale-card p:not(.kicker) {
  color: var(--muted);
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 24px;
}

@keyframes tadaaIn {
  from {
    opacity: 0;
    transform: translateX(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes finalPulse {
  0%,
  100% {
    box-shadow: var(--shadow);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(255, 207, 74, 0.44), 0 26px 70px rgba(240, 106, 166, 0.32);
  }
}

@media (min-width: 760px) {
  .app-shell {
    padding: 22px;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .top-actions {
    margin-top: 0;
    position: static;
  }

  .top-actions .icon-button {
    height: 42px;
    width: 42px;
  }

  .progress-band {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(190px, 260px) minmax(0, 1fr) minmax(220px, 280px);
    margin: 0;
  }

  .reward-stage {
    grid-column: 1 / -1;
    grid-row: 1;
    grid-template-columns: minmax(210px, 0.46fr) minmax(360px, 0.98fr);
    min-height: 520px;
  }

  .progress-orbit {
    aspect-ratio: 1;
    display: grid;
    grid-column: 1;
    grid-row: 2;
    max-width: none;
    padding: 0;
    width: 100%;
  }

  .progress-orbit svg {
    display: block;
  }

  .progress-number {
    display: grid;
    gap: 2px;
    place-items: center;
    position: absolute;
  }

  .progress-number strong {
    font-size: clamp(2.4rem, 7vw, 4.4rem);
  }

  .streak-panel {
    display: block;
    grid-column: 3;
    grid-row: 2;
  }

  .workspace {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
    margin: 0;
  }

  .list-rail,
  .task-zone,
  .tadaa-zone {
    order: 0;
  }

  .task-zone {
    grid-column: 1;
  }

  .tadaa-zone {
    grid-column: 2;
  }

  .reveal-steps {
    grid-template-columns: repeat(5, 1fr);
  }

  .timer-row {
    display: none;
    grid-template-columns: minmax(120px, 1fr) 90px auto auto;
  }

  .timer-readout {
    text-align: right;
  }
}

@media (min-width: 981px) {
  .reward-stage {
    grid-column: 2;
    grid-row: 1 / span 2;
    grid-template-columns: minmax(150px, 0.55fr) minmax(240px, 0.9fr);
    min-height: 420px;
  }

  .stage-frame {
    min-height: 380px;
  }

  .progress-orbit {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .streak-panel {
    grid-column: 3;
    grid-row: 1 / span 2;
  }
}

@media (max-width: 620px) {
  .password-row,
  .add-subtask,
  .add-task-form {
    grid-template-columns: 1fr;
  }

  .stage-frame {
    min-height: min(58vh, 470px);
  }

  .stage-frame img {
    object-position: center 10%;
  }

  .task-main {
    grid-template-columns: 42px minmax(0, 1fr) minmax(64px, auto);
    min-height: 90px;
  }

  .zone-head {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr;
  }

  .zone-head .primary-button {
    width: 100%;
  }
}
