/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold:        #d9c27a;
  --gold-dim:    #a8903a;
  --gold-light:  #e8d898;
  --gold-glow:   rgba(168,144,58,0.13);
  --sidebar-bg:  #160b0b;
  --header-bg:   #1e0e0e;
  --body-bg:     #1a1410;
  --panel-bg:    #110808;
  --text:        #f7f8f2;
  --text-muted:  #c8bfa0;
  --border:      rgba(168,144,58,0.22);
  --hover-bg:    rgba(255,255,255,0.04);
  /* layout dimensions as rem */
  --sidebar-w:   13.75rem;   /* 220px / 16px base */
  --oracle-w:    25rem;      /* 400px */
  --topbar-h:    3rem;       /* 48px */
  --touch-min:   2.75rem;    /* 44px minimum touch target */
  /* dynamic viewport height — updated by JS for keyboard-aware panels */
  --viewport-height: 100dvh;
}

html { font-size: 18px; }

body {
  background-color: var(--body-bg);
  color: var(--text);
  font-family: 'EB Garamond', Georgia, serif;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Background gradient on a pseudo-element so it stays fixed without
   disabling GPU compositing on the body (background-attachment:fixed
   forces software rendering and is broken on iOS). */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(139,26,26,.15) 0, transparent 70%),
    radial-gradient(ellipse 50% 30% at 50% 0,    rgba(200,168,75,.06) 0, transparent 60%),
    linear-gradient(180deg, #0d0b08 0%, #1a1410 50%, #120f0c 100%);
  pointer-events: none;
}

/* ── Watermark ── */
.bg-watermark {
  position: fixed;
  top: 0;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 0;
}
.bg-watermark img {
  width: min(520px, 65vw);
  opacity: 0.055;
  filter: grayscale(1) brightness(3) invert(1);
}

/* ── Layout ── */
.layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: transform 0.28s ease, scrollbar-color 0.3s;
  z-index: 100;
}
.sidebar:hover { scrollbar-color: var(--gold-dim) transparent; }
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: transparent; border-radius: 2px; }
.sidebar:hover::-webkit-scrollbar-thumb { background: var(--gold-dim); }

/* ── Sidebar header / logo ── */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1rem 1rem 0.9rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  text-decoration: none;
}

/* ── Sidebar campaign strip ── */
.sidebar-campaign-info {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.3rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-family: 'Cinzel', serif;
  font-size: 0.53rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(168,144,58,0.5);
  flex-shrink: 0;
  line-height: 1.4;
}
.sidebar-logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
  opacity: 0.85;
  flex-shrink: 0;
}
.sidebar-title {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.72rem;
  color: var(--gold);
  letter-spacing: 0.04em;
  line-height: 1.2;
}

/* ── Nav ── */
.pdb-nav {
  display: block;
  padding: 0.4rem 0 2.5rem;
}

/* Section labels */
.nav-section {
  display: block;
}
.nav-section-label {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold-dim);
  padding: 0.9rem 1rem 0.25rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  /* no expand arrow */
}
.nav-section > summary { list-style: none; }
.nav-section-link {
  color: inherit;
  text-decoration: none;
}
.nav-section-link:hover { color: var(--gold); }
.nav-section > summary::-webkit-details-marker { display: none; }
.nav-section > summary::marker { display: none; }

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.3rem;
}

/* Nav links — EB Garamond, cream, gold left border on hover/active */
.nav-link {
  display: block;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 1rem;
  border-left: 2px solid transparent;
  transition: color 0.14s, background 0.14s, border-color 0.14s;
  line-height: 1.4;
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
  touch-action: manipulation;
}
.nav-link:hover {
  color: var(--gold-light);
  border-left-color: var(--gold-dim);
  background: var(--hover-bg);
}
.nav-link.active {
  color: var(--gold);
  border-left: 3px solid var(--gold-dim);
  background: var(--gold-glow);
}
.nav-link.nav-top {
  margin-top: 0.1rem;
}

/* ── Main wrapper ── */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ── Top bar ── */
.top-bar {
  height: var(--topbar-h);
  background: rgba(13,9,7,0.75);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 0.9rem;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 0.25rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  flex-shrink: 0;
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  touch-action: manipulation;
}
.menu-toggle span {
  display: block;
  width: 1.25rem;
  height: 0.125rem;
  background: var(--gold-dim);
  border-radius: 1px;
}

.breadcrumb {
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(168,144,58,0.7);
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
}
.breadcrumb a { color: rgba(168,144,58,0.7); text-decoration: none; }
.breadcrumb a:hover { color: var(--gold); }
.breadcrumb span { margin: 0 0.45em; color: rgba(168,144,58,0.35); }

/* ── Content wrap (content + right TOC) ── */
.content-wrap {
  display: flex;
  flex: 1;
  align-items: flex-start;
}

/* ── Content ── */
.content {
  flex: 1;
  padding: 2.5rem 3rem 5rem;
  max-width: 920px;
  min-width: 0;
}

/* ── Page TOC (right rail) ── */
.page-toc {
  display: none;
  width: 13rem;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--topbar-h) + 1.5rem);
  max-height: calc(100vh - var(--topbar-h) - 3rem);
  overflow-y: auto;
  padding: 0.25rem 0 0.25rem 1rem;
  margin-top: 2.5rem;
  border-left: 1px solid var(--border);
  scrollbar-width: none;
}
.page-toc::-webkit-scrollbar { display: none; }
.page-toc-title {
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(168,144,58,0.45);
  margin-bottom: 0.6rem;
}
.page-toc a {
  display: block;
  font-size: 0.75rem;
  line-height: 1.35;
  color: rgba(168,144,58,0.55);
  text-decoration: none;
  padding: 0.2rem 0;
  transition: color 0.15s;
}
.page-toc a:hover,
.page-toc a.toc-active { color: var(--gold); }
.page-toc a.toc-h3 { padding-left: 0.75rem; font-size: 0.7rem; }

@media (min-width: 1200px) {
  .page-toc.has-items { display: block; }
}

/* ── Prose ── */
.prose h1 {
  font-family: 'Cinzel Decorative', serif;
  font-size: 2.1rem;
  color: var(--gold);
  line-height: 1.2;
  margin-bottom: 1.1rem;
  padding-bottom: 0.45em;
  background:
    linear-gradient(90deg, var(--gold-dim) 0%, transparent 70%) bottom / 100% 1px no-repeat;
}
.prose h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.45rem;
  color: #d9c27a;
  border-bottom: 1px solid rgba(168,144,58,0.28);
  padding-bottom: 0.22em;
  margin: 2.2rem 0 0.8rem;
  letter-spacing: 0.02em;
}
.prose h3 {
  font-family: 'Cinzel', serif;
  font-size: 1.15rem;
  color: #e8d898;
  margin: 1.7rem 0 0.5rem;
}
.prose h4 {
  font-family: 'Cinzel', serif;
  font-size: 0.92rem;
  color: #e8d898;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin: 1.3rem 0 0.4rem;
}
/* Heading anchor links */
.heading-anchor {
  opacity: 0;
  margin-left: 0.4em;
  font-size: 0.75em;
  color: var(--gold-dim);
  text-decoration: none;
  transition: opacity 0.15s;
  vertical-align: middle;
}
.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.prose h4:hover .heading-anchor { opacity: 1; }
@media (hover: none) {
  .heading-anchor { opacity: 0.45; }
}
.prose p {
  line-height: 1.78;
  margin-bottom: 1rem;
  color: var(--text);
}
.prose a {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid rgba(217,194,122,0.28);
  transition: color 0.14s, border-color 0.14s;
}
.prose a:hover {
  color: var(--gold-light);
  border-bottom-color: var(--gold-light);
}
.prose strong { color: var(--gold-light); font-weight: 700; }
.prose em { font-style: italic; color: #d4c9a8; }
.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}
.prose ul, .prose ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}
.prose li {
  line-height: 1.72;
  margin-bottom: 0.18rem;
}
.prose blockquote {
  border-left: 3px solid var(--gold-dim);
  margin: 1.5rem 0;
  padding: 0.4rem 0 0.4rem 1.2rem;
  color: #c0b490;
  font-style: italic;
}
.prose code {
  background: rgba(18,14,10,0.55);
  border: 1px solid rgba(168,144,58,0.18);
  border-radius: 3px;
  padding: 0.1em 0.35em;
  font-family: 'Courier New', Consolas, monospace;
  font-size: 0.82em;
  color: var(--gold-light);
}
.prose pre {
  background: rgba(8,6,4,0.75);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}
.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
}

/* Tables */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.94rem;
}
.prose th {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(168,144,58,0.1);
  border: 1px solid var(--border);
  padding: 0.55rem 0.85rem;
  text-align: left;
  white-space: nowrap;
}
.prose td {
  border: 1px solid rgba(168,144,58,0.13);
  padding: 0.48rem 0.85rem;
  line-height: 1.5;
}
.prose tr:hover td { background: var(--hover-bg); }

/* ── Page footer ── */
.page-footer {
  margin-top: 3.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}
.add-note-btn {
  background: none;
  border: 1px solid var(--border);
  color: rgba(168,144,58,0.65);
  font-family: 'Cinzel', serif;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.38rem 0.85rem;
  cursor: pointer;
  border-radius: 2px;
  transition: border-color 0.15s, color 0.15s;
}
.add-note-btn:hover { border-color: var(--gold); color: var(--gold); }

.stat-dot { opacity: 0.4; }

/* ── Home page ── */
.home-content { max-width: 860px; padding-top: 3.5rem; }
.home-hero { text-align: center; margin-bottom: 2.5rem; }
.home-guild-label {
  font-family: 'Cinzel', serif;
  font-size: 0.62rem;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 1.1rem;
}
.home-title {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(1.6rem, 4vw, 3.4rem);
  font-weight: 900;
  line-height: 1.1;
  color: var(--gold-light);
  text-shadow: 0 0 60px rgba(200,168,75,0.25), 0 2px 4px rgba(0,0,0,0.8);
  margin-bottom: 0.4rem;
}
.home-subtitle {
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 1.5rem;
}
.home-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 auto 2.5rem;
  max-width: 300px;
}
.home-divider::before,
.home-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}
.home-divider-glyph { color: var(--gold); font-size: 1rem; opacity: 0.65; }

/* ── Party cards ── */
.party-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}
.party-card {
  display: block;
  text-decoration: none;
  background: linear-gradient(160deg, var(--surface) 0%, rgba(36,28,24,0.9) 100%);
  border: 1px solid var(--border);
  border-top: 2px solid var(--gold-dim);
  padding: 1.5rem 1.35rem;
  position: relative;
  transition: transform 0.25s, box-shadow 0.25s, border-top-color 0.25s;
}
.party-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0;
  transition: opacity 0.25s;
}
.party-card:hover { transform: translateY(-4px); box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 20px rgba(200,168,75,0.08); border-top-color: var(--gold); }
.party-card:hover::before { opacity: 1; }
.card-player {
  font-family: 'Cinzel', serif;
  font-size: 0.58rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 0.3rem;
}
.card-name {
  font-family: 'Cinzel Decorative', serif;
  font-size: 1.2rem;
  color: var(--gold-light);
  margin-bottom: 0.2rem;
  line-height: 1.2;
  border: none;
  padding: 0;
}
.card-class {
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 0.9rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.card-desc { font-size: 0.88rem; color: #b0a088; line-height: 1.6; }

.home-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(168,144,58,0.4);
}

@media (max-width: 768px) {
  .party-grid { grid-template-columns: 1fr; }
  .home-content { padding-top: 2rem; }
}
@media (min-width: 769px) and (max-width: 960px) {
  .party-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Oracle toggle button ── */
.oracle-toggle {
  position: fixed;
  bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  right: 1.5rem;
  z-index: 200;
  background: linear-gradient(135deg, #9a8232 0%, #d9c27a 50%, #9a8232 100%);
  border: 1px solid rgba(255,215,100,0.3);
  border-radius: 2rem;
  padding: 0.62rem 1.25rem;
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #180f04;
  cursor: pointer;
  min-height: var(--touch-min);
  touch-action: manipulation;
  box-shadow:
    0 4px 20px rgba(168,144,58,0.38),
    0 2px 8px rgba(0,0,0,0.55);
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
}
.oracle-toggle:hover {
  transform: translateY(-2px);
  box-shadow:
    0 7px 28px rgba(217,194,122,0.5),
    0 2px 8px rgba(0,0,0,0.55);
}
.oracle-toggle.hidden { opacity: 0; pointer-events: none; }

/* ── Oracle panel ── */
.oracle-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--oracle-w);
  /* height tracks visual viewport so keyboard doesn't obscure content */
  height: var(--viewport-height, 100dvh);
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 300;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  box-shadow: -6px 0 40px rgba(0,0,0,0.55);
}
.oracle-panel.open { transform: translateX(0); }

.oracle-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg);
  flex-shrink: 0;
}
.oracle-title {
  font-family: 'Cinzel', serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--gold);
}
.oracle-header-actions { display: flex; gap: 0.4rem; align-items: center; }
.oracle-btn {
  background: none;
  border: none;
  color: rgba(168,144,58,0.65);
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  padding: 0.5rem 0.6rem;
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  border-radius: 3px;
  touch-action: manipulation;
  transition: color 0.14s, background 0.14s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.oracle-btn:hover { color: var(--gold); background: var(--hover-bg); }
.oracle-btn-close { font-size: 1.1rem; font-family: sans-serif; }

/* ── Messages ── */
.oracle-messages {
  flex: 1;
  min-height: 0;        /* critical: allows flex child to shrink and scroll */
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-dim) transparent;
}
.oracle-messages::-webkit-scrollbar { width: 3px; }
.oracle-messages::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 2px; }

.oracle-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2.5rem 1rem;
  color: #7a6e55;
  gap: 0.8rem;
}
.oracle-welcome-icon { font-size: 2rem; opacity: 0.6; }
.oracle-welcome p {
  font-size: 0.88rem;
  line-height: 1.6;
  font-style: italic;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}
.msg-user  { align-self: flex-end;  align-items: flex-end;  }
.msg-oracle{ align-self: flex-start; align-items: flex-start; }
.msg-label {
  font-family: 'Cinzel', serif;
  font-size: 0.52rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 0.18rem;
  padding: 0 0.25rem;
}
.msg-bubble {
  padding: 0.52rem 0.8rem;
  border-radius: 7px;
  font-size: 0.94rem;
  line-height: 1.65;
}
.msg-user .msg-bubble {
  background: rgba(168,144,58,0.13);
  border: 1px solid rgba(168,144,58,0.22);
  color: var(--gold-light);
}
.msg-oracle .msg-bubble {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  color: var(--text);
  white-space: pre-wrap;
}
/* Streaming cursor */
.msg-oracle.streaming .msg-bubble::after {
  content: '▋';
  animation: blink 0.75s step-end infinite;
  color: var(--gold-dim);
  margin-left: 1px;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }
.oracle-searching { color: var(--gold-dim); font-style: italic; opacity: 0.75; }

/* ── Oracle input ── */
.oracle-input-wrap {
  padding: 0.65rem 0.75rem;
  padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-shrink: 0;
}
.oracle-input {
  flex: 1;
  min-width: 0;           /* prevents flex blowout */
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-family: 'EB Garamond', serif;
  /* 1rem = 18px — explicitly above 16px to prevent iOS zoom */
  font-size: max(1rem, 1rem);
  line-height: 1.4;
  resize: none;
  outline: none;
  max-height: 7.5rem;     /* ~120px */
  transition: border-color 0.15s;
  /* smooth rendering on webkit */
  -webkit-appearance: none;
}
.oracle-input:focus { border-color: var(--gold-dim); }
.oracle-input::placeholder { color: rgba(247,248,242,0.28); }
.oracle-send {
  background: var(--gold-dim);
  border: none;
  border-radius: 6px;
  padding: 0 0.9rem;
  height: 2.5rem;
  min-width: var(--touch-min);
  color: #180f04;
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
  transition: background 0.15s;
  align-self: flex-end;
  flex-shrink: 0;
}
.oracle-send:hover { background: var(--gold); }
.oracle-send:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #1c1008;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  width: min(460px, 93vw);
  box-shadow: 0 10px 50px rgba(0,0,0,0.75);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.modal-title {
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  color: var(--gold);
  letter-spacing: 0.05em;
}
.modal-sub {
  font-size: 0.82rem;
  color: #7a6e55;
  margin-bottom: 0.2rem;
}
.modal-textarea, .modal-input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.55rem 0.8rem;
  color: var(--text);
  font-family: 'EB Garamond', serif;
  /* explicitly >= 16px to prevent iOS zoom on focus */
  font-size: 1rem;
  outline: none;
  -webkit-appearance: none;
  transition: border-color 0.15s;
}
.modal-textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.modal-textarea:focus, .modal-input:focus { border-color: var(--gold-dim); }
.modal-textarea::placeholder, .modal-input::placeholder { color: rgba(247,248,242,0.28); }
.modal-actions { display: flex; gap: 0.55rem; justify-content: flex-end; margin-top: 0.3rem; }

.btn-primary, .btn-ghost {
  border-radius: 4px;
  padding: 0.5rem 1.1rem;
  min-height: var(--touch-min);
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary {
  background: var(--gold-dim);
  border: none;
  color: #180f04;
  font-weight: 700;
}
.btn-primary:hover { background: var(--gold); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: rgba(168,144,58,0.65);
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.62);
  z-index: 99;
}

/* ── Ember particles ── */
@keyframes pdb-rise {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  10%  { opacity: 0.75; }
  90%  { opacity: 0.25; }
  100% { transform: translateY(-100vh) translateX(30px); opacity: 0; }
}
.pdb-ember {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  animation: pdb-rise linear infinite backwards;
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-wrap { margin-left: 0; }
  .menu-toggle { display: flex; }
  .bg-watermark { left: 0; }
  .content {
    padding: 1.5rem 1.1rem calc(4rem + env(safe-area-inset-bottom, 0px));
  }

  /* Oracle panel: slide up from bottom on mobile so keyboard shrinks it correctly */
  .oracle-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    /* height tracks visual viewport — JS updates --viewport-height on keyboard open/close */
    height: var(--viewport-height, 100dvh);
    max-height: var(--viewport-height, 100dvh);
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 0.75rem 0.75rem 0 0;
    transform: translateY(100%);
    box-shadow: 0 -4px 30px rgba(0,0,0,0.5);
  }
  .oracle-panel.open { transform: translateY(0); }

  .oracle-toggle {
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    right: 1rem;
    font-size: 0.72rem;
    padding: 0.52rem 1rem;
  }
}

@media (max-width: 480px) {
  .prose h1 { font-size: 1.6rem; }
  .prose h2 { font-size: 1.25rem; }
  .prose h3 { font-size: 1.05rem; }
  .content { padding: 1.2rem 0.9rem calc(4rem + env(safe-area-inset-bottom, 0px)); }
}
