:root {
  --bg: #0d1117;
  --bg-surface: #161b22;
  --bg-hover: #1c2128;
  --bg-active: #1f2937;
  --border: #30363d;
  --border-accent: #58a6ff;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-dimmed: #484f58;
  --link: #58a6ff;
  --link-hover: #79c0ff;
  --flash-bg: #1f6feb22;
  --flash-border: #1f6feb;
  --flash-alert-bg: #da363422;
  --flash-alert-border: #da3634;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* Nav */

nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

nav a {
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
}

nav a:hover {
  color: var(--link);
  text-decoration: none;
}

nav .nav-hint {
  margin-left: auto;
  color: var(--text-dimmed);
  font-size: 12px;
}

nav .nav-hint kbd {
  display: inline-block;
  padding: 0 5px;
  font-family: monospace;
  font-size: 11px;
  line-height: 1.6;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
}

nav form {
  display: inline;
}

nav form button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
}

nav form button:hover {
  color: var(--text);
}

/* Flash */

.flash {
  max-width: 720px;
  margin: 1rem auto;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 14px;
}

.flash-notice {
  background: var(--flash-bg);
  border: 1px solid var(--flash-border);
  color: var(--link);
}

.flash-alert {
  background: var(--flash-alert-bg);
  border: 1px solid var(--flash-alert-border);
  color: #f85149;
}

/* Feed container */

.feed-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1.5rem 4rem;
}

.feed-container .empty {
  color: var(--text-muted);
  padding: 3rem 0;
  text-align: center;
}

/* Date groups */

.date-group {
  margin-bottom: 2rem;
}

.date-group h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dimmed);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

/* Articles */

article.feed-item {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0.75rem;
  border-left: 3px solid transparent;
  scroll-margin-top: 3.5rem;
  border-radius: 4px;
  transition: background 0.1s, border-color 0.1s, opacity 0.2s;
}

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

article.feed-item.active {
  background: var(--bg-active);
  border-left-color: var(--border-accent);
}

article.feed-item.read {
  opacity: 0.45;
}

article.feed-item.read.active {
  opacity: 0.7;
}

.feed-item-thumbnail {
  flex-shrink: 0;
  width: 80px;
  height: 56px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--bg-surface);
}

.feed-item-body {
  flex: 1;
  min-width: 0;
}

.feed-item-body h3 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.25rem;
}

.feed-item-body h3 a {
  color: var(--text);
}

.feed-item-body h3 a:hover {
  color: var(--link);
}

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

.feed-favicon {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  border-radius: 2px;
  margin-right: 0.3em;
}

.feed-item-meta .separator {
  margin: 0 0.35em;
}

.feed-item-body .feed-item-summary {
  margin-top: 0.35rem;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Pagination */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.pagination-info {
  font-size: 13px;
  color: var(--text-dimmed);
}

.pagination-link {
  font-size: 14px;
}

/* Agents page (basic) */

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

.container h1 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

/* Forms */

label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 14px;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 0.75rem;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--border-accent);
}

button, input[type="submit"] {
  padding: 0.5rem 1rem;
  background: var(--border-accent);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

button:hover, input[type="submit"]:hover {
  opacity: 0.9;
}

/* Dialog */

dialog#story-dialog {
  max-width: 640px;
  width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin: auto;
}

dialog#story-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

@starting-style {
  dialog#story-dialog[open] {
    opacity: 0;
    transform: translateY(1rem);
  }
  dialog#story-dialog[open]::backdrop {
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0);
  }
}

dialog#story-dialog[open] {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s, transform 0.2s, overlay 0.2s allow-discrete, display 0.2s allow-discrete;
}

dialog#story-dialog[open]::backdrop {
  transition: background 0.2s, backdrop-filter 0.2s, overlay 0.2s allow-discrete, display 0.2s allow-discrete;
}

.dialog-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
}

.dialog-close:hover {
  color: var(--text);
  background: transparent;
}

.story-modal-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.story-modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.story-modal-summary {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

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

.story-modal-meta .separator {
  margin: 0 0.35em;
}

.story-feed-items {
  list-style: none;
}

.story-feed-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.story-feed-item:last-child {
  border-bottom: none;
}

.story-feed-item h3 {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.25rem;
}

.story-feed-item h3 a {
  color: var(--text);
}

.story-feed-item h3 a:hover {
  color: var(--link);
}

.story-feed-item-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.story-feed-item-meta .separator {
  margin: 0 0.35em;
}

.story-feed-item-summary {
  margin-top: 0.35rem;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

@media (max-width: 600px) {
  .feed-container,
  .container {
    padding: 0.75rem 1rem 3rem;
  }

  nav {
    padding: 0.5rem 1rem;
  }

  .feed-item-thumbnail {
    width: 60px;
    height: 42px;
  }
}
