/* =======================
   VARIABLES & GLOBALS
======================= */
:root {
  --bg-light: #f5f7fa;
  --bg-dark: #0f172a;
  --card-light: #ffffff;
  --card-dark: #020617;
  --text-light: #0f172a;
  --text-dark: #e5e7eb;
  --accent: #6366f1;
  --accent-light: #0b79ff;
  --muted: #94a3b8;
  --border: #334155;
  --border-light: #1e293b;
  --btn-gradient: linear-gradient(135deg, #6366f1, #22c55e);
  /* Speedometer layout & surfaces */
  --spd-space-xs: 6px;
  --spd-space-sm: 10px;
  --spd-space-md: 16px;
  --spd-space-lg: 20px;
  --spd-space-xl: 28px;
  --spd-radius: 16px;
  --spd-radius-sm: 12px;
  --spd-shadow: 0 8px 24px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(15, 23, 42, 0.04);
  --spd-shadow-dark: 0 12px 32px rgba(0, 0, 0, 0.45);
  --spd-sidebar-bg: rgba(255, 255, 255, 0.92);
  --spd-sidebar-bg-dark: rgba(15, 23, 42, 0.85);
}

/* =======================
   BODY
======================= */
body {
  margin: 0;
  font-family: "Inter", sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 20vh;
  background: transparent;
  color: var(--text-light);
  transition: all 0.3s ease;
}

body.dark {
  background: transparent;
  color: var(--text-dark);
}

/* =======================
   CONTAINERS & PANELS
======================= */
.container,
.tool-container,
.panel,
.results,
.result-box,
.preview-box,
.preview-container,
.preview,
.card,
.export-area,
.buttons-box,
.tools-box,
.controls {
  background: var(--card-light);
  color: var(--text-light);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
  
}

body.dark .container,
body.dark .tool-container,
body.dark .panel,
body.dark .results,
body.dark .result-box,
body.dark .preview-box,
body.dark .preview-container,
body.dark .preview,
body.dark .card,
body.dark .export-area,
body.dark .buttons-box,
body.dark .tools-box,
body.dark .controls {
  background: var(--card-dark);
  color: var(--text-dark);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}

/* =======================
   HEADINGS
======================= */
h2, h3, strong, .tool-title {
  color: var(--text-light);
  transition: color 0.3s ease;
}

body.dark h2, body.dark h3, body.dark strong, body.dark .tool-title {
  color: var(--text-dark);
}

/* =======================
   LABELS & SUBTITLES
======================= */
label, .subtitle, .field-info, .tooltip, .level, .timeline-legend, .small {
  color: var(--muted);
}

body.dark label, body.dark .subtitle, body.dark .field-info, body.dark .tooltip,
body.dark .level, body.dark .timeline-legend, body.dark .small {
  color: var(--muted);
}

/* =======================
   INPUTS / TEXTAREAS / SELECTS
======================= */
input, select, textarea {
  background: #f5f5f5;
  color: var(--text-light);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 8px 10px;
  transition: all 0.3s ease;
}

input::placeholder,
textarea::placeholder {
  color: #64748b;
}

body.dark input,
body.dark select,
body.dark textarea {
  background: #020617;
  color: var(--text-dark);
  border: 1px solid var(--border);
}

body.dark input::placeholder,
body.dark textarea::placeholder {
  color: var(--muted);
}

/* =======================
   BUTTONS
======================= */
button, .btn {
  background: var(--btn-gradient);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
}

button:hover, .btn:hover {
  filter: brightness(1.1);
}

button.secondary, .btn.secondary {
  background: var(--card-dark);
  color: var(--text-dark);
  border: 1px solid var(--border);
}

/* =======================
   TABLES
======================= */
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th, td {
  border: 1px solid var(--border-light);
  padding: 8px;
  color: var(--text-light);
}

th {
  background: #f0f0f0;
}

tr:nth-child(even) {
  background: #f9f9f9;
}

body.dark table {
  background: #1e1e1e;
}

body.dark th, body.dark td {
  border: 1px solid #333;
  color: #e0e0e0;
}

body.dark th {
  background: #2a2a2a;
}

body.dark tr:nth-child(even) {
  background: #242424;
}

body.dark tr:nth-child(odd) {
  background: #1e1e1e;
}

/* =======================
   CANVAS / GRAPH
======================= */
canvas {
  border-radius: 8px;
  transition: all 0.3s ease;
}

body.dark canvas {
  background: #020617;
}

/* =======================
   SCROLLBARS (Webkit)
======================= */
textarea::-webkit-scrollbar-track {
  background: #f0f0f0;
}

textarea::-webkit-scrollbar-thumb {
  background: #c0c0c0;
  border-radius: 6px;
}

body.dark textarea::-webkit-scrollbar-track {
  background: #020617;
}

body.dark textarea::-webkit-scrollbar-thumb {
  background: #475569;
}

/* =======================
   SPD LAYOUT (main + sidebar)
======================= */
.tool-container.spd-tool-shell {
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.spd-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: var(--spd-space-lg);
  align-items: start;
  width: 100%;
}

#spd-sidebar.spd-sidebar {
  box-sizing: border-box;
  min-width: 0;
}

#spd-sidebar.spd-sidebar-card {
  position: sticky !important;
  top: 0 !important;
  top: var(--spd-space-md);
  background: var(--spd-sidebar-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: var(--spd-radius);
  padding: var(--spd-space-md);
  box-shadow: var(--spd-shadow);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

body.dark #spd-sidebar.spd-sidebar-card {
  background: var(--spd-sidebar-bg-dark);
  border-color: rgba(51, 65, 85, 0.85);
  box-shadow: var(--spd-shadow-dark);
}

#spd-sidebar .btn.secondary {
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-light);
  border: 1px solid rgba(148, 163, 184, 0.45);
}

body.dark #spd-sidebar .btn.secondary {
  background: var(--card-dark);
  color: var(--text-dark);
  border: 1px solid var(--border);
}

@media (max-width: 880px) {
  .spd-layout {
    grid-template-columns: 1fr;
    gap: var(--spd-space-md);
  }

  #spd-sidebar.spd-sidebar-card {
    position: relative;
    top: auto;
  }
}

/* =======================
   SPD WIDGET
======================= */
#spd-widget.spd-card {
  box-sizing: border-box;
  position: relative;
  background: linear-gradient(145deg, #f5f5f5, #cce0ff);
  padding: var(--spd-space-lg);
  border-radius: var(--spd-radius);
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: var(--spd-shadow);
  text-align: center;
  transition: background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  min-height: 0;
  overflow-y: auto;
  flex-shrink: 0;
}

#spd-widget .spd-toast-host {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: calc(100% - 24px);
  max-width: 280px;
  pointer-events: none;
}

#spd-widget .spd-toast {
  width: 100%;
  max-width: 280px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  background: rgba(15, 23, 42, 0.92);
  color: #f1f5f9;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

#spd-widget .spd-toast--visible {
  opacity: 1;
  transform: translateY(0);
}

#spd-widget .spd-toast--out {
  opacity: 0;
  transform: translateY(-6px);
}

body.dark #spd-widget .spd-toast {
  background: rgba(2, 6, 23, 0.95);
  color: #e2e8f0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

#spd-widget.spd-card.spd-mode-scooter {
  background: linear-gradient(145deg, #f0f9ff, #dbeafe);
  box-shadow: var(--spd-shadow), 0 0 0 1px rgba(14, 165, 233, 0.08);
}

#spd-widget.spd-card.spd-mode-running {
  background: linear-gradient(145deg, #f5fdf5, #dcfce7);
  box-shadow: var(--spd-shadow), 0 0 0 1px rgba(34, 197, 94, 0.08);
}

body.dark #spd-widget.spd-card {
  background: linear-gradient(145deg, #0f172a, #1e293b);
  color: var(--text-dark);
  border-color: rgba(51, 65, 85, 0.65);
  box-shadow: var(--spd-shadow-dark);
}

body.dark #spd-widget.spd-card.spd-mode-scooter {
  background: linear-gradient(145deg, #0c1929, #164e63);
  box-shadow: var(--spd-shadow-dark), 0 0 0 1px rgba(34, 211, 238, 0.06);
}

body.dark #spd-widget.spd-card.spd-mode-running {
  background: linear-gradient(145deg, #0f1f14, #14532d);
  box-shadow: var(--spd-shadow-dark), 0 0 0 1px rgba(74, 222, 128, 0.05);
}

#spd-widget .spd-mode {
  display: flex;
  gap: var(--spd-space-xs);
  justify-content: center;
  margin-bottom: var(--spd-space-md);
  flex-wrap: wrap;
}

#spd-widget .spd-mode-btn {
  flex: 1;
  min-width: 76px;
  max-width: 120px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-light);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

body.dark #spd-widget .spd-mode-btn {
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-dark);
  border-color: var(--border);
}

#spd-widget .spd-mode-btn:hover {
  filter: brightness(1.03);
}

#spd-widget .spd-mode-btn[aria-pressed="true"] {
  background: var(--btn-gradient);
  color: #fff;
  border-color: transparent;
}

body.dark #spd-widget .spd-mode-btn[aria-pressed="true"] {
  color: #fff;
}

#spd-widget .spd-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--spd-space-sm);
  margin-bottom: var(--spd-space-md);
  padding: var(--spd-space-sm) var(--spd-space-md);
  text-align: left;
  font-size: 0.9rem;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.45);
  border-radius: var(--spd-radius-sm);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

@media (min-width: 400px) {
  #spd-widget .spd-stats {
    grid-template-columns: 1fr 1fr;
  }

  #spd-widget .spd-stats > div:nth-child(1) {
    grid-column: 1 / -1;
  }
}

body.dark #spd-widget .spd-stats {
  background: rgba(15, 23, 42, 0.35);
  border-color: rgba(51, 65, 85, 0.5);
}

#spd-widget .spd-stats .spd-accuracy {
  grid-column: 1 / -1;
  padding-top: var(--spd-space-xs);
  margin-top: var(--spd-space-xs);
  border-top: 1px dashed rgba(148, 163, 184, 0.35);
  font-size: 0.85rem;
}

body.dark #spd-widget .spd-stats .spd-accuracy {
  border-top-color: rgba(51, 65, 85, 0.55);
}

#spd-widget .spd-accuracy-value {
  font-weight: 700;
}

#spd-widget.spd-gps-weak {
  box-shadow: var(--spd-shadow), 0 0 0 2px rgba(239, 68, 68, 0.35);
}

body.dark #spd-widget.spd-gps-weak {
  box-shadow: var(--spd-shadow-dark), 0 0 0 2px rgba(248, 113, 113, 0.35);
}

#spd-widget .spd-accuracy--na .spd-accuracy-value {
  color: var(--muted);
  font-weight: 600;
}

#spd-widget .spd-accuracy--good .spd-accuracy-value {
  color: #15803d;
}

#spd-widget .spd-accuracy--medium .spd-accuracy-value {
  color: #a16207;
}

#spd-widget .spd-accuracy--poor .spd-accuracy-value {
  color: #b91c1c;
}

body.dark #spd-widget .spd-accuracy--good .spd-accuracy-value {
  color: #4ade80;
}

body.dark #spd-widget .spd-accuracy--medium .spd-accuracy-value {
  color: #facc15;
}

body.dark #spd-widget .spd-accuracy--poor .spd-accuracy-value {
  color: #f87171;
}

#spd-sidebar .spd-ride-history {
  text-align: left;
  margin: 0;
  padding: 0;
  border: none;
}

#spd-sidebar .spd-history-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 var(--spd-space-sm);
  padding-bottom: var(--spd-space-xs);
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  color: var(--text-light);
}

body.dark #spd-sidebar .spd-history-title {
  color: var(--text-dark);
  border-bottom-color: rgba(51, 65, 85, 0.85);
}

#spd-sidebar .spd-ride-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--spd-space-sm);
  max-height: min(52vh, 360px);
  overflow-y: auto;
}

#spd-sidebar .spd-ride-item {
  padding: var(--spd-space-sm) var(--spd-space-sm);
  margin-bottom: var(--spd-space-xs);
  border-radius: var(--spd-radius-sm);
  background: rgba(0, 0, 0, 0.04);
  font-size: 0.82rem;
  line-height: 1.45;
  border: 1px solid transparent;
  transition: border-color 0.2s ease, background 0.2s ease;
}

#spd-sidebar .spd-ride-item:last-child {
  margin-bottom: 0;
}

body.dark #spd-sidebar .spd-ride-item {
  background: rgba(255, 255, 255, 0.06);
}

#spd-sidebar .spd-ride-date {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--accent-light);
}

#spd-sidebar .spd-ride-stats {
  color: var(--muted);
}

#spd-sidebar .spd-ride-empty {
  padding: var(--spd-space-sm) 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

#spd-sidebar .spd-clear-history-btn {
  width: 100%;
  margin-top: var(--spd-space-xs);
}

#spd-widget .spd-status {
  margin: var(--spd-space-md) 0 0;
  padding: var(--spd-space-sm) var(--spd-space-sm);
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--muted);
  border-radius: var(--spd-radius-sm);
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

body.dark #spd-widget .spd-status {
  background: rgba(15, 23, 42, 0.4);
  border-color: rgba(51, 65, 85, 0.45);
}

#spd-widget .spd-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--spd-space-sm);
  margin-top: var(--spd-space-xs);
  padding-top: var(--spd-space-xs);
}

#spd-widget .spd-actions-options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spd-space-sm);
  justify-content: center;
  align-items: center;
}

#spd-widget .spd-actions .spd-inline {
  display: flex;
  align-items: center;
  gap: var(--spd-space-xs);
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
}

#spd-widget .spd-actions-primary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

#spd-widget .spd-actions-primary button {
  flex: 1 1 auto;
  min-width: 100px;
}

#spd-widget .spd-share-btn {
  width: 100%;
  font-size: 0.9rem;
  padding: 9px 14px;
}

#spd-widget .spd-graph-wrap {
  margin: 0 auto var(--spd-space-md);
  width: 100%;
  max-width: 260px;
}

#spd-widget .spd-debug {
  margin-top: var(--spd-space-md);
  text-align: left;
  font-size: 0.82rem;
}

#spd-widget .spd-debug summary {
  cursor: pointer;
  color: var(--muted);
  padding: var(--spd-space-xs) 0;
}

#spd-widget .spd-debug pre {
  margin: var(--spd-space-xs) 0 0;
  padding: var(--spd-space-sm);
  max-height: 120px;
  overflow: auto;
  border-radius: var(--spd-radius-sm);
  background: rgba(0, 0, 0, 0.04);
  font-size: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

body.dark #spd-widget .spd-debug pre {
  background: rgba(0, 0, 0, 0.25);
  border-color: rgba(51, 65, 85, 0.5);
}

#spd-widget #spd-graph {
  display: block;
  width: 100%;
  max-width: 260px;
  height: 80px;
  min-height: 80px;
  aspect-ratio: 13 / 4;
  border-radius: 8px;
  vertical-align: top;
  box-sizing: border-box;
  border: 1px solid var(--border-light);
}

body.dark #spd-widget #spd-graph {
  border-color: var(--border);
}

#spd-widget .spd-title {
  font-size: 1.7rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--accent-light);
  text-shadow: 0 0 8px rgba(96,165,250,0.45);
  transition: color 0.3s ease;
}

#spd-widget #spd-canvas {
  display: block;
  margin: 0 auto var(--spd-space-md);
  border-radius: 50%;
  transition: transform 0.2s ease;
}

#spd-widget #spd-canvas:hover {
  transform: scale(1.03);
}

#spd-widget button {
  padding: 10px 16px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #0b79ff, #22c1ff);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 122, 204, 0.25);
  transition: all 0.25s ease;
}

#spd-widget button:hover:not([disabled]) {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  box-shadow: 0 6px 16px rgba(0, 122, 204, 0.35);
}

#spd-widget button[disabled] {
  background: #d0e6ff;
  color: #0b79ff;
  border: 1px solid rgba(0, 122, 204, 0.25);
}

#spd-widget button[disabled]:hover {
  background: rgba(0, 122, 204, 0.1);
  box-shadow: none;
}

/* =======================
   SEO / EXTRA CONTENT
======================= */
.tool-seo-content {
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  padding: var(--spd-space-lg) var(--spd-space-md);
  text-align: left;
}

.tool-seo-content h2 {
  margin: 0 0 var(--spd-space-sm);
  font-size: 1.35rem;
}

.tool-seo-content h3 {
  margin: var(--spd-space-lg) 0 var(--spd-space-sm);
  font-size: 1.05rem;
}

.tool-seo-content ol {
  margin: 0;
  padding-left: 1.25rem;
  line-height: 1.55;
}

.tool-seo-content details {
  margin-bottom: var(--spd-space-sm);
  padding: var(--spd-space-sm) var(--spd-space-md);
  border-radius: var(--spd-radius-sm);
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.5);
}

body.dark .tool-seo-content details {
  border-color: rgba(51, 65, 85, 0.75);
  background: rgba(15, 23, 42, 0.35);
}

.tool-seo-content details summary {
  cursor: pointer;
  font-weight: 600;
}

.tool-seo-content details p {
  margin: var(--spd-space-sm) 0 0;
  line-height: 1.5;
  color: var(--muted);
}

/* =======================
   RESPONSIVE
======================= */
@media (max-width: 420px) {
  .wrapper {
    width: 95%;
    min-height: 480px;
    padding: 12px;
  }
  #spd-widget.spd-card {
    max-width: 100%;
    padding: var(--spd-space-md);
  }

  .tool-container.spd-tool-shell {
    padding: 12px;
  }
}





















