:root {
  --ink: #202421;
  --muted: #69736d;
  --bg: #eef2ee;
  --panel: #fffdf7;
  --line: #cdd6cf;
  --red: #92303a;
  --blue: #2f5f83;
  --green: #496f56;
  --shadow: 0 18px 48px rgba(31, 36, 33, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(47, 95, 131, 0.08), transparent 34%),
    linear-gradient(300deg, rgba(73, 111, 86, 0.09), transparent 42%),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

button,
input {
  font: inherit;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.96);
  backdrop-filter: blur(14px);
}

.brand {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 14px;
  align-items: center;
}

.brand img {
  width: 78px;
  height: 78px;
  object-fit: contain;
}

.brand h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.22rem;
  line-height: 1.05;
}

.brand p,
.brand em {
  display: block;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 400;
}

.brand em {
  font-style: italic;
}

.traditions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tradition-button,
.unit-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.tradition-button {
  min-height: 42px;
  padding: 9px 10px;
  text-align: center;
  font-weight: 750;
}

.tradition-button.active {
  border-color: var(--red);
  background: var(--red);
  color: var(--panel);
}

.search-box {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.unit-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.unit-button {
  display: block;
  width: 100%;
  padding: 11px 12px;
  text-align: left;
  line-height: 1.22;
}

.unit-button.active {
  border-color: var(--blue);
  box-shadow: inset 4px 0 0 var(--blue);
}

.unit-button mark {
  background: #f2e3a6;
  color: inherit;
}

.result-axis {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.result-axis h3 {
  margin: 8px 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.no-results {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 7px;
  color: var(--muted);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.sidebar-footer p {
  margin: 8px 0 0;
}

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

.app {
  margin-left: 360px;
  padding: 28px clamp(22px, 5vw, 76px) 76px;
}

.reader {
  min-height: calc(100vh - 56px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.reader-head,
.section,
.empty-state {
  padding: clamp(20px, 3vw, 36px);
}

.reader-head {
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(146, 48, 58, 0.1), transparent),
    var(--panel);
}

.tradition-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h2,
h3,
h4 {
  margin: 0;
  line-height: 1.08;
}

h2 {
  max-width: 980px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.7rem, 3.4vw, 3.75rem);
}

h3 {
  font-size: 1.35rem;
}

h4 {
  font-size: 1.05rem;
}

.reader-head p:last-child,
.section-summary,
.subsection-summary,
.empty-state {
  color: var(--muted);
  line-height: 1.7;
}

.section {
  border-bottom: 1px solid var(--line);
}

.section h3 {
  margin-bottom: 10px;
}

.section-summary,
.subsection-summary {
  max-width: 900px;
  margin: 0 0 16px;
}

.subsection {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}

.content-block {
  max-width: 980px;
  margin: 14px 0;
}

.content-block p {
  margin: 0;
  line-height: 1.78;
}

figure.content-block {
  margin: 22px 0;
  display: grid;
  justify-items: center;
}

figure img {
  display: block;
  max-width: min(760px, 100%);
  max-height: 520px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f2e9;
  -webkit-user-drag: none;
  pointer-events: none;
}

figcaption {
  max-width: 760px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
  text-align: center;
}

.table-wrap {
  overflow: auto;
  margin: 16px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

td {
  min-width: 140px;
  padding: 10px;
  border: 1px solid var(--line);
  vertical-align: top;
}

.watermark {
  position: fixed;
  right: 18px;
  bottom: 12px;
  z-index: 10;
  color: rgba(32, 36, 33, 0.28);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 2vw, 1.45rem);
  text-decoration: none;
  pointer-events: auto;
}

em.foreign {
  font-style: italic;
}

.search-hit {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  background: rgba(242, 227, 166, 0.45);
}

@media (max-width: 1020px) {
  .sidebar {
    position: static;
    width: auto;
    max-height: none;
  }

  .unit-list {
    max-height: 42vh;
  }

  .app {
    margin-left: 0;
    padding: 18px 16px 64px;
  }
}

@media (max-width: 640px) {
  .brand {
    grid-template-columns: 60px 1fr;
  }

  .brand img {
    width: 60px;
    height: 60px;
  }

  .traditions {
    grid-template-columns: 1fr;
  }
}
