:root {
  --bg: #181a20;
  --bg-2: #111319;
  --panel: #20232b;
  --panel-2: #262a33;
  --line: #363b47;
  --line-2: #454b59;
  --text: #edf0f8;
  --muted: #a4acbb;
  --accent: #c43b3b;
  --accent-soft: #5b2a31;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(1200px 650px at 0% -20%, #2c3140 0%, transparent 58%),
    radial-gradient(900px 550px at 100% -10%, #252b38 0%, transparent 52%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(125deg, rgba(255, 255, 255, 0.025), transparent 35%);
}
a { color: #eb6767; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #ff9393; }
.muted { color: var(--muted); }
.panel { background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); border-radius: 12px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 286px 1fr; }
.left-nav {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #14161d 0%, #1a1d25 100%);
  padding: 1rem 0.75rem;
}
.brand { color: #f4f6fb; letter-spacing: 0.09em; text-transform: uppercase; font-weight: 800; font-size: 0.86rem; margin-bottom: 0.32rem; }
.campaign { margin: 0 0 0.8rem; color: var(--muted); font-size: 0.82rem; }
.left-menu { display: grid; gap: 0.34rem; margin-top: 0.6rem; }
.nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  color: #e8ecf6;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0.48rem 0.58rem;
  background: transparent;
}
.nav-item small { color: #9fa7b7; font-size: 0.77rem; }
.nav-item:hover { color: #fff; border-color: #525968; background: #292f3d; text-decoration: none; }
.nav-item.active { border-color: #99505c; background: #38262d; color: #fff; }

.index-doc { width: min(1500px, 100%); margin: 0; padding: 1.1rem 1rem 2rem; }
.index-hero {
  padding: 0.95rem 1rem;
  margin-bottom: 0.85rem;
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: flex-start;
  background:
    radial-gradient(900px 220px at 18% -80%, rgba(196, 59, 59, 0.22), transparent 70%),
    linear-gradient(180deg, #252a36, #1f232c);
}
.kicker { margin: 0; color: #b3bccf; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.74rem; }
.index-hero h1 { margin: 0.22rem 0 0; font-size: 2.2rem; line-height: 1.05; }
.hero-sub { margin: 0.4rem 0 0; color: var(--muted); max-width: 760px; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 0.45rem; justify-content: flex-end; }
.hero-badge { border: 1px solid #515665; border-radius: 999px; height: 30px; display: inline-flex; align-items: center; padding: 0 0.62rem; background: rgba(13, 15, 20, 0.45); font-size: 0.83rem; color: #d9deeb; }

.quick-jump { display: flex; flex-wrap: wrap; gap: 0.42rem; padding: 0.56rem; margin-bottom: 0.85rem; }
.chip-link { display: inline-flex; align-items: center; height: 30px; padding: 0 0.65rem; border-radius: 999px; border: 1px solid var(--line); color: #e8ebf4; text-decoration: none; background: linear-gradient(180deg, #2a2f3b, #232834); font-size: 0.84rem; }
.chip-link:hover { border-color: #7f4451; color: #fff; background: linear-gradient(180deg, #333a48, #282e3a); text-decoration: none; }

.index-layout { display: grid; grid-template-columns: minmax(0, 1fr) 315px; gap: 0.95rem; align-items: start; }
.index-main { min-width: 0; }
.index-rail { position: sticky; top: 1rem; display: grid; gap: 0.8rem; }
.rail-card { padding: 0.6rem; }
.rail-card h2 { margin: 0 0 0.45rem; font-size: 0.94rem; text-transform: uppercase; letter-spacing: 0.08em; color: #d6dcee; }
.rail-row, .recent-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.38rem 0.44rem;
  border-radius: 8px;
  border: 1px solid transparent;
  color: #e1e5f1;
  text-decoration: none;
}
.rail-row strong { color: #b8c1d5; font-size: 0.84rem; }
.recent-row { flex-direction: column; align-items: flex-start; gap: 0.08rem; }
.recent-row small { color: var(--muted); }
.rail-row:hover, .recent-row:hover { border-color: var(--line-2); background: #2a303d; color: #fff; text-decoration: none; }

.stats-strip { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 0.55rem; margin-bottom: 0.85rem; }
.stat { padding: 0.55rem 0.62rem; display: grid; gap: 0.18rem; }
.stat small { color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; font-size: 0.72rem; }
.stat strong { font-size: 1.35rem; line-height: 1; }

.control-bar { position: sticky; top: 0.65rem; z-index: 5; backdrop-filter: blur(6px); padding: 0.75rem; margin-bottom: 0.9rem; }
#global-search { width: 100%; border: 1px solid #565d70; background: #171b24; color: var(--text); border-radius: 9px; padding: 0.58rem 0.63rem; }
.control-grid { margin-top: 0.6rem; display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 0.5rem; }
.control-grid label { display: grid; gap: 0.2rem; color: var(--muted); font-size: 0.8rem; }
.control-grid select, .control-grid input { border: 1px solid #565d70; background: #171b24; color: var(--text); border-radius: 8px; padding: 0.4rem 0.45rem; }
.index-tools { display: flex; align-items: center; gap: 0.45rem; margin-top: 0.6rem; }
.index-tools button { border: 1px solid #5e6578; border-radius: 8px; background: #242a37; color: var(--text); padding: 0.36rem 0.6rem; cursor: pointer; }
.index-tools button:hover { background: #2d3444; }
#visible-counter { color: var(--muted); margin-left: auto; }

.search-results { margin-bottom: 0.9rem; padding: 0.7rem; }
.search-results h2 { margin: 0 0 0.45rem; font-size: 1rem; text-transform: uppercase; letter-spacing: 0.06em; }
.search-results ul { margin: 0; padding-left: 1rem; }
.search-results li { margin-bottom: 0.35rem; }
.search-results mark { background: #e0b95a; color: #111; }

.fold { margin-bottom: 0.82rem; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(180deg, var(--panel-2), var(--panel)); overflow: hidden; box-shadow: 0 6px 22px rgba(0, 0, 0, 0.24); }
.fold summary { cursor: pointer; padding: 0.69rem 0.82rem; font-size: 1.1rem; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 0.5rem; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before { content: "▸"; color: #c7cbe0; font-size: 0.92rem; transform: translateY(-1px); transition: transform 0.16s ease; }
.fold[open] summary::before { transform: rotate(90deg) translateX(1px); }
.fold-section { margin-bottom: 0.95rem; }
.section-title { margin: 0; font-size: 1.55rem; line-height: 1.15; border-left: 4px solid var(--accent); padding: 0.5rem 0.72rem; background: linear-gradient(90deg, rgba(196, 59, 59, 0.16), transparent 45%); }
.section-body { padding: 0.45rem 0.72rem 0.85rem; }
.inner-fold { margin-top: 0.45rem; }
.inner-fold > summary { font-size: 1rem; background: #252b38; border-top: 1px solid #343a4a; border-bottom: 1px solid #343a4a; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin: 0.6rem 0; font-size: 0.98rem; }
thead th { position: sticky; top: 0; z-index: 1; text-align: left; background: rgba(22, 24, 30, 0.97); font-weight: 700; }
th, td { border: 1px solid var(--line); padding: 0.58rem 0.6rem; vertical-align: top; }
tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.05); }
tbody tr:hover { background: rgba(196, 59, 59, 0.12); }
tr.row-hidden { display: none; }
.thumb { width: 110px; max-width: 100%; height: auto; max-height: 170px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.thumb-pj { width: 88px; height: 88px; border-radius: 999px; }
.timeline { margin: 0.3rem 0 0; padding-left: 1.2rem; }
.timeline li { margin-bottom: 0.35rem; }
.timeline li span { color: var(--muted); margin-right: 0.5rem; }
#relation-graph { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #171921; cursor: crosshair; }
.faerun-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 0.75rem; align-items: start; }
.zone-nav { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.45rem; }
.zone-nav button { border: 1px solid #5e6578; border-radius: 8px; background: #242a37; color: var(--text); padding: 0.3rem 0.55rem; cursor: pointer; }
.zone-nav button:hover { background: #2d3444; }
.zone-nav span { color: #dfe4f3; font-weight: 700; letter-spacing: 0.02em; }
.faerun-session-list { padding: 0.55rem; max-height: 560px; overflow: auto; }
.faerun-session-list h3 { margin: 0 0 0.45rem; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.07em; color: #d6dcee; }
.session-group { border: 1px solid var(--line); border-radius: 8px; background: #1f2430; margin-bottom: 0.45rem; overflow: hidden; }
.session-group summary { cursor: pointer; list-style: none; padding: 0.45rem 0.5rem; font-size: 0.84rem; font-weight: 700; border-bottom: 1px solid transparent; }
.session-group[open] summary { border-bottom-color: var(--line); }
.session-group summary::-webkit-details-marker { display: none; }
.session-links { display: grid; gap: 0.24rem; padding: 0.4rem; }
.map-session-link { border: 1px solid #3e4558; background: #252b39; color: #e8ecf6; border-radius: 7px; padding: 0.35rem 0.45rem; text-align: left; font-size: 0.82rem; cursor: pointer; }
.map-session-link:hover { background: #30384a; border-color: #62708d; }
.map-session-link.active { background: #4a2b35; border-color: #b1596d; color: #fff; }
.map-session-link[draggable="true"] { cursor: grab; }
.map-session-link[draggable="true"]:active { cursor: grabbing; }
.faerun-map { position: relative; height: 560px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #151821; cursor: grab; }
.faerun-stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; user-select: none; }
.faerun-image { display: block; max-width: none; width: 1400px; height: auto; }
.faerun-pin {
  position: absolute;
  transform: translate(-50%, -50%) scale(var(--pin-scale, 1));
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #f36d6d;
  border: 2px solid #ffd0d0;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
  text-decoration: none;
}
.faerun-pin:hover { background: #ff8a8a; }
.faerun-pin.place-pin { background: #6dc3ff; border-color: #cceeff; --pin-scale: var(--place-pin-scale, 1); }
.faerun-pin.session-pin { background: #f36d6d; border-color: #ffd0d0; --pin-scale: var(--session-pin-scale, 1); z-index: 2; }
.faerun-pin.session-pin.active { background: #ffd166; border-color: #ffe6a5; box-shadow: 0 0 0 3px rgba(255, 200, 80, 0.26); }
.faerun-zone-hub {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 1px solid #935f5f;
  background: rgba(140, 57, 57, 0.88);
  color: #fff;
  border-radius: 999px;
  min-height: 28px;
  padding: 0.2rem 0.55rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  font-size: 0.76rem;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.28);
}
.faerun-zone-hub small { color: #ffd8d8; font-weight: 700; }
.faerun-zone-hub:hover { background: rgba(173, 75, 75, 0.94); }
.faerun-pin span {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: rgba(19, 21, 27, 0.9);
  border: 1px solid var(--line);
  color: #f0f2f7;
  font-size: 0.75rem;
  border-radius: 6px;
  padding: 0.18rem 0.36rem;
  opacity: 0;
  pointer-events: none;
}
.faerun-pin:hover span { opacity: 1; }
.map-admin { margin-top: 0.7rem; padding: 0.6rem; display: grid; gap: 0.55rem; }
.map-admin-tools { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.map-admin-tools button, .map-admin-import {
  border: 1px solid #5e6578;
  border-radius: 8px;
  background: #242a37;
  color: var(--text);
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  text-decoration: none;
}
.map-admin-import input { display: none; }
.map-admin-tools button:hover, .map-admin-import:hover { background: #2d3444; }

.note-page { background: var(--bg); }
.note-shell { max-width: 1140px; margin: 0 auto; padding: 0.9rem; }
.topbar { display: flex; justify-content: space-between; padding: 0.72rem 0.9rem; margin-bottom: 0.8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.top-actions { display: flex; align-items: center; gap: 0.85rem; }
.note { padding: 1rem; }
.note-hero { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 0.9rem; align-items: start; margin-bottom: 0.8rem; }
.note-portrait { width: 120px; height: 120px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }
.note-portrait.fallback { display: grid; place-items: center; background: #1a1d26; color: var(--muted); }
.note-summary { color: #d9dbe3; margin: 0.3rem 0 0; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.5rem; margin-bottom: 0.9rem; }
.meta div { border: 1px solid var(--line); border-radius: 8px; padding: 0.45rem 0.52rem; background: #1f2128; }
.meta span { display: block; color: var(--muted); font-size: 0.74rem; }
.meta strong { display: block; margin-top: 0.14rem; }
.note-content p { line-height: 1.55; color: #d9dbe3; }
.note-content h1, .note-content h2, .note-content h3 { color: #f0f2f7; }
.note-content pre { overflow-x: auto; border-radius: 8px; background: #14161d; border: 1px solid #2e3140; padding: 0.6rem; }
.note-content code { background: #171923; padding: 0.07rem 0.24rem; border-radius: 4px; }
.note-content img.inline-image { width: 100%; max-width: 620px; height: auto; border-radius: 8px; border: 1px solid var(--line); }
.linked { margin-top: 0.95rem; display: grid; gap: 0.8rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.linked h3 { margin: 0 0 0.35rem; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.06em; }
.linked ul { margin: 0; padding-left: 1rem; }

@media (max-width: 1220px) {
  .index-layout { grid-template-columns: 1fr; }
  .index-rail { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .stats-strip { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .control-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .section-title { font-size: 1.35rem; }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .left-nav { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .control-bar { position: static; }
  .index-hero { flex-direction: column; }
  .hero-badges { justify-content: flex-start; }
  .index-rail { grid-template-columns: 1fr; }
  .note-hero { grid-template-columns: 1fr; }
  .linked { grid-template-columns: 1fr; }
  .faerun-layout { grid-template-columns: 1fr; }
  .faerun-session-list { max-height: 280px; }
  .faerun-map { height: 420px; }
}
