/* ==========================================================================
   RouteReel Studio — MapRecap+ Deep Navy-Indigo Design System
   ========================================================================== */

:root {
  --bg: #121524;
  --bg-deep: #0e1120;
  --panel: #181c2e;
  --panel-2: #222740;
  --panel-3: #2a304f;
  --input-bg: #131728;
  --line: rgba(255, 255, 255, 0.085);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #eef1fb;
  --text-2: #c5cde3;
  --muted: #8b94b2;
  --accent: #6366f1;
  --accent-bright: #5e6bff;
  --accent-deep: #4f5bff;
  --cyan: #34e3e0;
  --green: #3ddc97;
  --amber: #f5b82e;
  --danger: #f05a68;
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 54px;
  --sidebar-w: 392px;
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Poppins', 'Inter', system-ui, sans-serif;
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--font-sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

[hidden] {
  display: none !important;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ==========================================================================
   Top Bar
   ========================================================================== */

.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 40;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  color: var(--text);
  font: 700 15px/1 var(--font-display);
  letter-spacing: 0.01em;
  flex-shrink: 0;
  padding: 4px 4px 4px 2px;
  border-radius: 8px;
  transition: opacity 0.15s;
}

.brand:hover {
  opacity: 0.92;
}

.back-chev {
  font-size: 19px;
  line-height: 1;
  color: var(--text-2);
  margin-right: -1px;
  transition: color 0.15s, transform 0.15s;
}

.brand:hover .back-chev {
  color: #fff;
  transform: translateX(-2px);
}

.logo {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6d78ff 0%, #4f5bff 100%);
  color: #fff;
  font-size: 15px;
  box-shadow: 0 2px 12px rgba(94, 107, 255, 0.42);
  transform: rotate(-14deg);
  flex-shrink: 0;
}

.brand-name {
  white-space: nowrap;
}

/* Project title + dropdown */
.proj-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  max-width: 280px;
}

.proj-title-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 5px 8px;
  color: var(--text);
  font: 600 13.5px/1.2 var(--font-sans);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 230px;
  transition: background 0.15s, border-color 0.15s;
}

.proj-title-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}

.proj-title-input {
  width: 200px;
  max-width: 230px;
  background: var(--input-bg);
  border: 1px solid var(--accent-bright);
  border-radius: 7px;
  padding: 4px 8px;
  color: #fff;
  font: 600 13.5px/1.2 var(--font-sans);
  outline: none;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.proj-menu-btn {
  width: 26px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: #cbd5e1;
  font-size: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.proj-menu-btn svg {
  display: block;
  transition: transform 0.16s ease;
}

.proj-menu-btn[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.proj-menu-btn:hover,
.proj-menu-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* Auto-save indicator */
.save-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  padding-left: 4px;
}

.save-dot {
  color: var(--green);
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
}

.save-status.warn,
.save-status.is-warn,
.save-status[data-state="warn"] {
  color: var(--amber);
}

.save-status.warn .save-dot,
.save-status.is-warn .save-dot,
.save-status[data-state="warn"] .save-dot {
  color: var(--amber);
}

.save-status.saving .save-dot,
.save-status[data-state="saving"] .save-dot {
  color: var(--cyan);
}

/* Top-right actions */
.top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.ghost,
.add-row button,
.row-btns button {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 11px;
  color: var(--text);
  font: 500 12.5px/1.2 var(--font-sans);
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.ghost:hover:not(:disabled),
.add-row button:hover:not(:disabled),
.row-btns button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.1);
}

.ghost:disabled {
  opacity: 0.42;
}

.primary {
  background: linear-gradient(180deg, #6b76ff 0%, #525ef5 100%);
  color: #fff;
  border: 0;
  border-radius: 9px;
  padding: 7px 14px;
  font: 600 12.5px/1.2 var(--font-sans);
  white-space: nowrap;
  box-shadow: 0 3px 14px rgba(94, 107, 255, 0.34);
  transition: filter 0.15s, transform 0.12s, box-shadow 0.15s;
}

.primary:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 4px 18px rgba(94, 107, 255, 0.48);
}

.primary:active:not(:disabled) {
  transform: translateY(0.5px);
}

.primary:disabled {
  opacity: 0.45;
  box-shadow: none;
  filter: none;
}

.magic {
  border: 0;
  border-radius: 9px;
  padding: 7px 12px;
  font: 600 12.5px/1.2 var(--font-sans);
  color: #fff;
  background: linear-gradient(135deg, #f59e0b 0%, #ec4899 54%, #6366f1 100%);
  box-shadow: 0 2px 12px rgba(236, 72, 153, 0.28);
  white-space: nowrap;
  transition: filter 0.15s, transform 0.12s;
}

.magic:hover {
  filter: brightness(1.09);
}

.danger-btn {
  background: linear-gradient(180deg, #f26471 0%, #dc4250 100%);
  color: #fff;
  border: 0;
  border-radius: 9px;
  padding: 8px 15px;
  font: 600 13px/1.2 var(--font-sans);
  transition: filter 0.15s;
}

.danger-btn:hover {
  filter: brightness(1.08);
}

.export-cta {
  padding: 7px 15px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.055);
  color: #cbd5e1;
  display: grid;
  place-items: center;
  font-size: 15px;
  line-height: 1;
  flex: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.icon-btn svg {
  display: block;
  flex-shrink: 0;
}

#btn-keys {
  color: #cbd5e1;
}

#btn-keys:hover:not(:disabled) {
  color: #ffffff;
}

.icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--line-strong);
  color: #fff;
}

.icon-btn:disabled {
  opacity: 0.35;
}

.help-link {
  color: var(--muted);
  text-decoration: none;
  font: 500 12.5px/1 var(--font-sans);
  padding: 6px 6px;
  border-radius: 6px;
  white-space: nowrap;
  transition: color 0.15s;
}

.help-link:hover {
  color: #fff;
}

.seg-group {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}

.seg-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  font: 600 11.5px/1 var(--font-sans);
  padding: 6px 9px;
  border-radius: 7px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.seg-btn:hover {
  color: #fff;
}

.seg-btn.active {
  background: #2c3354;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.lang-wrap {
  position: relative;
}

.lang-btn {
  height: 32px;
  padding: 0 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  color: #cbd5e1;
  font: 600 12px/1 var(--font-sans);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.lang-chev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s ease;
}

.lang-chev svg {
  display: block;
}

.lang-btn[aria-expanded="true"] .lang-chev {
  transform: rotate(180deg);
}

.lang-btn:hover,
.lang-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--line-strong);
  color: #fff;
}

/* Slim non-intrusive network / routing degraded banner */
.net-status-banner {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  z-index: 38;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 5px 14px;
  background: rgba(34, 26, 12, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(245, 184, 46, 0.42);
  color: #fde3a4;
  font: 500 12px/1.3 var(--font-sans);
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.net-banner-ico {
  color: var(--amber);
  flex-shrink: 0;
}

/* Crisp SVG chevron helper for collapsible headers */
.chev-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
  transition: transform 0.16s ease, color 0.15s;
}

.chev-icon svg {
  display: block;
}

.chev-icon.is-open,
.batch-mode-toggle[aria-expanded="true"] .chev-icon {
  transform: rotate(180deg);
  color: #ffffff;
}

/* Popover menus (Project Menu + Language Switcher) */
.popover-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 276px;
  max-width: min(320px, calc(100vw - 24px));
  background: #1b2036;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  padding: 6px;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.62);
  z-index: 90;
}

.lang-pop {
  left: auto;
  right: 0;
  min-width: 184px;
}

.pop-header {
  padding: 6px 10px 4px;
  font: 600 11px/1.2 var(--font-sans);
  color: var(--muted);
  letter-spacing: 0.03em;
}

.pop-proj-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
}

.pop-proj-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  color: var(--text);
  transition: background 0.12s;
}

.pop-proj-item:hover {
  background: rgba(255, 255, 255, 0.07);
}

.pop-proj-item.active {
  background: rgba(99, 102, 241, 0.18);
}

.pop-proj-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pop-proj-name {
  font: 600 12.5px/1.25 var(--font-sans);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pop-badge {
  font: 600 10.5px/1 var(--font-sans);
  color: var(--cyan);
  background: rgba(52, 227, 224, 0.12);
  padding: 3px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}

.pop-proj-meta {
  font-size: 11px;
  color: var(--muted);
}

.pop-sep {
  height: 1px;
  background: var(--line);
  margin: 6px 4px;
}

.pop-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: 500 13px/1.25 var(--font-sans);
  text-align: left;
  transition: background 0.12s, color 0.12s;
}

.pop-item:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
}

.pop-item.active {
  background: rgba(99, 102, 241, 0.2);
  color: #fff;
  font-weight: 600;
}

.pop-item.danger {
  color: #ff7e8a;
}

.pop-item.danger:hover:not(:disabled) {
  background: rgba(240, 90, 104, 0.14);
  color: #ff9ba4;
}

.pop-item:disabled {
  opacity: 0.4;
}

.pop-note {
  padding: 7px 10px 4px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
}

/* ==========================================================================
   Main Workspace Layout (Full calc(100vh - 54px) Height, Zero Footer Timeline)
   ========================================================================== */

.layout {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--topbar-h));
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
   Left Sidebar Shell (6-Tab Nav + Scrollable Panel + Sticky Footer)
   ========================================================================== */

.sidebar {
  position: relative;
  width: var(--sidebar-w);
  min-width: 300px;
  max-width: 520px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  z-index: 18;
  transition: width 0.2s ease, min-width 0.2s ease;
}

.sidebar.resizing {
  transition: none;
  user-select: none;
}

.sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  border-right-color: transparent;
}

.sidebar.collapsed .sidebar-tabs,
.sidebar.collapsed .tab-scroll,
.sidebar.collapsed .sidebar-footer,
.sidebar.collapsed .sidebar-resizer {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* 6-Tab Icon + Label Nav */
.sidebar-tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  flex: none;
  background: #141829;
  border-bottom: 1px solid var(--line);
  padding: 4px 4px 0;
}

.sidebar-tabs button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 2px 10px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font: 500 11px/1 var(--font-sans);
  transition: color 0.15s;
}

.sidebar-tabs button svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.sidebar-tabs button:hover {
  color: var(--text);
}

.sidebar-tabs button.active {
  color: #fff;
  font-weight: 600;
}

.sidebar-tabs button.active::after {
  content: '';
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(52, 227, 224, 0.55);
}

/* Scrollable Tab Container — NEVER overlaps sidebar-footer */
.tab-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

.tab-scroll::-webkit-scrollbar {
  width: 6px;
}

.tab-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}

.tab-panel {
  display: block;
  padding-bottom: 24px;
}

/* Persistent Sidebar Footer */
.sidebar-footer {
  flex: none;
  background: #141828;
  border-top: 1px solid var(--line);
  z-index: 6;
}

.footer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px 10px;
}

.play-main {
  flex: 1;
  height: 40px;
  border-radius: 10px;
  font: 600 13.5px/1 var(--font-sans);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.play-main.playing {
  background: var(--panel-2);
  color: #fff;
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.stop-main {
  height: 40px;
  padding: 0 13px;
  border-radius: 10px;
  font: 600 13px/1 var(--font-sans);
  flex: none;
}

.footer-controls .icon-btn {
  width: 38px;
  height: 40px;
  border-radius: 10px;
  font-size: 16px;
}

.route-stats {
  padding: 8px 16px 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Drag-Resizer & Collapse Handle */
.sidebar-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  right: -5px;
  width: 10px;
  cursor: col-resize;
  z-index: 24;
}

.sidebar-resizer::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 4px;
  width: 2px;
  background: transparent;
  transition: background 0.15s;
}

.sidebar-resizer:hover::after,
.sidebar.resizing .sidebar-resizer::after {
  background: var(--accent-bright);
  box-shadow: 0 0 8px rgba(94, 107, 255, 0.6);
}

.sidebar-collapse-btn {
  position: absolute;
  top: 50%;
  right: -13px;
  transform: translateY(-50%);
  width: 22px;
  height: 46px;
  border-radius: 0 9px 9px 0;
  border: 1px solid var(--line-strong);
  border-left: 0;
  background: #1e233a;
  color: var(--text-2);
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  z-index: 28;
  box-shadow: 4px 0 14px rgba(0, 0, 0, 0.36);
  transition: background 0.15s, color 0.15s, width 0.15s;
}

.sidebar-collapse-btn:hover {
  background: #2b3252;
  color: #fff;
}

.sidebar.collapsed .sidebar-collapse-btn {
  left: 0;
  right: auto;
  width: 26px;
  background: #242b47;
  color: #fff;
}

/* Editor Lock During Export — dims & disables everything EXCEPT #export-cancel-btn */
.sidebar.editor-locked .sidebar-tabs,
.sidebar.editor-locked .sidebar-footer,
.sidebar.editor-locked .sidebar-resizer,
.sidebar.editor-locked .tab-panel:not(#tab-export),
.sidebar.editor-locked #tab-export > *:not(#export-cancel-btn):not(:has(#export-cancel-btn)) {
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
}

.sidebar.editor-locked #tab-export :is(button, input, select, textarea):not(#export-cancel-btn) {
  opacity: 0.55;
  pointer-events: none;
}

.sidebar.editor-locked #export-cancel-btn {
  opacity: 1 !important;
  pointer-events: auto !important;
  cursor: pointer !important;
  position: relative;
  z-index: 12;
  filter: none !important;
}

/* ==========================================================================
   Shared Sidebar Controls Kit (All 6 Tabs)
   ========================================================================== */

.tab-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.tab-title {
  margin: 0 0 3px;
  font: 700 18px/1.2 var(--font-display);
  color: #fff;
  letter-spacing: -0.01em;
}

.tab-sub {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.sec-label,
.ctrl-label,
.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font: 600 10.5px/1.2 var(--font-sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 0 8px;
}

.slider-val,
.range-val {
  color: var(--cyan);
  font: 600 12px/1 var(--font-mono);
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.hint {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
  margin: 6px 0 10px;
}

.error {
  color: #ff8590;
  font-size: 12px;
  min-height: 1em;
}

/* Segmented Controls (.seg-tabs) */
.seg-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 4px 0 10px;
}

.seg-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 12px/1.2 var(--font-sans);
  padding: 8px 6px;
  border-radius: 7px;
  white-space: nowrap;
  text-align: center;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.seg-tabs button:hover:not(:disabled) {
  color: var(--text);
}

.seg-tabs button.active {
  background: linear-gradient(180deg, #6b76ff 0%, #525ef5 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(94, 107, 255, 0.36);
}

.seg-tabs button:disabled,
.seg-tabs button.is-disabled {
  opacity: 0.38;
  cursor: not-allowed;
  color: var(--muted);
}

.seg-tabs.compact button {
  font-size: 11px;
  padding: 7px 3px;
}

/* 2-Column Map Style Thumbnail Grid (.style-grid-2) */
.style-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 10px 0 6px;
}

.style-card {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid var(--line-strong);
  background: #0f1324;
  padding: 0;
  text-align: left;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.style-card:hover {
  border-color: rgba(107, 118, 255, 0.78);
  transform: translateY(-1px);
}

.style-card.active {
  border-color: #6a78ff;
  box-shadow: 0 0 0 2px rgba(106, 120, 255, 0.38);
}

.style-card > svg,
.style-card > img,
.style-card .style-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.style-card .style-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(6, 9, 20, 0.82) 0%, rgba(6, 9, 20, 0.16) 46%, transparent 100%);
  pointer-events: none;
}

.style-card .style-label {
  position: absolute;
  left: 8px;
  bottom: 6px;
  right: 30px;
  font: 600 12px/1.15 var(--font-sans);
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
  z-index: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.style-card .style-check {
  position: absolute;
  right: 7px;
  bottom: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #6a78ff;
  color: #fff;
  display: none;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  z-index: 2;
}

.style-card.active .style-check {
  display: grid;
}

.tile-credit {
  font-size: 11px;
  color: var(--muted);
  margin: 4px 0 12px;
  line-height: 1.4;
}

/* 3-Column Vehicle Variant Grid (.vehicle-grid-3) */
.vehicle-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 6px 0 10px;
}

.vehicle-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding: 8px 6px 7px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: #161b2f;
  color: var(--text-2);
  font: 500 11px/1.2 var(--font-sans);
  text-align: center;
  min-height: 92px;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.vehicle-card:hover {
  border-color: rgba(107, 118, 255, 0.65);
  background: #1e243e;
  color: #fff;
}

.vehicle-card.active {
  border-color: #6a78ff;
  background: rgba(99, 102, 241, 0.18);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(106, 120, 255, 0.35);
}

.vehicle-card img {
  width: 100%;
  max-width: 82px;
  height: 46px;
  object-fit: contain;
  display: block;
}

.vehicle-card span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Color Swatches (.swatch-row) */
.swatch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin: 6px 0 12px;
}

.swatch-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  padding: 0;
  position: relative;
  flex: none;
  background-clip: padding-box;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}

.swatch-btn:hover {
  transform: scale(1.1);
}

.swatch-btn.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px #fff;
}

.swatch-btn.is-default {
  background: conic-gradient(from 0deg, #ff3b30, #ff9500, #ffd60a, #34c759, #34e3e0, #0a84ff, #bf5af2, #ff3b30);
}

.swatch-picker {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.35);
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}

/* Inputs & Sliders */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-bright);
}

input[type="color"] {
  width: 100%;
  height: 34px;
  padding: 2px;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: #2b3250;
  outline: none;
  margin: 6px 0;
  accent-color: var(--accent-bright);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--accent-bright);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 0.12s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.12);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--accent-bright);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

input[type="range"]:disabled {
  opacity: 0.4;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}

/* Toggle Switch & Toggle Cards */
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text);
}

.toggle input,
.toggle-card input[type="checkbox"] {
  display: none;
}

.switch {
  position: relative;
  width: 38px;
  height: 22px;
  flex: none;
  border-radius: 999px;
  background: #2c3352;
  transition: background 0.18s;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #cfd6eb;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s, background 0.18s;
}

.toggle input:checked + .switch,
.toggle-card input:checked + .switch {
  background: linear-gradient(135deg, #6b76ff, #525ef5);
}

.toggle input:checked + .switch::after,
.toggle-card input:checked + .switch::after {
  transform: translateX(16px);
  background: #fff;
}

.toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  margin: 8px 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.toggle-card:hover {
  border-color: var(--line-strong);
}

.toggle-card.disabled,
.toggle-card:has(input:disabled) {
  opacity: 0.52;
  cursor: not-allowed;
}

.toggle-card .tc-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.toggle-card .tc-title {
  font: 600 13px/1.25 var(--font-sans);
  color: var(--text);
}

.toggle-card .tc-desc {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
}

.toggle-card .tc-note {
  font-size: 11px;
  color: var(--amber);
  margin-top: 2px;
}

.toggle-sub {
  margin: -2px 0 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* Info, Privacy & Attribution Cards */
.info-box {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  margin: 8px 0 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.privacy-box {
  background: rgba(61, 220, 151, 0.07);
  border-color: rgba(61, 220, 151, 0.28);
  color: #b7f5d8;
}

.warn-box {
  background: rgba(245, 184, 46, 0.08);
  border-color: rgba(245, 184, 46, 0.32);
  color: #fde09b;
}

.attrib-box {
  padding: 12px;
  margin: 12px 0;
  border-radius: 11px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-2);
}

.attrib-copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.attrib-code {
  flex: 1;
  font: 400 11px/1.45 var(--font-mono);
  color: var(--text-2);
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  word-break: break-word;
}

/* Transport Leg Cards & Upload Photo Button */
.leg-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin: 10px 0;
}

.leg-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  font: 600 13px/1.25 var(--font-sans);
  color: #fff;
}

.leg-dist {
  font: 500 12px/1 var(--font-mono);
  color: var(--muted);
  white-space: nowrap;
}

.teal-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(52, 227, 224, 0.35);
  background: rgba(52, 227, 224, 0.12);
  color: #aef7f5;
  font: 600 13px/1.2 var(--font-sans);
  transition: background 0.15s, border-color 0.15s;
}

.teal-btn:hover {
  background: rgba(52, 227, 224, 0.2);
  border-color: rgba(52, 227, 224, 0.58);
  color: #fff;
}

/* Export Tab Specifics */
.export-est-note {
  font: 500 11.5px/1.35 var(--font-mono);
  color: var(--cyan);
  margin: 0 0 6px;
  font-variant-numeric: tabular-nums;
}

.export-cap-note {
  font-size: 11px;
  line-height: 1.4;
  color: #fde3a4;
  background: rgba(245, 184, 46, 0.08);
  border: 1px solid rgba(245, 184, 46, 0.28);
  border-radius: 8px;
  padding: 6px 9px;
  margin: 4px 0 8px;
}

.export-unsupported-banner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px 12px;
  margin: 8px 0 10px;
  border-radius: 10px;
  background: rgba(240, 90, 104, 0.12);
  border: 1px solid rgba(240, 90, 104, 0.45);
  color: #ffc2c8;
  font-size: 12px;
  line-height: 1.45;
}

.export-unsupported-txt {
  font-weight: 500;
}

.export-copy-link-btn {
  align-self: flex-start;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
}

.export-share-btn {
  width: 100%;
  margin-top: 2px;
}

/* Persistent Cross-Sea Car Warning inside Route/Transport leg */
.leg-ocean-warn {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(245, 184, 46, 0.11);
  border: 1px solid rgba(245, 184, 46, 0.42);
  color: #fde3a4;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11.5px;
  line-height: 1.35;
}

.leg-ocean-warn-txt {
  font-weight: 500;
}

.leg-ocean-warn-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.leg-ocean-btn {
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid rgba(245, 184, 46, 0.5);
  background: rgba(245, 184, 46, 0.18);
  color: #fff6dc;
  font: 600 11.5px/1.2 var(--font-sans);
  transition: background 0.14s, border-color 0.14s;
}

.leg-ocean-btn:hover {
  background: rgba(245, 184, 46, 0.34);
  border-color: rgba(245, 184, 46, 0.85);
  color: #fff;
}

.render-cta {
  width: 100%;
  height: 44px;
  font: 700 14px/1 var(--font-sans);
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.export-progress-box {
  padding: 12px;
  border-radius: 11px;
  background: var(--panel-2);
  border: 1px solid rgba(99, 102, 241, 0.4);
  margin: 10px 0;
}

.export-bar-track,
.bar {
  height: 7px;
  border-radius: 999px;
  background: #272e4c;
  overflow: hidden;
  margin: 8px 0;
}

.export-bar-fill,
#ex-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #6366f1, #34e3e0);
  transition: width 0.15s linear;
}

#export-cancel-btn {
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid rgba(240, 90, 104, 0.55);
  background: rgba(240, 90, 104, 0.16);
  color: #ff98a2;
  font: 600 12.5px/1.2 var(--font-sans);
}

#export-cancel-btn:hover {
  background: rgba(240, 90, 104, 0.28);
  color: #fff;
}

.export-json-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* Collapsible sections (Audio mixer, Advanced scenes) */
.collapse-box,
.adv-scenes {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.collapse-box > summary,
.adv-scenes > summary {
  font: 600 12.5px/1.3 var(--font-sans);
  color: var(--text-2);
  cursor: pointer;
  margin-bottom: 8px;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.collapse-box > summary::-webkit-details-marker,
.adv-scenes > summary::-webkit-details-marker {
  display: none;
}

/* Legacy scene / highlight / spotlight cards */
.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.card.playing {
  border-color: var(--cyan);
}

.card.open {
  border-color: rgba(107, 118, 255, 0.55);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  cursor: pointer;
}

.card-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 7px;
  background: #2c3354;
  font-weight: 700;
  font-size: 12px;
}

.card.playing .card-num {
  background: var(--accent-bright);
  color: #fff;
}

.card-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.card-title small {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-tools {
  display: flex;
  gap: 2px;
}

.card-tools button,
.x {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.card-tools button:hover,
.x:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.card-tools .danger:hover {
  background: rgba(240, 90, 104, 0.22);
  color: #ff8e99;
}

.card-body {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
}

.countries {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.country-row {
  display: grid;
  grid-template-columns: 34px 1fr 100px 24px;
  gap: 6px;
  align-items: center;
}

.country-row input[type="color"] {
  height: 28px;
}

.wide {
  width: 100%;
  padding: 11px;
  margin-top: 8px;
}

.btn-link {
  display: block;
  text-align: center;
  text-decoration: none;
}

.link-btn {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--cyan);
  font: 600 12px/1.2 var(--font-sans);
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Cinema Map Stage + Phone Bezel + Internal Overlays + Embedded Scrubber
   ========================================================================== */

.stage {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 42%, #202744 0%, #15192d 58%, #101322 100%);
}

.stage.placing,
.stage.placing #map,
.stage.placing canvas {
  cursor: crosshair !important;
}

.stage-center {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 20px 10px;
}

/* Phone Bezel Wrapper */
.phone-bezel {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-radius 0.22s ease, box-shadow 0.22s ease;
}

.phone-notch,
.phone-home-bar {
  display: none;
  pointer-events: none;
}

/* Realistic Titanium-Black iPhone Bezel when PREVIEW AS is active */
.phone-bezel[data-preview="tiktok"],
.phone-bezel[data-preview="instagram"],
.phone-bezel[data-preview="shorts"] {
  flex: none;
  box-sizing: content-box;
  aspect-ratio: 9 / 16;
  height: min(calc(100% - 46px), 740px);
  max-width: calc(100% - 36px);
  width: auto;
  border: 10px solid #161820;
  border-radius: 42px;
  background: #090b12;
  overflow: hidden;
  box-shadow:
    0 34px 86px rgba(0, 0, 0, 0.76),
    0 0 0 1.5px rgba(255, 255, 255, 0.14),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.phone-bezel[data-preview="tiktok"] .phone-notch,
.phone-bezel[data-preview="instagram"] .phone-notch,
.phone-bezel[data-preview="shorts"] .phone-notch {
  display: block;
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 92px;
  height: 22px;
  border-radius: 999px;
  background: #07080c;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.65), inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  z-index: 36;
}

.phone-bezel[data-preview="tiktok"] .phone-home-bar,
.phone-bezel[data-preview="instagram"] .phone-home-bar,
.phone-bezel[data-preview="shorts"] .phone-home-bar {
  display: block;
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 112px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  z-index: 36;
}

.phone-bezel[data-preview="tiktok"] .frame,
.phone-bezel[data-preview="instagram"] .frame,
.phone-bezel[data-preview="shorts"] .frame {
  border-radius: 32px;
  box-shadow: none;
}

/* Cinema Map Frame */
.frame {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center;
  border-radius: 14px;
  overflow: hidden;
  background: #070a14;
  box-shadow:
    0 28px 76px rgba(0, 0, 0, 0.58),
    0 0 0 1px rgba(255, 255, 255, 0.09);
}

/* Only canvas/map/safezone fill the full frame; buttons & scrubber stay cleanly positioned! */
.frame > #stars,
.frame > #map,
.frame > #overlay,
.frame > .safezone {
  position: absolute;
  inset: 0;
}

#overlay {
  pointer-events: none;
  z-index: 6;
}

/* Hide MapLibre's default colliding attribution so our clean #map-credit-pill handles it */
.maplibregl-ctrl-attrib {
  display: none !important;
}

/* Unscaled HUD overlay aligned 1:1 over #frame (P0-5: crisp 36-40px touch targets on desktop & mobile!) */
.stage-hud {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 25;
  border-radius: 14px;
}

.stage-hud > button,
.stage-hud > .map-zoom-stack,
.stage-hud > .anim-scrubber {
  pointer-events: auto;
}

/* Corner Overlays & Embedded Scrubber (Unscaled inside #stage-hud) */
.map-pill.tl-pill {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(18, 22, 36, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f4f6fc;
  font: 600 13.5px/1 var(--font-sans);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  transition: opacity 0.22s ease, background 0.15s, transform 0.12s;
}

.map-pill.tl-pill:hover {
  background: rgba(24, 30, 50, 0.96);
  transform: translateY(-1px);
}

.map-pill.tl-pill.active {
  background: #e11d48;
  border-color: #fb7185;
  color: #fff;
}

.map-sq-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.94);
  color: #141826;
  font: 700 18px/1 var(--font-sans);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
  transition: background 0.14s, opacity 0.22s ease;
}

.map-sq-btn:hover {
  background: #fff;
}

.map-sq-btn.tr-fit {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 25;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(18, 22, 36, 0.84);
  backdrop-filter: blur(8px);
  color: #f4f6fc;
  font-size: 18px;
}

.map-sq-btn.tr-fit:hover {
  background: rgba(26, 32, 52, 0.96);
}

.map-zoom-stack {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.26);
  transition: opacity 0.22s ease, bottom 0.2s ease;
}

.map-zoom-stack .map-sq-btn {
  width: 36px;
  height: 36px;
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: none;
}

.map-zoom-stack .map-sq-btn:last-child {
  border-bottom: 0;
  font-size: 16px;
  cursor: grab;
}

.map-zoom-stack .map-sq-btn:last-child:active {
  cursor: grabbing;
}

/* Style-Aware Attribution Pill INSIDE #stage-hud BR (cleanly LEFT of zoom stack) */
.map-credit-pill {
  position: absolute;
  right: 60px;
  bottom: 14px;
  z-index: 24;
  max-width: calc(100% - 104px);
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(12, 16, 28, 0.72);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(240, 244, 255, 0.9);
  font: 500 11.5px/1.25 var(--font-sans);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transition: bottom 0.2s ease, right 0.2s ease;
}

/* Lift bottom controls cleanly above scrubber whenever scrubber is visible (playing OR paused mid-route) */
.stage.has-scrubber .map-zoom-stack,
.stage.has-scrubber .map-credit-pill {
  bottom: 60px;
}

/* Hide interactive corner tools during playback; lift credit pill above scrubber */
.stage.is-playing .stage-hud .tl-pill,
.stage.is-playing .stage-hud .tr-fit,
.stage.is-playing .stage-hud .map-zoom-stack {
  opacity: 0;
  pointer-events: none;
}

.stage.is-playing .map-credit-pill {
  right: 14px;
  bottom: 60px;
}

/* Embedded Dark-Pill Scrubber INSIDE bottom of #stage-hud (always unscaled 38px tall!) */
.anim-scrubber {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 9px 0 14px;
  border-radius: 999px;
  background: rgba(15, 18, 30, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.48);
}

.anim-scrubber input[type="range"] {
  flex: 1;
  height: 4px;
  margin: 0;
  background: rgba(255, 255, 255, 0.24);
  accent-color: var(--cyan);
}

.anim-scrubber input[type="range"]::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--cyan);
  border: 2px solid #0e1322;
  box-shadow: 0 0 10px rgba(52, 227, 224, 0.78);
}

.anim-scrubber input[type="range"]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--cyan);
  border: 2px solid #0e1322;
  box-shadow: 0 0 10px rgba(52, 227, 224, 0.78);
}

.scrub-time {
  font: 600 13px/1 var(--font-mono);
  color: #eef1fb;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.scrub-speed-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  min-width: 44px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.09);
  color: #eef1fb;
  font: 700 12px/1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.scrub-speed-btn:hover {
  background: rgba(255, 255, 255, 0.17);
  border-color: rgba(255, 255, 255, 0.34);
  color: #fff;
}

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

.scrub-speed-btn.is-fast {
  background: rgba(52, 227, 224, 0.2);
  border-color: rgba(52, 227, 224, 0.7);
  color: #7df6f3;
  box-shadow: 0 0 12px rgba(52, 227, 224, 0.28);
}

.scrub-speed-btn.is-slow {
  background: rgba(245, 184, 46, 0.2);
  border-color: rgba(245, 184, 46, 0.68);
  color: #fde3a4;
  box-shadow: 0 0 12px rgba(245, 184, 46, 0.24);
}

/* Below-Frame Row (Interactive Segment Module Dock + Speed Hint + OSM Credit) */
.stage-subrow {
  position: relative;
  flex: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 6px 8px 0;
}

.segment-dock-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.segment-dock-wrap::before,
.segment-dock-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.segment-dock-wrap::before {
  left: 0;
  background: linear-gradient(to right, rgba(16, 19, 34, 0.96) 0%, rgba(16, 19, 34, 0) 100%);
}

.segment-dock-wrap::after {
  right: 0;
  width: 52px;
  background: linear-gradient(to left, rgba(16, 19, 34, 0.98) 32%, rgba(16, 19, 34, 0) 100%);
}

.segment-dock-wrap.has-scroll-left::before {
  opacity: 1;
}

.segment-dock-wrap.has-scroll-right::after {
  opacity: 1;
}

.segment-dock-counter {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(20, 25, 44, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e2e8f0;
  font: 700 10.5px/1.2 var(--font-mono);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.segment-dock {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  margin: 0 auto;
}

.segment-dock-wrap.is-overflowing .segment-dock {
  padding-right: 46px;
}

.segment-dock::-webkit-scrollbar {
  display: none;
}

.seg-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  min-width: 112px;
  max-width: 240px;
  padding: 0 10px;
  scroll-snap-align: start;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(25, 30, 50, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-2);
  font: 500 12px/1 var(--font-sans);
  white-space: nowrap;
  transition: border-color 0.16s, background 0.16s, color 0.16s, box-shadow 0.16s, transform 0.12s;
}

.seg-chip:hover {
  border-color: rgba(107, 118, 255, 0.6);
  background: rgba(36, 43, 72, 0.94);
  color: #fff;
  transform: translateY(-1px);
}

.seg-chip.is-highlight {
  background: rgba(245, 184, 46, 0.13);
  border-color: rgba(245, 184, 46, 0.42);
  color: #fde3a4;
}

.seg-chip.is-highlight:hover {
  background: rgba(245, 184, 46, 0.22);
  border-color: rgba(245, 184, 46, 0.72);
  color: #fff3d1;
}

.seg-chip.is-spotlight {
  background: rgba(236, 72, 153, 0.13);
  border-color: rgba(236, 72, 153, 0.42);
  color: #fbcfe8;
}

.seg-chip.is-spotlight:hover {
  background: rgba(236, 72, 153, 0.22);
  border-color: rgba(236, 72, 153, 0.72);
  color: #ffe4f2;
}

.seg-chip.active,
.seg-chip.is-open {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.32) 0%, rgba(52, 227, 224, 0.22) 100%);
  border-color: rgba(52, 227, 224, 0.82);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(52, 227, 224, 0.35), 0 4px 16px rgba(52, 227, 224, 0.22);
}

.seg-ico {
  font-size: 13.5px;
  line-height: 1;
  flex-shrink: 0;
}

.seg-idx {
  font: 700 10.5px/1 var(--font-mono);
  color: var(--muted);
  flex-shrink: 0;
}

.seg-chip.active .seg-idx,
.seg-chip.is-open .seg-idx {
  color: var(--cyan);
}

.seg-lbl {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  font-weight: 600;
}

.seg-dur {
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font: 600 10.5px/1.1 var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: #d6def5;
}

.seg-dur.is-custom {
  background: rgba(52, 227, 224, 0.18);
  color: var(--cyan);
}

/* Floating Glassmorphic Segment Timing Popover (#segment-popover) */
.segment-popover {
  position: fixed;
  width: 290px;
  max-width: calc(100vw - 24px);
  border-radius: 14px;
  z-index: 60;
  padding: 13px 14px 12px;
  background: rgba(20, 24, 42, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 22px 54px rgba(0, 0, 0, 0.68),
    0 0 0 1px rgba(107, 118, 255, 0.22);
  color: var(--text);
}

.seg-pop-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 9px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.seg-pop-title-wrap {
  min-width: 0;
  flex: 1;
}

.seg-pop-title {
  font: 700 13px/1.25 var(--font-display);
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seg-pop-sub {
  margin-top: 2px;
  font: 500 11.5px/1.2 var(--font-mono);
  color: var(--muted);
}

.seg-pop-close {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 12px;
  flex-shrink: 0;
  transition: background 0.14s, color 0.14s;
}

.seg-pop-close:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.seg-pop-field {
  margin: 8px 0;
}

.seg-pop-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  font: 600 10.5px/1.2 var(--font-sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.seg-pop-val {
  color: var(--cyan);
  font: 700 12px/1 var(--font-mono);
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}

.seg-pop-reset {
  display: inline-block;
  margin-top: 2px;
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--cyan);
  font: 600 11px/1.2 var(--font-sans);
  cursor: pointer;
}

.seg-pop-reset:hover {
  text-decoration: underline;
}

.seg-pop-modes {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  margin-top: 6px;
}

.seg-pop-mode-btn {
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  font-size: 15px;
  display: grid;
  place-items: center;
  transition: border-color 0.14s, background 0.14s;
}

.seg-pop-mode-btn:hover {
  border-color: rgba(107, 118, 255, 0.6);
  background: rgba(99, 102, 241, 0.14);
}

.seg-pop-mode-btn.active {
  border-color: #6b76ff;
  background: rgba(99, 102, 241, 0.28);
  box-shadow: 0 0 0 1px rgba(107, 118, 255, 0.38);
}

.seg-pop-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.seg-pop-actions button {
  height: 31px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
}

.stage-subrow-meta {
  width: 100%;
  min-height: 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.speed-hint-row {
  grid-column: 2;
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.osm-footer-credit {
  grid-column: 3;
  justify-self: end;
  font-size: 11px;
  color: rgba(155, 166, 198, 0.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pure Route Mode Amber Card in Route Tab */
.pure-route-banner {
  background: rgba(245, 184, 46, 0.12) !important;
  border-color: rgba(245, 184, 46, 0.48) !important;
}

.amber-cta-btn {
  background: linear-gradient(180deg, #f7c348 0%, #e59f16 100%);
  color: #16120a;
  border: 0;
  border-radius: 7px;
  padding: 6px 11px;
  font: 700 11.5px/1.2 var(--font-sans);
  box-shadow: 0 2px 10px rgba(245, 184, 46, 0.28);
  transition: filter 0.15s;
}

.amber-cta-btn:hover {
  filter: brightness(1.07);
}

/* ==========================================================================
   High-Contrast TikTok / Instagram Reels / YouTube Shorts Safe-Zone Chrome
   ========================================================================== */

.safezone {
  pointer-events: none;
  z-index: 22;
  font-family: var(--font-sans);
  overflow: hidden;
}

/* Top & bottom dark gradient scrims guarantee 100% white-text legibility on bright light-sky maps */
.safezone::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 19%;
  background: linear-gradient(to bottom, rgba(6, 9, 18, 0.56) 0%, rgba(6, 9, 18, 0.18) 58%, transparent 100%);
  pointer-events: none;
}

.safezone::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 44%;
  background: linear-gradient(to top, rgba(6, 9, 18, 0.84) 0%, rgba(6, 9, 18, 0.48) 42%, rgba(6, 9, 18, 0.14) 76%, transparent 100%);
  pointer-events: none;
}

.sz-top {
  position: absolute;
  top: 64px;
  left: 24px;
  right: 24px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  font-size: 24px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.78);
}

.sz-top.is-reels {
  justify-content: space-between;
  padding: 0 6px;
  font-size: 30px;
}

.sz-tab-muted {
  opacity: 0.72;
  font-weight: 600;
}

.sz-tab-active {
  position: relative;
  color: #fff;
}

.sz-tab-active::after {
  content: '';
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: -8px;
  height: 4px;
  border-radius: 999px;
  background: #fff;
}

.sz-right {
  position: absolute;
  right: 18px;
  bottom: 138px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 22px;
  align-items: center;
  color: #fff;
  font-size: 19px;
  font-weight: 600;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
}

.sz-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.sz-ico {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(12, 16, 28, 0.34);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  display: grid;
  place-items: center;
  font-size: 26px;
}

.sz-avatar {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6b76ff, #34e3e0);
  border: 3px solid #fff;
  display: grid;
  place-items: center;
  font-size: 26px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

.sz-avatar-plus {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fe2c55;
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.sz-vinyl {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: radial-gradient(circle, #e2e8f0 0 18%, #1e293b 20% 54%, #0f172a 56% 100%);
  border: 3px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.55);
}

.sz-bottom {
  position: absolute;
  left: 24px;
  right: 112px;
  bottom: 42px;
  z-index: 2;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}

.sz-handle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.sz-handle {
  font-weight: 700;
  font-size: 24px;
  line-height: 1.2;
}

.sz-follow-btn {
  padding: 5px 14px;
  border-radius: 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.82);
  font-size: 18px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.2);
}

.sz-sub-btn {
  padding: 6px 16px;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font-size: 17px;
  font-weight: 700;
  text-shadow: none;
}

.sz-cap {
  font-size: 21px;
  line-height: 1.38;
  opacity: 0.96;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sz-audio {
  font-size: 19px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sz-emoji {
  display: inline-block;
  margin: 0 3px 0 2px;
}

.sz-badge {
  display: none;
}

/* Pure TikTok / Reels / Shorts phone screen: hide ALL studio editing chrome inside phone mockup (P2-4) */
.phone-bezel[data-preview="tiktok"] .stage-hud,
.phone-bezel[data-preview="instagram"] .stage-hud,
.phone-bezel[data-preview="shorts"] .stage-hud {
  border-radius: 32px;
}

.phone-bezel[data-preview="tiktok"] .stage-hud .tl-pill,
.phone-bezel[data-preview="instagram"] .stage-hud .tl-pill,
.phone-bezel[data-preview="shorts"] .stage-hud .tl-pill,
.phone-bezel[data-preview="tiktok"] .stage-hud .tr-fit,
.phone-bezel[data-preview="instagram"] .stage-hud .tr-fit,
.phone-bezel[data-preview="shorts"] .stage-hud .tr-fit,
.phone-bezel[data-preview="tiktok"] .stage-hud .map-zoom-stack,
.phone-bezel[data-preview="instagram"] .stage-hud .map-zoom-stack,
.phone-bezel[data-preview="shorts"] .stage-hud .map-zoom-stack,
.phone-bezel[data-preview="tiktok"] .stage-hud .map-credit-pill,
.phone-bezel[data-preview="instagram"] .stage-hud .map-credit-pill,
.phone-bezel[data-preview="shorts"] .stage-hud .map-credit-pill {
  display: none !important;
}

.phone-bezel[data-preview="tiktok"] .stage-hud .anim-scrubber,
.phone-bezel[data-preview="instagram"] .stage-hud .anim-scrubber,
.phone-bezel[data-preview="shorts"] .stage-hud .anim-scrubber {
  display: none !important;
}

/* ==========================================================================
   Empty State & Loading Overlay
   ========================================================================== */

.empty-overlay {
  position: absolute;
  inset: 0;
  z-index: 26;
  display: grid;
  place-items: center;
  padding: 20px;
  pointer-events: none;
}

.empty-card {
  pointer-events: auto;
  width: min(440px, 100%);
  padding: 24px 26px;
  border-radius: 16px;
  background: rgba(20, 24, 42, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line-strong);
  box-shadow: 0 26px 68px rgba(0, 0, 0, 0.58);
  text-align: center;
}

.empty-card h3 {
  margin: 0 0 8px;
  font: 700 18px var(--font-display);
  color: #fff;
}

.empty-card p {
  margin: 0 0 18px;
  line-height: 1.5;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.empty-actions button {
  padding: 9px 14px;
}

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font: 500 15px var(--font-sans);
  background: var(--bg);
  z-index: 35;
}

/* ==========================================================================
   Modals (#clear-modal, #trip-modal, #keys-modal)
   ========================================================================== */

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6, 9, 18, 0.72);
  backdrop-filter: blur(5px);
  z-index: 80;
}

.modal-card {
  width: min(440px, calc(100vw - 32px));
  background: #1a1f35;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65);
}

.wide-card {
  width: min(600px, calc(100vw - 32px));
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.modal-head h3 {
  margin: 0;
  font: 700 17px var(--font-display);
  color: #fff;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* Type your trip modal */
#trip-text {
  width: 100%;
  resize: vertical;
  min-height: 110px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--input-bg);
  color: var(--text);
  font: 14.5px/1.5 var(--font-sans);
}

#trip-text:focus {
  border-color: var(--accent-bright);
}

.trip-preview {
  margin: 8px 0 6px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(52, 227, 224, 0.075);
  border: 1px solid rgba(52, 227, 224, 0.28);
  font-size: 12px;
  line-height: 1.4;
}

.trip-preview.is-warn {
  background: rgba(245, 184, 46, 0.08);
  border-color: rgba(245, 184, 46, 0.34);
  color: #fde3a4;
}

.trip-preview-head {
  font-weight: 600;
  color: #9bf7f4;
  display: flex;
  align-items: center;
  gap: 6px;
}

.trip-preview.is-warn .trip-preview-head {
  color: #fde3a4;
}

.trip-preview-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
}

.trip-prev-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #eef1fb;
  font: 500 11.5px/1.2 var(--font-sans);
}

.trip-prev-chip.is-highlight {
  background: rgba(245, 184, 46, 0.14);
  border-color: rgba(245, 184, 46, 0.42);
  color: #fde3a4;
}

.trip-prev-chip.is-spotlight {
  background: rgba(236, 72, 153, 0.14);
  border-color: rgba(236, 72, 153, 0.42);
  color: #fbcfe8;
}

.trip-prev-arrow {
  color: var(--muted);
  font-size: 11px;
}

.trip-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}

.trip-examples button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text-2);
  border-radius: 10px;
  padding: 5px 10px;
  font-size: 11.5px;
  line-height: 1.35;
  text-align: left;
  text-wrap: balance;
  max-width: 100%;
  transition: border-color 0.15s, color 0.15s;
}

.trip-examples button:hover {
  color: #fff;
  border-color: var(--accent-bright);
}

.trip-help {
  margin: 10px 0;
  color: var(--muted);
  font-size: 12.5px;
}

.trip-help summary {
  cursor: pointer;
}

.trip-help ul {
  margin: 6px 0 0;
  padding-left: 18px;
  line-height: 1.6;
}

.trip-log {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.6;
}

.trip-log .ok {
  color: var(--green);
}

.trip-log .warn {
  color: var(--amber);
}

/* Keyboard shortcuts table (Two-Section Playback + Map Navigation) */
.keys-card {
  width: min(760px, calc(100vw - 28px));
  max-height: 88vh;
  overflow-y: auto;
}

.keys-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 6px;
}

.keys-section {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
}

.keys-sec-title {
  font: 700 11px/1.2 var(--font-sans);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 6px;
}

.keys {
  width: 100%;
  border-collapse: collapse;
  margin: 4px 0 0;
  font-size: 12.5px;
}

.keys td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
}

.keys tr:last-child td {
  border-bottom: 0;
}

.keys td:first-child {
  white-space: nowrap;
  width: 44%;
}

@media (max-width: 720px) {
  .keys-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  background: var(--panel-2);
  font: 600 11.5px var(--font-mono);
  text-align: center;
  color: #fff;
}

/* ==========================================================================
   7-Step Interactive Spotlight Tour (#tour-overlay) & Floating Toast (#toast)
   ========================================================================== */

.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: auto;
}

.tour-spot {
  position: fixed;
  border-radius: 12px;
  box-shadow:
    0 0 0 9999px rgba(6, 9, 18, 0.72),
    0 0 0 2px var(--cyan),
    0 0 22px rgba(52, 227, 224, 0.35);
  pointer-events: none;
  transition: top 0.24s ease, left 0.24s ease, width 0.24s ease, height 0.24s ease;
}

.tour-card {
  position: fixed;
  width: min(352px, calc(100vw - 24px));
  background: #1c223b;
  border: 1px solid rgba(107, 118, 255, 0.45);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.68);
  z-index: 102;
}

.tour-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tour-step-badge {
  font: 600 11px/1 var(--font-mono);
  color: var(--cyan);
  background: rgba(52, 227, 224, 0.12);
  padding: 4px 8px;
  border-radius: 999px;
}

.tour-skip {
  color: var(--muted);
  font-weight: 500;
}

.tour-title {
  margin: 0 0 6px;
  font: 700 15.5px/1.25 var(--font-display);
  color: #fff;
}

.tour-body {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
}

.tour-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tour-dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.tour-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  transition: width 0.2s, background 0.2s;
}

.tour-dot.active {
  width: 18px;
  background: var(--cyan);
}

.tour-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Non-blocking floating toast in top-center safe zone (P2-2: never covers Leg 1 dock chip or modals) */
.toast {
  position: fixed;
  top: 66px;
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  max-width: min(520px, calc(100vw - 28px));
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(20, 25, 44, 0.96);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line-strong);
  color: #eef1fb;
  font: 500 13px/1.35 var(--font-sans);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.56);
  text-align: center;
  pointer-events: none;
}

.toast.warn {
  border-color: rgba(245, 184, 46, 0.55);
  color: #fde3a4;
}

.toast.error {
  border-color: rgba(240, 90, 104, 0.6);
  color: #ffa5ae;
}

.toast.ok {
  border-color: rgba(61, 220, 151, 0.55);
  color: #b7f5d8;
}

.toast.has-actions {
  pointer-events: auto;
  border-radius: 16px;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
  padding: 9px 14px;
}

.toast-msg {
  display: inline-block;
}

.toast-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.toast-action-btn {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font: 600 12px/1.2 var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
}

.toast-action-btn:hover {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(255, 255, 255, 0.48);
}

.toast.warn .toast-action-btn {
  border-color: rgba(245, 184, 46, 0.55);
  background: rgba(245, 184, 46, 0.2);
  color: #fff6dc;
}

.toast.warn .toast-action-btn:hover {
  background: rgba(245, 184, 46, 0.36);
}

/* ==========================================================================
   Responsive Breakpoints (Laptop, Tablet & Mobile <= 767px)
   ========================================================================== */

@media (max-width: 1200px) {
  :root {
    --sidebar-w: 356px;
  }
  .save-status .save-txt {
    display: none;
  }
}

@media (max-width: 1020px) {
  .brand-name,
  #btn-help {
    display: none;
  }
  .proj-title-btn {
    max-width: 160px;
  }
}

@media (max-width: 767px) {
  :root {
    --topbar-h: 48px;
  }

  html, body {
    height: 100dvh;
    overflow: hidden;
  }

  /* Compact single-row top bar with ZERO horizontal overflow */
  .topbar {
    height: var(--topbar-h);
    padding: 0 6px;
    padding-top: env(safe-area-inset-top);
    gap: 4px;
    max-width: 100vw;
  }

  .top-left {
    gap: 3px;
    flex: 1;
    min-width: 0;
  }

  .brand {
    padding: 2px;
    gap: 0;
  }

  .back-chev,
  .brand-name,
  #save-status,
  #btn-keys,
  #btn-help {
    display: none;
  }

  .logo {
    width: 26px;
    height: 26px;
    font-size: 13px;
    border-radius: 7px;
  }

  .proj-wrap {
    max-width: 96px;
    min-width: 0;
    gap: 0;
  }

  .proj-title-btn {
    max-width: 72px;
    padding: 4px 4px;
    font-size: 11.5px;
  }

  .proj-menu-btn {
    width: 20px;
    height: 26px;
  }

  .top-actions {
    gap: 3px;
  }

  .top-actions .btn-lbl {
    display: none;
  }

  #btn-trip,
  #btn-new {
    width: 28px;
    height: 28px;
    padding: 0;
    display: grid;
    place-items: center;
    font-size: 13px;
    border-radius: 7px;
  }

  #aspect-bar {
    padding: 2px;
    gap: 1px;
    border-radius: 7px;
  }

  #aspect-bar .seg-btn {
    padding: 5px 5px;
    font-size: 10px;
    border-radius: 5px;
  }

  #btn-export-tab {
    width: 28px;
    height: 28px;
    padding: 0;
    display: grid;
    place-items: center;
    font-size: 13px;
    border-radius: 7px;
  }

  #btn-tour {
    width: 26px;
    height: 28px;
    font-size: 12px;
    border-radius: 7px;
  }

  .lang-btn {
    height: 28px;
    padding: 0 6px;
    font-size: 10.5px;
    border-radius: 7px;
  }

  /* Stacked layout: tight top map stage (40vh, min 260px) + generous bottom sheet (~60vh) (P0-5, P1-7) */
  .layout {
    flex-direction: column;
    height: calc(100dvh - var(--topbar-h));
  }

  .stage {
    order: 1;
    flex: none;
    height: 40vh;
    min-height: 260px;
    width: 100%;
  }

  .stage-center {
    padding: 4px 8px 11px;
  }

  /* Keep unscaled HUD crisp & full-size on phones even in narrow 9:16/1:1 aspect */
  .phone-bezel[data-preview="off"] .stage-hud {
    min-width: min(100%, 340px);
  }

  .stage-hud .map-pill.tl-pill {
    top: 8px;
    left: 8px;
    min-height: 36px;
    padding: 7px 12px;
    font-size: 12.5px;
  }

  .stage-hud .map-sq-btn.tr-fit {
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    font-size: 17px;
  }

  .stage-hud .map-zoom-stack {
    right: 8px;
    bottom: 8px;
  }

  .stage-hud .map-zoom-stack .map-sq-btn {
    width: 36px;
    height: 34px;
    font-size: 17px;
  }

  .stage-hud .map-credit-pill {
    right: 50px;
    bottom: 8px;
    font-size: 10px;
    padding: 3px 8px;
    max-width: calc(100% - 68px);
  }

  .stage-hud .anim-scrubber {
    left: 8px;
    right: 8px;
    bottom: 6px;
    height: 38px;
    padding: 0 8px 0 12px;
    gap: 8px;
  }

  .stage-hud .scrub-time {
    font-size: 11.5px;
  }

  .stage-hud .scrub-speed-btn {
    height: 26px;
    min-width: 40px;
    padding: 0 7px;
    font-size: 11.5px;
  }

  .stage.has-scrubber .stage-hud .map-zoom-stack,
  .stage.has-scrubber .stage-hud .map-credit-pill {
    bottom: 48px;
  }

  .stage.is-playing .stage-hud .map-credit-pill {
    right: 8px;
    bottom: 48px;
  }

  .stage-subrow {
    gap: 3px;
    padding: 2px 4px 2px;
  }

  .seg-chip {
    height: 28px;
    min-width: 98px;
    padding: 0 8px;
    font-size: 11px;
  }

  .segment-dock-counter {
    font-size: 10px;
    padding: 2px 6px;
  }

  .segment-popover {
    padding: 10px 12px;
    width: min(290px, calc(100vw - 24px));
  }

  /* P1-7: Stack subrow meta cleanly & hide OSM credit whenever speed hint is shown — zero text collision! */
  .stage-subrow-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 18px;
    padding-bottom: 2px;
  }

  .speed-hint-row {
    font-size: 11px;
    line-height: 1.3;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .net-status-banner {
    font-size: 11px;
    padding: 4px 10px;
  }

  .osm-footer-credit {
    font-size: 10px;
    max-width: 100%;
  }

  .stage.has-scrubber .osm-footer-credit {
    display: none;
  }

  .phone-bezel[data-preview="tiktok"],
  .phone-bezel[data-preview="instagram"],
  .phone-bezel[data-preview="shorts"] {
    height: calc(100% - 14px);
    border-width: 6px;
    border-radius: 26px;
  }

  .sidebar {
    order: 2;
    flex: 1;
    min-height: 0;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    border-right: 0;
    border-top: 1px solid var(--line-strong);
    border-radius: 16px 16px 0 0;
    margin-top: -6px;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
    z-index: 22;
  }

  .sidebar-resizer,
  .sidebar-collapse-btn {
    display: none;
  }

  /* Reorder inside bottom sheet: scrollable panel -> compact play bar -> native 6-tab bar pinned at bottom */
  .tab-scroll {
    order: 1;
    padding: 10px 12px 24px;
  }

  /* P1-7: Keep primary Render video CTA 100% above the fold on 390x844 Export tab */
  .sidebar[data-tab="export"] .sidebar-footer {
    display: none;
  }

  #tab-export .tab-head {
    margin-bottom: 6px;
  }

  #tab-export .tab-title {
    font-size: 16px;
    margin-bottom: 1px;
  }

  #tab-export .tab-sub {
    font-size: 11px;
    line-height: 1.3;
  }

  #tab-export .sec-label {
    margin: 7px 0 4px;
    font-size: 10px;
  }

  #tab-export .seg-tabs {
    margin: 2px 0 5px;
    padding: 2px;
  }

  #tab-export .seg-tabs button {
    padding: 5px 4px;
    font-size: 11px;
  }

  #tab-export .hint {
    margin: 2px 0 5px;
    font-size: 10.5px;
    line-height: 1.3;
  }

  #tab-export .render-cta {
    height: 40px;
    margin-top: 6px;
  }

  /* Wider mobile stop search dropdown (P1-7 / N17b) */
  .stop-dd,
  .stop-search .dropdown {
    left: -56px;
    right: -52px;
  }

  .sidebar-footer {
    order: 2;
  }

  .footer-controls {
    padding: 8px 12px;
    gap: 6px;
  }

  .play-main,
  .stop-main,
  .footer-controls .icon-btn {
    height: 36px;
  }

  .route-stats {
    display: none;
  }

  .sidebar-tabs {
    order: 3;
    border-top: 1px solid var(--line);
    border-bottom: 0;
    background: #121626;
    padding: 4px 4px max(6px, env(safe-area-inset-bottom));
  }

  .sidebar-tabs button {
    padding: 6px 2px 4px;
    font-size: 10px;
    gap: 3px;
  }

  .sidebar-tabs button svg {
    width: 16px;
    height: 16px;
  }

  .sidebar-tabs button.active::after {
    top: 0;
    bottom: auto;
    border-radius: 0 0 2px 2px;
  }

  /* Prevent iOS Safari zoom on input tap */
  input[type="text"],
  input[type="number"],
  input[type="date"],
  select,
  textarea,
  #trip-text {
    font-size: 16px;
  }

  .modal {
    align-items: end;
  }

  .modal-card,
  .wide-card {
    width: 100%;
    max-height: 90dvh;
    overflow-y: auto;
    border-radius: 18px 18px 0 0;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .toast {
    top: 56px;
    bottom: auto;
    font-size: 12px;
  }
}
