:root {
  --bg: #f6f5f3;
  --card: #ffffff;
  --ink: #1d1b19;
  --muted: #6c6862;
  --line: #e3e0da;
  --line-strong: #cbc6bc;
  --accent: #9a4b2f;
  --accent-soft: #f4e7e1;
  --star: #d39a1e;
  --danger: #a3302a;
  --radius: 10px;

  --k-article: #9a7bb8;
  --k-video: #c2624f;
  --k-book: #5b8c6e;
  --k-film: #4a7fa5;
  --k-documentary: #7d94b5;
  --k-podcast: #c08a3e;
  --k-website: #8d8577;
  --k-other: #b0a89a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a;
    --card: #201f24;
    --ink: #eceaf0;
    --muted: #9b96a3;
    --line: #333039;
    --line-strong: #4a4653;
    --accent: #e08d6d;
    --accent-soft: #33262a;
    --star: #e5b84b;
    --danger: #e0756c;

    --k-article: #b39ccc;
    --k-video: #db8672;
    --k-book: #7fb396;
    --k-film: #6fa4c9;
    --k-documentary: #9db2cd;
    --k-podcast: #d9a860;
    --k-website: #a8a093;
    --k-other: #8d867b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, sans-serif;
}

a { color: var(--accent); }

/* Header ------------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

/* Same measure as .layout, so the brand and search line up with the columns. */
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 24px;
}

.brand {
  font-weight: 650;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--ink);
}

.search { display: flex; gap: 8px; margin-left: auto; flex: 1 1 260px; max-width: 460px; }
.search input { flex: 1; }

.signed-in { display: flex; align-items: center; gap: 10px; }
.signed-in .who { color: var(--muted); font-size: .85rem; text-decoration: none; }
.signed-in a.who:hover { color: var(--accent); }
.signed-in button { font-size: .82rem; padding: 5px 11px; }

/* Sign-in page -------------------------------------------------------- */

.layout.single { grid-template-columns: minmax(0, 620px); justify-content: center; }

.ok {
  margin: 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .9rem;
}

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login { width: 100%; max-width: 360px; }
.login h1 { font-size: 1.3rem; margin: 0; }
.login .card { gap: 14px; }
.login button { width: 100%; }
.login .hint { margin: 0; }

/* Layout ------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px;
}

.content { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sidebar { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.items .card { transition: border-color .12s ease, box-shadow .12s ease; }
.items .card:hover { border-color: var(--line-strong); box-shadow: 0 1px 3px rgba(20, 18, 16, .06); }

/* Add form ------------------------------------------------------------ */

summary { cursor: pointer; }
details[open] summary { margin-bottom: 12px; }

.add summary {
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}
.add summary::-webkit-details-marker { display: none; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); }
label.inline { display: flex; align-items: center; gap: 8px; }
.hint { font-weight: 400; color: var(--muted); font-size: .78rem; }

input[type="text"], input[type="search"], textarea, select {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  font: inherit;
  /* Labels are bold and fields sit inside them, so reset the inherited weight. */
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
}

::placeholder { color: var(--muted); opacity: .7; font-weight: 400; }
label.inline select { width: auto; margin-top: 0; }
textarea { resize: vertical; line-height: 1.6; }

input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button, .button {
  font: inherit;
  padding: 8px 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--accent); color: var(--accent); }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.08); color: #fff; }

button.star-toggle {
  flex: 1;
  font-size: .85rem;
  padding: 6px 12px;
}
button.star-toggle.on { border-color: var(--star); color: var(--star); }

button.destructive { border-color: var(--danger); color: var(--danger); }
.danger summary { color: var(--danger); font-size: .9rem; }

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

.list-head { display: flex; align-items: baseline; gap: 12px; padding: 0 2px; }
.list-head h1 { font-size: 1.3rem; margin: 0; }
.count { color: var(--muted); font-size: .85rem; }
.clear { font-size: .85rem; }

.sort { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.sort label { font-size: .78rem; }
.sort select { width: auto; margin-top: 0; font-size: .82rem; padding: 5px 8px; }

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

.item { display: flex; gap: 16px; align-items: flex-start; border-left: 3px solid transparent; }
.item { border-left-color: var(--kind, transparent); }
.item.kind-article { --kind: var(--k-article); }
.item.kind-video { --kind: var(--k-video); }
.item.kind-book { --kind: var(--k-book); }
.item.kind-film { --kind: var(--k-film); }
.item.kind-documentary { --kind: var(--k-documentary); }
.item.kind-podcast { --kind: var(--k-podcast); }
.item.kind-website { --kind: var(--k-website); }
.item.kind-other { --kind: var(--k-other); }
.item.starred { box-shadow: inset 3px 0 0 var(--star); }
.item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.item-main { flex: 1; min-width: 0; }
.item h2 { font-size: 1.02rem; margin: 0 0 6px; line-height: 1.4; }
.item h2 a { color: var(--ink); text-decoration: none; }
.item h2 a:hover { color: var(--accent); text-decoration: underline; }

.item-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  flex-shrink: 0;
}
.item-actions form { display: flex; }
.item-actions .button { text-align: center; font-size: .85rem; padding: 6px 12px; }
.notes-link { font-weight: 600; color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.notes-link:hover { border-color: var(--accent); }
.status-form select { width: auto; margin-top: 0; font-size: .85rem; padding: 6px 8px; }

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--muted);
  font-size: .8rem;
}
.kind {
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .68rem;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
}
.kind:hover { color: var(--accent); }
.creator { color: var(--ink); opacity: .75; }
.sep { opacity: .5; }

.excerpt {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: .9rem;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid var(--line);
}
.badge-queued { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-active { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.badge-done { background: transparent; color: var(--muted); opacity: .8; }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; }
.tags a {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: .76rem;
  text-decoration: none;
}
.tags a::before { content: "#"; opacity: .5; }
.tags a:hover { color: var(--accent); border-color: var(--accent); }

.empty { color: var(--muted); text-align: center; padding: 32px 16px; margin: 0; }

.error {
  margin: 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--danger);
  font-size: .9rem;
}

/* Sidebar ------------------------------------------------------------- */

.sidebar h3 {
  margin: 0 0 10px;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}

.filters { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.filters a {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 7px;
  text-decoration: none;
  color: var(--ink);
  font-size: .9rem;
}
.filters a:hover { background: var(--bg); }
.filters a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.filters span { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .82rem; }

/* Side panel --------------------------------------------------------- */

.panel-scrim {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(20, 18, 16, .34);
  backdrop-filter: blur(1.5px);
  animation: fade .16s ease-out;
}

.panel {
  position: fixed;
  z-index: 11;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 46px rgba(20, 18, 16, .18);
  animation: slide-in .2s cubic-bezier(.32, .72, .35, 1);
}

@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(22px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .panel, .panel-scrim { animation: none; }
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.panel-head .meta { flex: 1; min-width: 0; }

.panel-close { flex-shrink: 0; padding: 5px 11px; font-size: .82rem; color: var(--muted); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-body h2 {
  font-size: 1.22rem;
  line-height: 1.34;
  margin: 0;
  outline: none;
}

.panel .url {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 7px;
  margin: 0;
  font-size: .82rem;
}
.panel .url .dim { color: var(--muted); word-break: break-all; }

.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick button { font-size: .84rem; padding: 6px 12px; }

.panel-form { gap: 10px; }
.panel-form > label { margin-bottom: -6px; }
.panel-form textarea { min-height: 200px; }

.more summary {
  font-size: .82rem;
  color: var(--muted);
  padding: 2px 0;
}
.more summary:hover { color: var(--accent); }

.panel-save { display: flex; align-items: center; gap: 12px; }
.saved-note { color: var(--muted); font-size: .82rem; }

body.panel-open { overflow: hidden; }

@media (max-width: 800px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .sidebar { order: -1; }
  .grid-2 { grid-template-columns: 1fr; }
  .item { flex-direction: column; }
  .item-actions { flex-direction: row; width: 100%; }
  .item-actions .button, .item-actions form { flex: 1; }
  .panel { width: 100%; border-left: none; }
}
