@font-face {
  font-family: 'DotGothic16';
  src: url('/fonts/dotgothic16.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Silkscreen';
  src: url('/fonts/silkscreen.woff2') format('woff2');
  font-display: swap;
}

:root {
  --ink: #1b1226;
  --ink-2: #2a1c38;
  --ink-3: #3a2a4c;
  --panel: rgba(27, 17, 36, 0.86);
  --edge: #f3a6bd;
  --edge-dim: #8e5a7a;
  --cream: #fff1f4;
  --muted: #c9a9bf;
  --pink: #f18fae;
  --deep: #c4567f;
  --gold: #ffd27a;
  --leaf: #a9d98a;
  --late: #ff8b8b;
  --cursor: auto;
  --blossom: none;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--cream);
  font: 16px/1.4 'DotGothic16', ui-monospace, monospace;
  cursor: var(--cursor), auto;
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
}
button,
summary,
label.check,
.task .text {
  cursor: var(--cursor), pointer;
}
input[type='text'],
input:not([type]),
input[type='password'] {
  cursor: text;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}
#scene {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
#fx {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  z-index: 50;
}

/* Pixel box: a 4px border with notched corners. */
.px {
  box-shadow:
    -4px 0 0 0 var(--edge),
    4px 0 0 0 var(--edge),
    0 -4px 0 0 var(--edge),
    0 4px 0 0 var(--edge),
    0 12px 0 0 rgba(10, 4, 16, 0.35);
}

.blossom {
  background: var(--blossom) center / contain no-repeat;
  image-rendering: pixelated;
}

/* ---------- buttons ---------- */
.btn {
  font: 12px/1 'Silkscreen', monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cream);
  background: var(--ink-3);
  border: 0;
  padding: 10px 14px;
  margin: 3px;
  box-shadow:
    -3px 0 0 0 var(--edge-dim),
    3px 0 0 0 var(--edge-dim),
    0 -3px 0 0 var(--edge-dim),
    0 3px 0 0 var(--edge-dim),
    inset 0 -3px 0 0 rgba(0, 0, 0, 0.3);
}
.btn:hover {
  background: #4a3660;
}
.btn:active {
  transform: translateY(2px);
  box-shadow:
    -3px 0 0 0 var(--edge-dim),
    3px 0 0 0 var(--edge-dim),
    0 -3px 0 0 var(--edge-dim),
    0 3px 0 0 var(--edge-dim);
}
.btn.primary {
  background: var(--deep);
  box-shadow:
    -3px 0 0 0 var(--edge),
    3px 0 0 0 var(--edge),
    0 -3px 0 0 var(--edge),
    0 3px 0 0 var(--edge),
    inset 0 -3px 0 0 #8e3a62;
}
.btn.primary:hover {
  background: #d8628d;
}
.btn.small {
  font-size: 10px;
  padding: 8px 10px;
}
.btn.ghost {
  background: transparent;
}
.btn:focus-visible,
.icon-btn:focus-visible,
input:focus-visible,
summary:focus-visible,
.task .text:focus-visible,
.link:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.icon-btn {
  font: 18px/1 'DotGothic16', monospace;
  color: var(--muted);
  background: transparent;
  border: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
}
.icon-btn:hover {
  color: var(--cream);
  background: var(--ink-3);
}

/* ---------- gate ---------- */
.gate {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100vw - 48px));
  padding: 28px 26px 22px;
  background: var(--panel);
  text-align: center;
  z-index: 20;
  display: grid;
  gap: 12px;
}
.gate-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto;
}
.gate h1 {
  font: 20px/1.2 'Silkscreen', monospace;
  margin: 0;
  color: var(--cream);
}
.gate p {
  margin: 0;
  color: var(--muted);
}
.gate .err {
  min-height: 1.2em;
  color: var(--late);
  font-size: 15px;
}
.gate.shake {
  animation: shake 0.4s steps(6);
}
@keyframes shake {
  0%,
  100% {
    transform: translate(-50%, -50%);
  }
  25% {
    transform: translate(calc(-50% - 8px), -50%);
  }
  75% {
    transform: translate(calc(-50% + 8px), -50%);
  }
}

input {
  font: inherit;
  color: var(--cream);
  background: var(--ink);
  border: 0;
  padding: 10px 12px;
  margin: 3px;
  box-shadow:
    -3px 0 0 0 var(--ink-3),
    3px 0 0 0 var(--ink-3),
    0 -3px 0 0 var(--ink-3),
    0 3px 0 0 var(--ink-3);
  border-radius: 0;
  min-width: 0;
}
input::placeholder {
  color: #8f7590;
}
input:focus {
  outline: none;
  box-shadow:
    -3px 0 0 0 var(--pink),
    3px 0 0 0 var(--pink),
    0 -3px 0 0 var(--pink),
    0 3px 0 0 var(--pink);
}
input[type='date'] {
  font-size: 15px;
  padding: 6px 8px;
}
input[type='date']::-webkit-calendar-picker-indicator {
  filter: invert(0.8) sepia(1) hue-rotate(290deg);
  cursor: pointer;
}

/* ---------- panel ---------- */
.panel {
  position: fixed;
  left: 24px;
  top: 24px;
  bottom: 24px;
  width: 384px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  z-index: 10;
}
.brand {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 18px 16px 10px 18px;
}
.mark {
  width: 40px;
  height: 40px;
}
.brand h1 {
  margin: 0;
  font: 17px/1.1 'Silkscreen', monospace;
  letter-spacing: 0.02em;
}
.tag {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.progress {
  margin: 4px 18px 10px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.22);
}
.count {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.count b {
  font: 28px/1 'Silkscreen', monospace;
  color: var(--pink);
}
.count span {
  font: 12px 'Silkscreen', monospace;
  text-transform: uppercase;
  color: var(--cream);
}
.count em {
  margin-left: auto;
  font-style: normal;
  font-size: 14px;
  color: var(--leaf);
}
.bar {
  height: 10px;
  margin: 10px 0 8px;
  background: var(--ink);
  box-shadow: 0 0 0 2px var(--ink-3);
  position: relative;
}
.bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: repeating-linear-gradient(90deg, var(--pink) 0 6px, var(--edge) 6px 8px);
  transition: width 0.6s steps(12);
}
.next {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}
.next b {
  color: var(--gold);
  font-weight: 500;
}

.add {
  padding: 4px 18px 12px;
  display: grid;
  gap: 8px;
}
.add > input {
  width: calc(100% - 6px);
}
.add-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.due-pick {
  display: flex;
  align-items: center;
  gap: 4px;
  font: 11px 'Silkscreen', monospace;
  text-transform: uppercase;
  color: var(--muted);
}
.due-pick.auto input {
  box-shadow:
    -3px 0 0 0 var(--gold),
    3px 0 0 0 var(--gold),
    0 -3px 0 0 var(--gold),
    0 3px 0 0 var(--gold);
}

.lists {
  flex: 1;
  overflow-y: auto;
  padding: 2px 10px 12px 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--edge-dim) transparent;
}
.tasks {
  list-style: none;
  margin: 0;
  padding: 0;
}
.task {
  display: grid;
  grid-template-columns: 30px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 7px 4px 7px 2px;
  border-bottom: 2px dashed rgba(243, 166, 189, 0.12);
}
.task:hover {
  background: rgba(255, 255, 255, 0.035);
}
.task .text {
  overflow-wrap: anywhere;
  padding: 2px 0;
}
.task .text input {
  width: 100%;
  margin: 0;
  padding: 4px 6px;
}
.task .del {
  opacity: 0;
  width: 26px;
  height: 26px;
  font-size: 16px;
}
.task:hover .del,
.task:focus-within .del {
  opacity: 1;
}
@media (hover: none) {
  .task .del {
    opacity: 0.6;
  }
}

/* The checkbox: a pixel box that blooms when ticked. */
label.check {
  position: relative;
  width: 24px;
  height: 24px;
  display: block;
}
label.check input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: inherit;
}
label.check .box {
  position: absolute;
  inset: 3px;
  background: var(--ink);
  box-shadow:
    -3px 0 0 0 var(--edge-dim),
    3px 0 0 0 var(--edge-dim),
    0 -3px 0 0 var(--edge-dim),
    0 3px 0 0 var(--edge-dim);
}
label.check:hover .box {
  box-shadow:
    -3px 0 0 0 var(--pink),
    3px 0 0 0 var(--pink),
    0 -3px 0 0 var(--pink),
    0 3px 0 0 var(--pink);
}
label.check input:checked + .box {
  background: var(--blossom) center / 22px no-repeat, var(--ink-3);
  image-rendering: pixelated;
}
label.check input:focus-visible + .box {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
}

.due {
  font: 10px/1 'Silkscreen', monospace;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--ink-2);
  border: 0;
  padding: 5px 6px;
  white-space: nowrap;
}
.due.none {
  opacity: 0;
}
.task:hover .due.none,
.task:focus-within .due.none {
  opacity: 0.8;
}
.due.soon {
  color: var(--ink);
  background: var(--pink);
}
.due.today {
  color: var(--ink);
  background: var(--gold);
}
.due.late {
  color: var(--ink);
  background: var(--late);
}
.task input[type='date'] {
  margin: 0;
  padding: 3px 4px;
  font-size: 13px;
}

.task.blooming {
  animation: bloomrow 0.45s steps(5) forwards;
}
@keyframes bloomrow {
  0% {
    background: rgba(241, 143, 174, 0.35);
  }
  100% {
    background: transparent;
    opacity: 0.35;
  }
}
.task.planted {
  animation: plant 0.5s steps(5);
}
@keyframes plant {
  0% {
    background: rgba(169, 217, 138, 0.3);
    transform: translateX(-8px);
  }
  100% {
    background: transparent;
    transform: none;
  }
}
.task.flash {
  animation: flash 1.2s steps(6);
}
@keyframes flash {
  0%,
  50% {
    background: rgba(255, 210, 122, 0.3);
  }
  100% {
    background: transparent;
  }
}

.done .task .text {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--deep);
  text-decoration-thickness: 2px;
}
.done .task {
  grid-template-columns: 30px 1fr auto;
}

.empty {
  color: var(--muted);
  font-size: 15px;
  padding: 14px 4px;
  margin: 0;
}

details.done {
  margin-top: 14px;
}
details.done summary {
  font: 11px 'Silkscreen', monospace;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 2px;
  list-style: none;
}
details.done summary::-webkit-details-marker {
  display: none;
}
details.done summary::before {
  content: '▸ ';
}
details.done[open] summary::before {
  content: '▾ ';
}
details.done summary span {
  color: var(--pink);
}
.link {
  font: 14px 'DotGothic16', monospace;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 10px 2px;
  text-decoration: underline dotted;
}
.link:hover {
  color: var(--cream);
}

.foot {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 16px 14px;
  border-top: 2px dashed rgba(243, 166, 189, 0.15);
}

.show-btn {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 10;
}

/* ---------- tooltip, toasts, log ---------- */
.tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  pointer-events: none;
  max-width: 260px;
  padding: 7px 10px;
  background: var(--panel);
  box-shadow:
    -3px 0 0 0 var(--edge),
    3px 0 0 0 var(--edge),
    0 -3px 0 0 var(--edge),
    0 3px 0 0 var(--edge);
  display: grid;
  gap: 2px;
}
.tip b {
  font-weight: 500;
}
.tip span {
  font: 10px 'Silkscreen', monospace;
  text-transform: uppercase;
  color: var(--muted);
}
.tip span:empty {
  display: none;
}

.toasts {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  display: grid;
  gap: 14px;
  width: min(420px, calc(100vw - 40px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--panel);
  padding: 12px 14px 12px 52px;
  position: relative;
  animation: drop 0.35s steps(5);
  box-shadow:
    -4px 0 0 0 var(--gold),
    4px 0 0 0 var(--gold),
    0 -4px 0 0 var(--gold),
    0 4px 0 0 var(--gold);
}
.toast::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 50%;
  width: 28px;
  height: 28px;
  transform: translateY(-50%);
  background: var(--blossom) center / contain no-repeat;
  image-rendering: pixelated;
}
.toast b {
  display: block;
  font: 12px 'Silkscreen', monospace;
  text-transform: uppercase;
  color: var(--gold);
}
.toast.error {
  box-shadow:
    -4px 0 0 0 var(--late),
    4px 0 0 0 var(--late),
    0 -4px 0 0 var(--late),
    0 4px 0 0 var(--late);
}
.toast.error b {
  color: var(--late);
}
.toast.out {
  animation: rise 0.3s steps(4) forwards;
}
@keyframes drop {
  from {
    transform: translateY(-24px);
    opacity: 0;
  }
}
@keyframes rise {
  to {
    transform: translateY(-24px);
    opacity: 0;
  }
}

.log {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(12, 6, 18, 0.55);
  display: grid;
  place-items: center;
  padding: 24px;
}
.log-card {
  width: min(460px, 100%);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: var(--panel);
  padding: 16px 18px;
}
.log-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.log-card h2 {
  margin: 0;
  font: 15px 'Silkscreen', monospace;
}
.log-card ol {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}
.log-card li {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 2px dashed rgba(243, 166, 189, 0.12);
}
.log-card li .at {
  font: 13px 'Silkscreen', monospace;
  color: var(--pink);
  text-align: right;
}
.log-card li b {
  font-weight: 500;
}
.log-card li p {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--muted);
}
.log-card li.locked {
  opacity: 0.55;
}
.log-card li.locked .at {
  color: var(--muted);
}

/* ---------- small screens: orchard on top, list below ---------- */
@media (max-width: 760px) {
  #stage {
    bottom: auto;
    height: 46vh;
    height: 46svh;
  }
  body.panel-hidden #stage {
    height: 100%;
  }
  .panel {
    left: 4px;
    right: 4px;
    top: calc(46svh - 8px);
    bottom: 4px;
    width: auto;
  }
  .brand {
    padding: 12px 12px 6px 14px;
  }
  .progress {
    margin: 2px 14px 8px;
    padding: 8px 12px;
  }
  .add {
    padding: 2px 14px 10px;
  }
  .lists {
    padding: 2px 8px 10px 14px;
  }
  .tag {
    display: none;
  }
  .task .del {
    opacity: 0.6;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition: none !important;
  }
}
