/**
 * LONER ASSISTANT v2.0 - Modern, Clean Styling
 * No Bootstrap! Just clean, simple CSS
 */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600&family=Raleway:wght@600;700&display=swap');

/* ==================== VARIABLES ==================== */
:root {
  /* Colors */
  --primary: #1D1D1B;
  --primary-dark: #000000;
  --primary-contrast: #ffffff;
  --secondary: #4b5563; /* Neutral gray for secondary actions */
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  
  --bg: #ffffff;
  --bg-secondary: #f3f4f6; /* Light gray for contrast */
  --bg-tertiary: #e5e7eb;
  
  --text: #1D1D1B;
  --text-muted: #4b5563;
  --text-light: #9ca3af;
  
  --border: #e5e7eb;
  --border-dark: #d1d5db;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  
  /* Borders */
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* Dark theme */
/* Dark theme */
body.dark-theme {
  --primary: #E5E5E5;
  --primary-dark: #ffffff;
  --primary-contrast: #121212;
  --secondary: #9ca3af;
  
  --bg: #121212;
  --bg-secondary: #1f2937;
  --bg-tertiary: #374151;
  
  --text: #E5E5E5;
  --text-muted: #9ca3af;
  --text-light: #6b7280;
  
  --border: #374151;
  --border-dark: #4b5563;
}

/* ==================== RESET ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 
               'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-secondary);
}

/* ==================== NAVIGATION ==================== */
.navbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.nav-brand h1 {
  font-family: 'Raleway', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
}

.version {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
}

.nav-links {
  display: flex;
  gap: var(--space-sm);
}

.nav-btn {
  background: none;
  border: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s;
}

.nav-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

.nav-btn.active {
  background: var(--primary);
  color: var(--primary-contrast);
}

.theme-toggle {
  background: none;
  border: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.25rem;
  transition: all 0.2s;
  margin-left: var(--space-md);
}

.theme-toggle:hover {
  background: var(--bg-tertiary);
  transform: rotate(20deg);
}

/* ==================== HAMBURGER MENU ==================== */
.hamburger-menu {
  display: none;
  flex-direction: column;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius);
  transition: all 0.3s;
  z-index: 101;
}

.hamburger-menu:hover {
  background: var(--bg-tertiary);
}

.hamburger-menu span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s;
}

/* Hamburger animation - close (default) */
.hamburger-menu span:nth-child(1) {
  transform: translateY(0) rotate(0deg);
}

.hamburger-menu span:nth-child(2) {
  opacity: 1;
}

.hamburger-menu span:nth-child(3) {
  transform: translateY(0) rotate(0deg);
}

/* Hamburger animation - open (X icon) */
.hamburger-menu.active span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.hamburger-menu.active span:nth-child(2) {
  opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* Nav menu positioning */
.nav-links {
  position: relative;
}

/* Mobile nav menu styling */
@media (max-width: 768px) {
  .hamburger-menu {
    display: flex;
  }

  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-md);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    box-shadow: var(--shadow);
  }

  .nav-links.open {
    max-height: 500px;
  }

  .nav-btn {
    width: 100%;
    text-align: left;
    padding: var(--space-sm) var(--space-md);
  }

  .nav-btn:hover {
    background: var(--bg-tertiary);
    border-radius: var(--radius);
  }

  .nav-btn.active {
    background: var(--primary);
    border-radius: var(--radius);
    color: white;
  }

  .theme-toggle {
    width: 100%;
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    margin-left: 0;
  }
}

/* ==================== LAYOUT ==================== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-lg);
}

.layout-3col {
  display: grid;
  grid-template-columns: 250px 1fr 300px;
  gap: var(--space-lg);
  align-items: start;
}

/* Responsive */
@media (max-width: 1024px) {
  .layout-3col {
    display: flex;
    flex-direction: column;
  }

  /* Make sidebars and main transparent containers so their children can be reordered */
  .sidebar-left,
  .sidebar-right,
  .main-content {
    display: contents;
  }

  /* Force all panels to be full-width on mobile */
  .panel {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Apply mobile ordering based on data-mobile-order attribute */
  [data-mobile-order="0"] { order: 0; }
  [data-mobile-order="1"] { order: 1; }
  [data-mobile-order="2"] { order: 2; }
  [data-mobile-order="3"] { order: 3; }
  [data-mobile-order="4"] { order: 4; }
  [data-mobile-order="5"] { order: 5; }
  [data-mobile-order="6"] { order: 6; }
  [data-mobile-order="7"] { order: 7; }
  [data-mobile-order="8"] { order: 8; }
  [data-mobile-order="9"] { order: 9; }
  [data-mobile-order="10"] { order: 10; }
  [data-mobile-order="11"] { order: 11; }
  [data-mobile-order="12"] { order: 12; }
  [data-mobile-order="13"] { order: 13; }
  [data-mobile-order="14"] { order: 14; }
}

/* ==================== PANELS/CARDS ==================== */
.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.panel h3 {
  font-family: 'Raleway', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--space-md);
  color: var(--text);
}

/* Collapsible panel header */
.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  cursor: pointer;
  user-select: none;
}

.panel-title h3 {
  margin: 0;
  flex: 1;
}

.collapse-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.25rem;
  line-height: 1;
  transition: transform 0.2s, color 0.2s;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.collapse-toggle:hover {
  color: var(--text);
}

.panel.collapsed .collapse-toggle {
  transform: rotate(-90deg);
}

.panel.collapsed .panel-content {
  display: none;
}

.panel.collapsed {
  padding: var(--space-md) var(--space-lg);
}

.panel.collapsed .panel-title {
  margin-bottom: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.panel-header h2 {
  font-family: 'Raleway', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
}

.panel-highlight {
  border-color: var(--primary);
  border-width: 2px;
}

.panel-danger {
  border-color: var(--danger);
  border-width: 2px;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-contrast);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
}

.btn-secondary:hover {
  background: #5558f1;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-dark);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg-tertiary);
}

.btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.85rem;
}

.btn-large {
  padding: var(--space-md) var(--space-lg);
  font-size: 1rem;
  font-weight: 600;
  width: 100%;
}

/* ==================== VIEWS ==================== */
.view {
  display: none;
}

.view.active {
  display: block;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xl);
}

.view-header h2 {
  font-family: 'Raleway', sans-serif;
  font-size: 2rem;
  font-weight: 700;
}

/* ==================== ORACLE ==================== */
.oracle-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.modifier-selector {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.modifier-selector label {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.9rem;
  cursor: pointer;
}

.oracle-result {
  margin-top: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius);
  font-weight: 600;
}

.oracle-result.yes {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
}

.oracle-result.no {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #ef4444;
}

.oracle-result-detail {
  font-size: 0.85rem;
  margin-top: var(--space-xs);
  opacity: 0.8;
}

/* ==================== TWIST COUNTER ==================== */
.twist-counter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  text-align: center;
}

.twist-controls {
  display: flex;
  gap: var(--space-sm);
}

.counter-display {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.counter-display.danger {
  color: var(--danger);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ==================== ANIMATIONS & TRANSITIONS ==================== */

/* Smooth transitions for interactive elements */
button,
a,
input,
textarea,
select {
  transition: all 0.2s ease;
}

/* Button feedback animation */
button:active {
  transform: scale(0.98);
}

/* Subtle scale on hover for cards */
.card:hover {
  transform: translateY(-2px);
}

.panel:hover {
  box-shadow: var(--shadow-md);
}

/* Fade in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Slide in from right */
@keyframes slideInRight {
  from {
    transform: translateX(20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Slide in from left */
@keyframes slideInLeft {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Bounce animation for emphasis */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

/* ==================== TOAST NOTIFICATIONS ==================== */

.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 9999;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  background: var(--bg);
  border-left: 4px solid var(--border);
  pointer-events: auto;
  animation: slideInRight 0.3s ease;
  min-width: 300px;
  position: relative;
  overflow: hidden;
}

.toast.show {
  animation: slideInRight 0.3s ease;
}

.toast:not(.show) {
  animation: slideInRight 0.3s ease reverse forwards;
}

/* Success toast */
.toast-success {
  background: #d1fae5;
  border-color: var(--success);
  color: #065f46;
}

.toast-success .toast-icon {
  color: var(--success);
  font-weight: 700;
  font-size: 1.2rem;
}

/* Error toast */
.toast-error {
  background: #fee2e2;
  border-color: var(--danger);
  color: #991b1b;
}

.toast-error .toast-icon {
  color: var(--danger);
  font-weight: 700;
  font-size: 1.2rem;
}

/* Info toast */
.toast-info {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1e40af;
}

.toast-info .toast-icon {
  color: #3b82f6;
  font-weight: 700;
  font-size: 1.2rem;
}

/* Warning toast */
.toast-warning {
  background: #fef3c7;
  border-color: var(--warning);
  color: #92400e;
}

.toast-warning .toast-icon {
  color: var(--warning);
  font-weight: 700;
  font-size: 1.2rem;
}

.toast-message {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
}

.toast-close {
  background: none;
  border: none;
  padding: 0;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
  color: currentColor;
}

.toast-close:hover {
  opacity: 1;
}

/* ==================== LOADING STATES ==================== */

.loading {
  pointer-events: none;
  opacity: 0.7;
}

.loading::after {
  content: '';
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-left: var(--space-sm);
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: -2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==================== EMPTY STATES ==================== */

.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.empty-state-message {
  font-size: 0.95rem;
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}

.empty-state-action {
  display: inline-block;
}

/* ==================== ACCESSIBILITY IMPROVEMENTS ==================== */

/* Focus states for keyboard navigation */
button:focus,
a:focus,
input:focus,
textarea:focus,
select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
  border-color: var(--primary);
}

/* Better focus ring for dark theme */
body.dark-theme button:focus,
body.dark-theme a:focus,
body.dark-theme input:focus,
body.dark-theme textarea:focus,
body.dark-theme select:focus {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

/* Enhanced hover states */
button:not(:disabled):hover {
  filter: brightness(1.05);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Improved link focus */
a:focus {
  text-decoration: underline;
}

/* Form input improvements */
input:focus,
textarea:focus,
select:focus {
  background: var(--bg);
}

/* ==================== SMOOTH PAGE TRANSITIONS ==================== */

.view {
  animation: fadeIn 0.3s ease;
}

.panel {
  animation: fadeIn 0.4s ease;
}

/* Modal animation */
.modal {
  animation: fadeIn 0.3s ease;
}

.twist-result {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  border-left: 4px solid var(--warning);
}

/* ==================== LUCK TRACKER ==================== */
.luck-tracker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.luck-display {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  border: 2px solid var(--border);
}

.luck-display.low {
  background: #fee2e2;
  border-color: var(--danger);
  color: var(--danger);
}

/* ==================== CONFLICT ==================== */
.conflict-setup,
.conflict-active {
  transition: all 0.3s;
}

.conflict-result {
  margin: 1rem 0;
  padding: var(--space-md);
  border-radius: var(--radius);
  border-left: 4px solid var(--border);
}

.conflict-result.damage-dealt {
  background: #d1fae5;
  border-color: var(--success);
  color: #065f46;
}

.conflict-result.damage-taken {
  background: #fee2e2;
  border-color: var(--danger);
  color: #991b1b;
}

/* ==================== EDITOR ==================== */
.editor-container {
  min-height: 400px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

/* Quill toolbar styling */
.ql-toolbar {
  background: var(--bg-secondary);
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) var(--radius) 0 0 !important;
}

.ql-toolbar button,
.ql-toolbar button:hover,
.ql-toolbar select,
.ql-toolbar select:hover {
  color: var(--text) !important;
}

.ql-toolbar button:hover,
.ql-toolbar select:hover {
  background: var(--bg-tertiary) !important;
  color: var(--primary) !important;
}

.ql-toolbar button.ql-active,
.ql-toolbar select.ql-active {
  background: var(--primary) !important;
  color: white !important;
}

.ql-toolbar.ql-snow {
  padding: 0.5rem !important;
}

.ql-container {
  border: none !important;
  border-radius: 0 0 var(--radius) var(--radius) !important;
}

.ql-editor {
  background: var(--bg) !important;
  color: var(--text) !important;
}

.save-indicator {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ==================== GRID LISTS ==================== */
.grid-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
}

/* Mobile: force single column */
@media (max-width: 768px) {
  .grid-list {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card h3 {
  font-size: 1.25rem;
  margin-bottom: var(--space-sm);
}

.card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: var(--space-md);
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.character-card {
  cursor: default;
}

.character-card:hover {
  transform: none;
}

.campaign-card {
  cursor: default;
}

.campaign-card:hover {
  transform: none;
}

/* ==================== MODAL ==================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: var(--space-lg);
}

/* ==================== FORMS ==================== */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 500;
  font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

/* ==================== UTILITIES ==================== */
.hidden {
  display: none !important;
}

.text-muted {
  color: var(--text-muted);
}

.text-center {
  text-align: center;
}

.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }

.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }

/* ==================== QUICK LINKS ==================== */
/* Quick links now use standard collapsible panels */

/* ==================== TOOLS GRID ==================== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-lg);
}

/* Mobile: force single column */
@media (max-width: 768px) {
  .tools-grid {
    grid-template-columns: 1fr;
  }
}

.tool-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
}

.tool-card h3 {
  font-size: 1.25rem;
  margin-bottom: var(--space-sm);
}

.tool-card p {
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

/* Session info styling */
#current-session-info h4 {
  font-size: 1rem;
  margin: 0;
}

/* Old quick-links-grid removed - now using standard collapsible panels */

/* ==================== TABLE MANAGER ==================== */
.table-manager {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-md);
}

/* Mobile: force single column */
@media (max-width: 768px) {
  .quick-actions {
    grid-template-columns: 1fr;
  }
}

.table-categories {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.table-category h3 {
  margin-bottom: var(--space-md);
  color: var(--text-muted);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-md);
}

/* Mobile: force single column */
@media (max-width: 768px) {
  .table-list {
    grid-template-columns: 1fr;
  }
}

.table-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  transition: all 0.2s;
}

.table-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.table-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xs);
}

.table-card h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.adventure-maker-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.result-section h4 {
  margin-bottom: var(--space-xs);
  color: var(--primary);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-section p {
  margin: 0;
  font-size: 1rem;
}

.result-section ul {
  margin: 0;
  padding-left: var(--space-md);
}

.roll-history-item {
  padding: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.roll-history-item:last-child {
  border-bottom: none;
}

.roll-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xs);
  font-size: 0.85rem;
}

/* Flavor selector */
#inspired-flavor-select {
  width: 100%;
  padding: var(--space-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

#inspired-flavor-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ==================== QUICK LINKS PANELS ==================== */
/* Quick link list containers */
#npcs-quick-list,
#locations-quick-list,
#threads-quick-list,
#events-quick-list {
  max-height: 300px;
  overflow-y: auto;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.btn-close:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

.btn-close:active {
  transform: scale(0.95);
}

/* ==================== QUICK LINKS PANELS ==================== */
/* Quick link list containers */
#npcs-quick-list,
#locations-quick-list,
#threads-quick-list,
#events-quick-list {
  max-height: 300px;
  overflow-y: auto;
}

.panel-actions {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.btn-icon {
  background: var(--primary);
  color: white;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: all 0.2s;
  font-weight: bold;
}

.btn-icon:hover {
  background: var(--primary-dark);
  transform: scale(1.1);
}

.btn-icon:active {
  transform: scale(0.95);
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.btn-close:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

.btn-close:active {
  transform: scale(0.95);
}

/* Quick link list items */
.quick-link-item {
  padding: var(--space-xs) var(--space-sm);
  margin-bottom: var(--space-xs);
  background: var(--bg-secondary);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
  border-left: 3px solid transparent;
}

.quick-link-item:hover {
  background: var(--bg-tertiary);
  border-left-color: var(--primary);
  transform: translateX(2px);
}

.quick-link-item:last-child {
  margin-bottom: 0;
}

/* Empty state in quick link lists */
#npcs-quick-list .text-muted,
#locations-quick-list .text-muted,
#threads-quick-list .text-muted,
#events-quick-list .text-muted {
  font-size: 0.85rem;
  text-align: center;
  padding: var(--space-md) 0;
  color: var(--text-muted);
}

/* ==================== EVENT TIMELINE ==================== */
.timeline-section {
  margin-bottom: var(--space-xl);
}

.timeline-header {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--border);
}

.timeline-events {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.event-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  transition: all 0.2s;
}

.event-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ==================== ADVENTURE MAKER PANEL ==================== */
.panel-special {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  border: 2px solid var(--primary);
}

#adventure-maker-result {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-primary);
  border-radius: var(--radius);
  border-left: 4px solid var(--primary);
  display: none;
}

#adventure-maker-result.show {
  display: block;
}

.adventure-summary {
  font-size: 0.9rem;
  line-height: 1.6;
}

.adventure-summary strong {
  color: var(--primary);
  font-weight: 600;
}

.adventure-summary-item {
  margin-bottom: var(--space-sm);
  padding: var(--space-xs);
  background: var(--bg-secondary);
  border-radius: var(--radius);
}

.adventure-summary-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.adventure-summary-value {
  font-weight: 600;
  color: var(--text);
}

/* ==================== RANDOM TABLES PANEL ==================== */
#random-tables-supplement {
  cursor: pointer;
  font-size: 0.9rem;
}

#random-tables-supplement:focus {
  outline: none;
  border-color: var(--primary);
}

#random-tables-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 300px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.random-table-btn {
  width: 100%;
  text-align: left;
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.random-table-btn:hover {
  transform: translateX(4px);
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.random-table-btn:active {
  transform: translateX(2px);
}

/* ==================== MOBILE RESPONSIVE DESIGN ==================== */

/* Touch-friendly button sizes */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .btn-sm {
    min-height: 40px;
  }

  .nav-btn {
    min-height: 44px;
    padding: var(--space-sm) var(--space-sm);
  }

  button, input[type="button"], input[type="submit"] {
    min-height: 44px;
  }

  /* Reduce hover effects on touch devices */
  .btn:hover {
    transform: none;
  }
}

/* ==================== TABLET (768px to 1024px) ==================== */
@media (max-width: 1024px) {
  :root {
    --space-lg: 1rem;
    --space-xl: 1.5rem;
  }

  .container {
    padding: var(--space-md);
  }

  /* Stack 3-column layout to single column */
  .layout-3col {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .sidebar-left,
  .sidebar-right {
    position: relative;
  }

  .sidebar-right {
    margin-top: var(--space-lg);
  }

  /* Make nav buttons smaller on tablet */
  .nav-btn {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.8rem;
  }

  .nav-brand h1 {
    font-size: 1.25rem;
  }

  .panel {
    padding: var(--space-md);
    margin-bottom: var(--space-md);
  }

  /* Reduce editor height */
  .editor-container {
    min-height: 300px;
  }

  /* Quill toolbar on tablet */
  .ql-toolbar.ql-snow {
    padding: 0.4rem !important;
  }

  .ql-toolbar button,
  .ql-toolbar select {
    width: 28px !important;
    height: 28px !important;
    font-size: 14px !important;
  }

  .ql-toolbar button svg {
    width: 14px !important;
    height: 14px !important;
  }

  /* Stack quick actions */
  .quick-actions {
    flex-direction: column;
  }

  .quick-actions .btn {
    width: 100%;
  }
}

/* ==================== MOBILE (< 768px) ==================== */
@media (max-width: 768px) {
  :root {
    --space-lg: 0.75rem;
    --space-md: 0.75rem;
  }

  body {
    font-size: 15px;
  }

  .navbar {
    padding: var(--space-md) var(--space-md);
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  /* Ensure panels are truly full-width */
  .panel {
    width: 100% !important;
    max-width: 100% !important;
  }

  .nav-brand {
    width: 100%;
    margin-bottom: var(--space-xs);
  }

  .nav-brand h1 {
    font-size: 1.1rem;
    font-weight: 600;
  }

  .version {
    font-size: 0.65rem;
  }

  .container {
    padding: var(--space-sm);
  }

  /* Stack layout */
  .layout-3col {
    grid-template-columns: 1fr;
  }

  /* Hide sidebars by default, show as collapsible panels */
  .sidebar-left,
  .sidebar-right {
    margin-bottom: var(--space-lg);
  }

  .panel {
    padding: var(--space-md);
    margin-bottom: var(--space-md);
  }

  .panel h3 {
    font-size: 0.9rem;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .panel-header h2 {
    font-size: 1.1rem;
    width: 100%;
  }

  .session-controls {
    width: 100%;
    display: flex;
    gap: var(--space-sm);
  }

  .session-controls .btn {
    flex: 1;
    font-size: 0.8rem;
    padding: 0.5rem 0.25rem;
  }

  /* Editor adjustments */
  .editor-container {
    min-height: 250px;
  }

  /* Quill toolbar on mobile - compact size */
  .ql-toolbar {
    padding: 0.3rem !important;
  }

  .ql-toolbar.ql-snow {
    border: 1px solid var(--border) !important;
    border-bottom: none !important;
    padding: 0.3rem !important;
  }

  .ql-toolbar button,
  .ql-toolbar button.ql-active,
  .ql-toolbar select {
    width: 24px !important;
    height: 24px !important;
    font-size: 12px !important;
    margin: 0 2px !important;
  }

  .ql-toolbar button svg {
    width: 12px !important;
    height: 12px !important;
  }

  .ql-toolbar.ql-snow .ql-formats {
    margin-right: 0.3rem !important;
  }

  .ql-container {
    font-size: 0.9rem;
    border: 1px solid var(--border) !important;
    border-radius: 0 0 var(--radius) var(--radius) !important;
  }

  .ql-editor {
    padding: 0.75rem !important;
    font-size: 0.9rem !important;
    min-height: 200px;
  }

  /* Oracle controls */
  .oracle-controls {
    gap: var(--space-sm);
  }

  .btn-large {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.9rem;
  }

  .modifier-selector {
    gap: var(--space-xs);
  }

  .modifier-selector label {
    font-size: 0.85rem;
    gap: var(--space-xs);
  }

  /* Twist counter adjustments */
  .twist-counter {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
  }

  .counter-display {
    font-size: 1.5rem;
    text-align: center;
    padding: var(--space-sm);
  }

  .twist-counter .btn {
    width: 100%;
  }

  /* Luck tracker */
  .luck-tracker {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
  }

  .luck-display {
    font-size: 1.5rem;
    padding: var(--space-sm);
  }

  /* Modal adjustments */
  .modal-content {
    width: 90vw;
    max-width: 100%;
    margin: var(--space-md);
  }

  .modal-body {
    max-height: 70vh;
    overflow-y: auto;
  }

  /* Input fields */
  input[type="text"],
  input[type="email"],
  textarea,
  select {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.75rem;
  }

  /* Quick link lists on mobile */
  #npcs-quick-list,
  #locations-quick-list,
  #threads-quick-list,
  #events-quick-list {
    max-height: 250px;
    -webkit-overflow-scrolling: touch;
  }

  /* Table list - already single column above */

  .table-btn {
    width: 100%;
    text-align: left;
  }

  /* Form fields */
  .form-group {
    margin-bottom: var(--space-md);
  }

  .form-group input,
  .form-group textarea,
  .form-group select {
    width: 100%;
  }

  /* Character sheet */
  .character-sheet {
    grid-template-columns: 1fr;
  }

  .trait-group {
    grid-template-columns: 1fr;
  }

  /* List items */
  .list-item {
    padding: var(--space-sm);
    flex-direction: column;
  }

  .list-actions {
    width: 100%;
    justify-content: flex-start;
    gap: var(--space-xs);
  }
}

/* ==================== SMALL MOBILE (< 480px) ==================== */
@media (max-width: 480px) {
  :root {
    --space-md: 0.5rem;
    --space-sm: 0.4rem;
  }

  body {
    font-size: 14px;
  }

  .navbar {
    padding: 0.5rem;
  }

  .nav-brand h1 {
    font-size: 1rem;
  }

  .nav-btn {
    padding: 0.3rem 0.4rem;
    font-size: 0.65rem;
  }

  .version {
    display: none;
  }

  .container {
    padding: 0.5rem;
  }

  .panel {
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    border-radius: var(--radius);
  }

  .panel h3 {
    font-size: 0.85rem;
  }

  .panel-header h2 {
    font-size: 1rem;
  }

  .btn {
    padding: 0.5rem var(--space-sm);
    font-size: 0.8rem;
  }

  .btn-large {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.8rem;
  }

  .btn-sm {
    padding: 0.4rem 0.5rem;
    font-size: 0.7rem;
  }

  .oracle-result {
    padding: var(--space-sm);
    font-size: 0.85rem;
  }

  .counter-display {
    font-size: 1.25rem;
  }

  .session-controls .btn {
    font-size: 0.7rem;
    padding: 0.4rem 0.25rem;
  }

  /* Hide non-essential info on very small screens */
  .save-indicator {
    font-size: 0.7rem;
  }

  .modal-content {
    width: 95vw;
    margin: 0.5rem;
  }

  /* Quill toolbar on small mobile - ultra compact */
  .ql-toolbar button,
  .ql-toolbar button.ql-active,
  .ql-toolbar select {
    width: 20px !important;
    height: 20px !important;
    font-size: 10px !important;
    margin: 0 1px !important;
  }

  .ql-toolbar button svg {
    width: 10px !important;
    height: 10px !important;
  }

  .ql-toolbar.ql-snow {
    padding: 0.2rem !important;
  }

  .ql-toolbar.ql-snow .ql-formats {
    margin-right: 0.2rem !important;
  }
}

/* ==================== HELP SYSTEM ==================== */

/* Help button (?) in view headers */
.help-button {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: bold;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.help-button:hover {
  background: var(--bg-tertiary);
  transform: scale(1.1);
}

.help-button:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Help modal overlay */
.help-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-md);
  animation: fadeIn 0.3s ease-out;
}

.help-modal.hidden {
  display: none;
}

/* Help modal content */
.help-modal-content {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  animation: slideInUp 0.3s ease-out;
}

.help-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.help-modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.help-modal-header .btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.5rem;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.help-modal-header .btn-close:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

.help-description {
  padding: var(--space-md) var(--space-lg) 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 var(--space-md) 0;
}

/* Help sections container */
.help-sections {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--space-lg);
}

/* Individual help section */
.help-section {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.help-section:last-child {
  border-bottom: none;
  margin-bottom: var(--space-md);
}

.help-section h4 {
  margin: 0 0 var(--space-sm) 0;
  font-size: 1rem;
  color: var(--primary);
  font-weight: 600;
}

.help-section p {
  margin: 0;
  line-height: 1.5;
  color: var(--text);
  font-size: 0.9rem;
}

/* Modal footer */
.help-modal-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  text-align: center;
}

.help-modal-footer .btn {
  min-width: 120px;
}

/* Responsive help modal */
@media (max-width: 768px) {
  .help-modal {
    padding: var(--space-sm);
  }

  .help-modal-content {
    max-width: 100%;
    max-height: 90vh;
  }

  .help-modal-header {
    padding: var(--space-md);
  }

  .help-modal-header h2 {
    font-size: 1.25rem;
  }

  .help-sections {
    padding: 0 var(--space-md);
  }

  .help-modal-footer {
    padding: var(--space-md);
  }
}

@media (max-width: 480px) {
  .help-modal-content {
    border-radius: var(--radius);
  }

  .help-modal-header h2 {
    font-size: 1.1rem;
  }

  .help-description {
    font-size: 0.85rem;
  }

  .help-section h4 {
    font-size: 0.95rem;
  }

  .help-section p {
    font-size: 0.8rem;
  }
  }
}
/* ==================== DROPDOWN MENUS ==================== */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  margin-top: 0.25rem;
  min-width: 200px;
  z-index: 1000;
}

.dropdown-menu button {
  display: block;
  width: 100%;
  padding: 0.625rem 1rem;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.dropdown-menu button:hover {
  background: var(--bg-secondary);
}

.dropdown-menu button:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

.dropdown-menu button:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ==================== USER MANUAL ==================== */
.modal-large .modal-content {
  max-width: 900px;
  max-height: 85vh;
  overflow-y: auto;
}

.manual-content {
  line-height: 1.6;
}

.manual-content h1 {
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

.manual-content h2 {
  color: var(--text);
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.manual-content h3 {
  color: var(--text);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.2rem;
}

.manual-content ul, .manual-content ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.manual-content li {
  margin-bottom: 0.5rem;
}

.manual-content kbd {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.2rem 0.4rem;
  font-family: monospace;
  font-size: 0.9em;
}

.manual-content table {
  border-collapse: collapse;
  margin: 1rem 0;
}

.manual-content table th,
.manual-content table td {
  border: 1px solid var(--border);
  padding: 0.5rem;
}

.manual-content a {
  color: var(--primary);
  text-decoration: underline;
}

.manual-content a:hover {
  color: var(--primary-dark);
}

/* ==================== FOOTER ==================== */
.app-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: var(--space-lg);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: auto;
}

.app-footer p {
  margin: 0;
}

.app-footer a {
  color: var(--primary);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}
