:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --text: #1c1c1a;
  --muted: #8a8a84;
  --line: #ececea;
  --accent: #16a34a;
  --danger: #b91c1c;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211;
    --surface: #1c1c1a;
    --text: #ececea;
    --muted: #8d8d86;
    --line: #2a2a27;
    --accent: #22c55e;
    --danger: #f87171;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 0 48px;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 20px 8px;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

nav { display: flex; align-items: center; gap: 4px; }

button, .pill {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ghost {
  color: var(--muted);
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
}
.ghost:active { background: var(--line); }

.add { font-size: 26px; line-height: 1; padding: 8px 14px 12px; }

.small { font-size: 13px; }

/* ---- List ---- */

#list { list-style: none; margin: 0; padding: 0; }

.item {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  transition: opacity .28s ease, transform .28s ease;
  interpolate-size: allow-keywords;
}

.item.leaving {
  opacity: 0;
  transform: translateX(24px);
}

.item.collapsed {
  transition: opacity .28s ease, transform .28s ease,
              max-height .25s ease .18s, border-bottom-width .25s ease .18s;
  max-height: 0;
  border-bottom-width: 0;
}

.item-link {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 16px 8px 16px 20px;
  text-decoration: none;
  color: inherit;
}
.item-link:active { background: var(--line); }

.item-title {
  font-weight: 550;
  font-size: 17px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-domain {
  font-size: 13px;
  color: var(--muted);
}

/* ---- Done check ---- */

.check {
  flex: none;
  width: 64px;
  display: grid;
  place-items: center;
  padding: 0;
}

.check svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .15s ease;
}
.check:active svg { transform: scale(0.88); }

.check .tick {
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
}

.item.checked .check svg {
  stroke: var(--accent);
}
.item.checked .check circle {
  fill: color-mix(in srgb, var(--accent) 12%, transparent);
}
.item.checked .check .tick {
  stroke-width: 2.4;
  transition: stroke-dashoffset .25s ease-out;
  stroke-dashoffset: 0;
}

/* Archive view: pre-checked, tap restores */
.archive .check svg { stroke: var(--accent); }
.archive .check .tick { stroke-dashoffset: 0; stroke-width: 2.4; }
.archive .item-title { color: var(--muted); }

/* ---- Empty state ---- */

.empty {
  text-align: center;
  color: var(--muted);
  padding: 64px 20px;
  font-size: 17px;
}

/* ---- Gate ---- */

#gate { padding: 48px 20px; max-width: 420px; margin: 0 auto; }
#gate h1 { font-size: 28px; }

#gate input {
  width: 100%;
  font: inherit;
  color: inherit;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  margin: 8px 0 12px;
}

#gate button[type="submit"], .pill {
  display: inline-block;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  padding: 14px 22px;
  border-radius: 12px;
  text-decoration: none;
}

.error { color: var(--danger); font-size: 14px; }
.muted { color: var(--muted); font-size: 14px; }

/* ---- Footer / setup ---- */

footer { padding: 32px 20px 0; }
#setup h2 { font-size: 14px; margin: 22px 0 4px; }
#setup .muted { margin: 4px 0 10px; }

/* ---- Snackbar ---- */

#snackbar[hidden] { display: none; }

#snackbar {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 15px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
  animation: snack-in .2s ease-out;
  max-width: calc(100vw - 32px);
}

#snackbar button {
  color: inherit;
  font-weight: 700;
  padding: 6px 4px;
}

@keyframes snack-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
