:root {
  color-scheme: light;
  --bg: #f5f6f1;
  --panel: #fffefa;
  --paper: #ffffff;
  --text: #252a2e;
  --muted: #6f7872;
  --line: #ddd8cd;
  --line-soft: #ebe7dc;
  --accent: #2f6b5b;
  --accent-dark: #234c43;
  --accent-soft: #e8f0ea;
  --warm: #9c5d38;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}

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

.masthead {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  padding: 34px clamp(20px, 5vw, 64px) 28px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  max-width: 720px;
  padding-right: 96px;
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--warm);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.masthead h1 {
  margin: 0;
  color: #202426;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 56px);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: 0;
}

.home-link {
  color: inherit;
  text-decoration: none;
}

.masthead-actions {
  position: absolute;
  top: 28px;
  right: clamp(20px, 5vw, 64px);
}

.masthead p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.repo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  min-height: 32px;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px;
  color: var(--muted);
  background: transparent;
}

.repo-link svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.repo-link:hover,
.repo-link:focus-visible {
  border-color: var(--line);
  color: var(--accent-dark);
  background: var(--paper);
  outline: 0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  justify-content: center;
  gap: clamp(18px, 2.4vw, 34px);
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 30px clamp(14px, 2.4vw, 34px) 64px;
}

.sidebar {
  position: sticky;
  top: 24px;
  height: fit-content;
  padding-top: 4px;
}

.sidebar-title {
  margin-bottom: 14px;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
}

.sidebar label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

#dateSelect {
  display: none;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--text);
}

.date-list {
  display: grid;
  gap: 6px;
}

.date-button {
  width: 100%;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.date-button:hover,
.date-button.active {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 650;
}

.reader {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(49, 43, 31, 0.08);
}

.reader-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fffefa, #fbfaf5);
  border-radius: 10px 10px 0 0;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.current-date {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 700;
}

.status-text {
  color: var(--muted);
  font-size: 14px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.search-field input {
  width: min(280px, 30vw);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  line-height: 1.3;
}

.search-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: 0;
}

.favorite-toggle,
.favorite-button {
  cursor: pointer;
  font: inherit;
  line-height: 1.2;
}

.favorite-toggle {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--accent-dark);
}

.favorite-toggle {
  padding: 7px 12px;
  font-size: 13px;
}

.favorite-toggle:hover,
.favorite-toggle.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.favorite-toggle.active {
  font-weight: 700;
}

.favorite-button:hover {
  opacity: 0.6;
  color: var(--accent-dark);
}

.favorite-button[aria-pressed="true"] {
  color: var(--accent-dark);
}

.favorite-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 18px;
  min-height: 18px;
  margin-right: 5px;
  padding: 0;
  vertical-align: 0.1em;
  opacity: 0.22;
  white-space: nowrap;
  border: none;
  background: none;
  transition: opacity 0.15s, color 0.15s;
}

.paper-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 6px;
}

.paper-heading .favorite-button {
  order: 2;
  margin-left: 2px;
  margin-right: 0;
  transform: translateY(-1px);
}

.favorite-list-item .favorite-button {
  margin-left: -2px;
}

.markdown td .favorite-button {
  margin-bottom: 4px;
}

.favorite-button[aria-pressed="true"] {
  opacity: 1;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f6f4ed;
}

.tab {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  padding: 7px 12px;
  cursor: pointer;
  font-size: 14px;
}

.tab.active {
  background: var(--accent-dark);
  color: #ffffff;
}

.markdown {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px clamp(24px, 3vw, 46px) 48px;
}

.markdown h1,
.markdown h2,
.markdown h3 {
  line-height: 1.3;
  letter-spacing: 0;
}

.markdown h1 {
  margin: 8px 0 18px;
  color: #1f2427;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 500;
}

.markdown h2 {
  margin-top: 38px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
  color: var(--accent-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 600;
}

.markdown h3 {
  margin-top: 28px;
  font-size: 19px;
  line-height: 1.45;
}

.markdown p,
.markdown ul,
.markdown ol,
.markdown table {
  margin: 14px 0;
}

.markdown li + li {
  margin-top: 5px;
}

.markdown code {
  background: #f1f0ea;
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 0.92em;
}

.markdown mark {
  border-radius: 3px;
  background: #ffe58f;
  color: inherit;
  padding: 0 2px;
}

.markdown pre {
  overflow: auto;
  background: #24292c;
  color: #f4f1e7;
  border-radius: 8px;
  padding: 15px;
}

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

.markdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  display: block;
  overflow-x: auto;
}

.markdown th,
.markdown td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  vertical-align: top;
}

.markdown th {
  background: #f4f2eb;
  text-align: left;
}

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

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 18px;
    padding-inline: 14px;
  }

  .markdown {
    padding-inline: 24px;
  }
}

@media (max-width: 760px) {
  .masthead {
    align-items: flex-start;
    flex-direction: column;
    padding-bottom: 22px;
  }

  .brand {
    padding-right: 0;
  }

  .masthead-actions {
    position: static;
  }

  .layout {
    display: block;
    padding: 16px 12px 42px;
  }

  .sidebar {
    position: static;
    margin-bottom: 16px;
  }

  #dateSelect {
    display: block;
  }

  .date-list {
    display: none;
  }

  .reader-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .search-field {
    align-items: stretch;
    flex-direction: column;
    gap: 5px;
  }

  .search-field input {
    width: 100%;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
  }

  .markdown {
    padding: 20px 18px 32px;
  }
}
