/* The shared manuscript of adventures. Saved names, artwork and message colors
   remain content: only interface surfaces are styled here. */
body.adventure-grimoire {
  --gr-paper: #e6d1a3; --gr-page: #f3e5be; --gr-raised: #faf0d2;
  --gr-ink: #35271d; --gr-muted: #6d5740; --gr-wax: #792f39;
  --gr-gold: #95713c; --gr-line: rgba(112,78,39,.3);
  --gr-success: #386047; --gr-danger: #963a38; --gr-warning: #815421;
  --gr-heading: 'Cinzel', Georgia, serif;
  --gr-reading: 'EB Garamond', Georgia, serif;
  --gr-ui: 'Manrope', 'Segoe UI', system-ui, sans-serif;
  --ui-focus: var(--gr-wax);
  --imaginarium-bg: var(--gr-paper); --imaginarium-bg-alt: #ddc594;
  --imaginarium-panel: var(--gr-page); --imaginarium-card: var(--gr-raised);
  --imaginarium-border: var(--gr-line); --imaginarium-accent: var(--gr-wax);
  --imaginarium-accent2: var(--gr-gold); --imaginarium-text: var(--gr-ink);
  --imaginarium-danger: var(--gr-danger);
  margin: 0; width: 100%; min-height: 100dvh;
  font-family: var(--gr-reading); color: var(--gr-ink); color-scheme: light;
  background-color: var(--gr-paper);
  background-image: url('codex-paper-grain.svg'),
    radial-gradient(ellipse at 0% 15%, #966a3733, transparent 40%),
    radial-gradient(ellipse at 100% 85%, #966a3740, transparent 45%),
    linear-gradient(110deg, #dac08e, #f0dfb8 26%, #e6d1a3 80%, #caaa72);
  background-size: 512px 512px, auto, auto, auto;
  background-attachment: scroll;
}
body.adventure-grimoire :is(#background-glow,#particles-container,#mystic-veil) { display: none !important; }
body.adventure-grimoire :is(h1,h2,h3,h4,h5,h6) { color: var(--gr-wax); text-shadow: none; }
body.adventure-grimoire :is(h1,h2,h3) { font-family: var(--gr-heading); }
body.adventure-grimoire a { color: var(--gr-wax); text-underline-offset: .2em; }
body.adventure-grimoire :is(input,textarea,select,[contenteditable=true]) { accent-color: var(--gr-wax); }
body.adventure-grimoire :is(.form-control,select,input[type=text],input[type=url],input[type=number],textarea) {
  color: var(--gr-ink); background-color: var(--gr-raised);
  border-color: var(--gr-line); font-size: 16px; border-radius: 6px;
}
body.adventure-grimoire :is(input,textarea)::placeholder { color: #79654d; opacity: 1; }
body.adventure-grimoire :is(input,select,textarea):disabled { opacity: .65; cursor: not-allowed; }
body.adventure-grimoire :is(.btn,.hero-btn,.cast-btn,.rpi-btn,.back-link,.cast-back-link) {
  min-height: 42px; border-radius: 6px; font-family: var(--gr-ui);
  font-size: .82rem; font-weight: 650; line-height: 1.4;
  white-space: normal; text-shadow: none;
  transition: background-color .16s, border-color .16s, box-shadow .16s;
}
body.adventure-grimoire :is(.btn-primary,.btn-success,.hero-btn.primary,.cast-btn-primary,.rpi-btn.primary,.scn-create-btn,.btn-save) {
  color: #f9edce !important; background: linear-gradient(135deg,#74303a,#90463e) !important;
  border: 1px solid #692833 !important;
  box-shadow: 0 3px 9px #60332724 !important;
}
body.adventure-grimoire :is(.btn-primary,.btn-success,.hero-btn.primary,.cast-btn-primary,.rpi-btn.primary):hover { filter: brightness(1.08); }
body.adventure-grimoire :is(.btn-secondary,.btn-outline-info,.btn-outline-primary,.btn-outline-light,.btn-outline-secondary,.hero-btn.secondary,.cast-back-link,.rpi-btn:not(.primary)) {
  color: var(--gr-wax); border-color: var(--gr-line); background: #f3e5be;
  box-shadow: none; text-decoration: none;
}
body.adventure-grimoire :is(.btn-warning,.hero-btn.warning) { background: #e1c28a; color: #523816; border-color: #b99354; }
body.adventure-grimoire :is(.btn-danger,.btn-outline-danger) { color: var(--gr-danger); background: #f2d9be; border-color: #963a3866; }
body.adventure-grimoire :is(.text-muted,.small.text-muted) { color: var(--gr-muted) !important; }
body.adventure-grimoire :is(.alert,.cast-alert,.rpi-status-text.error) {
  border-radius: 6px; box-shadow: none; background: #f0dfb8;
  border: 1px solid var(--gr-line); color: var(--gr-ink);
}
body.adventure-grimoire :is(.alert-danger,.field-error,.cast-alert-danger) { color: #893432; }
body.adventure-grimoire :is(.alert-success,.cast-alert-success) { color: var(--gr-success); background: #e2e4bc; }
/* Ink, leather and tarnished gold frame the shared navigation. */
body.adventure-grimoire .mobile-bottom-nav { background: #36271ff7 !important; border-top-color: #a78346 !important; }
body.adventure-grimoire .mobile-bottom-nav-item { color: #eddfba !important; }
body.adventure-grimoire .mobile-bottom-nav-item img { filter: sepia(.55) saturate(.6); }
body.adventure-grimoire .hex-btn-label { background: #36271f; color: #f9edce; }
body.adventure-grimoire .grimoire-shell {
  position: relative; z-index: 1; width: min(1320px,calc(100% - 48px));
  margin: 84px auto 32px; padding: clamp(18px,3vw,38px);
  border: 1px solid #aa8450; border-radius: 7px 14px 9px 5px;
  background: url('codex-paper-wear.svg') center/100% 100%, #f3e5bee8;
  box-shadow: 0 15px 50px #63402226, inset 0 0 36px #a1783324;
}
body.adventure-grimoire .grimoire-shell::before {
  content: ''; position: absolute; inset: 7px; border: 1px solid #95713c55;
  border-radius: inherit; pointer-events: none;
}
body.adventure-grimoire .grimoire-chapter {
  display: flex; align-items: center; gap: 16px; margin-bottom: 26px;
  padding-bottom: 20px; border-bottom: 1px solid var(--gr-line);
}
body.adventure-grimoire .grimoire-chapter::before {
  content: ''; width: 58px; height: 58px; flex: 0 0 58px;
  background: url('codex-rune-seal.svg') center/contain no-repeat;
}
body.adventure-grimoire .grimoire-chapter h1 { font-size: clamp(1.45rem,2.8vw,2.25rem); margin: 0 0 5px; text-align: left; }
body.adventure-grimoire .grimoire-eyebrow { margin: 0 0 5px; font: 600 .65rem var(--gr-ui); letter-spacing: .16em; text-transform: uppercase; color: var(--gr-gold); }
body.adventure-grimoire .grimoire-chapter p:not(.grimoire-eyebrow) { margin: 0; color: var(--gr-muted); font-size: 1.08rem; }
body.adventure-grimoire .grimoire-index {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 12px 0; margin-bottom: 22px; border-bottom: 1px solid var(--gr-line);
  font: .78rem var(--gr-ui);
}
body.adventure-grimoire .grimoire-index a { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 9px 14px; border: 1px solid var(--gr-line); border-radius: 5px; text-decoration: none; background: #f5e9c9; }
body.adventure-grimoire .grimoire-index a:hover { background: #e9d3a4; }
body.adventure-grimoire .grimoire-index a[aria-current] { color: #f9edce; background: var(--gr-wax); border-color: var(--gr-wax); }
/* All scenario management surfaces belong to the same manuscript, including
   dialogs built dynamically by the existing chat and context-menu scripts. */
body.adventure-grimoire :is(.modal-content,.ui-modal-box,.smod-dialog,.mp-modal,.ctx-menu,.hd-panel,.lore-detail-modal) {
  --ui-focus: var(--gr-wax); color: var(--gr-ink);
  background: url('codex-paper-grain.svg') repeat, #f3e5be;
  border: 1px solid #b2935b; box-shadow: 0 20px 60px #35271d55;
}
body.adventure-grimoire :is(.modal-header,.modal-footer,.mp-head,.smod-header,.smod-tabs) { color: var(--gr-wax); background: #e5d1a5; border-color: var(--gr-line); }
body.adventure-grimoire :is(.modal-title,.ui-modal-title,.mp-title,.smod-title) { color: var(--gr-wax); text-shadow: none; }
body.adventure-grimoire :is(.mp-overlay,.ui-modal-overlay,.thread-modal) { --ui-focus: var(--gr-wax); }
body.adventure-grimoire .smod-overlay { z-index: var(--layer-dialog,12000); }
body.adventure-grimoire :is(.mp-quota,.mp-search,.mp-item,.mp-foot,.smod-search,.smod-member,.smod-role,.smod-role-editor,.smod-panel,.ui-modal-body,.ctx-item) { color: var(--gr-ink); background-color: #f3e5be; border-color: var(--gr-line); }
body.adventure-grimoire :is(.mp-empty,.mp-quota-text,.smod-subtitle,.smod-hint,.smod-member-meta) { color: var(--gr-muted); }
body.adventure-grimoire :is(.mp-btn,.mp-close,.smod-close,.smod-tab,.smod-btn,.ui-modal-btn,.ctx-item) { color: var(--gr-wax); border-color: var(--gr-line); min-height: 40px; }
body.adventure-grimoire :is(.mp-btn.primary,.smod-btn.primary,.ui-modal-btn.primary,.smod-tab.is-active) { color: #f9edce; background: var(--gr-wax); }
body.adventure-grimoire :is(.mp-quota-fill,.mp-item.selected) { border-color: var(--gr-wax); }
body.adventure-grimoire .mp-quota-fill { background: var(--gr-gold); }
body.adventure-grimoire .mp-grid-wrap.drag-over { background: #e5d1a5; border-color: var(--gr-wax); }
body.adventure-grimoire :is(.ctx-menu-item,.ui-modal-close) { color: var(--gr-ink); min-height: 40px; }
body.adventure-grimoire .ctx-menu-item:hover { background: #e5d1a5; color: var(--gr-wax); }
body.adventure-grimoire :is(.ui-modal-input,.ui-modal-select) { background: var(--gr-raised); color: var(--gr-ink); border-color: var(--gr-line); }
body.adventure-grimoire .grimoire-skip { position: fixed; left: 12px; top: 12px; transform: translateY(-160%); padding: 12px 16px; z-index: 16000; background: var(--gr-page); }
body.adventure-grimoire .grimoire-skip:focus { transform: none; }
@media(max-width:767px) {
  body.adventure-grimoire:not(.chat-grimoire) { padding-bottom: calc(86px + env(safe-area-inset-bottom)) !important; }
  body.adventure-grimoire .grimoire-shell { width: calc(100% - 16px); margin: 10px auto 18px; padding: 18px 14px; }
  body.adventure-grimoire .grimoire-chapter { gap: 10px; margin-bottom: 18px; padding-bottom: 14px; }
  body.adventure-grimoire .grimoire-chapter::before { width: 42px; height: 42px; flex-basis: 42px; }
  body.adventure-grimoire .grimoire-index { gap: 6px; }
  body.adventure-grimoire .grimoire-index a { padding: 8px 10px; }
}
@media(prefers-reduced-motion:reduce) {
  body.adventure-grimoire *, body.adventure-grimoire *::before, body.adventure-grimoire *::after { scroll-behavior: auto !important; }
}
@media print {
  body.adventure-grimoire { background: white; color: #35271d; }
  body.adventure-grimoire :is(.portal-header,.mobile-bottom-nav,.codex-magic,.grimoire-index) { display:none !important; }
  body.adventure-grimoire .grimoire-shell { margin: 0; width: 100%; border: none; box-shadow: none; background: white; }
}
