:root {
  --paper: #EFEDE3;
  --paper-raised: #F7F5EC;
  --ink: #23262B;
  --ink-soft: #5B5B52;
  --rule: #CBC6B4;
  --rule-strong: #A7A18C;
  --accent: #2B6E64;
  --accent-soft: #DCE6E1;
  --done: #A39D8A;
  --danger: #A6432F;
  --radius: 3px;
  --font-display: 'Fraunces', serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: var(--font-mono);
  cursor: pointer;
}

.hidden { display: none !important; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-decoration: none;
  padding: 4px 0;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Login ---------- */
.screen { min-height: 100vh; }
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 0 var(--rule-strong);
}
.login-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.08em;
}
.login-sub {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 12px;
}
.login-card input {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
.login-card input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.login-card button {
  margin-top: 8px;
  background: var(--ink);
  color: var(--paper-raised);
  border: none;
  border-radius: var(--radius);
  padding: 10px;
  font-size: 13px;
  letter-spacing: 0.05em;
}
.login-card button:hover { background: var(--accent); }
.login-error { color: var(--danger); font-size: 12px; margin: 0; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 10px;
  border-bottom: 1px solid var(--rule);
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.1em;
}

/* ---------- Timeline ---------- */
.timeline-wrap { padding: 18px 0 8px; }
.timeline {
  display: flex;
  gap: 0;
  padding: 0 24px 8px;
}
.day-col {
  flex: 1 1 0;
  min-width: 0;
  border-right: 1px solid var(--rule);
  padding: 0 16px 12px 0;
  margin-right: 16px;
}
.day-col:last-child { border-right: none; margin-right: 0; }

.timeline-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 24px 0;
}
.nav-btn {
  background: none;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 12px;
  padding: 5px 12px;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.nav-btn:disabled { opacity: 0.35; cursor: default; }
.nav-btn:disabled:hover { border-color: var(--rule); color: var(--ink); }

.day-head {
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 2px solid var(--ink);
}
.day-date {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.day-weekday {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}
.day-col.is-today .day-head { border-bottom-color: var(--accent); }
.day-col.is-today .day-weekday { color: var(--accent); }
.today-badge {
  display: inline-block;
  font-size: 9px;
  letter-spacing: 0.1em;
  background: var(--accent);
  color: var(--paper-raised);
  padding: 1px 6px;
  border-radius: 2px;
  margin-left: 6px;
  vertical-align: middle;
}

.todo-list { list-style: none; margin: 0; padding: 0; min-height: 20px; }
.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px dotted var(--rule);
}
.todo-item.dragging { opacity: 0.4; }
.day-col.drag-over {
  background: var(--accent-soft);
  outline: 1px dashed var(--accent);
  outline-offset: -2px;
}
.drag-handle {
  opacity: 0;
  cursor: grab;
  color: var(--rule-strong);
  font-size: 12px;
  line-height: 1.4;
  flex: 0 0 12px;
  user-select: none;
  touch-action: none;
}
.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 5px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  pointer-events: none;
  z-index: 100;
}
.todo-item:hover .drag-handle { opacity: 0.7; }
.drag-handle:hover { opacity: 1 !important; color: var(--accent); }
.drag-handle:active { cursor: grabbing; }

.todo-item .check {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--rule-strong);
  border-radius: 2px;
  margin-top: 2px;
  flex: 0 0 14px;
  cursor: pointer;
}
.todo-item.completed .check {
  background: var(--accent);
  border-color: var(--accent);
}
.todo-item .text {
  flex: 1;
  outline: none;
  word-break: break-word;
  cursor: text;
}
.todo-item .check,
.todo-item .del {
  cursor: pointer;
}
.todo-item.completed .text {
  color: var(--done);
  text-decoration: line-through;
}
.todo-item .del {
  opacity: 0;
  background: none;
  border: none;
  color: var(--danger);
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
}
.todo-item:hover .del { opacity: 0.6; }
.todo-item .del:hover { opacity: 1; }

.add-todo-row {
  padding: 6px 0;
  color: var(--ink-soft);
  font-size: 13px;
  cursor: text;
  border-bottom: 1px dotted transparent;
}
.add-todo-row:hover { color: var(--accent); }
.add-todo-input {
  border: none;
  background: none;
  font-family: var(--font-mono);
  font-size: 14px;
  width: 100%;
  outline: none;
  padding: 5px 0;
  border-bottom: 1px dotted var(--rule);
}

.timeline-controls { display: none; }

/* ---------- Lists (Someday) ---------- */
.lists-section {
  padding: 24px;
  margin-top: 12px;
  border-top: 1px solid var(--rule);
}
.lists-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 14px;
}
.lists-header h2 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0;
  letter-spacing: 0.03em;
}
.lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.list-card {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.list-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.list-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  outline: none;
}
.list-del {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 12px;
}
.list-del:hover { color: var(--danger); }

/* ---------- Undo toast ---------- */
.undo-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper-raised);
  padding: 10px 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  z-index: 50;
}
.undo-toast button {
  background: none;
  border: none;
  color: var(--accent-soft);
  text-decoration: underline;
  font-size: 13px;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .timeline {
    flex-direction: column;
    overflow-x: visible;
    padding: 0 16px;
  }
  .day-col {
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--rule);
    margin-right: 0;
    padding: 0 0 12px;
    margin-bottom: 14px;
  }
  .topbar { padding: 14px 16px 10px; }
  .lists-section { padding: 16px; }
  .login-card { width: 88vw; }
}
