:root {
  --bg: #ffffff;
  --bg-rail: #f6f6f6;
  --bg-hover: #f6f6f6;
  --bg-active: #e7e7e7;
  --text: #3e3e3e;
  --text-strong: #1a1a1a;
  --text-subtle: #787878;
  --text-tertiary: #a0a0a0;
  --border: rgba(0, 0, 0, 0.07);
  --border-strong: #e7e7e7;
  --accent: #0074bf;
  --accent-hover: #005f99;
  --danger: #c0392b;
  --font-ui:
    'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-reading: 'Literata', 'LyonText', Georgia, 'Times New Roman', serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

button {
  font-family: var(--font-ui);
  cursor: pointer;
}

input {
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* Login / register */

.auth {
  max-width: 340px;
  margin: 12vh auto 4rem;
  display: grid;
  gap: 0.875rem;
}

.auth h1 {
  margin: 0 0 0.5rem;
  font-family: var(--font-reading);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}

.auth form {
  display: grid;
  gap: 0.75rem;
}

.auth label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

.auth button {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--bg-rail);
  color: var(--text);
  font-size: 0.9375rem;
}

.auth button[type='submit'] {
  background: var(--text-strong);
  border-color: var(--text-strong);
  color: #fff;
  font-weight: 600;
}

.auth button[type='submit']:hover {
  background: #000;
}

.auth button[type='button'] {
  border: none;
  background: none;
  color: var(--text-subtle);
  font-size: 0.8125rem;
}

.auth button[type='button']:hover {
  color: var(--accent);
}

/* App shell */

main.layout {
  max-width: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  grid-template-rows: 52px minmax(0, 1fr);
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border-strong);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  margin: 0;
  font-family: var(--font-reading);
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}

.account {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

.account button {
  border: none;
  background: none;
  padding: 0;
  color: var(--text-subtle);
  font-size: 0.8125rem;
}

.account button:hover {
  color: var(--accent);
}

/* Left rail */

.rail {
  background: var(--bg-rail);
  border-right: 1px solid var(--border-strong);
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

.rail h2 {
  margin: 0 0.5rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.feed-nav {
  display: grid;
  gap: 1px;
  margin-top: 1.25rem;
}

.feed-nav button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.5rem;
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text);
  font-size: 0.875rem;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.feed-nav button:hover {
  background: var(--bg-active);
}

.feed-nav button.active {
  background: var(--bg-active);
  font-weight: 600;
  color: var(--text-strong);
}

.unread-count {
  margin-left: auto;
  min-width: 1.4rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  text-align: center;
}

/* Subscription manager */

.subs {
  display: grid;
  gap: 0.5rem;
}

.subs form {
  display: flex;
  gap: 0.35rem;
}

.subs input {
  flex: 1;
  min-width: 0;
  font-size: 0.8125rem;
  padding: 0.4rem 0.5rem;
}

.subs form button {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font-size: 0.8125rem;
}

.subs form button:hover {
  background: var(--bg-active);
}

.subs ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
}

.subs li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.35rem;
  border-radius: 4px;
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

.subs li:hover {
  background: var(--bg-active);
}

.subs li span {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.subs li button {
  border: none;
  background: none;
  padding: 0;
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

.subs li button:hover {
  color: var(--danger);
}

/* Article stream */

.stream {
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}

.reader {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  height: 100%;
}

.reader.has-preview {
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
}

.list-pane {
  height: 100%;
  overflow-y: auto;
}

.reader.has-preview .list-pane {
  background: var(--bg-rail);
  border-right: 1px solid var(--border-strong);
}

.preview-pane {
  height: 100%;
  overflow-y: auto;
  background: var(--bg);
}

.items {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem;
}

.reader.has-preview .items {
  max-width: none;
  margin: 0;
  padding: 0;
}

.item {
  padding: 1.125rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: none;
  border-radius: 0;
  cursor: pointer;
}

.item.selected {
  background: var(--bg-hover);
  box-shadow: inset 3px 0 0 var(--accent);
}

.reader.has-preview .item {
  padding: 0.9rem 0.85rem;
  border-bottom: 1px solid var(--border-strong);
  background: none;
}

.reader.has-preview .item:hover {
  background: var(--bg-active);
}

.reader.has-preview .item.selected {
  background: var(--bg-active);
}

.reader.has-preview .item h3 {
  font-size: 1.0625rem;
}

.reader.has-preview .content {
  display: none;
}

.item:hover {
  background: var(--bg-hover);
}

.item h3 {
  margin: 0;
  font-family: var(--font-reading);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
}

.item h3 a {
  color: var(--text-strong);
  text-decoration: none;
}

.item h3 a:hover {
  color: var(--accent);
}

.item.read h3 a {
  color: var(--text-subtle);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.meta .source {
  color: var(--text-subtle);
  font-weight: 500;
}

.meta .dot::before {
  content: '·';
}

.content {
  margin-top: 0.5rem;
  max-height: 6.5rem;
  overflow: hidden;
  font-family: var(--font-reading);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text-subtle);
}

.content img,
.content video,
.content iframe {
  display: none;
}

.actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.item .toggle {
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: #fff;
  color: var(--text-subtle);
  font-size: 0.75rem;
}

.item .toggle:hover {
  background: var(--bg-active);
  color: var(--text);
}

/* Item preview */

.preview {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 2rem 3rem;
}

.preview-bar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.preview-source {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-subtle);
}

.preview-close {
  padding: 0.1rem 0.3rem;
  border: none;
  background: none;
  color: var(--text-subtle);
  font-size: 1.5rem;
  line-height: 1;
}

.preview-close:hover {
  color: var(--text-strong);
}

.preview-header h1 {
  margin: 1rem 0 0.25rem;
  font-family: var(--font-reading);
  font-size: 1.75rem;
  line-height: 1.25;
  color: var(--text-strong);
}

.preview-content {
  font-family: var(--font-reading);
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--text);
}

.preview-content p {
  margin: 0 0 1rem;
}

.preview-content img,
.preview-content video,
.preview-content iframe {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.preview-content blockquote {
  margin: 1rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--border-strong);
  color: var(--text-subtle);
}

.preview-content pre {
  overflow-x: auto;
  padding: 0.75rem;
  background: var(--bg-rail);
  border-radius: 4px;
}

.preview-empty {
  font-family: var(--font-reading);
  color: var(--text-subtle);
}

.preview-footer {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}

.preview-footer a {
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.preview-footer a:hover {
  text-decoration: underline;
}

.sentinel {
  padding: 1.5rem 0 3rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.center {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-subtle);
}

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

@media (max-width: 980px) {
  .reader.has-preview {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(140px, 38%) minmax(0, 1fr);
  }

  .reader.has-preview .list-pane {
    border-right: none;
    border-bottom: 1px solid var(--border-strong);
  }

  .preview {
    padding: 0 1.25rem 2rem;
  }
}

@media (max-width: 760px) {
  main.layout {
    grid-template-columns: 1fr;
    grid-template-rows: 52px auto minmax(0, 1fr);
  }

  .rail {
    border-right: none;
    border-bottom: 1px solid var(--border-strong);
    max-height: 40vh;
  }

  .items {
    padding: 0 0.5rem;
  }

  .preview {
    padding: 0 1.25rem 1.25rem;
  }
}
