:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --ink: #1a1d29;
  --muted: #6b7180;
  --line: #e7e9f0;
  --accent: #4f6ef7;
  --accent-ink: #ffffff;
  --green: #2fbf71;
  --red: #e5484d;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(26,29,41,.04), 0 8px 24px rgba(26,29,41,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Inter", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 18px;
}

.brand {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -.02em;
  color: var(--ink);
  text-decoration: none;
}

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

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e8edff;
  color: var(--accent);
}

.linkbtn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  font-weight: 600;
}
.linkbtn:hover { color: var(--ink); }

.hero { padding: 26px 0 20px; }
.hero h1 { font-size: 32px; margin: 0 0 6px; letter-spacing: -.03em; }
.muted { color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Create form */
.create {
  display: flex;
  gap: 10px;
  padding: 14px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.create input[type=text] { flex: 1 1 220px; }
.create select { flex: 0 0 auto; }

input, select {
  font: inherit;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,110,247,.15);
}

.btn {
  font: inherit;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: transform .05s, box-shadow .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover { box-shadow: 0 6px 18px rgba(79,110,247,.35); }

.msg { min-height: 20px; margin: 6px 2px; font-size: 14px; color: var(--muted); }
.msg.err { color: var(--red); font-weight: 600; }

/* Grid of lists */
.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px,1fr)); gap: 14px; }

.list-card {
  display: block;
  text-decoration: none;
  color: var(--ink);
  padding: 18px;
  transition: transform .12s, box-shadow .15s, border-color .15s;
}
.list-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 12px 28px rgba(26,29,41,.10);
}
.list-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; letter-spacing: -.01em; }
.list-meta { display: flex; flex-direction: column; gap: 10px; }
.list-meta .muted, .list-meta span { font-size: 13px; }

.vis-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  width: fit-content;
}
.vis-private { background: #f2f2f5; color: var(--muted); }
.vis-public_view { background: #eef7ef; color: #1f9d55; }
.vis-public_edit { background: #fff4e0; color: #b26a00; }

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

/* List page */
.list-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 24px 0 18px; flex-wrap: wrap;
}
.list-head h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -.03em; }
.list-head .vis-badge { margin-top: 8px; }

.add-form {
  display: flex; gap: 10px; padding: 2px 0 4px; flex-wrap: wrap;
}
.add-form input[type=text] { flex: 1 1 200px; }

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

.item {
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 14px; box-shadow: var(--shadow);
  transition: opacity .15s;
}
.item.empty-item { justify-content: center; color: var(--muted); }
.item.done { opacity: .55; }
.item.done .item-text { text-decoration: line-through; }

.check {
  flex: 0 0 auto;
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--surface);
  cursor: pointer; padding: 0;
  background-position: center; background-repeat: no-repeat; background-size: 16px 16px;
  background-origin: border-box; box-sizing: border-box;
  transition: border-color .15s, background-color .15s;
}
.check:hover { border-color: var(--green); }
.item.done .check {
  border-color: var(--green);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%232fbf71' d='M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z'/></svg>");
  background-size: 17px 17px;
}

.item-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.item-text { font-weight: 500; word-break: break-word; }
.item-note { font-size: 13px; color: var(--muted); }

.del {
  flex: 0 0 auto;
  width: 28px; height: 28px; border-radius: 8px;
  border: none; background: none; color: var(--muted);
  cursor: pointer; font-size: 15px; opacity: 0; transition: opacity .15s, background .15s, color .15s;
}
.item:hover .del { opacity: 1; }
.del:hover { background: #fdecec; color: var(--red); }

/* Auth card */
.auth-card { max-width: 380px; margin: 40px auto; padding: 28px; }
.auth-card h1 { margin: 0 0 6px; font-size: 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.auth-card .btn { width: 100%; }

/* 403/404 */
.error-card { text-align: center; padding: 50px 24px; margin-top: 40px; }
.error-card h1 { font-size: 40px; margin: 0 0 8px; }
.error-card a { color: var(--accent); font-weight: 600; }

@media (max-width: 480px) {
  .hero h1 { font-size: 27px; }
  .add-form .btn, .create .btn { flex: 1; }
}