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

:root {
  --color-bg: #fff;
  --color-text: #1a1a1a;
  --color-muted: #666;
  --color-accent: #0066cc;
  --color-border: #e5e5e5;
  --font-body: Georgia, "Times New Roman", serif;
  --font-mono: "Courier New", Courier, monospace;
  --max-width: 680px;
}

body {
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
  margin: 0;
  padding: 0;
}

/* Layout */
header, main, footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */
header {
  padding-top: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 3rem;
}

nav {
  display: flex;
  gap: 1.5rem;
  align-items: baseline;
}

.site-title {
  font-size: 1.25rem;
  font-weight: bold;
  margin-right: auto;
}

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

nav a:hover {
  text-decoration: underline;
}

/* Footer */
footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  padding-bottom: 2rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 0.9rem;
}

/* Home */
.home h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.lead {
  color: var(--color-muted);
  font-size: 1.1rem;
  margin-bottom: 3rem;
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

.post-list a {
  color: var(--color-text);
  text-decoration: none;
  font-size: 1.05rem;
}

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

.post-list time {
  color: var(--color-muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

/* Post */
.post-header {
  margin-bottom: 2.5rem;
}

.post-header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.post-header time {
  color: var(--color-muted);
  font-size: 0.9rem;
}

.reading-time {
  display: block;
  color: var(--color-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* Post actions (PDF, listen) */
.post-actions {
  margin-top: 1.25rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.4em 0.85em;
  font-size: 0.875rem;
  color: var(--color-muted);
  cursor: pointer;
  font-family: var(--font-body);
  transition: color 0.15s, border-color 0.15s;
}

.pdf-btn:hover {
  color: var(--color-text);
  border-color: #bbb;
}

/* Listen player */
.listen-player {
  margin-top: 1.25rem;
}

.listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.4em 0.85em;
  font-size: 0.875rem;
  color: var(--color-muted);
  cursor: pointer;
  font-family: var(--font-body);
  transition: color 0.15s, border-color 0.15s;
}

.listen-btn:hover {
  color: var(--color-text);
  border-color: #bbb;
}

.listen-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.listen-ctrl {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-muted);
  padding: 0.25rem;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.listen-ctrl:hover {
  color: var(--color-text);
}

.listen-progress {
  flex: 1;
  position: relative;
  height: 18px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.listen-progress::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-border);
  border-radius: 2px;
}

.listen-bar {
  position: absolute;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--color-text);
  border-radius: 2px;
  transition: width 0.3s;
  pointer-events: none;
}

.listen-thumb {
  position: absolute;
  width: 11px;
  height: 11px;
  background: var(--color-text);
  border-radius: 50%;
  left: 0%;
  transform: translateX(-50%);
  transition: left 0.3s;
  pointer-events: none;
}

.listen-progress:hover .listen-thumb {
  transform: translateX(-50%) scale(1.3);
}

.listen-count {
  font-size: 0.75rem;
  color: var(--color-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  min-width: 3.5rem;
  text-align: right;
}

.listen-speed {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--color-muted);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 0.1em 0.3em;
  cursor: pointer;
  appearance: none;
}

.tags {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: flex;
  gap: 0.5rem;
}

.tags li a {
  background: var(--color-border);
  color: var(--color-muted);
  padding: 0.2em 0.6em;
  border-radius: 3px;
  font-size: 0.8rem;
  text-decoration: none;
  font-family: var(--font-mono);
}

.tags li a:hover {
  background: var(--color-accent);
  color: #fff;
}

/* Post content */
.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
}

.post-content h2 {
  margin-top: 2rem;
  font-size: 1.4rem;
}

.post-content a {
  color: var(--color-accent);
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: #f4f4f4;
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

.post-content pre {
  background: #1a1a1a;
  color: #f0f0f0;
  padding: 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.6;
}

.post-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.post-content blockquote {
  border-left: 3px solid var(--color-border);
  margin-left: 0;
  padding-left: 1.25rem;
  color: var(--color-muted);
}

/* Language switch */
.lang-switch {
  font-size: 0.875rem;
  color: var(--color-muted);
  text-decoration: none;
}

.lang-switch:hover {
  color: var(--color-text);
  text-decoration: underline;
}

/* Print / PDF */
@page {
  margin: 1.5cm;
}

@media print {
  body > header, footer, .post-actions, .listen-player, .tags {
    display: none !important;
  }

  body {
    font-size: 11pt;
    line-height: 1.6;
    color: #000;
    background: #fff;
  }

  main {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  .post-header {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #ccc;
    padding-bottom: 0.75rem;
  }

  .post-header h1 {
    font-size: 20pt;
    margin-bottom: 0.25rem;
  }

  .post-header time,
  .reading-time {
    display: inline;
    font-size: 9pt;
    color: #555;
  }

  .post-content img {
    max-width: 100%;
    page-break-inside: avoid;
  }

  .post-content pre {
    background: #f4f4f4;
    color: #000;
    border: 1px solid #ddd;
    page-break-inside: avoid;
    font-size: 8pt;
  }

  .post-content h2 {
    page-break-after: avoid;
  }

  .post-content p {
    orphans: 3;
    widows: 3;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  a[href]::after {
    content: none;
  }
}
