/* all'Amarone To Do: Todoist inspired light UI */
:root {
  --bg: #FFFFFF;
  --bg-side: #FCFAF8;
  --ink: #202020;
  --muted: #808080;
  --faint: #B3B3B3;
  --line: #F0EDE9;
  --hover: #F2EFED;
  --accent: #DC4C3E;
  --accent-dark: #C3392C;
  --accent-soft: #FDEDEB;
  --p-high: #D1453B;
  --p-high-soft: #FBE4E2;
  --p-med: #EB8909;
  --p-med-soft: #FCEFDB;
  --p-low: #999999;
  --p-low-soft: #F1F1F1;
  --today: #058527;
  --overdue: #D1453B;
  --laura: #058527;
  --shadow: 0 12px 40px rgba(32, 32, 32, 0.16);
  --font-body: 'Plus Jakarta Sans', -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: 'Space Grotesk', 'Plus Jakarta Sans', sans-serif;
}

* { box-sizing: border-box; }

/* keep the hidden attribute winning over any display rule below */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; cursor: pointer; color: inherit; background: none; border: none; }
input, select, textarea { font: inherit; color: var(--ink); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.ic { width: 20px; height: 20px; display: block; }

.brand-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 8px;
  vertical-align: 2px;
}

.thin { font-weight: 400; color: var(--muted); }

/* ---------- login ---------- */
#login-view {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-side);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-card h1 { margin: 0 0 4px; font-size: 1.3rem; font-weight: 700; font-family: var(--font-head); letter-spacing: -0.01em; }

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.login-card input {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-size: 1rem;
}

.login-card input:focus { border-color: var(--faint); outline: none; }

.error { color: var(--overdue); margin: 0; text-align: center; font-size: 0.9rem; }

/* ---------- app layout ---------- */
#app-view { display: flex; min-height: 100dvh; }

#sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-side);
  padding: 18px 12px calc(18px + env(safe-area-inset-bottom));
  padding-top: calc(18px + env(safe-area-inset-top));
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}

.brand { font-weight: 700; font-size: 1.05rem; padding: 4px 10px 16px; font-family: var(--font-head); letter-spacing: -0.01em; }

.side-views { display: flex; flex-direction: column; gap: 2px; }

.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.92rem;
  color: var(--ink);
  text-align: left;
  transition: background 120ms ease-out;
}

.side-item:hover { background: var(--hover); }
.side-item.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.side-item .ic { color: var(--muted); flex-shrink: 0; }
.side-item.active .ic { color: var(--accent-dark); }

.count { margin-left: auto; font-size: 0.78rem; color: var(--faint); }

.side-heading {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin: 22px 10px 6px;
  text-transform: none;
  letter-spacing: 0;
}

.cat-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  margin: 0 5px 0 3px;
}

/* ---------- content ---------- */
.content {
  flex: 1;
  min-width: 0;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 40px calc(90px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) 0 10px;
}

.topbar h1 { margin: 0; font-size: 1.4rem; font-weight: 700; flex: 1; min-width: 0; font-family: var(--font-head); letter-spacing: -0.015em; }

.topbar-actions { display: flex; gap: 2px; align-items: center; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--muted);
  transition: background 120ms ease-out, color 120ms ease-out;
}

.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.on { color: var(--accent); }

#menu-btn { display: none; }

#f-priority {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 8px 4px;
  border-radius: 8px;
  max-width: 130px;
}

#f-priority:hover { background: var(--hover); }

#status-line {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

/* ---------- task list ---------- */
.cat-group { margin-top: 20px; }

.cat-title {
  display: flex;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-head);
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 2px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.cat-title .count { margin-left: 8px; }

.task {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 2px 12px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  animation: rise 200ms ease-out both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.task.done .t-title { text-decoration: line-through; color: var(--muted); }
.task.done { opacity: 0.6; }

.task.flash { animation: flash 1.4s ease-out 2; }
@keyframes flash {
  0% { background: var(--accent-soft); }
  100% { background: transparent; }
}

/* priority colored check circle */
.t-check {
  width: 44px;
  height: 44px;
  margin: -10px 0 0 -10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.t-check .ring {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--p-low);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease-out, border-color 150ms ease-out;
}

.t-check .ring .ic { width: 12px; height: 12px; color: transparent; transition: color 120ms ease-out; }

.t-check.pr-High .ring { border-color: var(--p-high); background: var(--p-high-soft); }
.t-check.pr-Medium .ring { border-color: var(--p-med); background: var(--p-med-soft); }
.t-check.pr-Low .ring { border-color: var(--p-low); background: transparent; }

.t-check:hover .ring .ic { color: var(--muted); }
.t-check.pr-High:hover .ring .ic { color: var(--p-high); }
.t-check.pr-Medium:hover .ring .ic { color: var(--p-med); }

.t-check.checked .ring,
.t-check.completing .ring {
  background: var(--p-low);
  border-color: var(--p-low);
}

.t-check.checked .ring .ic,
.t-check.completing .ring .ic { color: #fff; }

.t-check.completing .ring { animation: pop 300ms ease-out; }
@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.t-main { min-width: 0; padding-top: 1px; }

.t-title {
  font-size: 0.95rem;
  overflow-wrap: break-word;
  cursor: pointer;
}

.t-desc {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 1px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.t-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}

.due { display: inline-flex; align-items: center; gap: 4px; }
.due .ic { width: 13px; height: 13px; }
.due.overdue { color: var(--overdue); font-weight: 600; }
.due.today { color: var(--today); font-weight: 600; }

.laura-tag { display: inline-flex; align-items: center; gap: 4px; color: var(--laura); font-weight: 500; }
.laura-tag .ic { width: 13px; height: 13px; }

.t-next {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.t-next .arrow { color: var(--accent); font-weight: 700; }
.t-next .t-next-text { border-bottom: 1px dashed transparent; cursor: text; }
.t-next .t-next-text:hover { border-bottom-color: var(--faint); }
.t-next .t-next-text.empty { color: var(--faint); font-style: italic; }

.t-next input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.82rem;
}

.t-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  padding-top: 2px;
}

.pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 8px;
  margin: -4px -6px 0 0;
  border-radius: 6px;
  transition: background 120ms ease-out;
}

.pill:hover { background: var(--hover); }
.pill.High { color: var(--p-high); }
.pill.Medium { color: var(--p-med); }
.pill.Low { color: var(--p-low); }

.laura-chip {
  font-size: 0.72rem;
  color: var(--faint);
  padding: 4px 8px;
  margin-right: -6px;
  border-radius: 6px;
  transition: background 120ms ease-out, color 120ms ease-out;
}

.laura-chip:hover { background: var(--hover); color: var(--muted); }
.laura-chip.on { color: var(--laura); font-weight: 600; }

.empty-state { text-align: center; color: var(--muted); padding: 64px 16px; }

/* ---------- add row / fab ---------- */
#add-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 0;
  color: var(--muted);
  font-size: 0.92rem;
  transition: color 120ms ease-out;
}

#add-row:hover { color: var(--accent); }

.add-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  transition: background 120ms ease-out, color 120ms ease-out;
}

.add-circle .ic { width: 15px; height: 15px; }

#add-row:hover .add-circle { background: var(--accent); color: #fff; }

#add-fab {
  display: none;
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(220, 76, 62, 0.4);
  transition: transform 120ms ease-out, background 120ms ease-out;
  z-index: 20;
}

#add-fab:hover { background: var(--accent-dark); }
#add-fab:active { transform: scale(0.94); }
#add-fab .ic { width: 24px; height: 24px; }

/* ---------- dialog ---------- */
dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: min(94vw, 480px);
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(32, 32, 32, 0.5); }

#task-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  background: var(--bg);
}

#task-form h2 { margin: 0; font-size: 1.1rem; font-weight: 600; font-family: var(--font-head); }

#task-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  flex: 1;
}

#task-form input,
#task-form select,
#task-form textarea {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.95rem;
  width: 100%;
}

#task-form input:focus, #task-form select:focus, #task-form textarea:focus {
  border-color: var(--faint);
  outline: none;
}

.form-row { display: flex; gap: 10px; }

.check-label {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  font-size: 0.9rem !important;
  color: var(--ink) !important;
  font-weight: 400 !important;
}

.check-label input { width: auto !important; accent-color: var(--laura); }

.delegate-row { align-items: center; }

.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }

.spacer { flex: 1; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 11px 18px;
  font-weight: 600;
  transition: background 120ms ease-out;
}

.btn-primary:hover { background: var(--accent-dark); }

.btn-ghost {
  background: var(--hover);
  color: var(--ink);
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 500;
}

.btn-danger {
  color: var(--overdue);
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 500;
}

.btn-danger:hover { background: var(--p-high-soft); }

/* ---------- mobile ---------- */
#scrim {
  position: fixed;
  inset: 0;
  background: rgba(32, 32, 32, 0.45);
  z-index: 29;
}

@media (max-width: 900px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 220ms ease-out;
    box-shadow: none;
    width: min(82vw, 300px);
  }

  #sidebar.open { transform: none; box-shadow: var(--shadow); }

  #menu-btn { display: flex; margin-left: -10px; }

  .content { padding: 0 16px calc(90px + env(safe-area-inset-bottom)); }

  .topbar h1 { font-size: 1.15rem; }

  #add-fab { display: flex; }

  #f-priority { max-width: 90px; }
}

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