:root {
  color-scheme: light;
  --bg: #f5f3ef;
  --bg-alt: #ece7de;
  --glass: rgba(255, 255, 255, 0.9);
  --glass-strong: #ffffff;
  --stroke: rgba(15, 17, 21, 0.12);
  --text: #0f1115;
  --muted: #5f6570;
  --accent: #f2c200;
  --accent-2: #1e4b8f;
  --danger: #c13f3f;
  --shadow: 0 18px 36px rgba(12, 15, 20, 0.08);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --mono: "IBM Plex Sans", "Segoe UI", sans-serif;
  --serif: "Merriweather", "Iowan Old Style", "Palatino", serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: var(--serif);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(245, 243, 239, 0.9)),
    repeating-linear-gradient(
      90deg,
      rgba(15, 17, 21, 0.03) 0 1px,
      transparent 1px 140px
    ),
    linear-gradient(120deg, var(--bg), var(--bg-alt));
  color: var(--text);
  position: relative;
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.12;
  z-index: 0;
}

.orb-1 {
  background: #f2d38a;
  top: -140px;
  left: -140px;
}

.orb-2 {
  background: #b9d0f2;
  bottom: -160px;
  right: -140px;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(120%);
}

.topbar {
  position: relative;
  z-index: 10;
  margin: 24px auto 18px;
  width: min(1280px, 94vw);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 18px;
  gap: 16px;
  border-top: 3px solid var(--accent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-wrap {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: #fffaf0;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 24px rgba(12, 15, 20, 0.1);
}

.logo-img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
}

.tagline {
  font-size: 13px;
  color: var(--muted);
}

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-link,
.nav-btn {
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 999px;
  transition: color 0.2s ease, background 0.2s ease;
  background: transparent;
  border: none;
  cursor: pointer;
}

.nav-link:hover,
.nav-btn:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

.topbar-meta {
  display: flex;
  align-items: center;
}

.status-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: #fff8d6;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.layout {
  width: min(1280px, 94vw);
  margin: 0 auto 90px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1.8fr) minmax(280px, 0.9fr);
  gap: 22px;
  position: relative;
  z-index: 1;
}

.panel {
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--glass-strong);
}

.library {
  position: sticky;
  top: 16px;
  align-self: start;
  max-height: calc(100vh - 120px);
}

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.article-card {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(15, 17, 21, 0.1);
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: transform 0.2s ease, border 0.2s ease, box-shadow 0.2s ease;
}

.article-card:hover {
  transform: translateY(-2px);
  border-color: rgba(15, 17, 21, 0.2);
  box-shadow: 0 10px 20px rgba(12, 15, 20, 0.08);
}

.article-card h3 {
  font-size: 16px;
  line-height: 1.4;
  margin-bottom: 6px;
}

.article-card .meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.tag-row {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(242, 194, 0, 0.12);
  color: #7a5a00;
  border: 1px solid rgba(242, 194, 0, 0.3);
}

.empty-state {
  padding: 16px;
  border-radius: 14px;
  border: 1px dashed rgba(15, 17, 21, 0.2);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-title {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
}

.panel-subtitle {
  font-size: 13px;
  color: var(--muted);
}

.glass-input {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 13px;
}

.glass-btn {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: #ffffff;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.glass-btn:hover {
  transform: translateY(-1px);
  background: #fffdf5;
}

.glass-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.ghost-btn {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.8);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}

.ghost-btn.active {
  border-color: rgba(242, 194, 0, 0.6);
  background: rgba(242, 194, 0, 0.12);
  color: var(--text);
}

.reader-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.breadcrumbs {
  text-transform: lowercase;
}

.vote-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid var(--stroke);
}

.vote-pill .vote-count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.vote-btn {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.article-header h1 {
  font-size: 34px;
  line-height: 1.2;
  margin-top: 6px;
}

.article-kicker {
  font-family: var(--mono);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--accent);
}

.article-meta {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
}

.article-header {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(15, 17, 21, 0.12);
}

.article-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  font-size: 17px;
  line-height: 1.7;
}

.article-body h2 {
  font-family: var(--mono);
  font-size: 20px;
  margin-top: 8px;
}

.article-body figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.article-body img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: #fff;
}

.article-body figcaption {
  font-size: 12px;
  color: var(--muted);
}

.article-body a {
  color: var(--accent-2);
  text-decoration: none;
}

.article-body a:hover {
  text-decoration: underline;
}

.article-body ul {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.article-body li {
  margin-left: 6px;
}

.equation {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--stroke);
  font-family: var(--mono);
  font-size: 15px;
}

.discussion {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(28, 36, 48, 0.12);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.discussion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-status {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.composer-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.composer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.warning {
  color: var(--danger);
}

.spark {
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(28, 36, 48, 0.1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.spark-title {
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.spark-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.spark-meta {
  font-size: 12px;
  color: var(--muted);
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, border 0.2s ease;
}

.chip:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.chip.active {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.comment {
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(28, 36, 48, 0.1);
}

.comment.ai {
  border-color: rgba(43, 108, 176, 0.3);
}

.comment-header {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.comment-body {
  white-space: pre-wrap;
  font-size: 15px;
}

.comment-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 12px;
}

.comment-actions button {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.comment-actions button:hover {
  color: var(--text);
}

.comment-children {
  margin-top: 12px;
  padding-left: 16px;
  border-left: 1px solid rgba(28, 36, 48, 0.12);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.analysis {
  align-self: start;
  position: sticky;
  top: 16px;
}

.focus {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(28, 36, 48, 0.1);
  background: rgba(255, 255, 255, 0.96);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.focus-title {
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.focus-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ops-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ops-item {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(28, 36, 48, 0.12);
  background: rgba(255, 255, 255, 0.98);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ops-item header {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.ops-item p {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.5;
}

.ops-item strong {
  color: var(--accent);
  font-weight: 600;
}

.ops-actions {
  display: flex;
  gap: 10px;
}

.cookie {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, 92vw);
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 30;
}

.cookie.show {
  display: flex;
}

.cookie-title {
  font-family: var(--mono);
  font-size: 13px;
}

.cookie-text {
  font-size: 13px;
  color: var(--muted);
}

.cookie-actions {
  display: flex;
  gap: 10px;
}

.not-found {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 25, 35, 0.12);
  z-index: 25;
}

.not-found.show {
  display: flex;
}

.not-found-card {
  padding: 28px;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.language-modal {
  position: fixed;
  inset: 0;
  background: rgba(12, 15, 20, 0.25);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 24px;
}

.language-modal.show {
  display: flex;
}

.language-card {
  width: min(820px, 94vw);
  padding: 22px;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.language-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.language-search {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.language-note {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.language-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  max-height: min(48vh, 420px);
  overflow-y: auto;
  padding-right: 6px;
}

.language-option {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15, 17, 21, 0.12);
  background: rgba(255, 255, 255, 0.96);
  font-family: var(--mono);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: border 0.2s ease, transform 0.2s ease;
}

.language-option:hover {
  border-color: rgba(15, 17, 21, 0.3);
  transform: translateY(-1px);
}

.language-option.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(242, 194, 0, 0.4);
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 240px minmax(0, 1.7fr) minmax(260px, 0.8fr);
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .library,
  .analysis {
    position: static;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    border-radius: var(--radius-lg);
    padding: 16px;
  }

  .nav {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }

  .reader-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel {
    padding: 16px;
  }

  .article-header h1 {
    font-size: 28px;
  }

  .composer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .cookie {
    flex-direction: column;
    align-items: flex-start;
  }

  .language-card {
    padding: 18px;
  }

  .language-grid {
    grid-template-columns: 1fr;
  }
}
