:root {
  --font-display: "Baskerville", "Times New Roman", Times, serif;
  --font-body: Charter, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-ui: "Avenir Next", "Gill Sans", "Segoe UI", sans-serif;
  --ink-strong: #1f1a16;
  --ink: #3f372f;
  --ink-muted: #6a5f54;
  --paper: #fbf5ec;
  --paper-deep: #f2e7d8;
  --surface: #fffdf9;
  --line: #d9c8b3;
  --accent: #7d3f20;
  --chip-bg: #f3e5d3;
  --chip-hover: #edd9c2;
  --chip-line: #cfb89e;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 16px;
}

body {
  margin: 0 auto;
  min-height: 100vh;
  max-width: 1080px;
  padding: clamp(18px, 4vw, 48px);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.72;
  background:
    radial-gradient(circle at 14% -10%, #fffaf2 0%, var(--paper) 45%, var(--paper-deep) 100%);
}

h1 {
  margin: 0 0 14px;
  color: var(--ink-strong);
  font-family: var(--font-display);
  font-size: clamp(2.15rem, 1.4rem + 2.2vw, 3.35rem);
  line-height: 1.08;
  letter-spacing: 0.01em;
}

h2 {
  margin: 34px 0 12px;
  color: #2f241c;
  font-family: var(--font-display);
  font-size: clamp(1.28rem, 1rem + 0.95vw, 1.75rem);
  font-weight: 500;
  line-height: 1.18;
}

p {
  margin: 0 0 14px;
  color: var(--ink-muted);
  max-width: 72ch;
}

a {
  color: var(--accent);
  text-decoration-color: rgba(125, 63, 32, 0.4);
  text-underline-offset: 3px;
}

a:hover {
  color: #633116;
}

a[href="/"] {
  display: inline-block;
  margin-bottom: 18px;
  color: #4f2a14;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 1px solid #b89f84;
  padding-bottom: 2px;
}

label[for="searchInput"] {
  display: block;
  margin-bottom: 8px;
  color: #594739;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

input[type="text"] {
  width: min(640px, 100%);
  max-width: 100%;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink-strong);
  font-family: var(--font-ui);
  font-size: 0.98rem;
  box-shadow: 0 2px 8px rgba(39, 28, 19, 0.04);
}

input[type="text"]:focus {
  outline: none;
  border-color: #b18d6b;
  box-shadow: 0 0 0 3px rgba(177, 141, 107, 0.22);
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  padding: 3px 0;
}

.tag-cloud-panel {
  margin-top: 26px;
}

.tag-cloud-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.tag-cloud-header h2 {
  margin: 0;
}

.tag-cloud-toggle {
  border: 1px solid #bfa58b;
  border-radius: 3px;
  background: #f7ebdc;
  color: #5f3118;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
  padding: 8px 10px;
  cursor: pointer;
}

.tag-cloud-toggle:hover {
  background: #efdcc8;
  color: #4a2410;
}

.tag-cloud-summary {
  margin: 10px 0 8px;
  color: #5f4b3c;
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tag-link {
  text-decoration: none;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
  border: 1px solid var(--chip-line);
  border-radius: 3px;
  background: var(--chip-bg);
  color: #594233;
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1;
  text-transform: uppercase;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.tag:hover {
  background: var(--chip-hover);
  border-color: #bea486;
  transform: translateY(-1px);
}

.search-result-count {
  margin: 4px 0 4px;
  color: #5f4b3c;
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search-empty-state {
  margin: 0 0 10px;
  color: #7e3a1c;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
}

.related-tags-panel {
  margin: 0 0 18px;
  padding: 14px 16px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 253, 249, 0.86);
}

.related-tags-panel h2 {
  margin: 0 0 6px;
  font-size: clamp(1.05rem, 0.94rem + 0.42vw, 1.32rem);
}

.related-tags-intro {
  margin: 0 0 9px;
  color: #615243;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.related-tag-link.is-active .tag {
  background: #e7ceb2;
  border-color: #bc926f;
  color: #4f2813;
}

.related-tags-summary {
  margin: 6px 0 0;
  color: #5a4a3c;
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.related-tags-clear {
  margin: 6px 0 0;
}

.related-tags-clear a {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
}

.taxonomy-markdown {
  margin: 0 0 18px;
  padding: 14px 16px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 253, 249, 0.86);
}

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

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

.image-card {
  width: 200px;
  margin: 15px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: 0 8px 18px rgba(43, 30, 21, 0.08);
  overflow: hidden;
  text-align: center;
}

.gallery-image {
  width: auto;
  height: 150px;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  border-radius: 3px;
}

.image-view {
  display: block;
  width: min(100%, 940px);
  height: auto;
  max-height: 72vh;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: 0 14px 30px rgba(30, 22, 15, 0.12);
}

.image-description {
  margin-top: 8px;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

@media (max-width: 640px) {
  body {
    padding: 16px;
  }

  .tag {
    font-size: 0.7rem;
  }
}
