@font-face {
  font-family: "Antropos";
  src: url("../public/assets/fonts/Antropos.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #fbf2df;
  --paper-soft: #fff9ed;
  --paper-green: #dfe9d2;
  --ink: #2d271f;
  --muted: #6b604f;
  --line: rgba(91, 72, 48, 0.22);
  --pine: #274f3d;
  --moss: #60764a;
  --berry: #9b3440;
  --rose: #c77d74;
  --gold: #c8932e;
  --indigo: #26395c;
  --white: #fffdf7;
  --shadow: 0 20px 50px rgba(71, 51, 25, 0.14);
  --radius: 8px;
  --max: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 10% 0%, rgba(200, 147, 46, 0.12), transparent 28rem),
    linear-gradient(180deg, var(--paper), #f7ead2 54%, #e7edd9 100%);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--berry);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

button,
a {
  touch-action: manipulation;
}

button {
  font: inherit;
}

.site-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 28px;
  align-items: center;
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0;
  background: rgba(251, 242, 223, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(91, 72, 48, 0.12);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  background:
    radial-gradient(circle, var(--gold) 0 13%, transparent 14%),
    conic-gradient(from 22deg, transparent 0 9%, var(--gold) 9% 14%, transparent 14% 34%, var(--berry) 34% 39%, transparent 39% 59%, var(--gold) 59% 64%, transparent 64% 84%, var(--berry) 84% 89%, transparent 89%);
  clip-path: polygon(50% 0, 61% 38%, 100% 50%, 61% 62%, 50% 100%, 39% 62%, 0 50%, 39% 38%);
}

.brand strong {
  display: block;
  font-family: "Antropos", Georgia, serif;
  font-size: 1.18rem;
  line-height: 1;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.main-nav {
  display: flex;
  justify-content: center;
  gap: 22px;
}

.main-nav a {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 750;
  text-decoration: none;
}

.main-nav a:hover {
  color: var(--berry);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-search {
  display: grid;
  grid-template-columns: minmax(150px, 240px) auto;
  gap: 6px;
  justify-self: end;
}

.site-search input,
.site-search button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.site-search input {
  width: 100%;
  min-width: 0;
  padding: 0 11px;
  background: rgba(255, 253, 247, 0.82);
  color: var(--ink);
}

.site-search button {
  padding: 0 13px;
  background: var(--pine);
  color: var(--white);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 850;
}

.search-panel {
  position: sticky;
  top: 72px;
  z-index: 18;
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
}

.search-panel-inner {
  display: grid;
  gap: 10px;
  max-width: 680px;
  margin-left: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.98);
  box-shadow: var(--shadow);
}

.search-close {
  justify-self: end;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(251, 242, 223, 0.88);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 850;
}

.search-results {
  display: grid;
  gap: 8px;
}

.search-result {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid rgba(91, 72, 48, 0.14);
  border-radius: 6px;
  background: rgba(251, 242, 223, 0.48);
  color: var(--ink);
  text-decoration: none;
}

.search-result:hover {
  border-color: rgba(155, 52, 64, 0.34);
  background: rgba(248, 234, 214, 0.72);
}

.search-result strong {
  color: var(--pine);
  font-size: 0.96rem;
}

.search-result span,
.search-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.language-toggle,
.admin-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.74);
}

.language-toggle button,
.admin-toggle button,
.button,
.role-select,
.category-card {
  border: 0;
  cursor: pointer;
}

.language-toggle button,
.admin-toggle button {
  min-width: 42px;
  min-height: 34px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 850;
}

.admin-toggle button {
  min-width: 68px;
}

.language-toggle button[aria-pressed="true"],
.admin-toggle button[aria-pressed="true"] {
  background: var(--pine);
  color: var(--white);
}

.hero-section {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(420px, 1.18fr);
  gap: 22px;
  align-items: center;
  width: min(1320px, calc(100% - 32px));
  min-height: calc(100vh - 76px);
  margin: 0 auto;
  padding: 26px 0 44px;
}

.hero-copy {
  position: relative;
  z-index: 2;
  padding: clamp(20px, 4vw, 56px) clamp(4px, 2vw, 28px);
}

h1,
h2,
h3 {
  font-family: "Antropos", Georgia, serif;
  letter-spacing: 0;
  color: var(--pine);
}

h1 {
  margin: 0 0 22px;
  font-size: clamp(2.85rem, 6.2vw, 5.25rem);
  line-height: 1;
  max-width: 740px;
}

.hero-copy p {
  max-width: 560px;
  margin: 0;
  color: #43392e;
  font-size: clamp(1.08rem, 1.6vw, 1.34rem);
  line-height: 1.62;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 850;
  text-decoration: none;
}

.button.primary {
  background: var(--pine);
  border-color: var(--pine);
  color: var(--white);
}

.button.small {
  min-height: 36px;
  padding: 0 13px;
  font-size: 0.82rem;
}

.button.quiet {
  background: rgba(255, 253, 247, 0.58);
}

.button.small {
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.85rem;
}

.hero-points {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 650px;
  margin-top: 34px;
}

.hero-points span {
  min-height: 56px;
  padding-left: 18px;
  border-left: 1px solid rgba(91, 72, 48, 0.2);
  color: var(--muted);
  font-size: 0.91rem;
  font-weight: 780;
  line-height: 1.35;
}

.hero-art {
  margin: 0;
  align-self: stretch;
  min-height: 520px;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  filter: drop-shadow(0 22px 30px rgba(73, 54, 29, 0.12));
}

.hero-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  mask-image: linear-gradient(90deg, transparent 0%, black 10%, black 100%);
}

main > section,
.reader-shell {
  width: min(var(--max), calc(100% - 32px));
  margin: 0 auto;
}

main > section {
  scroll-margin-top: 92px;
}

.role-section,
.activity-map-section,
.category-section,
.sources-section {
  padding: 58px 0;
}

.section-heading {
  display: grid;
  gap: 8px;
  max-width: 730px;
  margin-bottom: 24px;
}

.section-heading.centered {
  margin-inline: auto;
  text-align: center;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(2.1rem, 4.2vw, 3.6rem);
  line-height: 1.04;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.role-card,
.activity-card,
.source-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.72);
  box-shadow: 0 12px 32px rgba(77, 54, 24, 0.07);
}

.role-card {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.role-card.selected {
  border-color: rgba(155, 52, 64, 0.42);
  background: rgba(255, 246, 236, 0.88);
}

.role-select,
.category-card {
  width: 100%;
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 14px;
  align-items: center;
  min-height: 96px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.role-select strong,
.category-card strong,
.source-card h3,
.activity-card h3 {
  display: block;
  color: var(--ink);
  font-family: "Antropos", Georgia, serif;
  font-size: clamp(1.12rem, 1.45vw, 1.36rem);
  font-weight: 650;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.source-card h3 {
  font-size: 1.12rem;
}

.role-select small,
.category-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.91rem;
  line-height: 1.35;
}

.role-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.55;
}

.role-links {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.text-link,
.inline-doc-link {
  font-size: 0.88rem;
  font-weight: 850;
}

.sprite-icon {
  display: block;
  width: 84px;
  aspect-ratio: 1;
  border-radius: 50%;
  background-image: url("../public/assets/generated/category-medallions-sheet.png");
  background-repeat: no-repeat;
  background-size: 300% 200%;
  box-shadow: inset 0 0 0 1px rgba(91, 72, 48, 0.12);
}

.sprite-coordinator { background-position: 0% 0%; }
.sprite-representative { background-position: 50% 0%; }
.sprite-parent { background-position: 100% 0%; }
.sprite-workshops { background-position: 0% 100%; }
.sprite-food { background-position: 50% 100%; }
.sprite-program-logistics { background-position: 100% 100%; }

.activity-map-shell {
  display: grid;
  gap: 18px;
}

.map-admin-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: -10px 0 16px;
}

.map-admin-controls[hidden] {
  display: none;
}

.map-admin-status {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.activity-map-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 8px;
}

.activity-map-canvas {
  position: relative;
  width: max(920px, 100%);
  aspect-ratio: 1474 / 1067;
  overflow: hidden;
  border: 1px solid rgba(91, 72, 48, 0.2);
  border-radius: var(--radius);
  background: var(--paper-soft);
  box-shadow: var(--shadow);
}

.activity-map-canvas.map-editing {
  border-color: rgba(155, 52, 64, 0.56);
  box-shadow: 0 0 0 3px rgba(155, 52, 64, 0.1), var(--shadow);
}

.activity-map-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.activity-map-markers {
  position: absolute;
  inset: 0;
}

.activity-map-loading,
.activity-map-error {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 780;
}

.activity-map-loading {
  position: absolute;
  left: 18px;
  bottom: 18px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 247, 0.86);
}

.activity-map-marker {
  position: absolute;
  z-index: var(--map-z);
  left: var(--map-x);
  top: var(--map-y);
  display: grid;
  justify-items: center;
  gap: 3px;
  width: 92px;
  min-height: 94px;
  padding: 5px 4px 7px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(91, 72, 48, 0.2);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.88);
  color: var(--ink);
  box-shadow: 0 10px 22px rgba(71, 51, 25, 0.16);
  cursor: pointer;
  text-align: center;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.activity-map-marker:hover,
.activity-map-marker.selected {
  border-color: rgba(155, 52, 64, 0.54);
  background: rgba(255, 246, 236, 0.96);
  box-shadow: 0 14px 28px rgba(71, 51, 25, 0.22);
  transform: translate(-50%, -54%);
}

.activity-map-marker.editable {
  cursor: grab;
}

.activity-map-marker.dragging {
  cursor: grabbing;
  border-color: var(--berry);
  box-shadow: 0 18px 34px rgba(71, 51, 25, 0.28);
  transform: translate(-50%, -56%) scale(1.02);
  user-select: none;
}

.activity-map-marker img {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border: 1px solid rgba(91, 72, 48, 0.16);
  border-radius: 7px;
  background: var(--paper-soft);
}

.activity-map-number {
  min-width: 23px;
  padding: 1px 6px 2px;
  border-radius: 999px;
  background: var(--pine);
  color: var(--white);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1.2;
}

.activity-map-title {
  display: block;
  width: 100%;
  color: var(--ink);
  font-size: 0.66rem;
  font-weight: 850;
  line-height: 1.08;
  hyphens: auto;
  overflow-wrap: normal;
  word-break: normal;
}

.activity-map-summary-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 17px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.82);
  box-shadow: 0 12px 32px rgba(77, 54, 24, 0.07);
}

.activity-map-summary-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid rgba(91, 72, 48, 0.16);
  border-radius: var(--radius);
  background: var(--paper-soft);
}

.activity-map-summary-location {
  margin-bottom: 4px;
  color: var(--berry);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.activity-map-summary-card h3 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.08;
}

.activity-map-summary-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.category-card {
  grid-template-columns: 72px 1fr;
  min-height: 102px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.62);
}

.category-card .sprite-icon {
  width: 72px;
}

.category-card.selected {
  background: #f8ead6;
  border-color: rgba(155, 52, 64, 0.38);
}

.activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 14px;
}

.activity-card {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 15px;
  align-items: start;
  padding: 13px;
}

.activity-card .sprite-icon {
  width: 70px;
}

.activity-illustration {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid rgba(91, 72, 48, 0.16);
  border-radius: var(--radius);
  background: var(--paper-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 249, 237, 0.46);
}

.activity-card h3,
.source-card h3 {
  margin: 0;
}

.activity-card h3 {
  font-size: clamp(1rem, 1.12vw, 1.16rem);
  line-height: 1.08;
  overflow-wrap: normal;
  hyphens: auto;
}

.activity-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.48;
}

.activity-card-copy {
  min-width: 0;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.tags span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(96, 118, 74, 0.12);
  color: #4a5a39;
  font-size: 0.78rem;
  font-weight: 780;
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.source-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px;
}

.source-card .sprite-icon {
  width: 64px;
}

.reader-shell {
  padding: 34px 0 70px;
}

.reader-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

.reader-sidebar {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 10px;
}

.toc {
  display: grid;
  gap: 6px;
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.75);
}

.toc strong {
  color: var(--pine);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.toc a {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  line-height: 1.35;
}

.toc .toc-level-3 {
  padding-left: 12px;
  font-size: 0.82rem;
}

.manual-article {
  max-width: 920px;
  padding: clamp(24px, 4vw, 54px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.94);
  box-shadow: var(--shadow);
}

.article-topline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
  text-transform: uppercase;
}

.article-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.article-topline .sprite-icon {
  width: 42px;
}

.manual-article h1 {
  margin-top: 18px;
  max-width: 760px;
  font-size: clamp(2.1rem, 4vw, 3.45rem);
  line-height: 1.04;
}

.manual-body {
  color: #382f26;
  font-size: 1rem;
  line-height: 1.72;
}

.manual-body h2 {
  margin: 2.1em 0 0.45em;
  scroll-margin-top: 118px;
  font-size: clamp(1.6rem, 3vw, 2.35rem);
}

.manual-body h3 {
  margin: 1.6em 0 0.35em;
  scroll-margin-top: 118px;
  color: var(--berry);
  font-size: 1.35rem;
}

.manual-body p {
  margin: 0.8em 0;
}

.outdated-notice {
  display: inline-flex;
  margin: 0 0 1rem;
  padding: 0.34rem 0.58rem;
  border: 1px solid rgba(155, 52, 64, 0.28);
  border-radius: 6px;
  background: rgba(155, 52, 64, 0.08);
  color: #b42318;
  font-size: 0.96rem;
  font-weight: 900;
}

.manual-color {
  font-weight: 780;
}

.manual-figure {
  margin: 1.1rem 0 1.8rem;
}

.manual-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid rgba(91, 72, 48, 0.18);
  border-radius: var(--radius);
  background: var(--paper-soft);
}

.manual-body ul,
.manual-body ol {
  padding-left: 1.35rem;
}

.manual-body .task-list {
  display: grid;
  gap: 0.42rem;
  padding-left: 0;
  list-style: none;
}

.manual-body .task-list-item label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem;
  align-items: start;
}

.manual-body .task-list-item input {
  width: 1rem;
  height: 1rem;
  margin-top: 0.35em;
  accent-color: var(--pine);
}

.manual-body li + li {
  margin-top: 0.32em;
}

.manual-body code {
  padding: 0.16em 0.36em;
  border-radius: 4px;
  background: rgba(96, 118, 74, 0.12);
  color: #425437;
  font-size: 0.9em;
}

.table-wrap {
  overflow-x: auto;
  margin: 1.25rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
}

th,
td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid rgba(91, 72, 48, 0.14);
  text-align: left;
  vertical-align: top;
}

th {
  background: rgba(223, 233, 210, 0.58);
  color: var(--pine);
  font-size: 0.86rem;
  text-transform: uppercase;
}

.reader-loading,
.reader-error {
  min-height: 42vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.manual-editor {
  display: grid;
  gap: 14px;
  margin-top: 1.2rem;
}

.manual-editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(251, 242, 223, 0.62);
}

.manual-editor-toolbar button {
  min-height: 34px;
  border: 1px solid rgba(91, 72, 48, 0.18);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 850;
}

.manual-editor-toolbar > button:not(.button) {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 0 10px;
}

.manual-editor-colors {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 0 4px;
}

.manual-editor-colors button {
  width: 34px;
  padding: 0;
}

.manual-editor-colors span {
  display: block;
  width: 16px;
  height: 16px;
  margin: 0 auto;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(45, 39, 31, 0.2);
}

.manual-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
  gap: 14px;
  align-items: stretch;
}

.manual-editor-input,
.manual-editor-preview {
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

.manual-editor-input {
  width: 100%;
  padding: 16px;
  color: var(--ink);
  font: 0.94rem/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  resize: vertical;
}

.manual-editor-preview {
  overflow: auto;
  padding: 16px;
}

.manual-editor-preview .manual-body {
  font-size: 0.94rem;
}

.manual-editor-status {
  min-height: 1.4em;
  margin: 0;
  color: var(--berry);
  font-size: 0.9rem;
  font-weight: 800;
}

.chat-launcher,
.chat-window {
  position: fixed;
  right: 18px;
  z-index: 40;
}

.chat-launcher {
  bottom: 18px;
  min-height: 48px;
  max-width: calc(100vw - 36px);
  padding: 0 18px;
  border: 1px solid rgba(39, 79, 61, 0.18);
  border-radius: 999px;
  background: var(--pine);
  color: var(--white);
  box-shadow: 0 16px 34px rgba(45, 39, 31, 0.22);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.chat-window {
  bottom: 78px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(390px, calc(100vw - 36px));
  max-height: min(640px, calc(100vh - 112px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.98);
  box-shadow: var(--shadow);
}

.chat-window[hidden] {
  display: none;
}

.chat-window header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid rgba(91, 72, 48, 0.14);
  background: rgba(223, 233, 210, 0.58);
}

.chat-window h2 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.1;
}

.chat-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.chat-log {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 220px;
  overflow-y: auto;
  padding: 14px;
}

.chat-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.chat-message {
  display: grid;
  gap: 8px;
  max-width: 88%;
  padding: 10px 12px;
  border: 1px solid rgba(91, 72, 48, 0.14);
  border-radius: 8px;
  background: rgba(251, 242, 223, 0.66);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.chat-message.user {
  justify-self: end;
  background: var(--pine);
  color: var(--white);
}

.chat-message.assistant {
  justify-self: start;
}

.chat-message.pending {
  color: var(--muted);
}

.chat-message.error {
  border-color: rgba(155, 52, 64, 0.28);
  color: var(--berry);
}

.chat-message p {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.92rem;
  line-height: 1.48;
}

.chat-sources {
  display: grid;
  gap: 5px;
  padding-top: 2px;
}

.chat-sources strong {
  color: var(--pine);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.chat-sources div {
  display: grid;
  gap: 4px;
}

.chat-sources a {
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.35;
}

.chat-form {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  padding: 12px;
  border-top: 1px solid rgba(91, 72, 48, 0.14);
  background: rgba(251, 242, 223, 0.68);
}

.chat-form textarea {
  width: 100%;
  min-height: 42px;
  max-height: 120px;
  resize: vertical;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.35;
}

.chat-send,
.voice-button {
  min-height: 42px;
  border-radius: 6px;
  font-weight: 850;
}

.chat-send {
  padding: 0 13px;
  border: 1px solid var(--pine);
  background: var(--pine);
  color: var(--white);
  cursor: pointer;
}

.voice-button {
  width: 40px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.68);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.voice-button.connecting {
  border-color: rgba(200, 147, 46, 0.72);
  background: rgba(200, 147, 46, 0.16);
  color: var(--ink);
}

.voice-button.active,
.voice-button.recording {
  border-color: var(--berry);
  background: var(--berry);
  color: var(--white);
  box-shadow: 0 0 0 3px rgba(155, 52, 64, 0.14);
}

.chat-form button:disabled,
.chat-form textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(200, 147, 46, 0.72);
  outline-offset: 3px;
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr auto auto auto;
  }

  .main-nav {
    display: none;
  }

  .hero-section {
    grid-template-columns: 1fr;
  }

  .hero-section {
    min-height: auto;
  }

  .hero-art {
    min-height: 360px;
  }

  .hero-art img {
    mask-image: none;
  }

  .role-grid,
  .category-grid {
    grid-template-columns: 1fr;
  }

  .reader-layout {
    grid-template-columns: 1fr;
  }

  .reader-sidebar {
    position: static;
  }

  .manual-editor-grid {
    grid-template-columns: 1fr;
  }

  .manual-editor-input,
  .manual-editor-preview {
    min-height: 360px;
  }
}

@media (max-width: 620px) {
  .topbar {
    grid-template-columns: 1fr auto;
    width: min(100% - 24px, var(--max));
    gap: 12px;
  }

  .admin-toggle {
    grid-column: 1 / -1;
    justify-self: start;
    order: 2;
  }

  .site-search {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) auto;
    justify-self: stretch;
    order: 3;
  }

  .search-panel {
    top: 122px;
    width: min(100% - 24px, var(--max));
  }

  .brand strong {
    font-size: 1rem;
  }

  .brand small {
    display: none;
  }

  .hero-section,
  main > section,
  .reader-shell {
    width: min(100% - 24px, var(--max));
  }

  h1 {
    font-size: clamp(2.75rem, 18vw, 4.2rem);
  }

  .hero-points {
    grid-template-columns: 1fr;
  }

  .role-select,
  .category-card,
  .activity-card,
  .source-card,
  .activity-map-summary-card {
    grid-template-columns: 58px 1fr;
  }

  .sprite-icon,
  .role-select .sprite-icon,
  .category-card .sprite-icon,
  .activity-card .sprite-icon,
  .source-card .sprite-icon {
    width: 58px;
  }

  .manual-article {
    padding: 20px;
  }

  .admin-toggle button {
    min-width: 58px;
  }

  .manual-editor-toolbar {
    align-items: stretch;
  }

  .manual-editor-toolbar > button,
  .manual-editor-colors {
    flex: 1 1 auto;
  }

  .chat-launcher,
  .chat-window {
    right: 12px;
  }

  .chat-launcher {
    bottom: 12px;
  }

  .chat-window {
    bottom: 70px;
    width: calc(100vw - 24px);
    max-height: min(560px, calc(100vh - 92px));
  }

  .chat-form {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 6px;
    padding: 10px;
  }

  .voice-button {
    width: 38px;
  }
}

@media print {
  .topbar,
  .chat-launcher,
  .chat-window,
  .reader-sidebar,
  .hero-section,
  .role-section,
  .category-section,
  .sources-section {
    display: none !important;
  }

  .reader-shell {
    display: block !important;
    width: 100%;
    padding: 0;
  }

  .reader-layout {
    display: block;
  }

  .manual-article {
    box-shadow: none;
    border: 0;
    padding: 0;
  }
}
