@font-face {
  font-family: 'Lexend';
  src: url('/fonts/lexend-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light;
  --p: 33.25% 0.0017 106.5;          /* ink, used with alpha: oklch(var(--p) / .6) */
  --fg: oklch(23.9% 0.0019 106.5);
  --bg: oklch(100% 0 0);
  --shell: oklch(99.2% 0.0035 124);
  --surface: oklch(99.3% 0 275);
  --line: oklch(83.66% 0.0047 135 / 0.45);
  --line-strong: oklch(75.79% 0.0048 135 / 0.7);
  --live: oklch(66% 0.16 150);
  --warn: oklch(70% 0.15 70);
  --danger: oklch(60% 0.17 25);
  --mark: oklch(94% 0.07 118);
  --overlay: oklch(23.9% 0.0019 106.5 / 0.18);
  --shadow: 0 1px 2px oklch(0% 0 0 / 0.04), 0 8px 30px -12px oklch(0% 0 0 / 0.12);
  --radius: 0.425rem;
  --ease: cubic-bezier(0.215, 0.61, 0.355, 1);
  --side-w: 15rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --p: 88.9% 0.0199 172.7;
    --fg: oklch(95.43% 0.0094 171.8);
    --bg: oklch(30.66% 0.009 173.7);
    --shell: oklch(26.6% 0.0068 173.8);
    --surface: oklch(33.5% 0.0105 172);
    --line: oklch(59.6% 0.015 166.9 / 0.35);
    --line-strong: oklch(59.6% 0.015 166.9 / 0.6);
    --mark: oklch(45% 0.06 150);
    --overlay: oklch(10% 0.004 170 / 0.5);
    --shadow: 0 1px 2px oklch(0% 0 0 / 0.2), 0 12px 40px -12px oklch(0% 0 0 / 0.5);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --p: 88.9% 0.0199 172.7;
  --fg: oklch(95.43% 0.0094 171.8);
  --bg: oklch(30.66% 0.009 173.7);
  --shell: oklch(26.6% 0.0068 173.8);
  --surface: oklch(33.5% 0.0105 172);
  --line: oklch(59.6% 0.015 166.9 / 0.35);
  --line-strong: oklch(59.6% 0.015 166.9 / 0.6);
  --mark: oklch(45% 0.06 150);
  --overlay: oklch(10% 0.004 170 / 0.5);
  --shadow: 0 1px 2px oklch(0% 0 0 / 0.2), 0 12px 40px -12px oklch(0% 0 0 / 0.5);
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; border: 0 solid; }
html { -webkit-text-size-adjust: 100%; font-family: 'Lexend', ui-sans-serif, system-ui, sans-serif; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body { background: var(--shell); color: oklch(var(--p) / 0.9); font-weight: 300; min-height: 100dvh; overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; background: transparent; letter-spacing: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.5; }
img, svg { display: block; }
ul, ol { list-style: none; }
::selection { background: oklch(var(--p) / 0.15); }
:focus-visible { outline: 2px solid oklch(var(--p) / 0.4); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.muted { color: oklch(var(--p) / 0.55); }
.faint { color: oklch(var(--p) / 0.4); }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ frame */
.frame {
  position: relative;
  margin: 1rem auto;
  width: min(96vw, 96rem);
  min-height: calc(100dvh - 2rem);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-inline: 1px solid var(--line);
  padding: 1rem 0.5rem;
}
.frame::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
}

.layout {
  flex: 1;
  display: grid;
  gap: 2.5rem;
  padding: 2.5rem 1.5rem;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
}

/* ------------------------------------------------------------------ sidebar */
.side { position: sticky; top: 1.5rem; align-self: start; display: flex; flex-direction: column; gap: 2rem; max-height: calc(100dvh - 3rem); overflow-y: auto; scrollbar-width: none; }
.brand { display: flex; align-items: center; justify-content: space-between; height: 2rem; }
.brand h1 { font-size: 1.5rem; font-weight: 200; color: oklch(var(--p)); letter-spacing: -0.01em; }
.live { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; color: oklch(var(--p) / 0.5); }
.live i { width: 0.45rem; height: 0.45rem; border-radius: 999px; background: oklch(var(--p) / 0.3); }
.live[data-state='on'] i { background: var(--live); box-shadow: 0 0 0 0 var(--live); animation: pulse 2.4s var(--ease) infinite; }
.live[data-state='off'] i { background: var(--danger); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 oklch(66% 0.16 150 / 0.5); } 70%, 100% { box-shadow: 0 0 0 6px oklch(66% 0.16 150 / 0); } }
.intro { font-size: 0.875rem; line-height: 1.625; color: oklch(var(--p) / 0.6); margin-top: -1.25rem; }

.side-groups { display: flex; flex-direction: column; gap: 1.75rem; }
.nav-group { display: flex; flex-direction: column; gap: 0.125rem; }
.nav-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0.5rem 0.25rem; font-size: 0.75rem; color: oklch(var(--p) / 0.5); }
.nav-head button { color: oklch(var(--p) / 0.5); border-radius: 4px; padding: 0.125rem; transition: color 0.15s; }
.nav-head button:hover { color: oklch(var(--p)); }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  border-radius: var(--radius); padding: 0.375rem 0.5rem;
  font-size: 0.875rem; text-align: left; width: 100%;
  color: oklch(var(--p) / 0.6); transition: color 0.15s, background-color 0.15s;
}
.nav-item:hover { color: oklch(var(--p)); background: oklch(var(--p) / 0.05); }
.nav-item[aria-current='true'] { color: oklch(var(--p)); background: oklch(var(--p) / 0.1); }
.nav-item .label { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.nav-item .label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .count { font-size: 0.75rem; color: oklch(var(--p) / 0.4); font-variant-numeric: tabular-nums; }
.nav-item .count.unread { color: oklch(var(--p)); font-weight: 400; }
.nav-item .edit { opacity: 0; color: oklch(var(--p) / 0.5); transition: opacity 0.15s; display: grid; place-items: center; }
.nav-item:hover .edit, .nav-item:focus-within .edit { opacity: 1; }
.nav-item .edit:hover { color: oklch(var(--p)); }
.nav-item .tail { display: flex; align-items: center; gap: 0.375rem; }
.dot { width: 0.4rem; height: 0.4rem; border-radius: 999px; background: oklch(var(--p) / 0.25); flex-shrink: 0; }
.dot.ok { background: var(--live); }
.dot.err { background: var(--danger); }
.dot.busy { background: var(--warn); animation: blink 1s ease-in-out infinite; }
.dot.off { background: transparent; box-shadow: inset 0 0 0 1px oklch(var(--p) / 0.35); }
@keyframes blink { 50% { opacity: 0.3; } }
.empty-note { font-size: 0.8125rem; color: oklch(var(--p) / 0.5); padding: 0.25rem 0.5rem; line-height: 1.6; }

/* ------------------------------------------------------------------ main */
.main { display: flex; flex-direction: column; gap: 3rem; min-width: 0; }
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 2rem; }
.top h2 { font-size: 1.875rem; line-height: 1.2; font-weight: 200; color: oklch(var(--p)); }
.top p { margin-top: 0.375rem; font-size: 0.875rem; color: oklch(var(--p) / 0.6); max-width: 42rem; }
.toolbar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 0.6rem; color: oklch(var(--p) / 0.4); pointer-events: none; }
.search input {
  height: 2rem; width: 15rem; border-radius: 0.25rem; padding: 0 2rem 0 2rem;
  background: oklch(var(--p) / 0.05); font-size: 0.875rem; outline: none;
  transition: background-color 0.15s, box-shadow 0.15s;
}
.search input::placeholder { color: oklch(var(--p) / 0.45); }
.search input:focus { background: oklch(var(--p) / 0.08); box-shadow: inset 0 0 0 1px var(--line-strong); }
.search kbd { position: absolute; right: 0.5rem; font: inherit; font-size: 0.6875rem; color: oklch(var(--p) / 0.4); border: 1px solid var(--line); border-radius: 3px; padding: 0 0.3rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  height: 2rem; padding: 0 0.75rem; border-radius: 0.25rem;
  font-size: 0.875rem; color: oklch(var(--p) / 0.7);
  background: oklch(var(--p) / 0.05);
  transition: color 0.15s, background-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { color: oklch(var(--p)); background: oklch(var(--p) / 0.1); }
.btn.icon { width: 2rem; padding: 0; }
.btn.primary { background: oklch(var(--p)); color: var(--bg); font-weight: 400; }
.btn.primary:hover:not(:disabled) { background: oklch(var(--p) / 0.85); color: var(--bg); }
.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: oklch(var(--p) / 0.06); }
.btn.danger { color: var(--danger); }
.btn.on { color: oklch(var(--p)); background: oklch(var(--p) / 0.12); }
.seg { display: inline-flex; background: oklch(var(--p) / 0.05); border-radius: 0.25rem; padding: 2px; }
.seg button { height: calc(2rem - 4px); width: calc(2rem - 4px); display: grid; place-items: center; border-radius: 3px; color: oklch(var(--p) / 0.45); }
.seg button[aria-pressed='true'] { background: var(--bg); color: oklch(var(--p)); box-shadow: 0 1px 2px oklch(0% 0 0 / 0.08); }

.chipbar { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: -1.75rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.35rem; height: 1.625rem; padding: 0 0.6rem;
  border-radius: 999px; font-size: 0.75rem; color: oklch(var(--p) / 0.7);
  box-shadow: inset 0 0 0 1px var(--line);
}
.chip button { color: oklch(var(--p) / 0.45); display: grid; place-items: center; }
.chip button:hover { color: oklch(var(--p)); }

/* ------------------------------------------------------------------ feed */
.feed { display: flex; flex-direction: column; gap: 3.5rem; }
.day { display: flex; flex-direction: column; gap: 1.25rem; scroll-margin-top: 1.5rem; }
.day-head { display: flex; align-items: baseline; gap: 0.75rem; }
.day-head h3 { font-size: 1.25rem; font-weight: 200; color: oklch(var(--p)); }
.day-head span { font-size: 0.75rem; color: oklch(var(--p) / 0.4); font-variant-numeric: tabular-nums; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 1.75rem 2rem; }
[data-density='rows'] .cards { grid-template-columns: 1fr; gap: 0; }

.card {
  position: relative; display: flex; flex-direction: column; gap: 0.75rem;
  padding: 1rem; margin: -1rem; border-radius: var(--radius);
  cursor: pointer; text-align: left;
  transition: background-color 0.2s var(--ease);
}
.card:hover, .card.kb { background: oklch(var(--p) / 0.035); }
.card.kb { box-shadow: inset 0 0 0 1px var(--line-strong); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.who { display: flex; align-items: center; gap: 0.6rem; min-width: 0; font-size: 0.8125rem; color: oklch(var(--p) / 0.7); }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo {
  width: 1.75rem; height: 1.75rem; flex-shrink: 0; border-radius: 999px; overflow: hidden;
  box-shadow: 0 0 0 1px oklch(var(--p) / 0.15); background: oklch(var(--p) / 0.06);
  display: grid; place-items: center; font-size: 0.6875rem; font-weight: 400; color: oklch(var(--p) / 0.55);
  text-transform: uppercase;
}
.logo img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.logo.lg { width: 3rem; height: 3rem; font-size: 1rem; }
.time { font-size: 0.75rem; color: oklch(var(--p) / 0.45); font-variant-numeric: tabular-nums; white-space: nowrap; }
.title { font-size: 1.0625rem; line-height: 1.4; font-weight: 300; color: oklch(var(--p)); text-wrap: pretty; }
.title .new { display: inline-block; width: 0.4rem; height: 0.4rem; border-radius: 999px; background: var(--live); margin-right: 0.45rem; vertical-align: 0.15em; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.meta { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; font-size: 0.75rem; color: oklch(var(--p) / 0.6); }
.meta span { display: inline-flex; align-items: center; gap: 0.3rem; }
.meta svg { color: oklch(var(--p) / 0.4); }
.excerpt { font-size: 0.8125rem; line-height: 1.625; color: oklch(var(--p) / 0.65); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; gap: 0.3rem; max-height: 1.5rem; overflow: hidden; }
.tag { font-size: 0.6875rem; line-height: 1.375rem; padding: 0 0.45rem; border-radius: 3px; background: oklch(var(--p) / 0.06); color: oklch(var(--p) / 0.65); white-space: nowrap; }
.tag.alert { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: auto; }
.via { display: inline-flex; align-items: center; gap: 0.25rem; width: fit-content; font-size: 0.75rem; color: oklch(var(--p) / 0.55); text-decoration: underline; text-underline-offset: 4px; text-decoration-color: oklch(var(--p) / 0.3); transition: color 0.15s, text-decoration-color 0.15s; }
.via:hover { color: oklch(var(--p)); text-decoration-color: oklch(var(--p) / 0.6); }
.actions { display: flex; gap: 0.125rem; opacity: 0; transition: opacity 0.15s; }
.card:hover .actions, .card:focus-within .actions, .card.kb .actions { opacity: 1; }
.act { width: 1.75rem; height: 1.75rem; display: grid; place-items: center; border-radius: 4px; color: oklch(var(--p) / 0.45); transition: color 0.15s, background-color 0.15s; }
.act:hover { color: oklch(var(--p)); background: oklch(var(--p) / 0.07); }
.act[aria-pressed='true'] { color: oklch(var(--p)); }
.card.is-saved .act.save, .card.is-applied .act.apply { opacity: 1; }
@media (hover: none) { .actions { opacity: 1; } }

/* rows density */
[data-density='rows'] .card { flex-direction: row; align-items: center; gap: 1rem; margin: 0 -1rem; border-radius: 0; border-bottom: 1px solid var(--line); padding: 0.85rem 1rem; }
[data-density='rows'] .card:hover { border-radius: var(--radius); }
[data-density='rows'] .card .excerpt, [data-density='rows'] .card .tags { display: none; }
[data-density='rows'] .card-top { flex: 0 0 13rem; min-width: 0; }
[data-density='rows'] .card-top .time { display: none; }
[data-density='rows'] .card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.2rem; }
[data-density='rows'] .card-foot { flex: 0 0 auto; margin: 0; gap: 1rem; }
.meta .row-time { display: none; }
[data-density='rows'] .meta .row-time { display: inline-flex; }
.card-body { display: flex; flex-direction: column; gap: 0.5rem; }

@media (prefers-reduced-motion: no-preference) {
  .enter { animation: enter 0.4s var(--ease) both; animation-delay: calc(min(var(--i, 0), 12) * 45ms); }
  .flash { animation: enter 0.4s var(--ease) both, flash 2.4s ease-out 0.2s; }
}
@keyframes enter { from { opacity: 0; translate: 0 24px; } }
@keyframes flash { 0% { background: color-mix(in oklab, var(--live) 14%, transparent); } 100% { background: transparent; } }

.state { padding: 4rem 0; display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem; max-width: 34rem; }
.state h3 { font-size: 1.25rem; font-weight: 200; color: oklch(var(--p)); }
.state p { font-size: 0.875rem; line-height: 1.625; color: oklch(var(--p) / 0.6); }
.skeleton { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 2.5rem 2rem; }
.skeleton div { height: 9rem; border-radius: var(--radius); background: linear-gradient(90deg, oklch(var(--p) / 0.04), oklch(var(--p) / 0.08), oklch(var(--p) / 0.04)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.more { align-self: center; }

/* ------------------------------------------------------------------ footer */
.foot { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin: 2rem -0.5rem -0.5rem; padding: 1.25rem 2rem 0.5rem; border-top: 1px solid var(--line); font-size: 0.75rem; color: oklch(var(--p) / 0.5); }
.foot a { text-decoration: underline; text-underline-offset: 4px; text-decoration-color: oklch(var(--p) / 0.3); }
.foot a:hover { color: oklch(var(--p)); }
.keys { display: flex; gap: 1rem; flex-wrap: wrap; }
.keys kbd { font: inherit; border: 1px solid var(--line); border-radius: 3px; padding: 0 0.3rem; margin-right: 0.25rem; }

/* ------------------------------------------------------------------ drawer */
.scrim { position: fixed; inset: 0; z-index: 50; background: var(--overlay); backdrop-filter: blur(2px); opacity: 0; transition: opacity 0.25s var(--ease); }
.scrim.open { opacity: 1; }
.drawer {
  position: fixed; z-index: 60; top: 0.75rem; right: 0.75rem; bottom: 0.75rem;
  width: min(44rem, calc(100vw - 1.5rem));
  background: var(--bg); border: 1px solid var(--line); border-radius: calc(var(--radius) * 2);
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
  translate: calc(100% + 1rem) 0; transition: translate 0.35s var(--ease);
}
.drawer.open { translate: 0 0; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 0.75rem 0.75rem 1.5rem; border-bottom: 1px solid var(--line); }
.drawer-head .crumbs { font-size: 0.75rem; color: oklch(var(--p) / 0.5); }
.drawer-body { flex: 1; overflow-y: auto; padding: 2rem 1.5rem 3rem; display: flex; flex-direction: column; gap: 1.75rem; overscroll-behavior: contain; }
.drawer-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.75rem 1.5rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.detail-head { display: flex; flex-direction: column; gap: 1rem; }
.detail-head h2 { font-size: 1.875rem; line-height: 1.2; font-weight: 200; color: oklch(var(--p)); text-wrap: balance; }
.detail-head .who { font-size: 0.9375rem; }
.detail-meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 1rem; padding: 1rem 0; border-block: 1px solid var(--line); }
.detail-meta dt { font-size: 0.6875rem; color: oklch(var(--p) / 0.45); text-transform: uppercase; letter-spacing: 0.06em; }
.detail-meta dd { font-size: 0.875rem; color: oklch(var(--p) / 0.85); margin-top: 0.15rem; }
.desc { font-size: 0.9rem; line-height: 1.75; color: oklch(var(--p) / 0.8); white-space: pre-line; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ forms */
.form { display: flex; flex-direction: column; gap: 1.5rem; }
.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field > label, .field > .label { font-size: 0.8125rem; color: oklch(var(--p) / 0.85); font-weight: 400; }
.field .hint { font-size: 0.75rem; line-height: 1.55; color: oklch(var(--p) / 0.5); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 1rem 1.25rem; }
.input, select.input {
  height: 2.25rem; padding: 0 0.75rem; border-radius: 0.3rem; font-size: 0.875rem; width: 100%;
  background: oklch(var(--p) / 0.04); box-shadow: inset 0 0 0 1px var(--line); outline: none;
  transition: box-shadow 0.15s, background-color 0.15s;
}
.input:focus { box-shadow: inset 0 0 0 1px oklch(var(--p) / 0.5); background: oklch(var(--p) / 0.02); }
.input[aria-invalid='true'] { box-shadow: inset 0 0 0 1px var(--danger); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, oklch(var(--p) / 0.5) 50%), linear-gradient(135deg, oklch(var(--p) / 0.5) 50%, transparent 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2rem; }
.input-group { display: flex; gap: 0.5rem; }
.input-group .input { flex: 1; min-width: 0; }

.terms {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; min-height: 2.25rem; padding: 0.3rem 0.4rem;
  border-radius: 0.3rem; background: oklch(var(--p) / 0.04); box-shadow: inset 0 0 0 1px var(--line); cursor: text;
}
.terms:focus-within { box-shadow: inset 0 0 0 1px oklch(var(--p) / 0.5); }
.terms .term { display: inline-flex; align-items: center; gap: 0.25rem; height: 1.5rem; padding: 0 0.25rem 0 0.5rem; border-radius: 3px; background: oklch(var(--p) / 0.09); font-size: 0.8125rem; color: oklch(var(--p) / 0.9); }
.terms .term button { width: 1.1rem; height: 1.1rem; display: grid; place-items: center; border-radius: 2px; color: oklch(var(--p) / 0.5); }
.terms .term button:hover { color: oklch(var(--p)); background: oklch(var(--p) / 0.1); }
.terms input { flex: 1; min-width: 8rem; height: 1.5rem; outline: none; font-size: 0.875rem; padding: 0 0.25rem; }
.terms input::placeholder { color: oklch(var(--p) / 0.4); }
.terms.exclude .term { background: color-mix(in oklab, var(--danger) 12%, transparent); }

.checks { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.check { position: relative; display: inline-flex; align-items: center; height: 1.875rem; padding: 0 0.7rem; border-radius: 999px; font-size: 0.8125rem; color: oklch(var(--p) / 0.65); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; transition: all 0.15s; user-select: none; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check:hover { color: oklch(var(--p)); }
.check:has(input:checked) { background: oklch(var(--p)); color: var(--bg); box-shadow: none; }
.check:has(input:focus-visible) { outline: 2px solid oklch(var(--p) / 0.4); outline-offset: 2px; }

.switch { display: inline-flex; align-items: center; gap: 0.6rem; font-size: 0.875rem; cursor: pointer; user-select: none; color: oklch(var(--p) / 0.85); }
.switch input { appearance: none; width: 2.1rem; height: 1.2rem; border-radius: 999px; background: oklch(var(--p) / 0.15); position: relative; cursor: pointer; transition: background-color 0.2s; flex-shrink: 0; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: calc(1.2rem - 4px); height: calc(1.2rem - 4px); border-radius: 999px; background: var(--bg); box-shadow: 0 1px 2px oklch(0% 0 0 / 0.2); transition: translate 0.2s var(--ease); }
.switch input:checked { background: oklch(var(--p)); }
.switch input:checked::after { translate: 0.9rem 0; }

.preview { border-radius: var(--radius); padding: 1rem; background: oklch(var(--p) / 0.035); display: flex; flex-direction: column; gap: 0.6rem; font-size: 0.8125rem; }
.preview strong { font-weight: 400; color: oklch(var(--p)); }
.preview ul { display: flex; flex-direction: column; gap: 0.35rem; }
.preview li { display: flex; justify-content: space-between; gap: 1rem; color: oklch(var(--p) / 0.7); }
.preview li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error-text { font-size: 0.8125rem; color: var(--danger); }

/* settings page */
.settings { display: flex; flex-direction: column; gap: 3.5rem; max-width: 52rem; }
.panel { display: flex; flex-direction: column; gap: 1.5rem; }
.panel-head h3 { font-size: 1.25rem; font-weight: 200; color: oklch(var(--p)); }
.panel-head p { font-size: 0.8125rem; line-height: 1.6; color: oklch(var(--p) / 0.55); margin-top: 0.3rem; max-width: 40rem; }
.panel-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.steps { display: flex; flex-direction: column; gap: 0.5rem; counter-reset: s; font-size: 0.8125rem; color: oklch(var(--p) / 0.7); line-height: 1.6; }
.steps li { counter-increment: s; display: flex; gap: 0.75rem; }
.steps li::before { content: counter(s); flex-shrink: 0; width: 1.25rem; height: 1.25rem; border-radius: 999px; display: grid; place-items: center; font-size: 0.6875rem; box-shadow: inset 0 0 0 1px var(--line-strong); color: oklch(var(--p) / 0.6); margin-top: 0.1rem; }
.steps code, .code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.8em; background: oklch(var(--p) / 0.07); padding: 0.1rem 0.35rem; border-radius: 3px; }
.src-list { display: flex; flex-direction: column; }
.src { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.5rem 1rem; align-items: start; padding: 1.1rem 0; border-top: 1px solid var(--line); }
.src:last-child { border-bottom: 1px solid var(--line); }
.src-name { display: flex; flex-direction: column; gap: 0.2rem; }
.src-name a { font-size: 0.9375rem; color: oklch(var(--p)); width: fit-content; }
.src-name a:hover { text-decoration: underline; text-underline-offset: 4px; }
.src-status { font-size: 0.75rem; color: oklch(var(--p) / 0.5); display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.src-status .err { color: var(--danger); }
.src-opts { grid-column: 2 / -1; display: flex; flex-direction: column; gap: 0.75rem; }
.src-side { display: flex; align-items: center; gap: 0.5rem; }
.interval { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; color: oklch(var(--p) / 0.55); }
.interval input { width: 4rem; height: 2rem; text-align: right; }

/* ------------------------------------------------------------------ toast */
.toasts { position: fixed; z-index: 80; bottom: 1.25rem; left: 50%; translate: -50% 0; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 0.75rem; background: oklch(var(--p)); color: var(--bg); font-size: 0.8125rem; padding: 0.55rem 0.9rem; border-radius: 0.4rem; box-shadow: var(--shadow); max-width: min(32rem, 92vw); animation: enter 0.3s var(--ease) both; }
.toast.error { background: var(--danger); color: #fff; }
.toast button { text-decoration: underline; text-underline-offset: 3px; font-weight: 400; }
.new-pill { position: sticky; top: 1rem; z-index: 30; align-self: center; margin-bottom: -2.5rem; }
.new-pill .btn { box-shadow: var(--shadow); background: oklch(var(--p)); color: var(--bg); border-radius: 999px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1023px) {
  .layout { grid-template-columns: 1fr; padding: 1.5rem 1rem; gap: 2rem; }
  .side { position: static; max-height: none; gap: 1.25rem; }
  .intro { margin-top: -0.75rem; }
  .side-groups { flex-direction: row; gap: 0.25rem; overflow-x: auto; scrollbar-width: none; margin-inline: -1rem; padding-inline: 1rem; }
  .side-groups .nav-group { flex-direction: row; gap: 0.25rem; flex-shrink: 0; }
  .side-groups #nav-sources, .side-groups .empty-note, .side-groups .nav-head span { display: none; }
  .side-groups .nav-head { padding: 0 0.25rem; order: 2; }
  .side-groups .nav-item .edit { opacity: 1; }
  .side-groups .nav-item { width: auto; white-space: nowrap; }
  .search input { width: 100%; }
  .search { flex: 1; min-width: 12rem; }
  .toolbar { width: 100%; }
  [data-density='rows'] .card { flex-direction: column; align-items: stretch; }
  [data-density='rows'] .card-top { flex: none; }
}
@media (max-width: 640px) {
  .frame { width: 100%; margin: 0; border: 0; min-height: 100dvh; padding: 0.5rem 0; }
  .top h2 { font-size: 1.5rem; }
  .foot { padding-inline: 1rem; }
  .keys { display: none; }
  .drawer { inset: 0; width: 100%; border-radius: 0; border: 0; }
  .src { grid-template-columns: auto 1fr; }
  .src-side { grid-column: 2; }
}

/* ------------------------------------------------------------------ login */
.login-frame { align-items: center; justify-content: center; }
.login { width: min(22rem, 100%); padding: 2rem 1.5rem; display: flex; flex-direction: column; gap: 1.5rem; }
.login .intro { margin-top: -1rem; }
.login .btn { height: 2.25rem; }
