/* ===== Hand-drawn design tokens ===== */
:root {
  --bg: #fdfbf7;
  --fg: #2d2d2d;
  --muted: #e5e0d8;
  --accent: #ff4d4d;
  --accent-blue: #2d5da1;
  --paper: #ffffff;
  --postit: #fff9c4;
  --shadow-hard: 4px 4px 0px 0px #2d2d2d;
  --shadow-hard-sm: 2px 2px 0px 0px #2d2d2d;
  --shadow-soft: 3px 3px 0px 0px rgba(45, 45, 45, 0.1);
  --wobbly-md: 220px 18px 200px 20px / 22px 200px 18px 220px;
  --wobbly-sm: 30px 10px 28px 8px / 8px 28px 10px 30px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Patrick Hand', cursive;
  color: var(--fg);
  background-color: var(--bg);
  background-image: radial-gradient(#e5e0d8 1px, transparent 1px);
  background-size: 24px 24px;
  min-height: 100vh;
  font-size: 18px;
  line-height: 1.45;
}

h1, h2, h3 {
  font-family: 'Kalam', cursive;
  font-weight: 700;
  margin: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.screen { width: 100%; }
.screen[hidden] { display: none; }

/* ===== Paper card ===== */
.paper-card {
  position: relative;
  background: var(--paper);
  border: 2px solid var(--fg);
  padding: 28px;
  box-shadow: var(--shadow-soft);
}

.tape {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  width: 90px; height: 22px;
  background: rgba(45, 45, 45, 0.18);
  border: 1px dashed rgba(45,45,45,0.35);
  box-shadow: 1px 1px 0 rgba(0,0,0,0.1);
  pointer-events: none;
}
.tape-yellow {
  background: rgba(255, 235, 90, 0.6);
  border-color: rgba(120,100,0,0.4);
}

.thumbtack {
  position: absolute;
  top: -10px; left: 24px;
  width: 18px; height: 18px;
  background: var(--accent);
  border: 2px solid var(--fg);
  border-radius: 50%;
  box-shadow: 1px 2px 0 rgba(0,0,0,0.25);
}

/* ===== Wobbly button ===== */
.wobbly-btn {
  font-family: 'Patrick Hand', cursive;
  font-size: 1.15rem;
  background: #fff;
  color: var(--fg);
  border: 3px solid var(--fg);
  padding: 10px 22px;
  border-radius: 220px 18px 215px 20px / 22px 200px 18px 220px;
  box-shadow: var(--shadow-hard);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease, color 0.1s ease;
  min-height: 48px;
  white-space: nowrap;
}
.wobbly-btn:hover {
  background: var(--accent);
  color: #fff;
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-hard-sm);
}
.wobbly-btn:active {
  transform: translate(4px, 4px);
  box-shadow: none;
}
.wobbly-btn-primary {
  background: var(--fg);
  color: #fff;
}
.wobbly-btn-primary:hover {
  background: var(--accent);
  color: #fff;
}
.wobbly-btn-ghost {
  background: var(--muted);
  color: var(--fg);
  border-width: 2px;
  box-shadow: var(--shadow-hard-sm);
}
.wobbly-btn-ghost:hover {
  background: var(--accent-blue);
  color: #fff;
}
.wobbly-btn-sm {
  font-size: 1rem;
  padding: 6px 14px;
  min-height: 38px;
}

/* ===== Wobbly input ===== */
.wobbly-input {
  font-family: 'Patrick Hand', cursive;
  font-size: 1.1rem;
  color: var(--fg);
  background: #fff;
  border: 2px solid var(--fg);
  padding: 10px 14px;
  border-radius: 220px 18px 215px 20px / 22px 200px 18px 220px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  width: 100%;
}
.wobbly-input::placeholder {
  color: rgba(45,45,45,0.4);
}
.wobbly-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 4px rgba(45,93,161,0.18);
}
.wobbly-input-sm {
  font-size: 1rem;
  padding: 6px 12px;
  border-radius: 30px 10px 28px 8px / 8px 28px 10px 30px;
}
.wobbly-input-bare {
  border: none;
  border-bottom: 2px dashed var(--muted);
  border-radius: 0;
  background: transparent;
  padding: 8px 4px;
}
.wobbly-input-bare:focus {
  border-bottom-color: var(--accent-blue);
  box-shadow: none;
}
.notes-input {
  resize: none;
  overflow: hidden;
  min-height: 38px;
  font-family: 'Patrick Hand', cursive;
}

/* ===== Login screen ===== */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
}
.login-card {
  width: 100%;
  max-width: 440px;
  padding: 44px 36px;
  transform: rotate(-1.5deg);
  box-shadow: 8px 8px 0 0 var(--fg);
}
.login-title {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 6px;
}
.login-title .bouncy {
  display: inline-block;
  color: var(--accent);
  animation: bouncy 3s ease-in-out infinite;
}
@keyframes bouncy {
  0%, 100% { transform: translateY(0) rotate(8deg); }
  50% { transform: translateY(-6px) rotate(-6deg); }
}
.login-sub {
  text-align: center;
  margin: 0 0 24px;
  color: rgba(45,45,45,0.7);
  font-size: 1.1rem;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-error {
  color: var(--accent);
  text-align: center;
  margin: 0;
  font-size: 1rem;
}
.login-arrow {
  position: absolute;
  bottom: 8%;
  right: 8%;
  width: 120px;
  height: 80px;
  transform: rotate(20deg);
  display: none;
}
@media (min-width: 768px) {
  .login-arrow { display: block; }
}

/* ===== App ===== */
.app-screen {
  min-height: 100vh;
}
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 32px;
  border-bottom: 2px dashed var(--fg);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand {
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-size: 1.7rem;
  text-decoration: none;
  color: var(--fg);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.brand-az {
  background: var(--accent);
  color: #fff;
  padding: 0 10px;
  border: 2px solid var(--fg);
  border-radius: 28px 6px 26px 10px / 10px 26px 6px 28px;
  transform: rotate(-3deg);
  display: inline-block;
}
.brand-divider { color: rgba(45,45,45,0.4); font-weight: 400; }
.header-right { display: flex; align-items: center; gap: 16px; }
.sync-state {
  font-size: 0.95rem;
  color: rgba(45,45,45,0.6);
  font-style: italic;
}
.sync-state.saving { color: var(--accent-blue); }
.sync-state.error { color: var(--accent); }

.app-main {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 32px;
  align-items: start;
}

@media (max-width: 800px) {
  .app-main {
    grid-template-columns: 1fr;
    padding: 0 16px;
    gap: 24px;
  }
  .app-header { padding: 14px 18px; }
}

/* ===== Sidebar / lists ===== */
.sidebar {
  position: sticky;
  top: 96px;
  padding: 24px;
  transform: rotate(-0.6deg);
}
@media (max-width: 800px) {
  .sidebar { position: static; transform: none; }
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.sidebar-title { font-size: 1.6rem; }
.icon-btn {
  font-family: 'Kalam', cursive;
  font-size: 1.4rem;
  width: 36px; height: 36px;
  border: 2px solid var(--fg);
  background: #fff;
  border-radius: 50% 40% 55% 45% / 50% 55% 45% 50%;
  box-shadow: var(--shadow-hard-sm);
  cursor: pointer;
  line-height: 1;
  transition: transform 0.1s, background 0.1s;
}
.icon-btn:hover {
  background: var(--accent);
  color: #fff;
  transform: rotate(8deg);
}
.list-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border: 2px solid transparent;
  border-radius: 30px 8px 28px 10px / 8px 30px 10px 28px;
  cursor: pointer;
  font-size: 1.15rem;
  transition: transform 0.1s, background 0.1s, border-color 0.1s;
}
.list-item:hover {
  background: var(--muted);
  transform: rotate(-1deg);
}
.list-item.active {
  background: var(--postit);
  border-color: var(--fg);
  box-shadow: var(--shadow-hard-sm);
  transform: rotate(1deg);
}
.list-item .count {
  font-size: 0.95rem;
  color: rgba(45,45,45,0.5);
  background: #fff;
  border: 1.5px dashed var(--fg);
  padding: 0 8px;
  border-radius: 20px;
}
.new-list-form {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.form-actions-row {
  display: flex;
  gap: 8px;
}

/* ===== Tasks ===== */
.tasks-pane { min-width: 0; }
.tasks-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}
.tasks-title {
  font-size: 2.6rem;
  transform: rotate(-0.8deg);
  text-decoration: underline wavy var(--accent);
  text-underline-offset: 8px;
}
.tasks-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
  cursor: pointer;
}
.toggle input { transform: scale(1.2); accent-color: var(--accent); }

.new-task {
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transform: rotate(0.4deg);
}
.new-task-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.new-task-row .wobbly-input { flex: 1 1 140px; }

.task-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.task {
  position: relative;
  background: #fff;
  border: 2px solid var(--fg);
  padding: 14px 18px 14px 52px;
  border-radius: 220px 20px 215px 22px / 22px 215px 22px 220px;
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, background 0.1s;
}
.task:nth-child(3n) { transform: rotate(-0.6deg); }
.task:nth-child(3n+1) { transform: rotate(0.5deg); }
.task:nth-child(3n+2) { transform: rotate(-0.3deg); }
.task:hover {
  box-shadow: var(--shadow-hard);
  transform: rotate(0deg) translate(-2px,-2px);
}
.task .checkbox {
  position: absolute;
  left: 14px;
  top: 16px;
  width: 24px; height: 24px;
  border: 2.5px solid var(--fg);
  background: #fff;
  border-radius: 48% 52% 50% 50% / 50% 48% 52% 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.task .checkbox::after {
  content: '';
  width: 18px;
  height: 18px;
  background: var(--accent);
  -webkit-mask: url("/tasks/check.svg") center/contain no-repeat;
          mask: url("/tasks/check.svg") center/contain no-repeat;
  transform: translateX(-2px) scale(0) rotate(-4deg);
  transform-origin: center;
  transition: transform 0.18s ease;
}
.task.completed .checkbox::after {
  transform: translateX(-2px) scale(1) rotate(-4deg);
}
.task-body { flex: 1; min-width: 0; }
.task-title {
  font-size: 1.2rem;
  line-height: 1.3;
  word-wrap: break-word;
}
.task.completed .task-title {
  text-decoration: line-through solid var(--accent);
  text-decoration-thickness: 2.5px;
  text-decoration-skip-ink: none;
  text-underline-offset: 0;
  color: rgba(45, 45, 45, 0.55);
}
.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.95rem;
  color: rgba(45,45,45,0.65);
}
.task-meta .pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--muted);
  border: 1.5px dashed var(--fg);
  padding: 1px 10px;
  border-radius: 24px 8px 22px 8px / 8px 22px 8px 24px;
}
.task-meta .pill.overdue {
  background: var(--accent);
  color: #fff;
  border-style: solid;
  border-color: var(--fg);
}
.task-meta .pill.today {
  background: var(--postit);
}
.task-notes {
  margin-top: 6px;
  font-size: 0.98rem;
  white-space: pre-wrap;
  color: rgba(45,45,45,0.8);
}
.task-delete {
  background: transparent;
  border: none;
  font-family: 'Kalam', cursive;
  font-size: 1.3rem;
  color: rgba(45,45,45,0.4);
  cursor: pointer;
  padding: 2px 6px;
  align-self: flex-start;
}
.task-delete:hover { color: var(--accent); transform: rotate(8deg); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: rgba(45,45,45,0.55);
  font-size: 1.15rem;
  border: 2px dashed var(--fg);
  border-radius: 220px 25px 215px 20px / 25px 215px 25px 220px;
  background: rgba(255,255,255,0.4);
}

/* ===== Edit overlay ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(45,45,45,0.4);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 20;
}
.overlay[hidden] { display: none; }
.edit-card {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transform: rotate(-0.7deg);
  box-shadow: 8px 8px 0 0 var(--fg);
}
.edit-title {
  font-size: 1.8rem;
}
.edit-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.95rem;
}
@media (max-width: 600px) {
  .edit-row { grid-template-columns: 1fr; }
}
.edit-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
  gap: 10px;
}
.edit-actions-right { display: flex; gap: 10px; }

select.wobbly-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1 L6 7 L11 1' stroke='%232d2d2d' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
