:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #1f232c;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #8b92a1;
  --accent: #6d8bff;
  --accent-soft: #2a3358;
  --done: #5a6173;
  --danger: #ff6b6b;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #1a1f2e 0%, transparent 60%),
    var(--bg);
  min-height: 100vh;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 20px 96px;
}

/* ---------- landing ---------- */
.landing {
  text-align: center;
  padding-top: 8vh;
}
.landing h1 {
  font-size: 2.6rem;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.landing p {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 auto 36px;
  max-width: 420px;
  line-height: 1.5;
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font: inherit;
  border-radius: 10px;
  transition: transform .08s ease, background .15s ease, opacity .15s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, #7d97ff, #5a78f5);
  color: #fff;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 14px 28px;
  box-shadow: 0 6px 20px -6px var(--accent);
}
.btn-primary:hover { filter: brightness(1.05); }

/* ---------- list view ---------- */
.list-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.list-title {
  flex: 1;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 6px 4px;
  border-radius: 8px;
  outline: none;
  min-width: 0;
}
.list-title:focus { background: var(--panel); }

.list-header .icon-btn {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 6px; border-radius: 8px;
  transition: color .15s ease, background .15s ease;
}
.list-header .icon-btn:hover { color: var(--text); background: var(--panel); }
.list-header .icon-btn svg { display: block; }

.settings-wrap { position: relative; display: inline-flex; }
.settings-menu {
  position: absolute;
  right: 0; top: calc(100% + 6px);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  min-width: 150px;
  box-shadow: 0 10px 24px -8px #000;
  display: none;
  z-index: 20;
}
.settings-wrap.open .settings-menu { display: block; }
.settings-menu .menu-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; color: var(--text);
  cursor: pointer; font: inherit; padding: 8px 10px; border-radius: 6px;
}
.settings-menu .menu-item:hover { background: var(--panel); }
.settings-menu .menu-item.danger { color: var(--danger); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: .85rem;
}
.toolbar a, .toolbar button {
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: none;
}
.toolbar a:hover, .toolbar button:hover { color: var(--text); }
.toolbar .spacer { flex: 1; }
.toolbar .icon-btn { display: inline-flex; align-items: center; }
.toolbar .icon-btn svg { display: block; }
.count { color: var(--muted); }

.add-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.add-input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  padding: 14px 16px;
  border-radius: 12px;
  outline: none;
  transition: border .15s ease;
}
.add-input:focus { border-color: var(--accent); }
.add-input::placeholder { color: var(--muted); }
.add-btn {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 1.4rem;
  width: 52px;
  border-radius: 12px;
  line-height: 1;
}
.add-btn:hover { background: #323d6b; }

.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  transition: background .15s ease, opacity .15s ease, box-shadow .15s ease;
}
.item:hover { background: var(--panel-2); }
.item.dragging {
  opacity: .9;
  background: var(--panel-2);
  box-shadow: 0 10px 24px -8px #000;
  border-color: var(--accent);
  position: relative;
  z-index: 10; /* float above the FLIP-animating siblings */
  will-change: transform;
}

.handle {
  flex: none;
  color: var(--muted);
  cursor: grab;
  font-size: 1rem;
  line-height: 1;
  padding: 2px 2px;
  touch-action: none; /* let pointer events drive drag instead of scrolling */
  opacity: .5;
  user-select: none;
}
.handle:hover { opacity: 1; color: var(--text); }
.item.dragging .handle { cursor: grabbing; }

.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.added { font-size: .72rem; color: var(--muted); opacity: .7; }
.item.done .added { text-decoration: none; }

.check {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  cursor: pointer;
  position: relative;
  transition: border-color .15s ease, background .15s ease;
}
.check:hover { border-color: var(--accent); }
.item.done .check {
  background: var(--accent);
  border-color: var(--accent);
}
.item.done .check::after {
  content: "";
  position: absolute;
  left: 6px; top: 2px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.item-text {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  line-height: 1.4;
  background: transparent;
  border: none;
  color: var(--text);
  outline: none;
  padding: 2px 0;
  min-width: 0;
  resize: none;
  overflow: hidden; /* height is driven by autosize(); hide the scrollbar */
  white-space: pre-wrap;
  word-break: break-word; /* wrap long unbroken strings/URLs instead of overflowing */
  display: block;
}
.item.done .item-text {
  color: var(--done);
  text-decoration: line-through;
}

.del {
  flex: none;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  opacity: 0;
  transition: opacity .15s ease, color .15s ease;
  padding: 4px;
}
.item:hover .del { opacity: 1; }
.del:hover { color: var(--danger); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
  font-size: .95rem;
}

/* ---------- auth strip ---------- */
.auth-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
  color: var(--muted);
  font-size: .9rem;
}
.auth-hint { flex-basis: 100%; text-align: center; margin: 8px 0 0; color: var(--muted); }
.avatar { width: 26px; height: 26px; border-radius: 50%; }
.who { color: var(--text); }
.linkbtn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font: inherit; text-decoration: underline; padding: 0;
}
.linkbtn:hover { color: var(--text); }

.btn-google {
  display: inline-flex; align-items: center; gap: 10px;
  background: #fff; color: #1f2330; font-weight: 600;
  padding: 11px 20px; text-decoration: none;
}
.btn-google:hover { filter: brightness(.96); }
.btn-google .g {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: #4285f4; color: #fff; font-weight: 700; font-size: .8rem;
}

/* Signed-in users land on their lists: collapse the hero so the lists are the focus. */
.signed-in .landing { text-align: left; padding-top: 24px; }
.signed-in .landing h1 { font-size: 1.6rem; margin-bottom: 6px; }
.signed-in .landing p { margin: 0 0 18px; max-width: none; font-size: .98rem; }
.signed-in .btn-primary { padding: 11px 22px; font-size: 1rem; }

/* ---------- list sections (your lists / all lists) ---------- */
.dash { margin-top: 36px; }
.dash + .dash { margin-top: 28px; }
.dash h2 { font-size: 1.25rem; color: var(--text); font-weight: 600; margin: 0 0 16px; letter-spacing: .01em; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 1.02rem; }
.dash-table th {
  text-align: left; color: var(--muted); font-weight: 500; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .04em; padding: 0 10px 8px;
}
.dash-row { cursor: pointer; transition: background .12s ease; }
.dash-row:hover { background: var(--panel); }
.dash-table td { padding: 15px 10px; border-top: 1px solid var(--border); }
.dash-title { color: var(--text); font-weight: 500; }
.dash-table .num { color: var(--accent); font-variant-numeric: tabular-nums; }
.dash-table .when { color: var(--muted); white-space: nowrap; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: .9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
