:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #666666;
  --border: #d8d8d8;
  --border-strong: #111111;
  --surface: #ffffff;
  --panel: #ffffff;
  --accent: #111111;
}

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.55;
}

a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover,
a:focus {
  text-decoration-thickness: 2px;
}

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

[hidden] {
  display: none !important;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  line-height: 1.35;
}

.sidebar-inner {
  position: sticky;
  top: 0;
  padding: 14px 12px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.brand {
  display: block;
  margin-bottom: 1rem;
  text-decoration: none;
}

.brand-logo {
  width: 100px;
  max-width: 100%;
  height: auto;
  display: block;
}

.brand-desc {
  margin: 0.75rem 0 1.25rem;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.32rem 0.25rem;
  line-height: 1.25;
  border: 1px solid transparent;
  border-radius: 2px;
  text-decoration: none;
}

.nav-link:hover,
.nav-link:focus-visible {
  border-color: var(--border-strong);
}

.nav-count {
  color: var(--muted);
  font-size: 11px;
}

.sidebar-footer {
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
}

.main {
  padding: 24px 28px;
  max-width: 1240px;
}

.page-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.entry-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.page-intro {
  margin: 0;
  color: var(--muted);
  max-width: 72ch;
}

.page-subtitle {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.card-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
  align-items: start;
}

.card {
  margin: 0;
}

.card-link {
  display: block;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 12px;
  font-size: 15px;
}

.card-link.no-image {
  min-height: 150px;
  display: flex;
  flex-direction: column;
}

.card-link.no-image .card-tags {
  margin-top: auto;
  padding-top: 0.75rem;
}

.card-link.no-image .card-source {
  margin-top: auto;
  padding-top: 0.75rem;
}

.entry-card-image {
  display: block;
  width: calc(100% + 24px);
  margin: -12px -12px 0.75rem;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-bottom: 1px solid var(--border);
  background: #f3f3f3;
}

.card-link:hover,
.card-link:focus-visible {
  border-color: var(--border-strong);
}

.card-link.is-selected {
  border-color: var(--border-strong);
  outline: 1px solid var(--border-strong);
  outline-offset: 0;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.pill {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 2px;
  font-size: 12px;
  color: var(--text);
}

.meta-date {
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.card-title {
  margin: 0 0 6px;
  font-size: 14px;
  line-height: 1.35;
}

.card-summary {
  margin: 0 0 10px;
  color: var(--text);
}

.card-tags {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.tag {
  display: inline-block;
  margin-right: 8px;
}

.tag::before {
  content: "#";
}

.card-source {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.entry-preview {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(720px, 50vw);
  background: var(--panel);
  border-left: 1px solid var(--border-strong);
  z-index: 50;
  padding: 24px;
  overflow-y: auto;
}

.entry-preview.is-open {
  display: block;
}

.preview-close {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border-strong);
  padding: 4px 8px;
  cursor: pointer;
  font: inherit;
  float: right;
}

.preview-close:hover,
.preview-close:focus-visible {
  background: var(--text);
  color: var(--bg);
}

.preview-meta {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.preview-title {
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.25;
}

.preview-image {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border: 1px solid var(--border);
  margin: 1rem 0;
  background: #f3f3f3;
}

.preview-image[hidden] {
  display: none;
}

.preview-summary {
  margin: 0 0 12px;
  color: var(--muted);
}

.preview-body {
  margin: 0 0 14px;
  font: inherit;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.preview-source {
  margin: 0 0 12px;
  font-size: 12px;
}

.preview-tags {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--muted);
}

.preview-link-row {
  margin: 0;
  font-size: 12px;
}

.back {
  margin: 0 0 14px;
}

.entry {
  max-width: 760px;
}

.entry-head {
  margin-bottom: 12px;
}

.entry-title {
  margin: 6px 0 0;
  font-size: 18px;
  line-height: 1.25;
}

.lead {
  margin: 10px 0 0;
  color: var(--muted);
}

.entry-content {
  margin: 16px 0;
  word-break: break-word;
}

.plain-content {
  white-space: pre-wrap;
  line-height: 1.55;
}

.markdown-content {
  white-space: normal;
  line-height: 1.55;
}

.markdown-content > *:first-child {
  margin-top: 0;
}

.markdown-content > *:last-child {
  margin-bottom: 0;
}

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

.markdown-content h1 {
  font-size: 1.6rem;
  line-height: 1.25;
  margin: 0 0 1.25rem;
}

.markdown-content h2 {
  font-size: 1.25rem;
  line-height: 1.3;
  margin: 2rem 0 0.75rem;
}

.markdown-content h3 {
  font-size: 1.05rem;
  line-height: 1.35;
  margin: 1.5rem 0 0.5rem;
}

.markdown-content h4 {
  font-size: 1rem;
  line-height: 1.35;
  margin: 1.25rem 0 0.5rem;
}

.markdown-content em {
  font-style: italic;
}

.markdown-content strong {
  font-weight: 700;
}

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

.markdown-content blockquote p {
  margin: 0.5rem 0;
}

.markdown-content ul,
.markdown-content ol {
  margin: 0 0 1rem 1.25rem;
  padding: 0;
}

.markdown-content li {
  margin: 0.25rem 0;
}

.markdown-content hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.markdown-content code {
  font-family: inherit;
  font-size: 0.95em;
  background: #f3f3f3;
  padding: 0.1rem 0.25rem;
  border: 1px solid var(--border);
}

.markdown-content pre {
  margin: 1rem 0;
  padding: 1rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  background: #f7f7f7;
}

.markdown-content pre code {
  border: 0;
  padding: 0;
  background: transparent;
}

.markdown-content a {
  color: inherit;
  text-decoration: underline;
}

.entry-image {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: cover;
  border: 1px solid var(--border);
  margin: 1.5rem 0;
  background: #f3f3f3;
}

.entry-source {
  margin: 18px 0 0;
  font-size: 12px;
}

.entry-tags {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.empty,
.error {
  margin: 0;
  color: var(--text);
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-inner {
    min-height: auto;
    position: static;
    padding: 12px 10px;
  }

  .main {
    padding: 18px;
  }

  .page-header {
    display: block;
  }

  .brand-logo {
    width: 72px;
  }

  .entry-preview {
    width: 100vw;
    left: 0;
    right: 0;
    padding: 18px;
  }
}
