:root {
  --bg: #ffffff;
  --text: #000000;
  --muted: #4d4d4d;
  --border: #d7d7d7;
  --panel: #fafafa;
  --hsk1: #f4b6b6;
  --hsk2: #bfe7bf;
  --hsk3: #f6e8a6;
}

html[data-theme="dark"] {
  --bg: #000000;
  --text: #ffffff;
  --muted: #b0b0b0;
  --border: #2f2f2f;
  --panel: #111111;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Noto Serif", serif;
  line-height: 1.55;
}

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

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.intro {
  margin: 0;
  color: var(--muted);
  max-width: 42rem;
  font-size: 0.98rem;
  margin-bottom: 3rem;
}

.page-nav {
  display: flex;
  gap: 2.25rem;
}

.page-button {
  background: transparent;
  color: var(--text);
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.98rem;
  padding: 0;
}

.page-button.active {
  text-decoration: underline;
  text-underline-offset: 0.28em;
  text-decoration-thickness: 2px;
}

.page-button:hover {
  text-decoration: underline;
  text-underline-offset: 0.28em;
}

.theme-toggle,
.tab-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
}

.theme-toggle {
  padding: 0.4rem 0.8rem;
  font-size: 0.92rem;
}

.top-nav {
  display: flex;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
}

.tab-button {
  padding: 0.45rem 0.85rem;
  font-size: 0.92rem;
}

.tab-button.active {
  background: var(--text);
  color: var(--bg);
}

.filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.35rem;
}

.filters-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.level-buttons {
  display: inline-flex;
  gap: 0.45rem;
}

.legend {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 1rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.legend-item {
  color: var(--muted);
  font-size: 0.85rem;
}

.legend-mark {
  text-decoration-line: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 0.22em;
}

.legend-mark.hsk1 {
  text-decoration-color: var(--hsk1);
}

.legend-mark.hsk2 {
  text-decoration-color: var(--hsk2);
}

.legend-mark.hsk3 {
  text-decoration-color: var(--hsk3);
}

.level-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.3rem 0.7rem;
}

.level-button.active {
  background: var(--text);
  color: var(--bg);
}

.day-group {
  margin-bottom: 2.3rem;
}

.day-heading {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.6rem;
}

.article-card {
  border-top: 1px solid var(--border);
  padding-top: 1.35rem;
  margin-top: 1.35rem;
}

.article-card:first-of-type {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.article-title-zh {
  margin: 0;
  font-size: 1.22rem;
}

.article-title-en {
  margin: 0.15rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.98rem;
}

.sentence-translation {
  margin: 0 0 0.7rem;
  border-left: 2px solid var(--border);
  padding: 0.2rem 0 0.2rem 0.7rem;
  color: var(--muted);
  min-height: 2.4rem;
  font-size: 0.92rem;
}

.article-body {
  margin: 0;
}

.sentence {
  margin: 0.45rem 0;
  font-size: 1.1rem;
}

.hsk-word {
  text-decoration-line: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 0.18em;
  position: relative;
  cursor: help;
}

.hsk-word.hsk-1 {
  text-decoration-color: var(--hsk1);
}

.hsk-word.hsk-2 {
  text-decoration-color: var(--hsk2);
}

.hsk-word.hsk-3 {
  text-decoration-color: var(--hsk3);
}

.hsk-word:hover::after,
.hsk-word:focus-visible::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  font-size: 0.82rem;
  white-space: nowrap;
  z-index: 10;
}

.hsk-word:hover::before,
.hsk-word:focus-visible::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border);
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 1rem;
  color: var(--muted);
}

.past-date-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.past-date-button,
.past-back-arrow {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  width: fit-content;
}

.past-date-button {
  padding: 0.45rem 0.9rem;
}

.past-back-arrow {
  padding: 0.35rem 0.7rem;
  margin-bottom: 0.6rem;
  font-size: 1rem;
  line-height: 1;
}

.mobile-wrap {
  display: grid;
  gap: 1.2rem;
}

.mobile-lead {
  margin: 0;
  color: var(--muted);
  max-width: 44rem;
}

.mobile-list {
  margin: 0;
  padding-left: 1.1rem;
}

.mobile-list li {
  margin: 0.4rem 0;
}

.mobile-gallery {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.mobile-shot {
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
}

.mobile-download {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  text-decoration: none;
  color: var(--text);
}

.mobile-download:hover {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .theme-toggle {
    align-self: flex-start;
  }

  .sentence {
    font-size: 1.03rem;
  }

  .filters-label {
    width: 100%;
  }

  .legend {
    width: 100%;
  }
}
