/* ─── COMPANION (map + sidebar) ──────────────────────────────────────────── */
body.body-companion main { display: flex; flex-direction: column; }

.companion-shell { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.companion-toolbar {
  display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: center;
  padding: .55rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tb-group { display: flex; align-items: center; gap: .35rem; }
.tb-label {
  font-size: .58rem; letter-spacing: .18em; color: var(--text-dim);
  text-transform: uppercase; margin-right: .35rem;
}
.tb {
  background: none; border: 1px solid #2a2a38; color: var(--text-mute);
  padding: .28rem .7rem; font-family: var(--mono); font-size: .68rem;
  letter-spacing: .08em; transition: all .12s;
}
.tb:hover { border-color: #555; color: var(--text); }
.tb.active { border-color: var(--accent); color: var(--accent-2); background: #1a150e; }
select.tb { background: var(--bg-2); }

.companion-main {
  display: flex; flex: 1; min-height: 0;
  height: calc(100vh - 56px - 50px - 60px); /* nav + toolbar + footer */
}

.companion-map {
  flex: 1; position: relative; overflow: hidden;
  background: radial-gradient(ellipse at center, #08080e 0%, #03030a 100%);
  isolation: isolate;
}

#world-svg { width: 100%; height: 100%; cursor: grab; user-select: none; }
#world-svg.dragging { cursor: grabbing; }

/* Zoom controls overlay */
.map-zoom-controls {
  position: absolute; top: .8rem; right: .8rem;
  display: flex; flex-direction: column; gap: 2px;
  z-index: 10;
}
.map-zoom-btn {
  background: rgba(10,10,15,.88); border: 1px solid var(--border-2);
  color: var(--text-mute); font-family: var(--mono); font-size: 1rem; line-height: 1;
  width: 28px; height: 28px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .1s, border-color .1s;
}
.map-zoom-btn:hover { color: var(--text-bright); border-color: var(--accent); }

/* Graticule */
.grat-line { stroke: #111118; stroke-width: .5; fill: none; }
.grat-major { stroke: #1a1a26; stroke-width: .6; }

/* Countries */
.country {
  fill: #15151e; stroke: #2a2a38; stroke-width: .35;
  transition: fill .15s, stroke .15s;
  cursor: pointer;
}
.country:hover { stroke: var(--accent-2); stroke-width: .8; }
.country.c-orion     { fill: rgba(42,77,143,.45);  stroke: rgba(42,77,143,.6); }
.country.c-mandate   { fill: rgba(181,53,42,.45);  stroke: rgba(181,53,42,.6); }
.country.c-dominion  { fill: rgba(139,32,32,.45);  stroke: rgba(139,32,32,.6); }
.country.c-ungoverned{ fill: url(#hatch); stroke: rgba(139,115,85,.6); stroke-dasharray: 2 2; }
.country.c-contested { fill: rgba(107,91,69,.4); stroke: rgba(107,91,69,.6); }
.country.c-collapsed { fill: rgba(90,80,64,.3); stroke: rgba(90,80,64,.45); }
.country.c-orion:hover, .country.c-mandate:hover, .country.c-dominion:hover,
.country.c-ungoverned:hover, .country.c-contested:hover, .country.c-collapsed:hover { filter: brightness(1.4); }

/* Regions (canon circles, kept for label anchors) */
.region-marker { cursor: pointer; transition: opacity .15s; }
.region-marker:hover { opacity: .9; filter: brightness(1.3); }
.region-marker-detail { opacity: .72; }

/* Places */
.place-dot { cursor: pointer; }
.place-dot:hover { filter: brightness(1.5); }

/* Characters */
.char-pulse { animation: pulse 2.2s ease-in-out infinite; transform-origin: center; }
@keyframes pulse {
  0%, 100% { opacity: .45; r: 10; }
  50%      { opacity: .12; r: 17; }
}
.char-marker { cursor: pointer; }
.char-marker:hover .char-inner { filter: brightness(1.4); }

/* Labels */
.map-label {
  font-size: 10px; fill: rgba(180,170,150,.6);
  pointer-events: none; font-family: var(--mono);
}
.map-label-region  {
  font-size: 13px;
  fill: rgba(224,205,166,.9);
  letter-spacing: .04em;
  text-transform: none;
  font-weight: 650;
  paint-order: stroke;
  stroke: rgba(5,5,12,.86);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.map-label-story-area {
  fill: rgba(232,216,178,.94);
  letter-spacing: .16em;
  text-transform: uppercase;
  font-weight: 750;
  stroke-width: 4px;
}
.map-label-region-detail {
  fill: rgba(200,168,112,.58);
  letter-spacing: .08em;
  font-size: 10px;
  paint-order: stroke;
  stroke: rgba(5,5,12,.82);
  stroke-width: 2.4px;
  stroke-linejoin: round;
}
.map-label-place   { font-size: 9.5px; fill: rgba(210,190,160,.85); }
.map-label-char    { font-size: 10.5px; fill: #e8d090; font-weight: bold; }
.map-label-country { font-size: 8.5px; fill: rgba(160,155,140,.35); pointer-events: none; font-family: var(--mono); }

/* Legend */
.map-legend {
  position: absolute; top: .8rem; left: .8rem;
  display: flex; flex-direction: column; gap: .3rem;
  background: rgba(10,10,15,.92); padding: .65rem .85rem;
  border: 1px solid rgba(139,115,85,.45);
  font-family: var(--mono);
  z-index: 30;
  pointer-events: none;
  box-shadow: 0 12px 30px rgba(0,0,0,.38);
}
.leg-row { display: flex; align-items: center; gap: .55rem; font-size: .62rem; color: var(--text); }
.leg-row .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.leg-row .dot-ring { background: transparent; border: 1px solid #ddd8cc; }
.leg-row .diamond { width: 9px; height: 9px; transform: rotate(45deg); flex-shrink: 0; background: #e8d090; display: inline-block; }
.leg-row .dot-hatch {
  background: repeating-linear-gradient(135deg, transparent 0 3px, #8b7355 3px 5px);
  border: 1px solid rgba(139,115,85,.8);
  border-radius: 0;
}

/* ─── SIDEBAR ─────────────────────────────────────────────────────────────── */
.companion-sidebar {
  width: 320px; flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bg);
}
.panel { flex: 1; overflow-y: auto; padding: 1.2rem; display: none; }
.panel.active { display: block; }
.panel-title {
  font-size: .62rem; letter-spacing: .2em; color: var(--text-dim);
  text-transform: uppercase; margin-bottom: 1rem; padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.panel p { font-size: .78rem; color: var(--text); line-height: 1.7; }

.detail-name { font-size: 1.05rem; color: var(--text-bright); margin-bottom: .3rem; font-family: var(--serif); }
.detail-sub  { font-size: .65rem; color: var(--text-dim); letter-spacing: .12em; text-transform: uppercase; margin-bottom: .8rem; }
.detail-desc { font-size: .78rem; line-height: 1.7; color: #988880; }
.detail-link {
  display: inline-block; margin-top: 1rem;
  font-size: .65rem; letter-spacing: .18em; text-transform: uppercase; color: var(--accent-2);
}

.section-head {
  font-size: .58rem; letter-spacing: .18em; color: var(--text-dim);
  text-transform: uppercase; margin: 1.1rem 0 .5rem;
  padding-bottom: .25rem; border-bottom: 1px solid #1a1a22;
}

/* Character LitRPG */
.char-name  { font-size: 1.1rem; color: var(--text-bright); font-family: var(--serif); }
.char-title { font-size: .68rem; color: var(--accent-2); margin: .25rem 0 .8rem; letter-spacing: .12em; text-transform: uppercase; }
.char-level { font-size: .72rem; color: var(--text-mute); margin-bottom: .8rem; }

.hp-bar { height: 4px; background: #1a1a1a; margin-bottom: .8rem; border-radius: 2px; }
.hp-fill { height: 100%; background: linear-gradient(90deg, #4a8a4a, #6aa86a); border-radius: 2px; transition: width .3s; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem 1rem; margin-bottom: .5rem; }
.stat-row { display: flex; justify-content: space-between; font-size: .68rem; }
.stat-name { color: var(--text-mute); }
.stat-val { color: #c8b890; font-weight: bold; }

.item-list { list-style: none; }
.item-list li {
  font-size: .7rem; padding: .3rem 0;
  border-bottom: 1px solid #111; color: #908070;
  display: flex; justify-content: space-between; gap: .5rem;
}
.item-list li .tag {
  font-size: .58rem; color: var(--text-dim);
  border: 1px solid #2a2a2a; padding: 0 .3rem;
}
.item-none { font-size: .68rem; color: #333; font-style: italic; }

.equip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.equip-slot {
  border: 1px solid #1a1a22; padding: .3rem .4rem; font-size: .62rem;
}
.equip-slot .slot-name { color: var(--text-dim); margin-bottom: .15rem; }
.equip-slot .slot-item { color: #908070; }
.equip-slot .slot-empty { color: #2a2a2a; font-style: italic; }

.effect-list { display: flex; flex-wrap: wrap; gap: .3rem; }
.effect-tag {
  font-size: .58rem; padding: .15rem .4rem;
  background: #1a1020; border: 1px solid #3a2040; color: #a070c0;
  letter-spacing: .05em;
}

.notes-box {
  font-size: .7rem; color: #665a50; line-height: 1.6;
  margin-top: .5rem; padding: .6rem; background: #0c0c10;
  border-left: 2px solid #2a2a35;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .companion-main { flex-direction: column; height: auto; }
  .companion-map { min-height: 60vh; }
  .companion-sidebar { width: 100%; border-left: none; border-top: 1px solid var(--border); max-height: 50vh; }
}
@media (max-width: 640px) {
  .companion-toolbar { padding: .5rem .8rem; gap: .8rem; }
  .tb { padding: .22rem .5rem; font-size: .62rem; }
  .map-legend { font-size: .55rem; padding: .4rem .55rem; }
}
