/* ==========================================================================
   D&D Companion — Warm Dark Theme
   ========================================================================== */

:root {
  --bg:           #141211;
  --bg-raised:    #1c1a18;
  --bg-dark:      #0f0e0d;
  --surface:      #242220;
  --surface-hover:#2e2c29;
  --surface-light:#383532;
  --border:       #33302d;
  --border-light: #443f3b;

  --text:         #e8e4df;
  --text-secondary:#b8b2ac;
  --text-muted:   #908a84;

  --accent:       #d97706;
  --accent-hover: #b45309;
  --accent-glow:  rgba(217, 119, 6, 0.20);

  --red:          #ef4565;
  --red-hover:    #d93a58;
  --green:        #2cb67d;
  --green-hover:  #24a06d;
  --blue:         #4d9ef6;
  --yellow-warn:  #eab308;

  --purple:       #7c5cfc;
  --purple-light: #a78bfa;
  --success:      #2cb67d;
  --warning:      #eab308;
  --danger:       #ef4565;
  --error:        #ef4565;

  --radius:       10px;
  --radius-sm:    6px;
  --radius-lg:    16px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.3);

  --sidebar-w:    72px;
  --header-h:     56px;
  --font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Newsreader', 'Georgia', serif;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ==========================================================================
   Auth Screen
   ========================================================================== */
.auth-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.auth-screen[hidden] { display: none; }

.auth-backdrop {
  position: absolute; inset: 0;
  background: var(--bg);
}

.auth-box {
  position: relative;
  width: 100%; max-width: 380px;
  padding: 2.5rem 2rem 2rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
}

.auth-logo p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-toggle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 1.25rem;
}

/* ==========================================================================
   Inputs
   ========================================================================== */
input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="url"],
input[type="color"],
textarea, select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}

/* Hide number-input spinners on compact inputs to prevent text cutoff */
input[type="number"].no-spin::-webkit-outer-spin-button,
input[type="number"].no-spin::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"].no-spin {
  -moz-appearance: textfield;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: none;
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.check-label input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}

.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.inline-form input { flex: 1; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover:not(:disabled) { background: var(--accent-hover); }

.btn-success {
  background: var(--green);
  color: #fff;
}
.btn-success:hover:not(:disabled) { background: var(--green-hover); }

.btn-danger {
  background: var(--red);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: var(--red-hover); }

.btn-danger-ghost {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}
.btn-danger-ghost:hover:not(:disabled) { background: rgba(239,69,101,0.1); }

.btn-secondary {
  background: var(--surface-light);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface); border-color: var(--border-light); }

.btn-gold {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}
.btn-gold:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-light);
}

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 0.95rem; width: 100%; }

.link-btn {
  background: none; border: none; padding: 0;
  color: var(--accent); font-family: var(--font);
  font-size: inherit; cursor: pointer; font-weight: 600;
}
.link-btn:hover { text-decoration: underline; }

/* Unstyled buttons fallback */
button:not(.btn):not(.link-btn):not(.sidebar-btn):not(.tab):not(.overlay-close) {
  padding: 0.45rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.83rem;
  cursor: pointer;
  transition: all 0.15s;
}
button:not(.btn):not(.link-btn):not(.sidebar-btn):not(.tab):not(.overlay-close):hover {
  background: var(--surface-hover);
  border-color: var(--border-light);
  color: var(--text);
}

/* ==========================================================================
   Session Screen
   ========================================================================== */
.session-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  z-index: 90;
  background: var(--bg);
}
.session-screen[hidden] { display: none; }

.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  height: var(--header-h);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.top-bar-brand {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text);
  font-weight: 700;
}

.session-content {
  flex: 1;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  overflow-y: auto;
}

.session-heading {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--text);
  margin-bottom: 1.5rem;
}

.session-actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.session-actions .inline-form { flex: 1; min-width: 200px; }

.session-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.session-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}

.session-card:hover {
  background: var(--surface-hover);
  border-color: var(--border-light);
}

.session-card-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.session-card-code {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: var(--bg);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-size: 0.9rem;
}

/* ==========================================================================
   App Shell — Sidebar Layout
   ========================================================================== */
.app-shell {
  display: flex;
  height: 100vh;
}
.app-shell[hidden] { display: none; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 0;
  flex-shrink: 0;
}

.sidebar-brand {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.sidebar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.6rem 0.4rem;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  width: 64px;
  font-family: var(--font);
}

.sidebar-btn svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
}

.sidebar-btn span {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.sidebar-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.sidebar-btn.active {
  color: var(--accent);
  background: rgba(217, 119, 6, 0.10);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.sidebar-footer .sidebar-btn { color: var(--text-muted); }
.sidebar-footer .sidebar-btn:hover { color: var(--red); }

/* Main area */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  height: var(--header-h);
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

.session-badge {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.panel-body {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.panel-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
}

.panel-content[hidden] { display: none !important; }

/* Map panel: always visible, no padding (full-bleed canvas) */
#map-panel {
  padding: 0;
}

/* ==========================================================================
   Left Floating Panel (sidebar over the map, left side)
   ========================================================================== */
:root {
  --left-w: 380px;
}

.left-float {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--left-w);
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 15;
}

.left-float[hidden] { display: none; }

.left-float-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.left-float-header h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
  margin: 0;
}

.left-float-body {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.left-float .panel-content {
  position: relative;
  inset: auto;
  flex: 1;
  min-height: 0;
}

/* When left panel is open, offset map so it doesn't hide under it */
.panel-body.left-open #map-panel {
  left: var(--left-w);
}

.panel-body.left-open .chat-float {
  /* chat stays on the right, unaffected */
}

.overlay-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0.1rem 0.4rem;
  line-height: 1;
  border-radius: var(--radius-sm);
  font-family: var(--font);
}

.overlay-close:hover {
  color: var(--text);
  background: var(--surface-hover);
}

/* ==========================================================================
   Floating Chat Panel (right side)
   ========================================================================== */
:root {
  --chat-w: 320px;
}

.chat-float {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--chat-w);
  background: var(--bg-raised);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 15;
}

.chat-float[hidden] { display: none; }

.chat-float-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-float-header h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
  margin: 0;
}

.chat-float .panel-content {
  position: relative;
  inset: auto;
  flex: 1;
  min-height: 0;
  padding-bottom: 0;
}

/* When chat is open, offset map so it doesn't extend past it */
.panel-body.chat-open #map-panel {
  right: var(--chat-w);
}

/* Unread badge on sidebar */
.sidebar-btn {
  position: relative;
}

.chat-unread-badge {
  position: absolute;
  top: 4px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}

.chat-unread-badge[hidden] { display: none; }

/* ==========================================================================
   Chat
   ========================================================================== */

.message-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-bottom: 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-light) transparent;
}

.chat-input-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 0 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: transparent;
}

.chat-input-bar input { flex: 1; }

.chat-bubble {
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  max-width: 75%;
  animation: slideUp 0.15s ease-out;
}

.chat-bubble .username {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.chat-bubble .timestamp {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.chat-bubble .message-body {
  font-size: 0.88rem;
  margin-top: 0.1rem;
  line-height: 1.45;
  color: var(--text);
}

.chat-bubble.self {
  align-self: flex-end;
  background: var(--surface-light);
  border-left: 2px solid var(--accent);
}
.chat-bubble.self .username { color: var(--text-secondary); }
.chat-bubble.self .message-body { color: var(--text); }

.chat-bubble.system {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.82rem;
  max-width: 100%;
  text-align: center;
}

/* ==========================================================================
   Initiative
   ========================================================================== */
.initiative-status {
  text-align: center;
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.initiative-list {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

.initiative-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.initiative-row:nth-child(odd) { background: var(--surface); }
.initiative-row:nth-child(even) { background: var(--bg-raised); }

.initiative-row.active-turn {
  border-left-color: var(--accent);
  background: rgba(217, 119, 6, 0.06);
}

.initiative-row .init-value {
  min-width: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  font-size: 1.1rem;
}

.initiative-row .init-name { flex: 1; font-weight: 500; }
.initiative-row .init-hp { font-size: 0.85rem; color: var(--green); }

.initiative-row .drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 0.9rem;
  user-select: none;
  opacity: 0.5;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.initiative-row:hover .drag-handle { opacity: 1; }
.initiative-row.dragging {
  opacity: 0.4;
  background: var(--surface-light);
}
.initiative-row.drag-over {
  border-top: 2px solid var(--accent);
}

.initiative-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   Dice
   ========================================================================== */
.dice-toolbar { margin-bottom: 1rem; }

.roll-history {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dice-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem;
}

.dice-result .total { font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.dice-result .roll-formula { font-size: 0.85rem; color: var(--text-muted); }
.dice-result .die-values { display: flex; flex-wrap: wrap; gap: 0.3rem; justify-content: center; }

.dice-result .die-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.8rem; height: 1.8rem; padding: 0 0.3rem;
  background: var(--surface-light); border: 1px solid var(--border);
  border-radius: 4px; font-size: 0.8rem; font-weight: 600;
}

.dice-result .die-badge.crit { color: var(--accent); border-color: var(--accent); }
.dice-result .die-badge.min { color: var(--red); border-color: var(--red); }

/* ==========================================================================
   Reference
   ========================================================================== */
.ref-search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.ref-search-bar input { flex: 1; }
.ref-search-bar select { max-width: 200px; }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   Scrollbar
   ========================================================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ==========================================================================
   Rendered Markdown
   ========================================================================== */
.rendered-md { line-height: 1.7; word-wrap: break-word; }
.rendered-md h1,.rendered-md h2,.rendered-md h3,.rendered-md h4 { color: var(--text); margin: 1.25rem 0 0.5rem; }
.rendered-md h1 { font-size: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.rendered-md h2 { font-size: 1.3rem; }
.rendered-md h3 { font-size: 1.1rem; }
.rendered-md p { margin: 0.5rem 0; }
.rendered-md a { color: var(--accent); }
.rendered-md ul,.rendered-md ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.rendered-md code { background: var(--bg); padding: 0.15rem 0.4rem; border-radius: 3px; font-size: 0.85em; }
.rendered-md pre { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.85rem; overflow-x: auto; margin: 0.75rem 0; }
.rendered-md pre code { padding: 0; background: none; }
.rendered-md blockquote { border-left: 3px solid var(--accent); margin: 0.75rem 0; padding: 0.4rem 0.85rem; color: var(--text-secondary); background: rgba(217,119,6,0.05); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.rendered-md table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; }
.rendered-md th,.rendered-md td { padding: 0.45rem 0.75rem; border: 1px solid var(--border); text-align: left; }
.rendered-md th { background: var(--surface-light); color: var(--text); font-weight: 600; }
.rendered-md tr:nth-child(even) { background: var(--bg-raised); }

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes turnPulse {
  0%, 100% { border-left-color: var(--accent); }
  50% { border-left-color: rgba(217, 119, 6, 0.3); }
}

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

.fade-in { animation: fadeIn 0.2s ease-out; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
#connection-dot.reconnecting {
  animation: pulse 1.5s ease-in-out infinite;
}

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.65);
}

.modal-dialog {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  min-width: 20rem;
  max-width: 32rem;
  width: 90vw;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.25s ease-out;
}

.modal-title {
  margin: 0 0 0.75rem 0;
  font-size: 1.15rem;
  color: var(--text);
}

.modal-body {
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ==========================================================================
   Toast
   ========================================================================== */
.toast {
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  opacity: 1;
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform: translateX(0);
  max-width: 22rem;
  word-wrap: break-word;
  color: #fff;
}

.toast--success { background-color: var(--success); }
.toast--error { background-color: var(--danger); }
.toast--info { background-color: var(--surface-light); color: var(--text); }

/* ==========================================================================
   DM Only Badge
   ========================================================================== */
.dm-only-badge {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--red);
  background-color: rgba(239, 69, 101, 0.12);
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
  display: inline-block;
}

/* ==========================================================================
   Utilities
   ========================================================================== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-red { color: var(--red); }
.text-success { color: var(--green); }
.w-full { width: 100%; }
.mt-sm { margin-top: 0.35rem; }
.mt-md { margin-top: 0.75rem; }
.mt-lg { margin-top: 1.5rem; }
.mb-sm { margin-bottom: 0.35rem; }
.mb-md { margin-bottom: 0.75rem; }
.mb-lg { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-1 { flex: 1; }
.gap-sm { gap: 0.35rem; }
.gap-md { gap: 0.75rem; }
.gap-lg { gap: 1.5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
  :root { --sidebar-w: 56px; }
  .sidebar-btn span { display: none; }
  .sidebar-btn { padding: 0.6rem; width: 44px; }
  .panel-content { padding: 1rem; }
  .session-actions { flex-direction: column; }
  .ref-search-bar { flex-direction: column; }
  .ref-search-bar select { max-width: 100%; }
}

@media (max-width: 480px) {
  :root { --sidebar-w: 48px; }
  .sidebar-btn svg { width: 18px; height: 18px; }
  .auth-box { padding: 1.5rem 1.25rem; margin: 1rem; }
  .panel-header { padding: 0 1rem; }
}

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 200;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0.5rem;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  font-family: var(--font);
}

@media (max-width: 600px) {
  .sidebar-toggle { display: block; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: var(--sidebar-w);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }

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

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 140;
    background: rgba(0,0,0,0.5);
    display: none;
  }

  .sidebar-backdrop.active {
    display: block;
  }

  .left-float {
    width: 100%;
    z-index: 20;
  }

  .chat-float {
    width: 100%;
    z-index: 20;
  }

  .panel-body.left-open #map-panel {
    left: 0;
  }

  .panel-body.chat-open #map-panel {
    right: 0;
  }

  .panel-header {
    padding-left: 3rem;
  }
}
