:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #16191d;
  --text-muted: #5a6370;
  --text-faint: #8a929d;
  --text-read: #7b838e;
  --border: #e2e5ea;
  --accent: #3d5afe;
  --accent-soft: #e8ecff;
  --accent-text: #2a44d8;
  --on-accent: #ffffff;
  --saved: #d97706;
  --focus: #3d5afe;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.04), 0 1px 3px rgb(16 24 40 / 0.06);
  --header-bg: rgb(245 246 248 / 0.85);
  --backdrop: rgb(10 12 16 / 0.4);

  --src-hackernews: #ff6600;
  --src-hatena: #00a4de;
  --src-zenn: #3ea8ff;
  --src-qiita: #55c500;
  --src-devto: #3b49df;
  --src-huggingface: #e6a800;
  --src-github: #6e7781;
  --src-official: #3d5afe;
  --src-release: #1a7f37;
  --voice: #f1f4ff;
  --voice-edge: #dde3fb;

  --radius: 14px;
  --radius-sm: 8px;
  --gutter: 16px;
  --max-width: 760px;
  --font:
    -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Segoe UI",
    "Yu Gothic UI", Meiryo, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1014;
    --surface: #171a20;
    --surface-2: #20242c;
    --text: #e7e9ec;
    --text-muted: #a1a9b4;
    --text-faint: #737c88;
    --text-read: #7d8590;
    --border: #2a2f38;
    --accent: #8c9bff;
    --accent-soft: #232a4d;
    --accent-text: #aab5ff;
    --on-accent: #0e1014;
    --saved: #f5a524;
    --focus: #8c9bff;
    --shadow: none;
    --header-bg: rgb(14 16 20 / 0.85);
    --backdrop: rgb(0 0 0 / 0.6);
    --src-github: #9198a1;
    --src-official: #8c9bff;
    --src-release: #3fb950;
    --src-devto: #8c96ff;
    --voice: #1c2233;
    --voice-edge: #2b3450;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1014;
  --surface: #171a20;
  --surface-2: #20242c;
  --text: #e7e9ec;
  --text-muted: #a1a9b4;
  --text-faint: #737c88;
  --text-read: #7d8590;
  --border: #2a2f38;
  --accent: #8c9bff;
  --accent-soft: #232a4d;
  --accent-text: #aab5ff;
  --on-accent: #0e1014;
  --saved: #f5a524;
  --focus: #8c9bff;
  --shadow: none;
  --header-bg: rgb(14 16 20 / 0.85);
  --backdrop: rgb(0 0 0 / 0.6);
  --src-github: #9198a1;
  --src-official: #8c9bff;
  --src-release: #3fb950;
  --src-devto: #8c96ff;
  --voice: #1c2233;
  --voice-edge: #2b3450;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Leaves room for the sticky section list when jumping to a section */
  scroll-padding-top: 64px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Hidden on screen, still read by screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
}
.skip-link:focus {
  top: 8px;
}

.app-header {
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.section-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.section-bar:has(.section-nav:empty) {
  display: none;
}

.header-inner,
.tabs,
.section-nav,
.content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
}

.brand {
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.brand-meta {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.icon-button:hover {
  background: var(--surface-2);
  color: var(--text);
}
.theme-icon {
  display: none;
}
#theme[aria-pressed="false"] .theme-icon-light,
#theme[aria-pressed="true"] .theme-icon-dark {
  display: block;
}

.tabs {
  display: flex;
  gap: 4px;
  padding-top: 6px;
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.tab[aria-current="page"] {
  color: var(--text);
}
.tab[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
}

.tab-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.tab-count:empty {
  display: none;
}

/* Section chips (only this row scrolls horizontally) */
.section-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-top: 8px;
  padding-bottom: 8px;
}
.section-nav::-webkit-scrollbar {
  display: none;
}
.section-nav:empty {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}
.chip:hover {
  color: var(--text);
}
.chip-count {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.content {
  padding-top: 8px;
  padding-bottom: calc(48px + env(safe-area-inset-bottom));
}
.content:focus {
  outline: none;
}

.page-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 max(var(--gutter), env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom))
    max(var(--gutter), env(safe-area-inset-left));
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

.page-footer p {
  margin: 0 0 4px;
}

.page-footer a {
  color: inherit;
}

.section {
  margin-top: 24px;
}

.section-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 0 2px 10px;
}

.section-title {
  margin: 0;
  font-size: 17px;
  font-weight: 750;
}

.section-description {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-faint);
}

.stories {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stories > li + li {
  border-top: 1px solid var(--border);
}

.story {
  position: relative;
  min-width: 0;
  padding: 11px 6px 2px 14px;
}
.story-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* What people said: speech bubbles under the title, three lines until tapped */
.voices {
  display: grid;
  gap: 6px;
  margin: 8px 8px 2px 0;
  justify-items: start;
}

/* Above the story link, which covers the whole story */
.voice,
.voice-by,
.voices-more {
  position: relative;
  z-index: 1;
}

.voice {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--voice-edge);
  border-radius: 4px 14px 14px;
  background: var(--voice);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.6;
  text-align: start;
  cursor: pointer;
}

.voice-text {
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.voice.is-open .voice-text {
  display: block;
}

.voice-original {
  padding-top: 6px;
  border-top: 1px dashed var(--voice-edge);
  color: var(--text-muted);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.voice-item {
  display: grid;
  gap: 2px;
  width: 100%;
  justify-items: start;
}

.voice-by {
  margin-left: 12px;
  color: var(--text-muted);
  font-size: 12px;
  text-decoration: none;
}

.voice-by:hover {
  text-decoration: underline;
}

.voices-more {
  color: var(--accent-text);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
}

.voices-more:hover {
  text-decoration: underline;
}

.story-translation {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.9em;
  font-weight: 500;
}

.story-title {
  margin: 0;
  padding-right: 8px;
  font-size: 15.5px;
  font-weight: 620;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: normal;
  line-break: strict;
}
.story-link {
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
/* The whole row is the title's tap target (the source link and buttons sit above it) */
.story-link::after {
  content: "";
  position: absolute;
  inset: 0;
}
.story-link:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.story-link:focus-visible {
  outline: none;
}
.story-link:focus-visible::after {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

.story-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text-faint);
}
.story-domain {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.source {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}
a.source:hover {
  color: var(--text);
}
.source-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot, var(--text-faint));
  flex-shrink: 0;
}
.source-score {
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.source svg {
  width: 13px;
  height: 13px;
}

.source[data-source="hackernews"] {
  --dot: var(--src-hackernews);
}
.source[data-source="hatena"] {
  --dot: var(--src-hatena);
}
.source[data-source="zenn"] {
  --dot: var(--src-zenn);
}
.source[data-source="qiita"] {
  --dot: var(--src-qiita);
}
.source[data-source="devto"] {
  --dot: var(--src-devto);
}
.source[data-source="huggingface"] {
  --dot: var(--src-huggingface);
}
.source[data-source="github_new_repos"] {
  --dot: var(--src-github);
}
.source[data-source="official"] {
  --dot: var(--src-official);
}
.source[data-source="github_release"] {
  --dot: var(--src-release);
}

.tag {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.tag-accent {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.story-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-shrink: 0;
}

.action {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.action:hover {
  color: var(--text);
  background: var(--surface-2);
}
.action svg {
  width: 19px;
  height: 19px;
}
.action-later[aria-pressed="true"] svg {
  fill: currentColor;
}
.action-later[aria-pressed="true"] {
  color: var(--saved);
}

.more {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.more:hover {
  background: var(--surface-2);
}

.empty {
  margin: 48px 8px;
  text-align: center;
  color: var(--text-muted);
}
.empty-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
}
.empty p {
  margin: 0;
  font-size: 14px;
}

.skeleton {
  height: 68px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
}

.notice {
  margin-top: 28px;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-faint);
  overflow-wrap: anywhere;
}

.mute-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.mute-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 4px 4px 4px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.mute-item-label {
  min-width: 0;
  overflow-wrap: anywhere;
}
.mute-kind {
  margin-right: 8px;
  font-size: 12px;
  color: var(--text-faint);
}
.help {
  margin: 20px 2px 0;
  font-size: 13px;
  color: var(--text-muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.button:hover {
  background: var(--surface-2);
}
.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.button-primary:hover {
  background: var(--accent);
  filter: brightness(1.08);
}
.button-small {
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
}

.field {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.field-input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  /* At least 16px so iOS doesn't zoom in on focus */
  font: inherit;
  font-size: 16px;
}

.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 85dvh;
  margin: auto auto 0;
  padding: 0;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  color: var(--text);
}
.sheet::backdrop {
  background: var(--backdrop);
}
.sheet-body {
  padding: 20px var(--gutter) calc(16px + env(safe-area-inset-bottom));
}
.sheet-title {
  margin: 0;
  font-size: 17px;
  font-weight: 750;
}
.sheet-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.mute-options {
  display: grid;
  gap: 6px;
  margin: 16px 0 0;
  padding: 0;
  border: 0;
}
.mute-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.mute-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.mute-option input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.mute-option-text {
  min-width: 0;
  overflow-wrap: anywhere;
}
.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

@media (min-width: 640px) {
  .sheet {
    margin: auto;
    border-bottom: 1px solid var(--border);
    border-radius: 20px;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 10px 10px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  transform: translateX(-50%);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.2);
}
.toast[hidden] {
  display: none;
}
.toast-text {
  overflow-wrap: anywhere;
}
.toast-action {
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

@media (min-width: 720px) {
  :root {
    --gutter: 24px;
  }
  .brand-title {
    font-size: 22px;
  }
  .story {
    padding: 12px 8px 4px 18px;
  }
  .story-title {
    font-size: 16px;
  }
}

@media (max-width: 359px) {
  :root {
    --gutter: 12px;
  }
  .story-title {
    font-size: 15px;
  }
}

/* Read stories: after the size rules so the dimmed style wins */
.story.is-read .story-title {
  color: var(--text-read);
  font-weight: 550;
}

/* Motion only for people who haven't asked to reduce it */
@media (prefers-reduced-motion: no-preference) {
  .skeleton {
    animation: shimmer 1.4s ease-in-out infinite;
  }
}
@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}
