:root {
  color-scheme: light dark;
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --border: #d1d9e0;
  --border-soft: #e6eaef;
  --text: #1f2328;
  --muted: #59636e;
  --faint: #818b98;
  --accent: #0969da;
  --accent-soft: #ddf4ff;
  --green: #1a7f37;
  --red: #cf222e;
  --gold: #9a6700;
  --cat-ai: #8250df;
  --cat-ios: #bc4c00;
  --cat-web: #0969da;
  --cat-tool: #59636e;
  --shadow: 0 1px 0 rgba(31, 35, 40, 0.04);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #151b23;
    --surface-2: #0d1117;
    --border: #3d444d;
    --border-soft: #262c36;
    --text: #f0f6fc;
    --muted: #9198a1;
    --faint: #6e7681;
    --accent: #4493f8;
    --accent-soft: rgba(56, 139, 253, 0.12);
    --green: #3fb950;
    --red: #f85149;
    --gold: #d29922;
    --cat-ai: #ab7df8;
    --cat-ios: #f0883e;
    --cat-web: #4493f8;
    --cat-tool: #9198a1;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

button { font: inherit; color: inherit; }
kbd {
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--muted);
  background: var(--surface);
}

/* Header */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
  padding-top: env(safe-area-inset-top);
}
.top-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 16px;
  align-items: center;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.brand img { border-radius: 6px; }

.tabs { display: flex; gap: 4px; justify-self: end; }
.tabs button {
  border: 0;
  background: transparent;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 150ms ease, color 150ms ease, transform 120ms var(--ease-out);
}
.tabs button:hover { background: var(--border-soft); color: var(--text); }
.tabs button:active { transform: scale(0.97); }
.tabs button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.count {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  margin-left: 2px;
  border-radius: 999px;
  background: var(--border-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.count:empty { display: none; }
[data-view="unread"] .count:not(:empty) { background: var(--accent); color: #fff; }

.tools {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  align-items: center;
}
.search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { width: 14px; height: 14px; fill: var(--faint); flex: none; }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  color: var(--text);
}
.search input::-webkit-search-cancel-button { display: none; }
.search:focus-within kbd { display: none; }

.btn {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow);
  transition: background-color 150ms ease, transform 120ms var(--ease-out);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
}
.link:hover { text-decoration: underline; }

/* Feed */
.feed {
  max-width: 820px;
  margin: 0 auto;
  padding: 8px 16px 24px;
}
.day { margin-top: 18px; }
.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 8px;
}
.day-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.day-head h2 span { color: var(--faint); font-weight: 400; margin-left: 6px; }
.day-head .link { font-size: 13px; }

.cards {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  padding: 14px 12px 14px 22px;
  outline: none;
  transition: background-color 150ms ease;
}
.card + .card { border-top: 1px solid var(--border-soft); }
.card:hover { background: var(--surface-2); }
.card.is-focused { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }

.dot {
  position: absolute;
  left: 9px;
  top: 30px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.card.is-read .dot { opacity: 0; transform: scale(0.5); }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--border-soft);
  box-shadow: inset 0 0 0 1px var(--border-soft);
}

.body { min-width: 0; }
.head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.name {
  color: var(--accent);
  text-decoration: none;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.name:hover { text-decoration: underline; }
.name .owner { font-weight: 400; }
.name .repo { font-weight: 600; }
.card.is-read .name { color: var(--muted); }

.chip {
  --c: var(--cat-tool);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  padding: 0 7px;
  border-radius: 999px;
  color: var(--c);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 40%, transparent);
  white-space: nowrap;
}
.chip[data-cat="ai"] { --c: var(--cat-ai); }
.chip[data-cat="ios"] { --c: var(--cat-ios); }
.chip[data-cat="web"] { --c: var(--cat-web); }

.desc {
  margin: 4px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.desc:empty { display: none; }
.reason {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--text);
  overflow-wrap: anywhere;
}
.reason:empty { display: none; }
.card.is-read .reason { background: var(--border-soft); color: var(--muted); }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.meta .lang { display: inline-flex; align-items: center; gap: 5px; }
.meta .lang i { width: 10px; height: 10px; border-radius: 50%; background: var(--lc, var(--faint)); }
.meta .up { color: var(--green); }

.actions {
  display: grid;
  grid-template-columns: repeat(2, 32px);
  align-content: start;
  gap: 2px;
}
.act {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, transform 120ms var(--ease-out);
}
.act svg { width: 16px; height: 16px; fill: currentColor; }
.act:hover { background: var(--border-soft); color: var(--text); }
.act:active { transform: scale(0.9); }
.act:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.act[data-act="read"] .tick { opacity: 0; }
.act[data-act="read"][aria-pressed="true"] { color: var(--green); }
.act[data-act="read"][aria-pressed="true"] .tick { opacity: 1; }
.act[data-act="saved"] .fill { opacity: 0; }
.act[data-act="saved"][aria-pressed="true"] { color: var(--gold); }
.act[data-act="saved"][aria-pressed="true"] .fill { opacity: 1; }
.act[data-act="saved"][aria-pressed="true"] .outline { opacity: 0; }
.act[data-act="up"][aria-pressed="true"] { color: var(--green); }
.act[data-act="down"][aria-pressed="true"] { color: var(--red); }

/* Empty, loading, banner */
.empty {
  margin-top: 56px;
  text-align: center;
  color: var(--muted);
}
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.banner {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--red) 40%, transparent);
  background: color-mix(in srgb, var(--red) 8%, transparent);
  color: var(--text);
}
.skeleton {
  height: 118px;
  background: linear-gradient(90deg, var(--border-soft), var(--surface-2), var(--border-soft));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.skeleton + .skeleton { border-top: 1px solid var(--border-soft); }
@keyframes shimmer { to { background-position: -200% 0; } }

.foot {
  max-width: 820px;
  margin: 0 auto;
  padding: 8px 16px calc(32px + env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  color: var(--faint);
  font-size: 12px;
}
.foot .link { color: var(--faint); font-size: 12px; }
.foot .sep { opacity: 0.6; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  translate: -50% 0;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-weight: 500;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(8px); }
}
.toast .link { color: var(--bg); text-decoration: underline; font-weight: 600; }
.toast[hidden] { display: none; }

.help {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 20px 22px;
  width: min(380px, calc(100vw - 32px));
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}
.help::backdrop { background: rgba(0, 0, 0, 0.35); }
.help h2 { margin: 0 0 12px; font-size: 15px; }
.help dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0 0 16px; }
.help dt { white-space: nowrap; }
.help dd { margin: 0; color: var(--muted); }
.help form { text-align: right; }

/* Login */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login form {
  width: min(320px, 100%);
  display: grid;
  gap: 14px;
  text-align: center;
}
.login img { margin: 0 auto; border-radius: 12px; }
.login h1 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.login p { margin: 0; color: var(--muted); }
.login input {
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: 600 20px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.4em;
  text-align: center;
  outline: 0;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.login input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login .btn { height: 42px; background: var(--accent); border-color: transparent; color: #fff; }
.login .btn:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.login .err { color: var(--red); min-height: 21px; }
.shake { animation: shake 320ms var(--ease-out); }
@keyframes shake {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

@media (max-width: 640px) {
  .top-inner { grid-template-columns: 1fr; padding: 10px 12px; }
  .tabs { justify-self: stretch; }
  .tabs button { flex: 1; padding: 6px 4px; }
  .feed { padding: 4px 8px 24px; }
  .card { grid-template-columns: 32px 1fr; gap: 10px; padding: 14px 12px 10px 20px; }
  .avatar { width: 32px; height: 32px; }
  .dot { top: 26px; left: 8px; }
  .actions { grid-column: 2; grid-template-columns: repeat(4, 40px); margin-left: -8px; gap: 6px; }
  .act { width: 40px; height: 36px; }
  .search kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation: none !important; }
}
