/* ─── CSS Variables / Theme ────────────────────────────────────── */
:root {
  --bg: #F5F0E8;
  --bg-alt: #EDE7DA;
  --ink: #2C1810;
  --ink-light: #5a4a3a;
  --accent: #8B2635;
  --accent-light: #a83a4a;
  --border: #C8BBAA;
  --shadow: rgba(44, 24, 16, 0.15);
  --font-title: 'Cinzel', serif;
  --font-body: 'Source Serif 4', 'Georgia', serif;
  --radius: 6px;
  --toolbar-bg: rgba(245, 240, 232, 0.95);
  --sidebar-width: 380px;
  --timeline-height: 180px;
  --transition: 0.25s ease;
}

[data-theme="night"] {
  --bg: #1A1A2E;
  --bg-alt: #22223a;
  --ink: #E8E0D0;
  --ink-light: #a8a090;
  --accent: #C9A84C;
  --accent-light: #ddc06a;
  --border: #3a3a5a;
  --shadow: rgba(0, 0, 0, 0.4);
  --toolbar-bg: rgba(26, 26, 46, 0.95);
}

/* ─── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--accent); }

/* ─── Screens ─────────────────────────────────────────────────── */
.screen { display: none; height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 8px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  color: var(--ink);
  cursor: pointer;
  transition: all var(--transition);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-light); border-color: var(--accent-light); }
.btn-secondary { background: transparent; }
.btn-sm { font-size: 12px; padding: 5px 12px; }
.btn-icon {
  background: none;
  border: none;
  color: var(--ink);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.btn-icon:hover { background: var(--bg-alt); }

.btn-danger { color: #c0392b; border-color: #c0392b; }
.btn-danger:hover { background: #c0392b; color: #fff; }

/* ─── Home Screen ─────────────────────────────────────────────── */
#home-screen {
  overflow-y: auto;
  overflow-x: hidden;
}

/* ─── Hero ───────────────────────────────────────────────────── */
.hero {
  position: relative;
  min-height: clamp(320px, 50vh, 520px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.hero-map-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.12;
  filter: blur(1.5px);
  pointer-events: none;
}
.hero-content {
  position: relative;
  text-align: center;
  z-index: 1;
  padding: 40px 20px;
}
.hero-title {
  font-family: var(--font-title);
  font-size: clamp(42px, 6vw, 96px);
  letter-spacing: clamp(3px, 0.4vw, 8px);
  margin-bottom: 12px;
  color: var(--ink);
  text-shadow:
    0 1px 0 var(--bg-alt),
    0 2px 0 var(--border),
    0 3px 6px var(--shadow);
}
.hero-tagline {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--ink-light);
  font-size: clamp(15px, 1.4vw, 20px);
  margin-bottom: clamp(24px, 3vw, 44px);
}
.home-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn-cta-primary {
  font-family: var(--font-body);
  font-size: 15px;
  padding: 12px 28px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
  transition: all var(--transition);
  font-weight: 600;
}
.btn-cta-primary:hover {
  background: var(--accent-light);
  border-color: var(--accent-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--shadow);
}
.btn-cta-outline {
  font-family: var(--font-body);
  font-size: 15px;
  padding: 12px 28px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  display: inline-block;
}
.btn-cta-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

/* Scroll indicator */
.scroll-indicator {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--ink-light);
  opacity: 0.5;
  animation: scroll-pulse 2s ease-in-out infinite;
}
@keyframes scroll-pulse {
  0%, 100% { opacity: 0.3; transform: translateX(-50%) translateY(0); }
  50% { opacity: 0.7; transform: translateX(-50%) translateY(6px); }
}

/* ─── Home Sections ──────────────────────────────────────────── */
.home-section {
  padding: clamp(24px, 3vw, 48px) clamp(20px, 4vw, 80px);
}
.section-title {
  font-family: var(--font-title);
  font-size: clamp(18px, 1.5vw, 24px);
  margin-bottom: clamp(16px, 1.5vw, 28px);
  color: var(--ink);
  position: relative;
  padding-bottom: 10px;
}
.section-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--accent);
}

/* ─── Home Footer ────────────────────────────────────────────── */
.home-footer {
  text-align: center;
  padding: 24px 20px;
  border-top: 1px solid var(--border);
  color: var(--ink-light);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.footer-compass {
  animation: compass-spin 60s linear infinite;
}
@keyframes compass-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.worlds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: clamp(16px, 1.5vw, 28px);
}
.world-card {
  background: var(--bg-alt);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.world-card:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 20px var(--shadow);
  transform: translateY(-3px);
}
.world-card-preview {
  width: 100%;
  height: 180px;
  display: block;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.world-card-body {
  padding: 16px 20px 20px;
}
.world-card h3 {
  font-family: var(--font-title);
  font-size: 17px;
  margin-bottom: 6px;
}
.world-card p {
  color: var(--ink-light);
  font-size: 13px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.world-card-meta {
  font-size: 11px;
  color: var(--ink-light);
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.world-card-meta span { white-space: nowrap; }
/* Hover overlay with action buttons */
.world-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.world-card:hover .world-card-overlay {
  opacity: 1;
  pointer-events: auto;
}
.world-card-overlay .btn {
  font-size: 13px;
  padding: 8px 16px;
  background: var(--bg);
  border-color: var(--bg);
  color: var(--ink);
}
.world-card-overlay .btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.world-card .delete-world {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 14px;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 2;
}
.world-card:hover .delete-world { opacity: 1; }
/* New world card (dashed) */
.world-card-new {
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  background: transparent;
  transition: all var(--transition);
}
.world-card-new:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.world-card-new-inner {
  text-align: center;
  color: var(--ink-light);
}
.world-card-new-inner .plus-icon {
  font-size: 48px;
  color: var(--border);
  transition: color var(--transition), transform var(--transition);
  display: block;
  margin-bottom: 8px;
}
.world-card-new:hover .plus-icon {
  color: var(--accent);
  transform: scale(1.1);
}
.world-card-new-inner span {
  font-family: var(--font-title);
  font-size: 14px;
}

/* ─── Templates ───────────────────────────────────────────────── */
.templates-section {
  padding: 0;
}
.templates-section h2 {
  font-family: var(--font-title);
  font-size: clamp(16px, 1.3vw, 22px);
  margin-bottom: 16px;
  color: var(--ink-light);
}
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: clamp(12px, 1.2vw, 20px);
}
/* Horizontal scroll on narrower screens */
@media (max-width: 1400px) {
  .templates-grid {
    display: flex;
    overflow-x: auto;
    gap: 16px;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
  }
  .template-card {
    min-width: 280px;
    max-width: 320px;
    flex-shrink: 0;
    scroll-snap-align: start;
  }
}
.template-card {
  background: var(--bg-alt);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
}
.template-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px var(--shadow);
  transform: translateY(-2px);
}
.template-preview {
  width: 100%;
  height: 140px;
  display: block;
  border-bottom: 1px solid var(--border);
}
.template-info {
  padding: 12px 16px;
}
.template-info h4 {
  font-family: var(--font-title);
  font-size: 14px;
  margin-bottom: 4px;
}
.template-info p {
  font-size: 12px;
  color: var(--ink-light);
  line-height: 1.4;
}

/* ─── Modal ───────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal[hidden] { display: none; }
.modal-content {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 90%;
  max-width: 420px;
}
.modal-content h2 {
  font-family: var(--font-title);
  margin-bottom: 20px;
}
.modal-content label {
  display: block;
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--ink-light);
}
.modal-content input[type="text"],
.modal-content input[type="number"],
.modal-content textarea,
.modal-content select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-alt);
  color: var(--ink);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ─── Editor Top Bar ──────────────────────────────────────────── */
.editor-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-alt);
  border-bottom: 2px solid var(--border);
  z-index: 10;
}
.world-title {
  font-family: var(--font-title);
  font-size: 18px;
  flex: 1;
}
.topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ─── Theme Switcher ──────────────────────────────────────────── */
.theme-switcher {
  position: relative;
}
.theme-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px var(--shadow);
  z-index: 20;
  min-width: 200px;
  overflow: hidden;
}
.theme-dropdown[hidden] { display: none; }
.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  text-align: left;
  transition: background var(--transition);
}
.theme-option:hover {
  background: var(--bg-alt);
}
.theme-swatch {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 2px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.theme-swatch span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: block;
}

/* ─── Editor Body ─────────────────────────────────────────────── */
.editor-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ─── Canvas ──────────────────────────────────────────────────── */
.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.canvas-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ─── Toolbar ─────────────────────────────────────────────────── */
.toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  background: var(--toolbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow:
    0 4px 16px var(--shadow),
    inset 0 1px 0 rgba(255,255,255,0.08);
  z-index: 5;
  max-height: calc(100% - 32px);
  overflow-y: auto;
}
/* Fallback for no backdrop-filter */
@supports not (backdrop-filter: blur(12px)) {
  .toolbar { background: var(--bg-alt); opacity: 0.97; }
}
/* Two-column layout when window is very short */
@media (max-height: 700px) {
  .toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    max-width: 90px;
    max-height: none;
  }
  .tool-separator {
    width: 100%;
    height: 1px;
  }
}
.tool-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--ink);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.tool-btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.tool-btn.active {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 2px 6px color-mix(in srgb, var(--accent) 40%, transparent);
}
.tool-btn:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}
/* Custom tooltips */
.tool-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--ink);
  color: var(--bg);
  font-size: 11px;
  font-family: var(--font-body);
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 10;
}
.tool-btn:hover::after {
  opacity: 1;
}
.tool-btn:not([data-tooltip])::after { display: none; }
.tool-separator {
  height: 1px;
  background: var(--border);
  margin: 4px 2px;
  opacity: 0.5;
}
#tool-color {
  width: 36px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: none;
  padding: 2px;
}

/* ─── Tool Options ────────────────────────────────────────────── */
.tool-options {
  position: absolute;
  top: 16px;
  left: 72px;
  background: var(--toolbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  box-shadow: 0 4px 16px var(--shadow);
  z-index: 5;
}
.tool-options[hidden] { display: none; }
.tool-options label { display: flex; align-items: center; gap: 4px; color: var(--ink-light); white-space: nowrap; }
.tool-options select, .tool-options input {
  font-family: var(--font-body);
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-alt);
  color: var(--ink);
}

/* ─── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: 280px;
  max-width: 480px;
  background: var(--bg);
  border-left: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 5;
  position: relative;
}
.sidebar[hidden] { display: none; }
.sidebar-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  z-index: 6;
  background: transparent;
  transition: background 0.15s ease;
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle.active {
  background: var(--accent);
  opacity: 0.4;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h3 {
  font-family: var(--font-title);
  font-size: 16px;
  letter-spacing: 0.5px;
}
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
}

/* Sidebar tabs */
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  font-size: 13px;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--ink-light);
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.sidebar-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Sidebar form */
.sidebar-field {
  margin-bottom: 14px;
}
.sidebar-field label {
  display: block;
  font-size: 12px;
  color: var(--ink-light);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.sidebar-field input,
.sidebar-field select {
  width: 100%;
  padding: 8px 4px;
  font-family: var(--font-body);
  font-size: 14px;
  border: none;
  border-bottom: 1.5px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  transition: border-color var(--transition);
}
.sidebar-field input:focus,
.sidebar-field select:focus {
  outline: none;
  border-bottom-color: var(--accent);
}
.sidebar-field textarea {
  width: 100%;
  padding: 8px;
  font-family: var(--font-body);
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: color-mix(in srgb, var(--bg-alt) 50%, transparent);
  color: var(--ink);
  resize: vertical;
  min-height: 80px;
  transition: border-color var(--transition);
}
.sidebar-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Terrain panel */
.terrain-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.terrain-preview-wrap {
  position: relative;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-align: center;
}
.terrain-preview-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}
.terrain-preview-label {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 10px;
  color: var(--ink-light);
  opacity: 0.7;
}
.terrain-seed-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.terrain-seed-row input[type="number"] {
  flex: 1;
}
.seed-controls {
  display: flex;
  gap: 4px;
}
.seed-controls button {
  font-size: 12px;
  padding: 4px 8px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  cursor: pointer;
  transition: background var(--transition);
}
.seed-controls button:hover {
  background: var(--accent);
  color: var(--bg);
}
.terrain-panel .sidebar-field input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}
.terrain-panel .sidebar-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
  box-shadow: 0 1px 3px var(--shadow);
}
.terrain-panel .sidebar-field input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
  box-shadow: 0 1px 3px var(--shadow);
}
.terrain-panel .color-reset-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.terrain-panel .color-reset-row input[type="color"] {
  width: 36px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0;
}
.terrain-panel .color-reset-row button {
  font-size: 11px;
  padding: 3px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink-light);
  cursor: pointer;
}
.terrain-panel .color-reset-row button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Tags */
.tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 10px;
  margin: 2px;
}

/* Markdown preview */
.md-preview {
  font-size: 14px;
  line-height: 1.6;
  padding: 8px;
  background: var(--bg-alt);
  border-radius: 4px;
  min-height: 60px;
}
.md-preview h1, .md-preview h2, .md-preview h3 {
  font-family: var(--font-title);
  margin: 8px 0 4px;
}
.md-preview strong { font-weight: 700; }
.md-preview em { font-style: italic; }
.md-preview p { margin-bottom: 8px; }

/* Markdown toolbar */
.md-toolbar {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}
.md-toolbar button {
  padding: 2px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-alt);
  color: var(--ink);
  cursor: pointer;
}
.md-toolbar button:hover { border-color: var(--accent); }

/* Relation links */
.relation-link {
  display: block;
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--accent);
  text-decoration: none;
  transition: background var(--transition);
}
.relation-link:hover { background: var(--bg-alt); }

/* Delete entity button */
.sidebar-delete {
  margin-top: 16px;
  text-align: center;
}

/* ─── Timeline ────────────────────────────────────────────────── */
.timeline {
  background: var(--bg-alt);
  border-top: 2px solid var(--border);
  transition: height var(--transition);
  z-index: 10;
  position: relative;
}
.timeline.collapsed {
  height: 32px;
}
.timeline:not(.collapsed) {
  height: var(--timeline-height);
}
.timeline-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  cursor: row-resize;
  z-index: 11;
  background: transparent;
  transition: background 0.15s ease;
}
.timeline-resize-handle:hover,
.timeline-resize-handle.active {
  background: var(--accent);
  opacity: 0.4;
}
.timeline.collapsed .timeline-resize-handle { display: none; }
.timeline-toggle {
  display: block;
  width: 100%;
  padding: 6px;
  text-align: center;
  font-size: 13px;
  border: none;
  background: none;
  color: var(--ink-light);
  cursor: pointer;
  font-family: var(--font-body);
}
.timeline.collapsed .timeline-toggle { transform: rotate(180deg) translateY(2px); }
.timeline-body {
  position: relative;
  height: calc(var(--timeline-height) - 32px);
  overflow: hidden;
}
.timeline.collapsed .timeline-body { display: none; }
.timeline-body canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.timeline-add {
  position: absolute;
  right: 12px;
  bottom: 8px;
}

/* Event markers on timeline */
.timeline-event-tooltip {
  position: absolute;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  pointer-events: none;
  box-shadow: 0 2px 8px var(--shadow);
  z-index: 20;
  max-width: 200px;
}

/* Event modal */
.event-modal-fields label {
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--ink-light);
}
.event-modal-fields input,
.event-modal-fields select,
.event-modal-fields textarea {
  display: block;
  width: 100%;
  margin-top: 3px;
  padding: 6px 8px;
  font-family: var(--font-body);
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-alt);
  color: var(--ink);
}

/* ─── Cursors (custom SVG) ────────────────────────────────────── */
.cursor-select { cursor: default; }
.cursor-territory,
.cursor-region {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M12 2v20M2 12h20' stroke='%232C1810' stroke-width='1.5' stroke-linecap='round'/%3E%3Ccircle cx='12' cy='12' r='3' fill='none' stroke='%232C1810' stroke-width='1'/%3E%3C/svg%3E") 12 12, crosshair;
}
.cursor-city {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='4' fill='none' stroke='%232C1810' stroke-width='1.5'/%3E%3Ccircle cx='12' cy='12' r='1' fill='%232C1810'/%3E%3C/svg%3E") 12 12, cell;
}
.cursor-route {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M4 20 Q12 4 20 20' fill='none' stroke='%232C1810' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") 12 12, crosshair;
}
.cursor-text {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M8 4h8M12 4v16M8 20h8' stroke='%232C1810' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") 12 12, text;
}
.cursor-symbol {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpolygon points='12,3 14,10 21,10 16,14 18,21 12,17 6,21 8,14 3,10 10,10' fill='none' stroke='%232C1810' stroke-width='1.2'/%3E%3C/svg%3E") 12 12, crosshair;
}
.cursor-river {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M12 2c-1 4-4 6-4 10s2 6 0 10' fill='none' stroke='%232C1810' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") 12 12, crosshair;
}
.cursor-grab { cursor: grab; }
.cursor-grabbing { cursor: grabbing; }

/* ─── Minimap ─────────────────────────────────────────────────── */
.minimap {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 200px;
  height: 150px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
  z-index: 7;
  background: var(--bg-alt);
}
.minimap.hidden { display: none; }
.minimap.dragging { opacity: 0.8; }
.minimap canvas {
  display: block;
  cursor: crosshair;
}
.minimap-drag-handle {
  position: absolute;
  top: 2px;
  left: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--ink-light);
  cursor: grab;
  font-size: 10px;
  padding: 1px 3px;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--transition);
  user-select: none;
}
.minimap-drag-handle:active { cursor: grabbing; }
.minimap:hover .minimap-drag-handle { opacity: 0.7; }
.minimap-toggle {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--ink-light);
  cursor: pointer;
  font-size: 12px;
  padding: 1px 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--transition);
}
.minimap:hover .minimap-toggle { opacity: 1; }

/* ─── Symbol Palette ──────────────────────────────────────────── */
.symbol-palette {
  position: absolute;
  top: 60px;
  right: 16px;
  width: 280px;
  max-height: 60vh;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px var(--shadow);
  z-index: 8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.symbol-palette[hidden] { display: none; }
.symbol-palette-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.symbol-palette-header h4 {
  font-family: var(--font-title);
  font-size: 13px;
  margin: 0;
  white-space: nowrap;
}
.symbol-search {
  flex: 1;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-alt);
  color: var(--ink);
  font-family: var(--font-body);
}
.symbol-close { font-size: 16px; }
.symbol-palette-body {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}
.symbol-category h5 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-light);
  margin: 8px 0 4px;
  padding: 0 4px;
}
.symbol-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.symbol-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  cursor: pointer;
  color: var(--ink);
  transition: all var(--transition);
}
.symbol-item span {
  font-size: 9px;
  color: var(--ink-light);
  text-align: center;
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.symbol-item:hover {
  background: var(--bg-alt);
  border-color: var(--border);
}
.symbol-item.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.symbol-item.active span { color: var(--bg); }

.cursor-symbol { cursor: crosshair; }

/* ─── Layers Panel ────────────────────────────────────────────── */
.layers-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  background: var(--bg);
  border-right: 2px solid var(--border);
  z-index: 6;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
}
.layers-panel.collapsed {
  transform: translateX(-240px);
}
.layers-toggle {
  position: absolute;
  right: -36px;
  top: 70px;
  width: 36px;
  height: 36px;
  background: var(--toolbar-bg);
  border: 2px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
  flex-direction: column;
  gap: 2px;
}
.layers-toggle-label {
  font-size: 0;
}
.layers-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.layers-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--border);
}
.layers-header h4 {
  font-family: var(--font-title);
  font-size: 14px;
  margin: 0;
}
.layers-add {
  font-size: 18px;
  padding: 2px 6px;
}
.layers-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.layer-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  cursor: default;
  transition: background var(--transition);
}
.layer-item.active {
  background: var(--bg-alt);
  border-left: 3px solid var(--accent);
}
.layer-item.drag-over {
  border-top: 2px solid var(--accent);
}
.layer-item.dragging {
  opacity: 0.4;
}
.layer-visibility {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: var(--ink-light);
  display: flex;
  align-items: center;
  transition: color var(--transition), opacity var(--transition);
  opacity: 0.5;
}
.layer-visibility.visible {
  color: var(--accent);
  opacity: 1;
}
.layer-name {
  flex: 1;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-opacity {
  width: 50px;
  cursor: pointer;
  accent-color: var(--accent);
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
.layer-opacity::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 1px 3px var(--shadow);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.layer-opacity::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.layer-opacity::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
}
.layer-delete {
  font-size: 14px;
  opacity: 0;
  transition: opacity var(--transition);
  padding: 0 4px;
}
.layer-item:hover .layer-delete {
  opacity: 0.6;
}
.layer-rename-input {
  flex: 1;
  font-size: 13px;
  padding: 2px 4px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--bg-alt);
  color: var(--ink);
  font-family: var(--font-body);
  min-width: 0;
}
.layers-active-indicator {
  padding: 6px 10px;
  font-size: 11px;
  color: var(--ink-light);
  border-top: 1px solid var(--border);
  text-align: center;
}
/* Layers panel compact mode on smaller screens */
@media (max-width: 1280px) {
  .layers-panel:not(.collapsed) {
    width: 180px;
  }
  .layers-panel.collapsed {
    transform: translateX(-180px);
  }
  .layer-opacity { width: 40px; }
  .layer-name { font-size: 12px; }
  .layers-header h4 { font-size: 12px; }
}

/* ─── Mode Simple/Advanced ────────────────────────────────────── */
.settings-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: 0 4px 16px var(--shadow);
  z-index: 20;
  min-width: 180px;
}
.settings-dropdown[hidden] { display: none; }
.settings-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}
.settings-toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* Simple mode: hide advanced UI */
.mode-simple [data-tool="region"],
.mode-simple [data-tool="symbol"],
.mode-simple #btn-snap,
.mode-simple #btn-grid-snap,
.mode-simple .layers-panel,
.mode-simple .layers-toggle {
  display: none !important;
}

/* ─── Onboarding ──────────────────────────────────────────────── */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
}
.onboarding-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: auto;
}
.onboarding-spotlight {
  position: fixed;
  border-radius: var(--radius);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  z-index: 10000;
  pointer-events: none;
  transition: all 0.3s ease;
}
.onboarding-tooltip {
  position: fixed;
  width: 320px;
  background: var(--bg);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px;
  z-index: 10001;
  pointer-events: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.onboarding-step-count {
  font-size: 11px;
  color: var(--ink-light);
  margin-bottom: 4px;
}
.onboarding-tooltip h3 {
  font-family: var(--font-title);
  font-size: 16px;
  margin-bottom: 8px;
}
.onboarding-tooltip p {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-light);
  margin-bottom: 16px;
}
.onboarding-actions {
  display: flex;
  justify-content: space-between;
}

/* ─── Utility ─────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Scrollbar (thin & discreet) ─────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-light); }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* ─── Selection highlight ─────────────────────────────────────── */
::selection {
  background: var(--accent);
  color: var(--bg);
}

/* ─── SVG Export Modal ────────────────────────────────────────── */
.svg-export-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}
.export-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  cursor: pointer;
}
.export-check input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}
.export-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.export-field label {
  font-size: 0.85rem;
  color: var(--ink-light);
}
.export-field select,
.export-field input[type="text"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
}
.export-field-row {
  display: flex;
  gap: 8px;
}
.export-field-row input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
}

/* ─── Section 4: Micro-animations ─────────────────────────────── */

/* Card stagger fade-up */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
.world-card, .world-card-new, .template-card {
  opacity: 0;
}
.world-card.visible, .world-card-new.visible, .template-card.visible {
  animation: fade-up 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Sidebar slide-in */
.sidebar {
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.sidebar.open {
  transform: translateX(0);
}

/* Theme transition on all panels */
body, .editor-topbar, .sidebar, .timeline, .toolbar, .tool-options, .modal-content {
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

/* Toast notification */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-10px); }
}
.toast {
  pointer-events: auto;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 4px 16px var(--shadow);
  animation: toast-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  position: relative;
  overflow: hidden;
}
.toast.toast-success { background: #2a7d4f; }
.toast.toast-error   { background: #8B2635; }
.toast.toast-info    { background: var(--ink); }
.toast.dismissing {
  animation: toast-out 0.3s ease forwards;
}
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(255,255,255,0.4);
  animation: toast-progress-shrink linear forwards;
}
@keyframes toast-progress-shrink {
  from { width: 100%; }
  to   { width: 0; }
}

/* Skeleton shimmer for world cards during load */
@keyframes skeleton-shimmer {
  0%   { background-position: -200px 0; }
  100% { background-position: 400px 0; }
}
.skeleton-card {
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 280px;
}
.skeleton-card .skeleton-preview {
  height: 160px;
  background: linear-gradient(90deg, var(--bg-alt) 25%, var(--border) 37%, var(--bg-alt) 63%);
  background-size: 600px 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
}
.skeleton-card .skeleton-line {
  height: 14px;
  margin: 12px 16px 0;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-alt) 25%, var(--border) 37%, var(--bg-alt) 63%);
  background-size: 600px 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
}
.skeleton-card .skeleton-line.short { width: 60%; }

/* Button press bounce */
.btn, .btn-icon, .tool-btn, .btn-cta-primary, .btn-cta-outline {
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), background var(--transition), color var(--transition), border-color var(--transition), opacity var(--transition);
}
.btn:active, .btn-icon:active, .tool-btn:active, .btn-cta-primary:active, .btn-cta-outline:active {
  transform: scale(0.97);
}

/* prefers-reduced-motion: disable all animations */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .sidebar {
    transition: none;
  }
  .lp-scroll-chevron { animation: none !important; }
  .lp-hero-map { transform: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   LANDING PAGE — Dark theme for home screen
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Skip Link ──────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: #8B2635;
  color: #F5F0E8;
  padding: 8px 16px;
  border-radius: 0 0 4px 4px;
  font-family: 'Cinzel', serif;
  font-size: 13px;
  z-index: 10000;
  text-decoration: none;
}
.skip-link:focus {
  top: 0;
  outline: 2px solid #8B2635;
  outline-offset: 2px;
}

/* ─── LP Focus visible ───────────────────────────────────────────── */
#home-screen *:focus-visible {
  outline: 2px solid #8B2635;
  outline-offset: 3px;
}

/* ─── 1. HERO ────────────────────────────────────────────────────── */
.lp-hero {
  position: relative;
  height: 100dvh;
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #0D0A07;
}

/* Background map */
.lp-hero-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  will-change: transform;
}
.lp-hero-map svg {
  width: 100%;
  height: 100%;
  filter: blur(1.5px);
  opacity: 0.25;
}

/* Gradient overlay */
.lp-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(13,10,7,0.2) 30%,
    rgba(13,10,7,0.6) 60%,
    #0D0A07 100%
  );
  pointer-events: none;
}

/* Hero content */
.lp-hero-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 0 20px;
}

/* Ornament */
.lp-ornament {
  display: block;
  margin: 0 auto 1.5rem;
  opacity: 0.8;
}

/* Title */
.lp-hero-title {
  font-family: 'Cinzel Decorative', 'Cinzel', serif;
  font-weight: 700;
  font-size: clamp(52px, 8vw, 96px);
  color: #F5F0E8;
  letter-spacing: 0.15em;
  text-shadow:
    0 1px 0 #8B6340,
    0 2px 0 #7A5530,
    0 4px 12px rgba(0,0,0,0.6);
  margin: 0;
  line-height: 1.1;
}

/* Tagline */
.lp-hero-tagline {
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: clamp(16px, 2vw, 22px);
  color: #C4A882;
  margin: 1.5rem 0 0;
}

/* Sub-tagline */
.lp-hero-sub {
  font-family: 'Source Serif 4', 'Georgia', serif;
  font-size: 16px;
  color: #8A7A6A;
  margin: 0.75rem 0 0;
}

/* CTA buttons */
.lp-hero-ctas {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 3rem;
}

.lp-cta-primary {
  font-family: 'Cinzel', serif;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.12em;
  padding: 14px 36px;
  border: none;
  border-radius: 2px;
  background: #8B2635;
  color: #F5F0E8;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.lp-cta-primary:hover {
  background: #A33040;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(139,38,53,0.4);
}
.lp-cta-primary:active {
  transform: translateY(0) scale(0.98);
}

.lp-cta-outline {
  font-family: 'Cinzel', serif;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.12em;
  padding: 14px 36px;
  border: 1px solid #C4A882;
  border-radius: 2px;
  background: transparent;
  color: #C4A882;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.lp-cta-outline:hover {
  background: rgba(196,168,130,0.1);
  transform: translateY(-2px);
}
.lp-cta-outline:active {
  transform: translateY(0) scale(0.98);
}

/* Import link (subtle) */
.lp-import-link {
  display: inline-block;
  margin-top: 1.5rem;
  font-family: 'Source Serif 4', 'Georgia', serif;
  font-size: 13px;
  color: #5A4A3A;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.lp-import-link:hover {
  color: #C4A882;
  border-bottom-color: #C4A882;
}

/* Scroll indicator */
.lp-scroll-indicator {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #5A4A3A;
}
.lp-scroll-text {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.lp-scroll-chevron {
  animation: lp-bounce 2s ease-in-out infinite;
}
@keyframes lp-bounce {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(6px); opacity: 1; }
}

/* ─── 2. STATS BAND ─────────────────────────────────────────────── */
.lp-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 28px 20px;
  background: #1A1208;
  border-top: 1px solid #2E2416;
  border-bottom: 1px solid #2E2416;
  flex-wrap: wrap;
}

.lp-stats-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0 clamp(20px, 3vw, 48px);
  /* fade-up animation */
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.lp-stats-item.lp-visible {
  opacity: 1;
  transform: translateY(0);
}

.lp-stats-icon {
  color: #8B2635;
  flex-shrink: 0;
}

.lp-stats-title {
  font-family: 'Cinzel', serif;
  font-weight: 500;
  font-size: 13px;
  color: #F5F0E8;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.lp-stats-sub {
  font-family: 'Source Serif 4', 'Georgia', serif;
  font-size: 12px;
  color: #8A7A6A;
  white-space: nowrap;
}

.lp-stats-sep {
  width: 1px;
  height: 40px;
  background: #2E2416;
  flex-shrink: 0;
}

/* Responsive: stack on small screens */
@media (max-width: 768px) {
  .lp-stats {
    flex-wrap: wrap;
    gap: 20px 0;
    padding: 24px 16px;
  }
  .lp-stats-sep {
    display: none;
  }
  .lp-stats-item {
    width: 50%;
    padding: 8px 0;
  }
}

/* ─── LP Sections (shared) ───────────────────────────────────── */
.lp-section {
  padding: 80px 0;
}
.lp-section-header {
  text-align: center;
  margin-bottom: 48px;
}
.lp-section-ornament {
  display: block;
  margin: 0 auto 20px;
}
.lp-section-title {
  font-family: 'Cinzel', serif;
  font-weight: 500;
  font-size: 32px;
  color: #F5F0E8;
  margin: 0;
}
.lp-section-sub {
  font-family: 'Source Serif 4', 'Georgia', serif;
  font-style: italic;
  font-size: 16px;
  color: #8A7A6A;
  margin: 8px 0 0;
}

/* ─── 3. WORLDS SECTION ──────────────────────────────────────── */
.lp-worlds-section {
  background: #0D0A07;
}

.lp-worlds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  padding: 0 clamp(24px, 5vw, 80px);
}

/* Override old .worlds-grid if #worlds-grid is used */
#worlds-grid.lp-worlds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

/* Dark world card */
.lp-worlds-section .world-card {
  background: #1A1208;
  border: 1px solid #2E2416;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.lp-worlds-section .world-card:hover {
  border-color: #8B2635;
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

/* Thumbnail wrapper */
.world-card-thumb {
  position: relative;
  overflow: hidden;
}
.lp-worlds-section .world-card-preview {
  width: 100%;
  height: 180px;
  display: block;
  background: #1A1208;
  border-bottom: 1px solid #2E2416;
}

/* Overlay on thumbnail only */
.lp-worlds-section .world-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13,10,7,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.lp-worlds-section .world-card:hover .world-card-overlay {
  opacity: 1;
  pointer-events: auto;
}
.lp-worlds-section .world-card-overlay .card-open {
  background: #8B2635;
  border: 1px solid #8B2635;
  color: #F5F0E8;
  font-family: 'Cinzel', serif;
  font-size: 12px;
  padding: 6px 16px;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.2s;
}
.lp-worlds-section .world-card-overlay .card-open:hover {
  background: #A33040;
}
.lp-worlds-section .world-card-overlay .card-export {
  background: transparent;
  border: 1px solid #C4A882;
  color: #C4A882;
  font-family: 'Cinzel', serif;
  font-size: 12px;
  padding: 6px 16px;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.2s;
}
.lp-worlds-section .world-card-overlay .card-export:hover {
  background: rgba(196,168,130,0.1);
}
.lp-worlds-section .world-card-overlay .delete-world {
  background: transparent;
  border: 1px solid #5A4A3A;
  color: #8A7A6A;
  border-radius: 2px;
  padding: 5px 7px;
  cursor: pointer;
  transition: all 0.2s;
  position: static;
  opacity: 1;
  font-size: inherit;
}
.lp-worlds-section .world-card-overlay .delete-world:hover {
  border-color: #c0392b;
  color: #c0392b;
}

/* Card body */
.lp-worlds-section .world-card-body {
  padding: 20px;
}
.lp-worlds-section .world-card h3 {
  font-family: 'Cinzel', serif;
  font-weight: 500;
  font-size: 18px;
  color: #F5F0E8;
  margin: 0 0 6px;
}
.lp-worlds-section .world-card p {
  font-family: 'Source Serif 4', 'Georgia', serif;
  font-size: 14px;
  color: #8A7A6A;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}
.lp-worlds-section .world-card-meta {
  font-size: 12px;
  color: #5A4A3A;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #2E2416;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.lp-worlds-section .world-card-meta svg {
  vertical-align: -1px;
  margin-right: 2px;
}

/* New world card (dashed) */
.lp-worlds-section .world-card-new {
  border: 1px dashed #2E2416;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  background: transparent;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.lp-worlds-section .world-card-new:hover {
  border-color: #8B2635;
  background: rgba(139,38,53,0.05);
}
.lp-worlds-section .world-card-new-inner {
  text-align: center;
  color: #5A4A3A;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.lp-worlds-section .world-card-new-inner svg {
  color: #2E2416;
  transition: color 0.25s;
}
.lp-worlds-section .world-card-new:hover .world-card-new-inner svg {
  color: #8B2635;
}
.lp-worlds-section .world-card-new-inner span {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  transition: color 0.25s;
}
.lp-worlds-section .world-card-new:hover .world-card-new-inner span {
  color: #C4A882;
}

/* Card animations (reuse existing fade-up) */
.lp-worlds-section .world-card,
.lp-worlds-section .world-card-new {
  opacity: 0;
}
.lp-worlds-section .world-card.visible,
.lp-worlds-section .world-card-new.visible {
  animation: fade-up 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Skeleton cards in dark theme */
.lp-worlds-section .skeleton-card {
  background: #1A1208;
  border: 1px solid #2E2416;
}
.lp-worlds-section .skeleton-card .skeleton-preview {
  background: linear-gradient(90deg, #1A1208 25%, #2E2416 37%, #1A1208 63%);
  background-size: 600px 100%;
}
.lp-worlds-section .skeleton-card .skeleton-line {
  background: linear-gradient(90deg, #1A1208 25%, #2E2416 37%, #1A1208 63%);
  background-size: 600px 100%;
}

/* ─── Section 4: Templates ──────────────────────────────────────── */

.lp-templates-section {
  background: #0F0C08;
  padding: clamp(48px, 5vw, 80px) clamp(20px, 4vw, 80px);
}

/* Carousel wrapper */
.lp-carousel-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Templates grid — 5 columns on large, carousel on smaller */
.lp-templates-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: clamp(14px, 1.2vw, 20px);
  flex: 1;
  min-width: 0;
}

@media (max-width: 1400px) {
  .lp-templates-grid {
    display: flex;
    overflow-x: auto;
    gap: 16px;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
  }
  .lp-templates-grid::-webkit-scrollbar {
    display: none;
  }
}

/* Carousel arrow buttons */
.lp-carousel-arrow {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #2E2416;
  background: rgba(15, 12, 8, 0.8);
  color: #8A7A6A;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  backdrop-filter: blur(4px);
}
.lp-carousel-arrow:hover {
  border-color: #C4A882;
  color: #C4A882;
  background: rgba(46, 36, 22, 0.6);
}
.lp-carousel-arrow:active {
  transform: scale(0.95);
}
/* Hide arrows on wide screens (grid, no scroll) */
@media (min-width: 1401px) {
  .lp-carousel-arrow {
    display: none;
  }
}

/* Template card — dark theme */
.lp-templates-section .lp-tpl-card {
  background: #1A1208;
  border: 1px solid #2E2416;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
  position: relative;
  min-width: 260px;
  scroll-snap-align: start;
}
.lp-templates-section .lp-tpl-card:hover {
  border-color: #C4A882;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  transform: translateY(-3px);
}

/* Template preview canvas */
.lp-tpl-card .lp-tpl-preview {
  width: 100%;
  height: 160px;
  display: block;
  border-bottom: 1px solid #2E2416;
}

/* Template info */
.lp-tpl-card .lp-tpl-info {
  padding: 14px 16px 16px;
}
.lp-tpl-card .lp-tpl-name {
  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: 500;
  color: #F5F0E8;
  margin: 0 0 6px;
}
.lp-tpl-card .lp-tpl-desc {
  font-family: 'Source Serif 4', serif;
  font-size: 12px;
  color: #8A7A6A;
  line-height: 1.5;
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Tags as pills */
.lp-tpl-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.lp-tpl-tag {
  font-family: 'Source Serif 4', serif;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #C4A882;
  border: 1px solid #2E2416;
  border-radius: 2px;
  padding: 2px 8px;
  background: rgba(46, 36, 22, 0.3);
}

/* "Utiliser ce template" hover button overlay */
.lp-tpl-card .lp-tpl-use {
  display: block;
  width: 100%;
  padding: 8px 0;
  background: #8B2635;
  color: #F5F0E8;
  border: none;
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease;
}
.lp-tpl-card:hover .lp-tpl-use {
  opacity: 1;
  transform: translateY(0);
}
.lp-tpl-card .lp-tpl-use:hover {
  background: #A02E40;
}

/* Card fade-up animation */
.lp-templates-section .lp-tpl-card {
  opacity: 0;
}
.lp-templates-section .lp-tpl-card.visible {
  animation: fade-up 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ─── Section 5: Features ───────────────────────────────────────── */

.lp-features-section {
  background: #0D0A07;
  padding: clamp(48px, 5vw, 80px) clamp(20px, 4vw, 80px);
}

/* Feature row — alternating layout */
.lp-feature {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(32px, 4vw, 80px);
  align-items: center;
  padding: clamp(32px, 3vw, 56px) 0;
  border-bottom: 1px solid #1A1208;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.lp-feature.visible {
  opacity: 1;
  transform: translateY(0);
}
.lp-feature:last-child {
  border-bottom: none;
}

/* Reverse row: visual left, text right */
.lp-feature-row-reverse {
  direction: rtl;
}
.lp-feature-row-reverse > * {
  direction: ltr;
}

/* Feature number decoration */
.lp-feature-num {
  display: block;
  font-family: 'Cinzel Decorative', 'Cinzel', serif;
  font-size: clamp(36px, 4vw, 64px);
  font-weight: 700;
  color: #1A1208;
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: 2px;
  user-select: none;
}

/* Feature text */
.lp-feature-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(18px, 1.6vw, 24px);
  font-weight: 500;
  color: #F5F0E8;
  margin: 0 0 12px;
}
.lp-feature-desc {
  font-family: 'Source Serif 4', serif;
  font-size: clamp(14px, 1.1vw, 16px);
  color: #8A7A6A;
  line-height: 1.7;
  margin: 0;
  max-width: 480px;
}

/* Feature visual — SVG illustration */
.lp-feature-visual {
  display: flex;
  align-items: center;
  justify-content: center;
}
.lp-feature-visual svg {
  width: 100%;
  max-width: 300px;
  height: auto;
  opacity: 0.85;
}

/* Responsive: stack on mobile */
@media (max-width: 768px) {
  .lp-feature {
    grid-template-columns: 1fr;
    gap: 24px;
    text-align: center;
  }
  .lp-feature-row-reverse {
    direction: ltr;
  }
  .lp-feature-desc {
    max-width: none;
  }
  .lp-feature-visual {
    order: -1;
  }
  .lp-feature-visual svg {
    max-width: 240px;
  }
}

/* ─── Section 6: Open Source ────────────────────────────────────── */

.lp-opensource-section {
  background: #1A1208;
  padding: clamp(56px, 6vw, 100px) clamp(20px, 4vw, 80px);
  text-align: center;
}
.lp-opensource-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Compass rose */
.lp-compass-rose {
  margin-bottom: 32px;
  opacity: 0;
  transform: rotate(-30deg) scale(0.8);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.lp-opensource-section.visible .lp-compass-rose {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Title & description */
.lp-opensource-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(22px, 2vw, 32px);
  font-weight: 500;
  color: #F5F0E8;
  margin: 0 0 16px;
  letter-spacing: 1px;
}
.lp-opensource-desc {
  font-family: 'Source Serif 4', serif;
  font-size: clamp(14px, 1.1vw, 16px);
  color: #8A7A6A;
  line-height: 1.7;
  margin: 0 0 32px;
  max-width: 520px;
}

/* GitHub stats row */
.lp-gh-stats {
  display: flex;
  gap: clamp(24px, 3vw, 48px);
  margin-bottom: 36px;
}
.lp-gh-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #5A4A3A;
}
.lp-gh-stat svg {
  color: #C4A882;
}
.lp-gh-stat-val {
  font-family: 'Cinzel', serif;
  font-size: 20px;
  font-weight: 700;
  color: #F5F0E8;
}
.lp-gh-stat-label {
  font-family: 'Source Serif 4', serif;
  font-size: 11px;
  color: #5A4A3A;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* CTAs */
.lp-opensource-ctas {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}
.lp-opensource-ctas .lp-cta-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.lp-gh-icon {
  flex-shrink: 0;
}

/* ─── Section 7: Footer ────────────────────────────────────────── */

.lp-footer {
  background: #0D0A07;
  padding: 0 clamp(20px, 4vw, 80px) clamp(24px, 2vw, 40px);
  color: #5A4A3A;
  font-family: 'Source Serif 4', serif;
}

.lp-footer-top {
  margin-bottom: clamp(32px, 3vw, 48px);
}

/* 3-column grid */
.lp-footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: clamp(24px, 3vw, 60px);
  margin-bottom: clamp(32px, 3vw, 48px);
}
@media (max-width: 768px) {
  .lp-footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}

/* Brand column */
.lp-footer-brand {
  font-family: 'Cinzel Decorative', 'Cinzel', serif;
  font-size: 18px;
  font-weight: 700;
  color: #C4A882;
  margin: 0 0 10px;
  letter-spacing: 2px;
}
.lp-footer-tagline {
  font-size: 13px;
  color: #5A4A3A;
  line-height: 1.6;
  margin: 0 0 16px;
  max-width: 320px;
}

/* Theme indicator */
.lp-footer-theme-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #5A4A3A;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.lp-footer-theme-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8B2635;
  box-shadow: 0 0 6px #8B263580;
}

/* Column headings */
.lp-footer-heading {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  font-weight: 500;
  color: #8A7A6A;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 0 0 14px;
}

/* Navigation links */
.lp-footer-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lp-footer-link {
  font-size: 13px;
  color: #5A4A3A;
  text-decoration: none;
  transition: color 0.2s ease;
}
.lp-footer-link:hover {
  color: #C4A882;
}

/* Bottom bar */
.lp-footer-bottom {
  border-top: 1px solid #1A1208;
  padding-top: clamp(16px, 1.5vw, 24px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.lp-footer-compass {
  animation: compass-spin 60s linear infinite;
}
.lp-footer-copy {
  font-size: 11px;
  color: #5A4A3A;
  margin: 0;
  letter-spacing: 0.5px;
}

/* ─── Language toggle ───────────────────────────────────── */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}
.lang-toggle-landing {
  position: absolute;
  top: 18px;
  right: 24px;
  z-index: 100;
}
.lang-toggle span[aria-hidden] {
  color: #5A4A3A;
  font-size: 10px;
  user-select: none;
}
.lang-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Cinzel', serif;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: #5A4A3A;
  padding: 2px 4px;
  transition: color 150ms, opacity 150ms;
}
.lang-btn:hover {
  color: #C4A882;
}
.lang-btn[aria-pressed="true"] {
  color: #F5F0E8;
}

/* ─── Empty State ───────────────────────────────────────── */
#canvas-empty-state {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 100;
  background: rgba(13, 10, 7, 0.92);
  border: 1px solid #2E2416;
  border-radius: 8px;
  padding: 48px 56px;
  backdrop-filter: blur(8px);
  box-shadow: 0 24px 64px rgba(0,0,0,0.8);
  max-width: 480px;
  width: 90%;
  transition: opacity 0.3s ease;
  color: #C4A882;
  pointer-events: auto;
}
@supports not (backdrop-filter: blur(8px)) {
  #canvas-empty-state { background: rgba(13,10,7,0.96); }
}
#canvas-empty-state h2 {
  font-family: 'Cinzel', serif;
  font-weight: 500;
  font-size: 22px;
  color: #F5F0E8;
  margin: 16px 0 12px;
}
#canvas-empty-state p {
  font-family: 'Source Serif Pro', 'Georgia', serif;
  font-size: 15px;
  color: #8A7A6A;
  line-height: 1.7;
  text-align: center;
  margin-bottom: 28px;
}
.empty-state-actions { display: flex; flex-direction: column; width: 100%; gap: 0; }
.es-btn-primary {
  background: #8B2635; color: #F5F0E8; border: none;
  padding: 12px 32px; border-radius: 2px; cursor: pointer;
  font-family: 'Cinzel', serif; font-weight: 500; font-size: 13px;
  letter-spacing: 0.12em; width: 100%; margin-bottom: 12px;
  transition: background 150ms, transform 150ms;
}
.es-btn-primary:hover { background: #A33040; transform: translateY(-1px); }
.es-btn-secondary {
  background: transparent; color: #8A7A6A;
  border: 1px solid #2E2416; padding: 12px 32px;
  border-radius: 2px; cursor: pointer;
  font-family: 'Cinzel', serif; font-weight: 500; font-size: 13px;
  letter-spacing: 0.12em; width: 100%;
  transition: border-color 150ms, color 150ms;
}
.es-btn-secondary:hover { border-color: #C4A882; color: #C4A882; }
.empty-state-compass { animation: compass-spin 20s linear infinite; }
@keyframes compass-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.empty-state-progress {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; gap: 12px;
}
.es-progress-text {
  font-family: 'Source Serif Pro', 'Georgia', serif;
  font-size: 13px; color: #8A7A6A;
}
.es-progress-bar {
  width: 100%; height: 3px; background: #2E2416;
  border-radius: 2px; overflow: hidden;
}
.es-progress-fill {
  height: 100%; background: #8B2635; width: 0%;
  border-radius: 2px; transition: width 400ms ease;
}
.empty-state-spinner { animation: spin-loader 1s linear infinite; }
@keyframes spin-loader {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ─── Brush Cursor ──────────────────────────────────────── */
#brush-cursor {
  position: absolute;
  pointer-events: none;
  border: 2px solid currentColor;
  border-radius: 50%;
  z-index: 999;
  transform: translate(-50%, -50%);
}

/* ─── Hints ─────────────────────────────────────────────── */
.hint-toast {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.6);
  color: #C4A882;
  font-family: 'Cinzel', serif;
  font-size: 12px;
  padding: 8px 16px;
  border: 1px solid #2E2416;
  border-radius: 4px;
  z-index: 100;
  pointer-events: none;
  transition: opacity 0.3s;
}

/* ─── Tutorial ──────────────────────────────────────────── */
.tutorial-overlay {
  position: fixed; inset: 0; z-index: 9998;
  pointer-events: auto; transition: opacity 0.2s;
}
.tutorial-tooltip {
  position: fixed; z-index: 9999;
  background: rgba(13, 10, 7, 0.95);
  border: 1px solid #2E2416;
  border-radius: 6px;
  padding: 20px 24px;
  max-width: 300px;
  color: #C4A882;
  transition: opacity 0.2s;
  pointer-events: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.tutorial-step-num {
  font-size: 11px; color: #5A4A3A;
  display: block; margin-bottom: 8px;
}
.tutorial-tooltip p {
  font-family: 'Source Serif Pro', 'Georgia', serif;
  font-size: 14px; color: #C4A882;
  line-height: 1.6; margin: 0 0 16px;
}
.tutorial-dots {
  display: flex; gap: 6px; margin-bottom: 12px;
}
.tutorial-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #2E2416;
}
.tutorial-dot.active { background: #8B2635; }
.tutorial-skip, .tutorial-finish {
  background: transparent; border: 1px solid #2E2416;
  color: #8A7A6A; padding: 6px 16px; border-radius: 2px;
  cursor: pointer; font-family: 'Cinzel', serif;
  font-size: 12px; letter-spacing: 0.08em;
  transition: border-color 150ms, color 150ms;
}
.tutorial-skip:hover, .tutorial-finish:hover {
  border-color: #C4A882; color: #C4A882;
}
.tutorial-finish {
  background: #8B2635; border-color: #8B2635;
  color: #F5F0E8; width: 100%;
}
.tutorial-finish:hover { background: #A33040; }

/* ─── Analysis Panel ─────────────────────────────────────────── */
.analysis-panel {
  position: fixed; top: 0; right: 0; width: 360px; height: 100vh;
  background: var(--bg); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.22,1,0.36,1);
  z-index: 900; display: flex; flex-direction: column; overflow-y: auto;
}
.analysis-panel.open { transform: translateX(0); }
.analysis-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.analysis-header h3 { font-family: var(--font-heading); margin: 0; font-size: 1.1rem; }
.analysis-score-row {
  display: flex; align-items: center; gap: 12px; padding: 16px;
  border-bottom: 1px solid var(--border);
}
.analysis-score-num { font-size: 2.4rem; font-family: var(--font-heading); font-weight: 700; }
.analysis-grade { font-size: 1.6rem; font-weight: 700; }
.analysis-rerun { margin-left: auto; font-size: 1.2rem; }
.analysis-filters {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}
.analysis-filter-btn {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px;
  background: transparent; font-size: 0.75rem; cursor: pointer;
  color: var(--ink); transition: background 0.15s;
}
.analysis-filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.analysis-list { padding: 8px 16px; flex: 1; }
.analysis-card {
  display: flex; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
  animation: fadeUp 0.3s ease both;
}
.analysis-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.analysis-card-body { flex: 1; }
.analysis-msg { margin: 0 0 4px; font-size: 0.85rem; }
.analysis-fix { margin: 0 0 6px; font-size: 0.8rem; font-style: italic; color: #8A7A6A; }
.analysis-card-actions { display: flex; gap: 6px; }
.analysis-card-actions .btn-sm {
  padding: 2px 8px; font-size: 0.75rem; border: 1px solid var(--border);
  border-radius: 3px; background: transparent; cursor: pointer; color: var(--ink);
}
.analysis-card-actions .btn-sm:hover { background: var(--bg-alt); }
.analysis-empty {
  text-align: center; padding: 40px 16px; color: #8A7A6A;
}
.analysis-empty svg { margin-bottom: 12px; }

/* ─── Lorebook Panel ─────────────────────────────────────────── */
.lorebook-panel {
  position: fixed; top: 0; right: 0; width: 380px; height: 100vh;
  background: var(--bg); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.22,1,0.36,1);
  z-index: 900; display: flex; flex-direction: column; overflow-y: auto;
}
.lorebook-panel.open { transform: translateX(0); }
.lorebook-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.lorebook-header h3 { margin: 0; font-family: var(--font-heading); font-size: 1.1rem; }
.lorebook-header small { display: block; color: #8A7A6A; font-size: 0.75rem; margin-top: 2px; }
.lorebook-header-actions { display: flex; gap: 6px; }
.lorebook-tabs {
  display: flex; border-bottom: 1px solid var(--border);
}
.lorebook-tab {
  flex: 1; padding: 8px; text-align: center; font-size: 0.8rem;
  border: none; background: transparent; cursor: pointer; color: var(--ink);
  border-bottom: 2px solid transparent; transition: border-color 0.15s;
}
.lorebook-tab.active { border-bottom-color: var(--accent); font-weight: 600; }
.lorebook-content { padding: 12px 16px; flex: 1; }
.lorebook-empty { text-align: center; padding: 40px 16px; color: #8A7A6A; }
.lorebook-event-card {
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.lorebook-ev-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.lorebook-ev-badge {
  padding: 2px 6px; border-radius: 3px; font-size: 0.7rem;
  color: #fff; text-transform: uppercase;
}
.lorebook-ev-year { font-size: 0.75rem; color: #8A7A6A; }
.lorebook-event-card h4 { margin: 4px 0; font-size: 0.9rem; }
.lorebook-event-card p { margin: 4px 0 8px; font-size: 0.82rem; color: #5A4A3A; }
.lorebook-add-timeline, .lorebook-accept, .lorebook-regen {
  padding: 3px 10px; font-size: 0.75rem; border: 1px solid var(--border);
  border-radius: 3px; background: transparent; cursor: pointer; color: var(--ink);
}
.lorebook-add-timeline:hover, .lorebook-accept:hover, .lorebook-regen:hover {
  background: var(--bg-alt);
}
.lorebook-territory-card, .lorebook-entity-card {
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.lorebook-territory-card h4, .lorebook-entity-card h4 {
  margin: 0 0 4px; font-size: 0.9rem;
}
.lorebook-lore-text { margin: 0 0 6px; font-size: 0.82rem; color: #5A4A3A; line-height: 1.4; }
.lorebook-entity-actions { display: flex; gap: 6px; }

/* ─── Analysis badge on toolbar ──────────────────────────────── */
.analysis-badge {
  position: absolute; top: -2px; right: -2px;
  width: 8px; height: 8px; border-radius: 50%;
  border: 1px solid var(--bg);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
