/* Smash List — Smashboard-inspired warm surfaces + BTC orange
   Fonts aligned with Math (system stack, larger + bolder weights) */

:root {
  color-scheme: light dark;
  --background: 35 18% 96%;
  --foreground: 30 12% 12%;
  --border: 35 12% 86%;
  --card: 0 0% 100%;
  --card-foreground: 30 12% 12%;
  --muted: 35 14% 92%;
  --muted-foreground: 30 6% 42%;
  --primary: 32 95% 49%;
  --primary-foreground: 0 0% 100%;
  --destructive: 0 70% 45%;
  --destructive-foreground: 0 0% 98%;
  --input: 35 12% 80%;
  --radius: 0.5rem;
  --shadow-sm: 0 1px 2px hsl(30 30% 5% / 0.05);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --prio-1: 32 95% 49%;
  --prio-2: 32 95% 49%;
  --prio-3: 32 95% 49%;
  --prio-4: 32 95% 49%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: 30 8% 7%;
    --foreground: 35 12% 92%;
    --border: 30 6% 18%;
    --card: 30 8% 10%;
    --card-foreground: 35 12% 92%;
    --muted: 30 6% 14%;
    --muted-foreground: 35 8% 65%;
    --primary: 32 95% 55%;
    --primary-foreground: 30 8% 7%;
    --destructive: 0 65% 50%;
    --input: 30 6% 22%;
    --shadow-sm: 0 1px 2px hsl(0 0% 0% / 0.3);
    --prio-1: 32 95% 55%;
    --prio-2: 32 95% 55%;
    --prio-3: 32 95% 55%;
    --prio-4: 32 95% 55%;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.app {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem 0.85rem calc(1.25rem + var(--safe-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.85rem;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.tagline {
  margin: 0.2rem 0 0;
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}

.header-actions {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.btn {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border-radius: calc(var(--radius) - 2px);
  padding: 0.4rem 0.75rem;
  font-size: 1rem;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
  line-height: 1.2;
}

.btn:hover { background: hsl(var(--muted)); }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: transparent;
}

.btn.primary:hover { filter: brightness(1.06); }

.btn.ghost {
  background: transparent;
  box-shadow: none;
}

.btn.small {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

.btn.danger { color: hsl(var(--destructive)); }

.btn.icon {
  width: 1.75rem;
  height: 1.75rem;
  min-width: 1.75rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.btn.icon svg {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn.icon.danger:hover {
  background: color-mix(in srgb, hsl(var(--destructive)) 14%, transparent);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.lists-bar {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
}

.list-tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.list-tab {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 1.05rem;
  font-weight: 800;
}

.list-tab[aria-selected="true"] {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-color: transparent;
}

.list-ops {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.3rem;
  flex-shrink: 0;
  align-items: center;
  margin-left: auto;
}

.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.4rem;
  align-items: center;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.4rem;
  box-shadow: var(--shadow-sm);
}

.prio-select {
  border: 1px solid hsl(var(--input));
  border-radius: 6px;
  background: transparent;
  padding: 0.35rem 0.35rem;
  font-size: 1rem;
  font-weight: 800;
}

.new-text {
  border: none;
  background: transparent;
  outline: none;
  min-width: 0;
  padding: 0.3rem 0.2rem;
  resize: none;
  min-height: 1.4em;
  max-height: 8rem;
  line-height: 1.35;
  font: inherit;
  color: inherit;
}

.main { flex: 1; }

.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.todo-item {
  display: grid;
  grid-template-columns: auto auto auto 1fr auto;
  gap: 0.45rem;
  align-items: start;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.45rem 0.5rem;
  box-shadow: var(--shadow-sm);
}

.todo-item.done .todo-text {
  text-decoration: line-through;
  opacity: 0.55;
}

.todo-item input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin-top: 0.2rem;
  accent-color: hsl(var(--primary));
}

.prio-badge {
  font-size: 0.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  margin-top: 0.15rem;
  color: hsl(var(--primary-foreground));
  background: hsl(var(--primary));
  cursor: pointer;
}

.prio-badge.p1 { background: hsl(var(--prio-1)); }
.prio-badge.p2 { background: hsl(var(--prio-2)); }
.prio-badge.p3 { background: hsl(var(--prio-3)); }
.prio-badge.p4 { background: hsl(var(--prio-4)); }

.todo-body { min-width: 0; }

.todo-text-row {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  gap: 0.25rem;
  align-items: start;
}

.todo-text-row.no-toggle {
  grid-template-columns: 1.25rem 1fr;
}

.note-toggle.invisible {
  visibility: hidden;
  pointer-events: none;
}

.todo-note-row {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  gap: 0.25rem;
  align-items: start;
  margin-top: 0.35rem;
}

.note-toggle {
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
}

.note-toggle:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--muted));
}

.note-toggle svg {
  width: 0.85rem;
  height: 0.85rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.todo-note {
  min-width: 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: hsl(var(--muted-foreground));
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
  border-radius: 4px;
  padding: 0.1rem 0.2rem;
}

.todo-note.collapsed {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
  white-space: normal;
}

.todo-note[contenteditable="true"] {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  white-space: pre-wrap;
}

.todo-text {
  outline: none;
  word-break: break-word;
  white-space: pre-wrap;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.35;
}

.todo-text.collapsed {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.todo-text[contenteditable="true"] {
  background: hsl(var(--muted));
  border-radius: 4px;
  padding: 0.1rem 0.25rem;
}

.todo-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-top: 0.25rem;
}

.todo-actions {
  display: flex;
  gap: 0.15rem;
  flex-shrink: 0;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.todo-actions .btn.small {
  padding: 0.2rem 0.4rem;
  font-size: 0.72rem;
}

.stats {
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.show-done {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
}

.empty {
  padding: 1.25rem 0.5rem;
  text-align: center;
  color: hsl(var(--muted-foreground));
  font-size: 1.05rem;
}

@media (max-width: 480px) {
  .composer { grid-template-columns: auto 1fr; }
  .composer .btn.primary { grid-column: 1 / -1; }
}


.drag-handle {
  width: 1.5rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  flex-shrink: 0;
  border-radius: 6px;
  align-self: center;
}

.drag-handle:active { cursor: grabbing; }

.drag-handle svg {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

.todo-item.dragging {
  opacity: 0.35;
}

.todo-item.drop-target {
  outline: 2px solid hsl(var(--primary));
  outline-offset: -2px;
}

.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.92;
  list-style: none;
  margin: 0;
  box-shadow: 0 8px 24px hsl(30 30% 5% / 0.25);
  border-radius: 10px;
  background: hsl(var(--card));
  transform: translate(-9999px, -9999px);
}

.todo-text.editing,
.todo-text[contenteditable="true"] {
  white-space: pre-wrap;
  min-height: 2.5rem;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  outline: 2px solid hsl(var(--primary) / 0.35);
}



.prio-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.15rem 0.35rem;
}

.prio-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.prio-chip {
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-size: 0.9rem;
  font-weight: 800;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.2;
}

.prio-chip.on {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.prio-chip:hover {
  filter: brightness(1.05);
}


/* Auth gate — Smashboard orange */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: hsl(var(--background) / 0.92);
  backdrop-filter: blur(8px);
}

.auth-gate[hidden] { display: none !important; }

.auth-card {
  width: 100%;
  max-width: 22rem;
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) + 4px);
  padding: 1.35rem 1.25rem 1.25rem;
  box-shadow: 0 12px 40px hsl(30 30% 5% / 0.18);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.auth-card h2 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.auth-hint {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground));
}

.auth-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}

.auth-card input[type="password"] {
  border: 1px solid hsl(var(--input));
  border-radius: 8px;
  background: hsl(var(--muted));
  padding: 0.55rem 0.7rem;
  outline: none;
}

.auth-card input[type="password"]:focus {
  border-color: hsl(var(--primary));
  outline: 2px solid hsl(var(--primary) / 0.25);
}

.auth-username,
.auth-user-label {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.auth-error {
  margin: 0;
  font-size: 0.82rem;
  color: hsl(var(--destructive));
}

.auth-submit {
  margin-top: 0.35rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-weight: 600;
}

body.auth-locked .app {
  pointer-events: none;
  user-select: none;
  filter: blur(1.5px);
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: hsl(var(--muted-foreground));
  padding: 0.15rem 0.1rem 0;
}

.todo-inline-edit {
  display: block;
  width: 100%;
  min-height: 4.5rem;
  max-height: 360px;
  margin: 0;
  padding: 0.35rem 0.45rem;
  border: 1px solid hsl(var(--primary));
  border-radius: 8px;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  caret-color: hsl(var(--foreground));
  font: inherit;
  font-weight: 700;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-y: auto;
  resize: vertical;
  box-sizing: border-box;
}
.todo-inline-edit:focus {
  outline: 2px solid hsl(var(--primary) / 0.45);
  outline-offset: 1px;
}
.todo-text.editing {
  padding: 0;
}
