html, body {
  height: 100%;
  margin: 0;
  background: #0a0f1a;
  color: #e0e6f0;
  font-family: Arial, sans-serif;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* v1.2 Layout: Split Pane */
.split-pane {
    display: grid;
    grid-template-columns: 1fr 350px;
    height: 100%;
}

.map-pane { position: relative; border-right: 1px solid #1e293b; }
.inspector-pane { display: flex; flex-direction: column; background: rgba(10, 15, 26, 0.95); backdrop-filter: blur(16px); }

/* Header Enhancements */
.header-select { background: #1e293b; border: 1px solid #334155; color: #fff; padding: 4px; border-radius: 4px; font-size: 12px; }
.status-grid { display: flex; gap: 8px; margin-left: 16px; }
.speed-controls { display: flex; gap: 4px; background: #0f172a; padding: 4px; border-radius: 6px; border: 1px solid #1e293b; }
.btn-speed { background: none; border: none; color: #64748b; padding: 4px 8px; font-size: 11px; cursor: pointer; border-radius: 4px; }
.btn-speed.active { background: #38bdf8; color: #000; font-weight: 700; }

.header-left h1 {
  margin: 0;
  font-size: 1.1rem;
}

.connection-status {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-secondary {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.btn-secondary:hover {
  background: #334155;
}

.map-toolbar {
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(10, 15, 26, 0.92);
  border-bottom: 1px solid #1e293b;
  backdrop-filter: blur(8px);
}

.map-menu,
.world-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-right: 4px;
}

.map-menu-btn {
  background: #0f172a;
  border: 1px solid #334155;
  color: #94a3b8;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.map-menu-btn:hover {
  color: #e2e8f0;
}

.map-menu-btn.active {
  border-color: #38bdf8;
  color: #e0f2fe;
  background: #0c4a6e;
}

.btn-action {
  background: #0ea5e9;
  border: none;
  color: #0f172a;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.btn-action:hover {
  background: #38bdf8;
}

.btn-block {
  width: 100%;
  margin-top: 8px;
}

.muted {
  color: #64748b;
  font-size: 13px;
  line-height: 1.4;
}

.login-error {
  color: #ef4444;
  margin-top: 10px;
  font-size: 14px;
}

.app-footer {
  height: 40px;
  background: #0a0f1a;
  color: white;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-top: 1px solid #1e293b;
}

.app-body {
  flex: 1;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 48px;
}

#map-container {
  position: absolute;
  inset: 0;
}

#dynmap-frame {
  width: 100%;
  height: 100%;
  border: none;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: #020617;
}

#legend {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(15, 23, 42, 0.8);
    padding: 10px;
    border-radius: 6px;
    font-size: 12px;
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-radius: 50%;
}

.player { background: #3b82f6; }
.biosim { background: #22c55e; }
.monster { background: #ef4444; }

/* Sim Panel Components */
.pane-header { padding: 20px; border-bottom: 1px solid #1e293b; }
.pane-header h2 { margin: 0; font-size: 1.25rem; }
.archetype-badge { font-size: 10px; color: #38bdf8; text-transform: uppercase; letter-spacing: 0.1em; margin-top: 4px; font-weight: 700; }

.pane-tabs { display: flex; border-bottom: 1px solid #1e293b; background: rgba(0,0,0,0.2); }
.pane-tabs .tab { flex: 1; padding: 12px 0; background: none; border: none; color: #64748b; font-size: 12px; cursor: pointer; border-bottom: 2px solid transparent; }
.pane-tabs .tab.active { color: #fff; border-bottom-color: #38bdf8; }

.pane-content { flex: 1; overflow-y: auto; padding: 20px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Mind Tab: Stacked Bars */
.stacked-bar-container { margin-top: 16px; }
.stacked-label { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 4px; color: #94a3b8; }
.bar-track { height: 8px; background: #1e293b; border-radius: 4px; overflow: hidden; display: flex; }
.bar-segment { height: 100%; transition: width 0.3s ease; }

/* Social Tab: Relationship Rows */
.rel-row { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: rgba(255,255,255,0.03); border-radius: 8px; margin-bottom: 8px; border: 1px solid transparent; }
.rel-row.hostile { border-left: 3px solid #ef4444; }
.rel-row.friendly { border-left: 3px solid #22c55e; }
.rel-row.tense { border-left: 3px solid #94a3b8; }

.rel-name { font-weight: 600; font-size: 14px; }
.rel-metrics { display: flex; gap: 12px; font-size: 11px; color: #94a3b8; }
.trend-up { color: #22c55e; }
.trend-down { color: #ef4444; }

/* Switch Toggle (Debug Mode) */
.debug-toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 12px; border-top: 1px solid #1e293b; font-size: 12px; color: #64748b; }
.switch { position: relative; display: inline-block; width: 34px; height: 18px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background-color: #334155; transition: .4s; border-radius: 18px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #38bdf8; }
input:checked + .slider:before { transform: translateX(16px); }

/* Phase 14 Minimal Login Layout */
.overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100vh;
    background: #020617;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.overlay.hidden { display: none; }

.login-box {
    background: #0f172a;
    padding: 30px;
    border: 1px solid #1e293b;
    border-radius: 8px;
    text-align: center;
    width: 300px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
.login-box h2 {
    margin-top: 0;
    color: #f8fafc;
}
.login-box input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    margin-bottom: 12px;
    background: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
    border-radius: 4px;
}
.login-box button {
    width: 100%;
    padding: 10px;
    background: #3b82f6;
    border: none;
    color: white;
    cursor: pointer;
    font-weight: bold;
    border-radius: 4px;
}
.login-box button:hover {
    background: #2563eb;
}

#logoutBtn {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 4px;
}
#logoutBtn:hover {
    background: #ef4444;
    color: white;
}

/* Phase 17.6 Connection Status Indicators */
.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 12px;
    background: #222;
    color: #aaa;
}

.status-pill .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #555;
    margin-right: 0; /* override global .dot margin since flex gap handles spacing */
}

.status-pill.online .dot {
    background: #00ff88;
}

.status-pill.offline .dot {
    background: #ff4444;
}

.status-pill.unknown .dot {
    background: #888;
}

/* Footer deck status */
.deck-status {
  font-size: 13px;
  letter-spacing: 0.02em;
}

.deck-status.deck-ok {
  color: #4ade80;
}

.deck-status.deck-degraded {
  color: #fbbf24;
}

.deck-status.deck-offline {
  color: #f87171;
}

.deck-status.deck-unknown {
  color: #94a3b8;
}

/* Blade content states */
.blade-state {
  padding: 10px 0;
  font-size: 13px;
  border-radius: 6px;
}

.blade-state.loading {
  color: #94a3b8;
}

.blade-state.error {
  color: #f97316;
}

.blade-state.empty {
  color: #64748b;
}

.blade-state.muted {
  color: #64748b;
  font-style: italic;
}

.blade-selected {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #1e293b;
}

.selected-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px;
}

.selected-name {
  font-weight: 600;
  color: #f8fafc;
}

.selected-heading {
  margin: 0 0 8px 0;
  font-size: 1rem;
  font-weight: 600;
  color: #f8fafc;
}

.selected-line {
  margin: 4px 0;
  font-size: 13px;
  color: #cbd5e1;
}

.selected-k {
  display: inline-block;
  min-width: 3.5rem;
  color: #64748b;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.selected-meta,
.selected-pos {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 4px;
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: min(40vh, 320px);
  overflow-y: auto;
}

.player-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #1e293b;
  background: #0f172a;
  color: #e2e8f0;
  cursor: pointer;
  font-size: 13px;
}

.player-row:hover {
  border-color: #334155;
  background: #1e293b;
}

.player-row.is-selected {
  border-color: #38bdf8;
  background: #0c4a6e;
}

.player-row-world {
  font-size: 11px;
  color: #64748b;
  margin-left: 8px;
}
