﻿/* Fonts (EB Garamond + IM Fell English) are loaded via <link> in Layout.astro */

/* ── Lenis smooth scroll ────────────────────────────────────────────────────── */
html.lenis, html.lenis body { height: auto; }
.lenis:not(.lenis-autoToggle).lenis-stopped { overflow: clip; }
.lenis [data-lenis-prevent],
.lenis [data-lenis-prevent-wheel],
.lenis [data-lenis-prevent-touch] { overscroll-behavior: contain; }
.lenis.lenis-smooth iframe { pointer-events: none; }

:root {
  --bg: #1a1a1a;
  --text: #f4e6d7;
  --accent: #ffcc66;
  --panel: #1c1c1a;
  --panel-alt: #242422;
  --shadow: rgba(0, 0, 0, 0.5);
  --font: 'EB Garamond', 'Garamond', Georgia, serif;
  --title: 'IM Fell English', 'Garamond', serif;
  /* Clean modern sans for UI chrome (nav, labels) where serif is hard to scan */
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --muted: #888880;

  /* RGB triplets for alpha tints: rgba(var(--accent-rgb), 0.12) etc. */
  --accent-rgb: 255, 204, 102;
  --bronze-rgb: 200, 164, 92;

  /* ── Design system tokens (DESIGN.md) ───────────────────────────────────── */
  /* Neutrals & surfaces (vault → near-void) */
  --ivory:          #f4e6d7;
  --bronze:         #c8a45c;   /* attunement / weighty warm accent — NOT amber */
  --crypt-surface:  #161615;   /* deepest surface: modal headers, inner sections */
  --leather-border: #312c22;   /* default border on inputs, cards, dividers — bronze-tinted grey (solid equiv of rgba(200,164,92,0.12) over #1c1c1a; also used as a solid bg) */
  --smoke:          #888888;   /* secondary text, labels, tab defaults */
  --deep-smoke:     #555555;   /* tertiary text, disabled, placeholders */

  /* Status */
  --health-green: #66bb6a;
  --hazard-red:   #e05050;

  /* Rarity covenant — items & spells only */
  --rarity-common:    #9e9e9e;
  --rarity-uncommon:  #4caf50;
  --rarity-rare:      #2196f3;
  --rarity-very-rare: #9c27b0;
  --rarity-legendary: #ff9800;

  /* Radii */
  --rounded-sm:   6px;
  --rounded-md:   8px;
  --rounded-lg:   12px;
  --rounded-xl:   16px;
  --rounded-pill: 20px;

  /* Shadow vocabulary */
  --shadow-panel:      0 4px 10px rgba(0,0,0,0.4);
  --shadow-hero:       0 6px 14px rgba(0,0,0,0.45);
  --shadow-card-hover: 0 6px 22px rgba(0,0,0,0.5);
  --shadow-modal:      0 12px 48px rgba(0,0,0,0.8);
  --shadow-nav:        0 2px 16px rgba(0,0,0,0.6);
  --glow-amber:        0 0 18px rgba(200,164,92,0.35);

  /* Spacing scale */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  40px;
  --space-2xl: 64px;
  --space-3xl: 96px;

  /* Layout */
  --page-width:   min(1400px, 100%);
  --page-padding: clamp(16px, 4vw, 40px);

  /* Easing */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo:  cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

/* ── Custom scrollbar ───────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #161615;
}
::-webkit-scrollbar-thumb {
  background: #454138;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--bronze);
}
::-webkit-scrollbar-corner {
  background: transparent;
}
/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: #454138 #161615;
}

iconify-icon {
  display: inline-block;
  vertical-align: -0.125em;
}

body {
  font-family: var(--font-ui);
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
}

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

a:hover {
  color: var(--accent);
}

nav {
  background: linear-gradient(180deg, #1c1c1a 0%, #131312 100%);
  border-bottom: 1px solid var(--leather-border);
  padding: 10px 24px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.6);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
}

.nav-logo {
  height: 50px;
  width: auto;
  flex-shrink: 0;
  margin-right: 8px;
  display: block;
}

nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}

/* Hidden by default; base.js un-hides for admins */
nav li.nav-dm-only { display: none; }

nav a {
  text-decoration: none;
  font-size: 15px;
  font-family: var(--title);
  letter-spacing: 0.06em;
  color: #b8986a;
  padding: 14px 18px;
  display: block;
  position: relative;
  transition: color 0.25s var(--ease-out-expo), text-shadow 0.25s var(--ease-out-expo), transform 0.2s var(--ease-out-expo);
}

nav a::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 18px;
  right: 18px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  transform: scaleX(0);
  transition: transform 0.28s var(--ease-out-expo);
}

nav a:hover {
  color: var(--accent);
  text-shadow: 0 0 20px rgba(var(--accent-rgb), 0.45), 0 0 40px rgba(var(--accent-rgb), 0.15);
}

nav a:hover::after {
  transform: scaleX(1);
}

nav a.active {
  color: var(--accent);
  text-shadow: 0 0 16px rgba(var(--accent-rgb), 0.3);
}

nav a.active::after {
  transform: scaleX(1);
}

/* Username link injected by base.js — smaller, right-aligned, underline on hover */
nav .nav-username-link {
  font-size: 13px;
  padding: 5px 8px;
  color: #c9a87a;
  letter-spacing: 0;
}
nav .nav-username-link::after { display: none; }
nav .nav-username-link:hover {
  color: var(--accent);
  text-shadow: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}

section {
  padding: 40px;
  margin: auto;
  max-width: 100vw;
  text-align: center;
}

img {
  max-width: 100%;
  height: auto;
}

.toggle-content.hidden {
  display: none;
}

/* ── Shared filter/sort bar + gold "add" button ─────────────────────────────── */
/* Used by items, lore, spells, exploration, missions and inventory. Pages keep
   only their deltas (margins, label color, hover glow) in their own CSS. */
.items-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(var(--bronze-rgb), 0.08);
  border-radius: var(--rounded-md);
  margin-bottom: 10px;
}

.filter-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #8a8070;
  margin-right: 4px;
}

.items-sort-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.items-btn-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #8a6010 0%, #c8922a 40%, #e0b040 60%, #b07820 100%);
  border: 1px solid rgba(220,170,60,0.6);
  border-radius: var(--rounded-md);
  color: #0e0e0d;
  font-family: var(--title);
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 7px 14px;
  cursor: pointer;
  transition: filter 0.22s, box-shadow 0.25s, transform 0.2s;
  white-space: nowrap;
}
.items-btn-add:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 14px rgba(221,88,26,0.32), 0 4px 16px rgba(0,0,0,0.4);
  transform: translateY(-1px);
}
.items-btn-add:active { transform: translateY(0) scale(0.98); }

/* ── Give-to-player floating panel (shared) ─────────────────────────────────── */
.give-panel {
  display: none;
  position: absolute;
  z-index: 700;
  /* Grey glow theme — matches the item detail / editor slideouts. */
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(var(--accent-rgb), 0.10), transparent 60%),
    linear-gradient(180deg, #1b1e24 0%, #151513 60%, #121210 100%);
  border: 1px solid rgba(var(--bronze-rgb), 0.22);
  border-radius: 10px;
  min-width: 200px;
  box-shadow:
    0 12px 36px rgba(0,0,0,0.6),
    0 0 22px -6px rgba(var(--accent-rgb), 0.18),
    inset 0 1px 0 rgba(var(--accent-rgb), 0.06);
  overflow: hidden;
}
.give-panel.open { display: block; }

.give-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 13px 8px;
  border-bottom: 1px solid rgba(var(--bronze-rgb), 0.16);
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 100%);
}
.give-panel-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(var(--accent-rgb), 0.25);
}
.give-panel-close {
  background: none; border: none;
  color: rgba(200,210,228,0.5); cursor: pointer; font-size: 13px;
  padding: 0 2px;
  transition: color 0.15s;
}
.give-panel-close:hover { color: var(--accent); }

.give-panel-list { padding: 6px; }

.give-panel-player {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: 1px solid transparent;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 7px 8px;
  cursor: pointer;
  border-radius: var(--rounded-sm);
  text-align: left;
  transition:
    background 0.2s var(--ease-out-expo),
    border-color 0.2s var(--ease-out-expo),
    transform 0.18s var(--ease-out-expo);
  transform: translateX(0);
}
.give-panel-player:hover:not(:disabled) {
  background: rgba(var(--accent-rgb), 0.08);
  border-color: rgba(var(--bronze-rgb), 0.25);
  transform: translateX(3px);
}
.give-panel-player:disabled { opacity: 0.5; cursor: default; }

.give-panel-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--pc, var(--smoke));
  box-shadow: 0 0 8px var(--pc, transparent);
  flex-shrink: 0;
}
.give-panel-name { flex: 1; }
.give-panel-role { font-size: 10px; color: rgba(200,210,228,0.4); }

.give-panel-empty { font-size: 12px; color: rgba(200,210,228,0.45); font-style: italic; padding: 6px 8px; margin: 0; }

.give-panel-feedback {
  font-size: 12px;
  text-align: center;
  padding: 6px 12px;
  display: none;
}
.give-panel-feedback.success { display: block; color: #6ad06a; background: rgba(80,192,80,0.08); }
.give-panel-feedback.error   { display: block; color: #e86b6b; background: rgba(200,50,50,0.08); }

.give-btn {
  background: rgba(80,192,80,0.08);
  border: 1px solid rgba(80,192,80,0.3);
  border-radius: 5px;
  color: #50c050;
  font-family: var(--font-ui);
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.give-btn:hover { background: rgba(80,192,80,0.15); border-color: #50c050; }

/* ── Rarity tag colours (shared across items + shop modal) ── */
.item-tag { font-size: 13px; border-radius: 10px; padding: 1px 8px; font-family: sans-serif; letter-spacing: 0.04em; }
.rarity-tag-common    { background: rgba(158,158,158,0.20); border: 1px solid rgba(158,158,158,0.65); color: #bdbdbd; }
.rarity-tag-uncommon  { background: rgba(76,175,80,0.20);   border: 1px solid rgba(76,175,80,0.70);   color: var(--health-green); }
.rarity-tag-rare      { background: rgba(33,150,243,0.20);  border: 1px solid rgba(33,150,243,0.70);  color: #56b4ff; }
.rarity-tag-very-rare { background: rgba(156,39,176,0.20);  border: 1px solid rgba(156,39,176,0.65);  color: #bb52d4; }
.rarity-tag-legendary { background: rgba(255,152,0,0.20);   border: 1px solid rgba(255,152,0,0.72);   color: #ffac20; }

/* ── Hamburger button (hidden on desktop) ─────────────────────────────────── */
.nav-hamburger {
  display: none;
  background: none;
  border: 1px solid var(--leather-border);
  border-radius: var(--rounded-sm);
  padding: 6px 9px;
  cursor: pointer;
  margin-left: auto;
  flex-direction: column;
  gap: 5px;
}

.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #c9a87a;
  border-radius: 2px;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

/* Animate to X when open */
nav.nav-open .nav-hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
nav.nav-open .nav-hamburger span:nth-child(2) { opacity: 0; }
nav.nav-open .nav-hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Nav backdrop (mobile drawer overlay) ────────────────────────────────── */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 98;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.nav-backdrop.open { display: block; }

/* ── Shared page hero ─────────────────────────────────────────────────────── */
.page-hero {
  background: linear-gradient(180deg, #312c22 0%, #1c1c1a 50%, var(--bg) 100%);
  padding: 40px 20px 28px;
  text-align: center;
  position: relative;
  border-bottom: 1px solid var(--leather-border);
}

.page-hero__title {
  font-family: var(--title);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  color: var(--accent);
  margin: 0 0 6px;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-shadow: 0 2px 24px rgba(var(--accent-rgb), 0.12);
}

.page-hero__sub {
  font-size: 14px;
  color: #7a6a58;
  font-style: italic;
  margin: 0;
}

.page-hero__add-btn {
  position: absolute;
  top: 16px;
  right: 20px;
}

/* ── Shared dm-btn (ghost/outlined) ─────────────────────────────────────── */
.dm-btn {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0.03em;
  padding: 8px 18px;
  background: rgba(var(--accent-rgb), 0.12);
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  color: var(--accent);
  border-radius: var(--rounded-sm);
  cursor: pointer;
  transition: background 0.22s var(--ease-out-expo),
              border-color 0.22s var(--ease-out-expo),
              box-shadow 0.28s var(--ease-out-expo),
              transform 0.22s var(--ease-out-expo);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
  transform: translateY(0);
}
.dm-btn:hover {
  background: rgba(var(--accent-rgb), 0.2);
  border-color: var(--accent);
  box-shadow: 0 6px 20px rgba(var(--accent-rgb), 0.2), 0 2px 8px rgba(0,0,0,0.4);
  transform: translateY(-2px);
}
.dm-btn:active { transform: translateY(0) scale(0.96); }
.dm-btn-sm { font-size: 12px; padding: 4px 12px; }

/* Secondary (filled) variant */
.dm-btn-secondary {
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--deep-smoke);
}
.dm-btn-secondary:hover { background: #3a382f; }

/* Active/toggled state (red outline) */
.dm-btn.active {
  background: rgba(229,115,115,0.15);
  border-color: #e57373;
  color: #e57373;
  box-shadow: none;
}
.dm-btn.active:hover {
  background: rgba(229,115,115,0.25);
  border-color: #ef9a9a;
  color: #ef9a9a;
}

/* ── Shared header search bar ───────────────────────────────────────────
   Canonical search component. Page CSS should NOT redefine these selectors;
   use page-specific class names for page-specific search widgets instead. */
.hdr-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.hdr-search-icon {
  position: absolute;
  left: 9px;
  font-size: 13px;
  color: rgba(200,180,140,0.5);
  pointer-events: none;
  z-index: 1;
}
.items-search {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(var(--bronze-rgb), 0.2);
  border-radius: var(--rounded-md);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 7px 12px 7px 30px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 200px;
}
.items-search:focus {
  border-color: rgba(var(--bronze-rgb), 0.5);
  box-shadow: 0 0 0 3px rgba(var(--bronze-rgb), 0.12);
}
/* Keyboard focus: rely on the field's own rounded ring (which follows its
   border-radius) instead of the generic offset outline below — that outline
   draws a rectangle that doesn't match the pill-shaped mobile search docks. */
.items-search:focus-visible { outline: none; }
.items-search::placeholder { color: rgba(200,180,150,0.4); }

/* Clear (×) button inside the search field */
.hdr-search-wrap .items-search { padding-right: 30px; }
.search-clear-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.search-clear-btn.visible { display: inline-flex; }
.search-clear-btn:hover { background: rgba(255,255,255,0.22); color: #fff; }
.search-clear-btn iconify-icon { font-size: 13px; }

@media (max-width: 768px) {
  section {
    padding: 24px 16px;
  }

  .page-hero {
    padding: 24px 16px 16px;
  }

  .page-hero__add-btn {
    position: static;
    display: block;
    margin: 0 auto 12px;
  }

  .dm-btn {
    min-height: 44px;
  }
}

@media (max-width: 768px) {
  /* Slim sticky nav bar — logo hidden, just the hamburger */
  nav {
    height: 52px;
    padding: 0 16px;
    overflow: visible;
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(180deg, #1c1c1a 0%, #131312 100%);
    border-bottom: 1px solid var(--leather-border);
    box-shadow: 0 2px 16px rgba(0,0,0,0.6);
  }

  .nav-logo {
    height: 34px;
  }

  /* Hamburger — fixed so it stays above the drawer, vertically centred in the 52px bar */
  .nav-hamburger {
    display: flex;
    position: fixed;
    top: 10px;
    right: 14px;
    z-index: 200;
    background: rgba(14, 14, 13, 0.88);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid #3a382f;
    border-radius: var(--rounded-md);
    padding: 8px 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.55);
  }

  /* Right-side drawer */
  nav ul {
    position: fixed;
    top: 0;
    right: 0;
    height: 100dvh;
    width: 72%;
    max-width: 280px;
    flex-direction: column;
    gap: 0;
    padding: 72px 0 24px;
    background: linear-gradient(180deg, #1c1c1a 0%, #131312 100%);
    border-left: 1px solid var(--leather-border);
    box-shadow: -4px 0 24px rgba(0,0,0,0.7);
    z-index: 199;
    transform: translateX(100%);
    transition: transform 0.32s var(--ease-out-expo);
    overflow-y: auto;
    display: flex;
  }

  nav.nav-open ul {
    transform: translateX(0);
  }

  nav ul li {
    width: 100%;
  }

  /* Override the auto-margin on the user li so it doesn't break layout */
  nav ul li[style*="margin-left:auto"],
  nav ul li[style*="margin-left: auto"] {
    margin-left: 0 !important;
    border-top: 1px solid var(--panel-alt);
    margin-top: auto;
  }

  nav a {
    font-size: 16px;
    padding: 14px 22px;
    display: block;
    border-radius: 0;
  }

  nav a::after { display: none; }

  nav a:hover,
  nav a.active {
    background: rgba(var(--bronze-rgb), 0.1);
  }
}

/* ── Keyboard focus ─────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── Motion system ──────────────────────────────────────────────────────────── */

@keyframes motionFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Canonical page/section entrances — shared by all pages. Do not redefine
   per-page copies (pages co-load stylesheets via extraCSS, and duplicate
   keyframe names silently override each other). */
@keyframes motionPageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

@keyframes motionModalIn {
  from { opacity: 0; transform: scale(0.88) translateY(28px); filter: blur(6px); }
  to   { opacity: 1; transform: scale(1)    translateY(0);    filter: blur(0px); }
}

@keyframes motionSheetUp {
  from { opacity: 0; transform: translateY(52px); filter: blur(4px); }
  to   { opacity: 1; transform: translateY(0);    filter: blur(0px); }
}

@keyframes motionHeroIn {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes motionGivePanelIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.92); filter: blur(4px); }
  to   { opacity: 1; transform: translateY(0)      scale(1);   filter: blur(0px); }
}

/* ── Glowing gradient-gold title ──────────────────────────────────────────────
   Shimmering molten-gold sheen + soft glow for the big page titles / headers.
   Applied generally to every main title class (plus the `.title-glow` opt-in
   class). !important so it wins over each page's own title colour / animation,
   including Astro-scoped component styles like .page-header-title.
   Don't add a title that contains an <iconify-icon> here — clipping the
   background to the text would make the icon invisible. */
@keyframes titleSheen {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

.title-glow,
.page-header-title,
.loc-title,
.hero-title,
.admin-title,
.login-title,
.setup-title,
.inv-viewer-name,
.modal-box h2,
.iem-title {
  background: linear-gradient(110deg, #b9822c 0%, #e9b34f 30%, #fffaf0 50%, #e9b34f 70%, #b9822c 100%) !important;
  background-size: 250% auto !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  color: transparent !important;
  filter: drop-shadow(0 0 12px rgba(var(--accent-rgb), 0.40));
  /* text-shadow bleeds through the transparent clipped glyphs and muddies the
     gold (each page's own shadow tinted it differently) — kill it everywhere. */
  text-shadow: none !important;
  will-change: background-position;
  animation: titleSheen 5s linear infinite !important;
}

/* Canonical modal title — every add/edit modal shares this shell (colour comes
   from the gold sheen block above; pages may override layout, never colour). */
.modal-box h2 {
  margin: 0 0 18px;
  font-family: var(--title);
  font-weight: normal;
  font-size: 23px;
  letter-spacing: 0.02em;
  text-align: center;
}

/* Titles that live inside a flex header bar centre on the bar — the 18px gap
   above only applies to titles sitting directly on top of modal content. */
.modal-header h2 { margin: 0; align-self: center; }

/* Overlay backdrop fades — enhanced with blur */
.modal-overlay.open      { animation: motionFadeIn 0.26s ease both; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.inv-overlay.open        { animation: motionFadeIn 0.26s ease both; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.char-modal-overlay.open { animation: motionFadeIn 0.26s ease both; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.nav-backdrop.open       { animation: motionFadeIn 0.28s ease both; }

/* Modal / panel entrances — cinematic */
.modal-overlay.open .modal-box { animation: motionModalIn 0.48s var(--ease-out-expo) both; }
.inv-overlay.open .inv-modal   { animation: motionModalIn 0.48s var(--ease-out-expo) both; }
.give-panel.open               { animation: motionGivePanelIn 0.28s var(--ease-out-expo) both; }

/* Page and section hero entrances */
.page-hero { animation: motionHeroIn 0.55s var(--ease-out-expo) both; }
.hero      { animation: motionHeroIn 0.55s var(--ease-out-expo) both; }

/* Mobile: inventory modal slides up as a bottom sheet */
@media (max-width: 700px) {
  .inv-overlay.open .inv-modal { animation: motionSheetUp 0.42s var(--ease-out-expo) both; }
}

/* ── Card shimmer (JS-driven, .motion-shimmer added by base.js) ─────────────── */
.motion-shimmer::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    circle at var(--shine-x, 50%) var(--shine-y, 50%),
    rgba(var(--accent-rgb), 0.055) 0%,
    transparent 62%
  );
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.motion-shimmer:hover::before { opacity: 1; }

/* ── Reduced motion ──────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── App shell layout ────────────────────────────────────────────────────────── */
html.app-layout,
html.app-layout body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

.app-shell {
  display: flex;
  height: 100vh;
  background: #131312;
}

.page-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
  min-width: 0;   /* flex items default to min-width:auto (min-content); without
                     this, a wide grid/content child blows the column out past
                     the viewport instead of shrinking to fit the shell */
  background: #141414;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #151513 0%, #151515 100%);
  border-right: 1px solid rgba(var(--bronze-rgb), 0.12);
  z-index: 10;
}

.sidebar-logo {
  padding: 28px 18px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.sidebar-logo img {
  height: 60px;
  width: auto;
}

.sidebar-wordmark {
  font-family: var(--title);
  font-size: 18px;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-align: center;
}

.sidebar-logo-ornament {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0 20px;
}

.sidebar-ornament-line {
  flex: 1;
  height: 1px;
  background: rgba(var(--bronze-rgb), 0.2);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--rounded-md);
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.22s, color 0.22s;
  position: relative;
  height: 50px;
  overflow: hidden;
}

.sidebar-nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  transform: scaleY(0);
  transform-origin: center;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s;
  opacity: 0;
}

.sidebar-nav-item:hover {
  background: rgba(var(--bronze-rgb), 0.09);
  color: var(--text);
  box-shadow: inset 0 0 20px rgba(var(--bronze-rgb), 0.04);
}

.sidebar-nav-item:hover::before {
  transform: scaleY(1);
  opacity: 0.6;
}

.sidebar-nav-item iconify-icon {
  transition: color 0.22s, filter 0.22s;
}

.sidebar-nav-item:hover iconify-icon {
  color: var(--accent) !important;
  filter: drop-shadow(0 0 4px rgba(var(--bronze-rgb), 0.45));
}

.sidebar-nav-item.active {
  background: rgba(var(--bronze-rgb), 0.1);
  color: var(--accent);
}

.sidebar-nav-item.active::before {
  transform: scaleY(1);
  opacity: 1;
}

/* Combat tab while a battle map is live — ember tint + pulsing dot. Players
   only get the tab at all during a battle (Sidebar.astro toggles it on
   campaigns/{cid}/battle/active); the DM's always-visible tab gains the same
   pulse so both sides can see at a glance that the board is up. */
.sidebar-nav-item.combat-live { color: #d98c7a; }
.sidebar-nav-item.combat-live:hover { color: #eaa392; }
.sidebar-nav-item.combat-live iconify-icon,
.sidebar-nav-item.combat-live:hover iconify-icon {
  color: #e05050 !important;
  filter: drop-shadow(0 0 4px rgba(224, 80, 80, 0.5));
}
.sidebar-nav-item.combat-live::after {
  content: '';
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-radius: 50%;
  background: #e05050;
  box-shadow: 0 0 8px rgba(224, 80, 80, 0.8);
  flex-shrink: 0;
  animation: combat-live-pulse 1.7s ease-in-out infinite;
}
@keyframes combat-live-pulse {
  0%, 100% { opacity: 1;    transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.75); }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar-nav-item.combat-live::after { animation: none; }
}

.sidebar-nav-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 4px;
  margin-top: 4px;
}

.sidebar-nav-divider-line {
  flex: 1;
  height: 1px;
  background: rgba(var(--bronze-rgb), 0.1);
}

.sidebar-nav-section-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(var(--bronze-rgb), 0.35);
  white-space: nowrap;
  font-family: var(--font-ui);
}

.sidebar-account-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 10px 16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 999px;
  padding: 7px 12px 7px 8px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
  min-width: 0;
  overflow: hidden;
}

.sidebar-account-btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(var(--bronze-rgb), 0.2);
}

.sidebar-account-btn.active {
  background: rgba(var(--bronze-rgb), 0.1);
  border-color: rgba(var(--bronze-rgb), 0.22);
}

.sidebar-account-btn.active:hover {
  background: rgba(var(--bronze-rgb), 0.16);
  border-color: rgba(var(--bronze-rgb), 0.35);
}

.sidebar-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-username {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Mobile top bar + drawer (hidden on desktop) ──────────────────────────── */
.mobile-topbar,
.mobile-nav-toggle,
.mobile-nav-backdrop { display: none; }

.mobile-topbar {
  align-items: center;
  gap: 8px;
  height: 54px;
  flex-shrink: 0;
  padding: 0 10px;
  background: linear-gradient(180deg, #151513 0%, #131311 100%);
  border-bottom: 1px solid rgba(var(--bronze-rgb), 0.12);
  z-index: 150;
}

/* Current section — orients the user without opening the drawer */
.mobile-topbar-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-family: var(--title);
  font-size: 17px;
  letter-spacing: 0.04em;
  color: var(--ivory);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-topbar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  text-decoration: none;
}

.mobile-topbar-logo img {
  height: 28px;
  width: auto;
}

.mobile-nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  align-items: center;
  background: none;
  border: 1px solid rgba(var(--bronze-rgb), 0.22);
  border-radius: var(--rounded-md);
  cursor: pointer;
  transition: border-color 0.2s var(--ease-out-expo), transform 0.16s var(--ease-out-expo);
}

.mobile-nav-toggle:hover { border-color: rgba(var(--bronze-rgb), 0.4); }
.mobile-nav-toggle:active { transform: scale(0.94); }

.mobile-nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: #c9a87a;
  border-radius: 2px;
  transition: transform 0.24s var(--ease-out-expo), opacity 0.24s var(--ease-out-expo);
}

.app-shell.nav-open .mobile-nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.app-shell.nav-open .mobile-nav-toggle span:nth-child(2) { opacity: 0; }
.app-shell.nav-open .mobile-nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 290;   /* above page-level floating UI (e.g. the combat dock, z260) */
  opacity: 0;
  transition: opacity 0.3s var(--ease-out-expo);
}
.app-shell.nav-open .mobile-nav-backdrop { opacity: 1; }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; height: 100dvh; }

  .mobile-topbar { display: flex; }

  .mobile-nav-backdrop { display: block; pointer-events: none; }
  .app-shell.nav-open .mobile-nav-backdrop { pointer-events: auto; }

  /* Sidebar becomes an off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    width: 84%;
    max-width: 270px;
    border-right: 1px solid rgba(var(--bronze-rgb), 0.18);
    box-shadow: 4px 0 28px rgba(0,0,0,0.7);
    transform: translateX(-100%);
    transition: transform 0.34s var(--ease-out-expo);
    z-index: 300;   /* stays above the backdrop (290) and any page dock (combat, z260) */
  }
  .app-shell.nav-open .sidebar { transform: translateX(0); }

  /* Drawer is open via JS, so no need for the desktop logo block to feel cramped */
  .sidebar-logo { padding: 22px 18px 18px; }
}

/* ── Prevent iOS auto-zoom on input focus ──────────────────────────────────
   Mobile Safari zooms the page in whenever a focused field renders below 16px.
   Forcing every form control to 16px on small screens stops that focus-zoom
   while leaving the user free to pinch-zoom (the viewport meta stays scalable). */
@media (max-width: 900px) {
  input,
  select,
  textarea {
    /* Must be ≥16px: iOS Safari zooms the page in on focus for anything smaller,
       and !important so the many compact component fields (12–14px) can't fall
       back below the threshold and re-trigger the zoom. */
    font-size: 16px !important;
  }
}

/* ════════════════════════════════════════════════════════════════════════════
   ITEM EDITOR — full-screen page (shared #item-modal / #qe-modal)
   Scoped under `.item-edit-modal`. Mirrors the shop editor: a grey page with a
   gold aurora and soft glow that sits beside the 220px nav. Everything the DM
   edits — identity, numbers, toggles, description, tags, abilities — is laid out
   across an identity sidebar + a two-column main area so the page fits one
   screen and barely scrolls.
   ════════════════════════════════════════════════════════════════════════════ */
.modal-overlay.item-edit-modal {
  left: 220px;
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
  background: rgba(8,8,7,0.5);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.item-edit-modal .modal-box.iem-box {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  border: none;
  border-radius: 0;
  padding: 0;
  overflow: hidden;
  position: relative;
  box-shadow: none;
  /* Grey page with a gold aurora from the top and a warm ember glow rising from
     the bottom corner — the same depth recipe as the shop page. */
  background:
    radial-gradient(130% 70% at 50% -12%, rgba(var(--iem-glow-rgb, var(--accent-rgb)), 0.14), transparent 60%),
    radial-gradient(90% 60% at 110% 115%, rgba(255,176,80,0.08), transparent 60%),
    linear-gradient(180deg, #1c1c1a 0%, #141413 52%, #0d0d0c 100%);
  animation: motionPageIn 0.34s var(--ease-out-expo);
}

/* Ambient gold orbs — the "glow". Behind the content, blurred, slow drift. */
.iem-bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.iem-orb {
  position: absolute;
  border-radius: 50%;
  /* --iem-glow-rgb is set by JS to the selected rarity's colour */
  background: radial-gradient(circle at 50% 50%, rgba(var(--iem-glow-rgb, var(--accent-rgb)), 0.55) 0%, transparent 70%);
  mix-blend-mode: screen;
  filter: blur(80px);
  opacity: 0.5;
  will-change: transform, opacity;
}
.iem-orb-1 { width: 620px; height: 620px; top: -10%; left: 4%;  animation: iemOrb1 18s ease-in-out infinite; }
.iem-orb-2 { width: 460px; height: 460px; top: 58%;  left: 60%; animation: iemOrb2 22s ease-in-out infinite; }
.iem-orb-3 { width: 380px; height: 380px; top: 24%;  left: 78%; opacity: 0.35; animation: iemOrb3 16s ease-in-out infinite; }
@keyframes iemOrb1 {
  0%   { transform: translate(0,0) scale(1);          opacity: 0.4; }
  50%  { transform: translate(80px,120px) scale(1.2); opacity: 0.55; }
  100% { transform: translate(0,0) scale(1);          opacity: 0.4; }
}
@keyframes iemOrb2 {
  0%   { transform: translate(0,0) scale(1);             opacity: 0.35; }
  50%  { transform: translate(-120px,-90px) scale(1.25); opacity: 0.5; }
  100% { transform: translate(0,0) scale(1);             opacity: 0.35; }
}
@keyframes iemOrb3 {
  0%   { transform: translate(0,0) scale(1);          opacity: 0.3; }
  50%  { transform: translate(60px,-80px) scale(1.3); opacity: 0.45; }
  100% { transform: translate(0,0) scale(1);          opacity: 0.3; }
}

/* Content sits above the glow and owns the scroll. */
.iem-shell {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Sticky page bar — back + title, then actions ── */
.iem-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px clamp(20px, 3.5vw, 44px);
  background: linear-gradient(180deg, rgba(20,20,18,0.96) 0%, rgba(20,20,18,0.7) 64%, transparent 100%);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  border-bottom: 1px solid rgba(var(--bronze-rgb), 0.12);
  box-shadow: 0 1px 16px -7px rgba(var(--accent-rgb), 0.55);
  flex-shrink: 0;
}
.iem-bar-lead { display: flex; align-items: center; gap: 14px; min-width: 0; }

.iem-back-btn {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: var(--accent);
  background: rgba(22,22,20,0.92);
  border: 1px solid rgba(var(--bronze-rgb), 0.42);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  cursor: pointer;
  transition: background 0.18s var(--ease-out-expo),
              border-color 0.18s var(--ease-out-expo),
              box-shadow 0.18s var(--ease-out-expo),
              transform 0.18s var(--ease-out-expo);
}
.iem-back-btn:hover {
  background: rgba(49, 44, 34,0.95);
  border-color: var(--accent);
  box-shadow: 0 6px 22px rgba(var(--bronze-rgb), 0.25), 0 2px 8px rgba(0,0,0,0.5);
  transform: translateY(-2px);
}
.iem-back-btn:active { transform: translateY(0) scale(0.94); }

/* h2 prefix keeps this at the same specificity as the canonical .modal-box h2
   block above — without it that rule's 18px bottom margin wins and shoves the
   bar title off-centre. */
h2.iem-title {
  margin: 0;
  align-self: center;
  font-family: var(--title);
  font-weight: 400;
  font-size: clamp(1.2rem, 2.2vw, 1.7rem);
  letter-spacing: 0.03em;
  /* colour comes from the shared molten-gold sheen block above */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.iem-bar-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.iem-error {
  margin: 0;
  min-height: 0;
  max-width: 280px;
  font-size: 12.5px;
  color: #e57373;
  text-align: right;
  line-height: 1.3;
}
.iem-error:empty { display: none; }

.iem-btn {
  font-family: var(--font-ui);
  font-size: 14px;
  border-radius: var(--rounded-md);
  padding: 9px 18px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.16s var(--ease-out-expo),
              border-color 0.16s var(--ease-out-expo),
              color 0.16s, box-shadow 0.16s var(--ease-out-expo),
              transform 0.12s var(--ease-out-expo);
}
.iem-btn:active { transform: scale(0.96); }
.iem-btn-ghost {
  background: transparent;
  border: 1px solid rgba(var(--bronze-rgb), 0.22);
  color: #9a958c;
}
.iem-btn-ghost:hover { border-color: rgba(var(--bronze-rgb), 0.5); color: var(--text); }
.iem-btn-save {
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.16) 0%, rgba(var(--bronze-rgb), 0.1) 100%);
  border: 1px solid rgba(var(--accent-rgb), 0.5);
  color: var(--accent);
  font-weight: 600;
}
.iem-btn-save > iconify-icon { font-size: 15px; }
.iem-btn-save:hover {
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.26) 0%, rgba(var(--bronze-rgb), 0.16) 100%);
  border-color: var(--accent);
  box-shadow: 0 0 22px rgba(var(--accent-rgb), 0.28);
}

/* ── Editor body: identity sidebar + main columns, fills the page ── */
.iem-body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  gap: clamp(16px, 2vw, 26px);
  padding: clamp(16px, 2.2vw, 26px) clamp(20px, 3.5vw, 44px) clamp(20px, 2.6vw, 30px);
}

/* The "sidebar to the left" — item identity & numbers in a glowing grey panel. */
.iem-sidebar {
  flex-shrink: 0;
  width: clamp(290px, 25vw, 350px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border-radius: 14px;
  background:
    radial-gradient(120% 50% at 50% 0%, rgba(var(--accent-rgb), 0.06), transparent 70%),
    rgba(26,26,24,0.72);
  border: 1px solid rgba(var(--bronze-rgb), 0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 16px 40px -22px rgba(0,0,0,0.8);
  overflow-y: auto;
}

.iem-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(16px, 2vw, 26px);
}
.iem-main-col {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 20px;
  border-radius: 14px;
  background: rgba(22,22,21,0.6);
  border: 1px solid rgba(var(--bronze-rgb), 0.13);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.025);
}

/* Tall fields flex to fill their column so the page itself does not scroll. */
.iem-fill { display: flex; flex-direction: column; flex: 1; min-height: 0; margin-bottom: 0; }
.iem-fill > label:not(.checkbox-label) { flex: 1; min-height: 0; }
.iem-col-desc .iem-fill { flex: 1; }
.iem-col-desc textarea {
  flex: 1;
  min-height: 120px;
  resize: none;
}
/* Price / weight side by side: the labels can wrap to different line counts,
   so pin both inputs to the bottom of their (equal-height) grid cells. */
.iem-sidebar .form-row.two-col > label:not(.checkbox-label) { height: 100%; }
.iem-sidebar .form-row.two-col input { margin-top: auto; }

/* Tags live in the sidebar under the rarity selector — the chips become a
   bordered, scrollable list so long tag collections stay contained. */
.iem-tags-row { margin-bottom: 0; flex-shrink: 0; }
.iem-sidebar .im-tag-picker-row { flex-direction: column; align-items: stretch; gap: 8px; }
.iem-sidebar .im-tag-chips {
  max-height: 350px;
  overflow-y: auto;
  align-content: flex-start;
  padding: 8px;
  background: rgba(16,16,15,0.5);
  border: 1px solid rgba(var(--bronze-rgb), 0.14);
  border-radius: 8px;
}
.iem-sidebar .im-tag-add-btn { align-self: flex-start; }

/* The "Abilities" label is a plain heading here (the list is its sibling, not
   its child) — without this it inherits .iem-fill's flex:1 and shoves the list
   down to the middle of the column. */
.iem-col-abilities .iem-fill > label:not(.checkbox-label) { flex: 0 0 auto; }
.iem-col-abilities .im-abilities-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}
.iem-col-abilities .im-ability-add-btn { flex-shrink: 0; margin-top: 8px; }

/* ── Grey surfaces for inputs / chips / abilities inside the editor ── */
.item-edit-modal .form-row input,
.item-edit-modal .form-row select,
.item-edit-modal .form-row textarea {
  background: rgba(16,16,15,0.66);
  border-color: rgba(var(--bronze-rgb), 0.16);
}
.item-edit-modal .form-row input:focus,
.item-edit-modal .form-row select:focus,
.item-edit-modal .form-row textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.14);
}
.item-edit-modal .form-row > label:not(.checkbox-label) { color: #9a958c; }
.item-edit-modal .rarity-sel-btn { background: rgba(255,255,255,0.04); }
.item-edit-modal .im-tag-chip { background: rgba(255,255,255,0.03); border-color: rgba(var(--bronze-rgb), 0.16); }
.item-edit-modal .im-tag-add-btn { border-color: rgba(var(--bronze-rgb), 0.22); padding: 6px 14px; line-height: 1; }
.item-edit-modal .im-tag-new-input { background: rgba(16,16,15,0.66); border-color: rgba(var(--bronze-rgb), 0.16); }
.item-edit-modal .im-ability-entry {
  background: rgba(255,255,255,0.025);
  border-color: rgba(var(--bronze-rgb), 0.14);
}
.item-edit-modal .im-ability-name-input,
.item-edit-modal .im-ability-desc-input {
  background: rgba(16,16,15,0.7);
  border-color: rgba(var(--bronze-rgb), 0.18);
}

/* ── Toggle rows (shop / attunement) ── */
.iem-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
  margin-left: 10px;
}
/* Capacity + extradimensional inputs revealed when "Container" is ticked */
.iem-container-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(var(--bronze-rgb), 0.16);
  background: rgba(var(--bronze-rgb), 0.05);
}
.iem-container-fields .form-row { margin-bottom: 0; }
.iem-toggle {
  align-items: center !important;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(var(--bronze-rgb), 0.14);
  transition: border-color 0.16s, background 0.16s;
}
.iem-toggle:hover { border-color: rgba(var(--bronze-rgb), 0.3); background: rgba(255,255,255,0.04); }
.iem-toggle-text { display: flex; flex-direction: column; gap: 3px; line-height: 1.3; }
.iem-toggle-text small { font-size: 13px; color: #7c776e; }

/* ── Tablet: drop the 220px offset, stack into a single scrolling column ── */
@media (max-width: 900px) {
  .modal-overlay.item-edit-modal { left: 0; }
  .item-edit-modal .modal-box.iem-box { overflow-y: auto; }
  .iem-body {
    flex-direction: column;
    overflow: visible;
    gap: 14px;
    padding: 16px 18px 22px;
  }
  .iem-sidebar { width: 100%; overflow: visible; padding: 16px; }
  .iem-main { grid-template-columns: 1fr; gap: 14px; }
  .iem-main-col { padding: 16px; }

  /* Stop the desktop "fill the height" flex from collapsing/overlapping once the
     layout is a normal scrolling column. Each section sizes to its content. */
  .iem-shell { height: auto; min-height: 100%; }
  .iem-body { flex: 0 0 auto; }
  .iem-main-col,
  .iem-fill { flex: 0 0 auto; min-height: 0; }
  .iem-fill > label:not(.checkbox-label) { flex: 0 0 auto; }
  .iem-col-desc textarea { flex: 0 0 auto; min-height: 130px; resize: vertical; }
  .iem-col-abilities .im-abilities-list { flex: 0 0 auto; overflow: visible; }

  /* Compact the identity inputs (name / price / weight) */
  .iem-sidebar .form-row.two-col { gap: 8px; }
  .iem-sidebar .form-row input { padding: 6px 9px; }

  /* Tighter, smaller chrome */
  .iem-bar { padding: 11px 18px; gap: 10px; }
  .iem-back-btn { width: 36px; height: 36px; font-size: 16px; }
  h2.iem-title { font-size: 1rem; }
  .iem-bar-actions { gap: 8px; }
  .iem-btn { font-size: 13px; padding: 7px 14px; border-radius: 7px; }
  .iem-btn-save > iconify-icon { font-size: 14px; }
  .iem-error { max-width: 180px; font-size: 11.5px; }
  .iem-toggle { padding: 10px 12px; }
  .iem-toggle-text { font-size: 13px; }
}

/* ── Phone: shrink everything that isn't an input value ── */
@media (max-width: 560px) {
  .iem-body { gap: 12px; padding: 12px 12px 20px; }
  .iem-sidebar { gap: 12px; padding: 13px; }
  .iem-main { gap: 12px; }
  .iem-main-col { padding: 13px; }

  .iem-bar { padding: 9px 12px; gap: 8px; }
  .iem-back-btn { width: 34px; height: 34px; font-size: 15px; }
  h2.iem-title { font-size: 1.05rem; letter-spacing: 0.02em; }
  .iem-btn { font-size: 12.5px; padding: 6px 12px; gap: 5px; }
  .iem-btn-save > iconify-icon { font-size: 13px; }
  .iem-error { max-width: 130px; font-size: 13px; }

  /* Field labels, chips and toggles step down a size */
  .item-edit-modal .form-row > label:not(.checkbox-label) { font-size: 10px; gap: 5px; }
  .item-edit-modal .form-row { margin-bottom: 11px; }
  .item-edit-modal .rarity-sel-btn { font-size: 13px; padding: 3px 9px; }
  .item-edit-modal .im-tag-chip { font-size: 10px; padding: 2px 8px; }
  .item-edit-modal .im-tag-add-btn { font-size: 10px; padding: 2px 7px; }
  .iem-toggle { padding: 9px 11px; gap: 10px; }
  .iem-toggle-text { font-size: 12.5px; gap: 2px; }
  .iem-toggle-text small { font-size: 10px; }
  .iem-toggle .checkbox-box { width: 16px; height: 16px; }
  .iem-col-desc textarea { min-height: 110px; }

  /* Description / ability text stays at 16px so focusing never zooms on iOS. */
  .item-edit-modal .form-row input,
  .item-edit-modal .form-row select,
  .item-edit-modal .form-row textarea { font-size: 16px; padding: 7px 10px; }
  .item-edit-modal .im-ability-name-input,
  .item-edit-modal .im-ability-desc-input { font-size: 16px; }

  /* Identity inputs (name / price / weight) are smaller and more compact. */
  .item-edit-modal .iem-sidebar .form-row input { font-size: 15px; padding: 5px 9px; }
  .iem-sidebar .form-row.two-col { gap: 7px; }
  .iem-sidebar { gap: 11px; }
  .iem-sidebar .im-name-row { margin-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .item-edit-modal .modal-box.iem-box { animation: none; }
  .iem-orb { animation: none; }
}

/* Single-column main variant (lore + character editors) */
.item-edit-modal .iem-main.iem-main-1 { grid-template-columns: 1fr; }

/* ── Session health: toasts, connection pip, feedback dialog ─────────────────
   Companion styles for /assets/js/session-health.js (loaded on every page). */

.ess-toast-wrap {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  max-width: min(440px, calc(100vw - 32px));
}

.ess-toast {
  display: flex;
  align-items: center;
  gap: 9px;
  background: linear-gradient(160deg, #1c1c1a 0%, #161615 100%);
  border: 1px solid var(--leather-border);
  border-radius: var(--rounded-md);
  box-shadow: var(--shadow-modal);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.4;
  padding: 10px 16px;
  pointer-events: auto;
}

.ess-toast iconify-icon { font-size: 15px; flex-shrink: 0; }
.ess-toast-info    iconify-icon { color: var(--accent); }
.ess-toast-success iconify-icon { color: var(--health-green); }
.ess-toast-error   iconify-icon { color: var(--hazard-red); }
.ess-toast-error   { border-color: rgba(224, 80, 80, 0.35); }
.ess-toast-success { border-color: rgba(102, 187, 106, 0.3); }

.ess-conn-pip {
  position: fixed;
  bottom: 18px;
  left: 18px;
  z-index: 1190;
  display: flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(160deg, #1c1c1a 0%, #161615 100%);
  border: 1px solid var(--leather-border);
  border-radius: var(--rounded-pill);
  box-shadow: var(--shadow-panel);
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--smoke);
  padding: 6px 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.25s var(--ease-out-quart), transform 0.25s var(--ease-out-quart);
}

.ess-conn-pip.show { opacity: 1; transform: translateY(0); }

.ess-conn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ess-conn-bad .ess-conn-dot { background: var(--hazard-red); animation: essConnPulse 1.2s ease-in-out infinite; }
.ess-conn-ok  .ess-conn-dot { background: var(--health-green); }
.ess-conn-ok  { color: var(--health-green); }

@keyframes essConnPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

.ess-fb-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 16px;
}

.ess-fb-overlay.open { display: flex; animation: motionFadeIn 0.26s ease both; }

.ess-fb-box {
  width: 720px;
  background: linear-gradient(160deg, #1c1c1a 0%, #161615 100%);
  border: 1px solid rgba(200, 164, 92, 0.12);
  border-radius: var(--rounded-lg);
  box-shadow: var(--shadow-modal);
  padding: 24px;
}

.ess-fb-label {
  display: block;
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--smoke);
  margin: 0 0 6px;
}

.ess-fb-cat {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(200, 164, 92, 0.1);
  border-radius: var(--rounded-md);
  color: var(--text);
font-family: var(--font-ui);
  font-size: 16px;
  padding: 10px 12px;
  margin: 0 0 12px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.ess-fb-cat:focus { border-color: rgba(200, 164, 92, 0.5); }
.ess-fb-cat option { background: #1c1c1a; color: var(--text); }

.ess-fb-count {
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--deep-smoke);
  text-align: right;
  margin-top: 6px;
}

.ess-fb-count.over { color: var(--hazard-red); }

.ess-fb-title {
  font-family: var(--title);
  font-size: 1.4rem;
  font-weight: 400;
  margin: 0 0 6px;
}

.ess-fb-hint {
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 14px;
}

.ess-fb-text {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(200, 164, 92, 0.1);
  border-radius: var(--rounded-md);
  color: var(--text);
font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  padding: 10px 12px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.ess-fb-text:focus { border-color: rgba(200, 164, 92, 0.5); }
.ess-fb-text::placeholder { color: var(--deep-smoke); }

.ess-fb-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.ess-fb-cancel {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(200, 164, 92, 0.1);
  border-radius: var(--rounded-md);
  color: var(--muted);
font-family: var(--font-ui);
  font-size: 14px;
  padding: 9px 22px;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.2s, color 0.2s;
}

.ess-fb-cancel:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }

.ess-fb-send {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(200, 164, 92, 0.1);
  border: 1px solid rgba(200, 164, 92, 0.28);
  border-radius: var(--rounded-md);
  color: var(--accent);
font-family: var(--font-ui);
  font-size: 14px;
  padding: 9px 22px;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.2s, box-shadow 0.2s;
}

.ess-fb-send:hover { background: rgba(200, 164, 92, 0.18); box-shadow: 0 0 12px rgba(var(--bronze-rgb), 0.15); }
.ess-fb-send:disabled { opacity: 0.5; cursor: not-allowed; }

.sidebar-feedback-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 10px 8px;
  padding: 8px 14px;
  min-height: 36px;
  background: none;
  border: none;
  border-radius: var(--rounded-md);
  color: var(--deep-smoke);
  font-family: var(--font-ui);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.sidebar-feedback-btn:hover { color: var(--accent); background: rgba(var(--bronze-rgb), 0.08); }

@media (max-width: 900px) {
  .sidebar-feedback-btn { min-height: 44px; font-size: 13px; }
}

/* Feedback dialog goes full-screen on phones so there's real room to type. */
@media (max-width: 700px) {
  .ess-fb-overlay { padding: 0; align-items: stretch; justify-content: stretch; }
  .ess-fb-box {
    width: 100%;
    max-width: none;
    height: 100%;
    border: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: max(20px, env(safe-area-inset-top)) 18px calc(20px + env(safe-area-inset-bottom));
  }
  /* The message field grows to fill the freed space instead of a fixed box. */
  .ess-fb-text { flex: 1; min-height: 200px; resize: none; }
}
