:root {
  color-scheme: light;
  --app-bg: #f4f5f2;
  --surface: #ffffff;
  --surface-muted: #edf1ef;
  --text: #1d2422;
  --muted: #68736f;
  --line: #d9dedb;
  --accent: #d73328;
  --accent-2: #0c7f83;
  --focus: #175fd1;
  --reader-bg: #fbfcf9;
  --reader-text: #1c211f;
  --reader-muted: #6c746f;
  --reader-width: 760px;
  --reader-size: 19px;
  --shadow: 0 18px 50px rgba(28, 35, 31, 0.08);
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent-2);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 180ms ease;
}

body.sidebar-collapsed .app-shell {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 90%, var(--surface-muted));
}

body.sidebar-collapsed .sidebar {
  border-right: 0;
  visibility: hidden;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 24px 18px;
}

.brand h1 {
  margin: 2px 0 0;
  font-size: 26px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.icon-button,
.segment {
  display: inline-grid;
  place-items: center;
  min-width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.icon-button:hover,
.segment:hover {
  border-color: color-mix(in srgb, var(--accent-2) 55%, var(--line));
  transform: translateY(-1px);
}

.icon-button:focus-visible,
.segment:focus-visible,
input:focus-visible,
select:focus-visible,
.article-item:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 2px;
}

.feed-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 124px;
  gap: 10px;
  padding: 0 24px 14px;
}

.search-field input,
.feed-tools select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.search-field input {
  padding: 0 14px;
}

.feed-tools select {
  padding: 0 10px;
}

.status-line {
  min-height: 28px;
  padding: 0 24px 10px;
  color: var(--muted);
  font-size: 13px;
}

.article-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding: 0 14px 20px;
}

.article-item {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  min-height: 92px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.article-item:hover {
  background: var(--surface);
  border-color: var(--line);
}

.article-item.is-active {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow);
}

.article-thumb {
  width: 70px;
  height: 70px;
  border-radius: 8px;
  background: linear-gradient(135deg, #d73328, #0c7f83);
  background-position: center;
  background-size: cover;
}

.article-copy {
  display: grid;
  align-content: center;
  gap: 8px;
  min-width: 0;
}

.article-title {
  display: -webkit-box;
  overflow: hidden;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.article-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  background: var(--reader-bg);
}

.reader-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  background: color-mix(in srgb, var(--reader-bg) 88%, transparent);
  backdrop-filter: blur(12px);
}

.sidebar-toggle {
  margin-right: auto;
}

.segmented,
.tool-cluster {
  display: inline-flex;
  gap: 4px;
}

.segment {
  min-width: 44px;
  font-size: 14px;
}

.segment.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.reader {
  width: min(100% - 42px, var(--reader-width));
  margin: 0 auto;
  padding: 54px 0 86px;
  color: var(--reader-text);
  font-family: Georgia, "Noto Serif TC", "PMingLiU", serif;
  font-size: var(--reader-size);
  line-height: 1.9;
}

.reader-header {
  margin-bottom: 28px;
}

.reader-header h2 {
  margin: 8px 0 14px;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.18;
}

.reader-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--reader-muted);
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 14px;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.reader-action {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--text);
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.reader-action:hover {
  border-color: var(--accent-2);
}

.content {
  overflow-wrap: anywhere;
}

.content h2,
.content h3 {
  margin: 2em 0 0.65em;
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  line-height: 1.35;
}

.content p,
.content ul,
.content ol,
.content blockquote,
.content figure,
.content pre {
  margin: 1.1em 0;
}

.content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.3em auto;
  border-radius: 8px;
}

.content figcaption {
  color: var(--reader-muted);
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 13px;
  text-align: center;
}

.content blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 18px;
  color: color-mix(in srgb, var(--reader-text) 78%, var(--reader-muted));
}

.content pre,
.content code {
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-muted) 80%, var(--reader-bg));
  font-family: "Cascadia Code", Consolas, monospace;
}

.content pre {
  overflow: auto;
  padding: 14px;
}

.content code {
  padding: 0.15em 0.35em;
  font-size: 0.9em;
}

.empty-state {
  display: grid;
  min-height: 50vh;
  align-content: center;
  justify-items: center;
  color: var(--reader-muted);
  text-align: center;
}

.empty-state h2 {
  margin: 6px 0 0;
  color: var(--reader-text);
  font-family: Inter, "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 28px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

body[data-theme="warm"] {
  color-scheme: light;
  --app-bg: #f2eee7;
  --surface: #fffaf2;
  --surface-muted: #ebe4d8;
  --text: #2c261f;
  --muted: #71695d;
  --line: #ddd2c1;
  --accent: #bd3b2f;
  --accent-2: #167c62;
  --reader-bg: #fff8ed;
  --reader-text: #2b241c;
  --reader-muted: #776b5d;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --app-bg: #141716;
  --surface: #1f2523;
  --surface-muted: #29302d;
  --text: #e8ece9;
  --muted: #a9b3ad;
  --line: #343d39;
  --accent: #ff6b5e;
  --accent-2: #69d0b4;
  --focus: #8bb4ff;
  --reader-bg: #111412;
  --reader-text: #edf2ee;
  --reader-muted: #aab5ae;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  body.sidebar-collapsed .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  body.sidebar-collapsed .sidebar {
    display: none;
  }

  .article-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(270px, 78vw);
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 16px;
  }

  .reader-toolbar {
    justify-content: space-between;
    overflow-x: auto;
  }

  .reader {
    width: min(100% - 28px, var(--reader-width));
    padding-top: 34px;
  }
}

@media (max-width: 520px) {
  .brand {
    padding: 22px 16px 16px;
  }

  .feed-tools {
    grid-template-columns: 1fr;
    padding-inline: 16px;
  }

  .status-line {
    padding-inline: 16px;
  }

  .reader-header h2 {
    font-size: 30px;
  }

  .reader-toolbar {
    padding-inline: 12px;
  }
}
