:root {
  /* Dark Mode (Default) */
  --bg: #020617;
  --bg-alt: #0f172a;
  --card-bg: #020617;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.25);
  --border: #1f2933;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --error: #fb7185;

  --gradient-1: #1d4ed8;
  --gradient-2: #22c55e;
  --app-bg-gradient-start: rgba(15, 23, 42, 0.96);
  --app-bg-gradient-end: rgba(15, 23, 42, 0.98);
  --shadow-color: rgba(15, 23, 42, 0.85);
  --shadow-border: rgba(148, 163, 184, 0.1);

  --surface-highlight: rgba(255, 255, 255, 0.05);
  --surface-hover: rgba(255, 255, 255, 0.1);
  --border-light: rgba(255, 255, 255, 0.2);
  
  --input-bg: #1e293b;

  --panel-bg: rgba(15, 23, 42, 0.9);
  --panel-bg-gradient: rgba(148, 163, 184, 0.18);

  --waveCanvas-bg-gradient1: rgba(31, 41, 55, 0.8);
  --waveCanvas-bg-gradient2: rgba(15, 23, 42, 0.98);

  --waveCanvas-border: rgba(15, 23, 42, 0.95);

  --status-chip-bg: rgba(15, 23, 42, 0.7);
  --status-dot-idle: #4b5563;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --bg-alt: #ffffff;
  --card-bg: #ffffff;
  --accent: #16a34a;
  --accent-soft: rgba(22, 163, 74, 0.15);
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --error: #ef4444;

  --gradient-1: #60a5fa;
  --gradient-2: #4ade80;
  --app-bg-gradient-start: rgba(255, 255, 255, 0.9);
  --app-bg-gradient-end: rgba(255, 255, 255, 0.95);
  --shadow-color: rgba(148, 163, 184, 0.2);
  --shadow-border: rgba(148, 163, 184, 0.2);

  --surface-highlight: rgba(0, 0, 0, 0.05);
  --surface-hover: rgba(0, 0, 0, 0.1);
  --border-light: rgba(0, 0, 0, 0.1);
  
  --input-bg: #ffffff;

  --panel-bg: rgba(255, 255, 255, 0.9);
  --panel-bg-gradient: rgba(100, 116, 139, 0.12);

  --waveCanvas-bg-gradient1: rgba(241, 245, 249, 0.8);
  --waveCanvas-bg-gradient2: rgba(226, 232, 240, 0.98);

  --waveCanvas-border: rgba(100, 116, 139, 0.45);

  --status-chip-bg: rgba(241, 245, 249, 0.7);
  --status-dot-idle: #9ca3af;
}

* {
  box-sizing: border-box;
}

.global-controls {
  position: fixed;
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1100;
}

.global-back-button {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--shadow-color);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.global-back-button.hidden {
  display: none !important;
}

.global-back-button:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle-btn {
  position: static;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.theme-toggle-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: scale(1.05);
}

.global-controls select {
  min-width: 120px;
}

.back-button {
  position: fixed;
  top: 24px;
  left: 24px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--shadow-color);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
  z-index: 100;
}

.back-button:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: translateX(-2px);
  color: var(--accent);
}

.view-hidden {
  display: none !important;
}

#component-view {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.component-active #portal-view {
  display: none !important;
}

.component-active #component-view {
  display: flex;
}

#component-view > * {
  width: 100%;
  /* max-width: 1100px; */
}

/* .component-active #component-view .lang-selector,
.component-active #component-view .back-button {
  display: none !important;
} */

.route-error {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  color: var(--text);
  max-width: 960px;
  margin: 0 auto;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, var(--gradient-1) 0, transparent 55%),
    radial-gradient(circle at bottom right, var(--gradient-2) 0, transparent 55%),
    var(--bg);
}

.app {
  width: 100%;
  max-width: 720px;
  background: linear-gradient(
    to bottom right,
    var(--app-bg-gradient-start),
    var(--app-bg-gradient-end)
  );
  border-radius: 24px;
  padding: 22px 26px 20px;
  box-shadow: 0 24px 60px var(--shadow-color),
    0 0 0 1px var(--shadow-border);
}

h1 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: 0.03em;
}

.subtitle {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.controls label {
  font-size: 13px;
  color: var(--muted);
}

select {
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 13px;
  outline: none;
  min-width: 140px;
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

input {
  background: var(--input-bg);
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  width: 100%;
}

/* New Button Styles */
.btn-action {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-action:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(34, 197, 94, 0.1);
  transform: translateY(-1px);
}

.btn-action:active {
  transform: translateY(0px);
}

/* Log Panel Styles */
#logPanel {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

#logPanel summary {
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}

#logPanel summary:hover {
  color: var(--text);
}

#logOutput {
  margin-top: 8px;
  width: 100%;
  height: 150px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-family: "Consolas", "Monaco", monospace;
  font-size: 11px;
  color: #a3e635;
  overflow-y: auto;
  white-space: pre-wrap;
  resize: vertical;
}

/* Checkbox styles */
.checkbox-wrapper {
  display: flex;
  align-items: center;
  margin-left: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.2);
  transition: all 0.2s ease;
}

.checkbox-wrapper:hover {
  background: rgba(148, 163, 184, 0.15);
  border-color: rgba(148, 163, 184, 0.3);
}

.checkbox-wrapper input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--muted);
  border-radius: 4px;
  margin-right: 8px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.checkbox-wrapper input[type='checkbox']:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}

.checkbox-wrapper input[type='checkbox']:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-wrapper label {
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}

/* Mobile Optimizations */
@media (max-width: 600px) {
  body {
    padding: 12px;
    align-items: flex-start; /* Allow scrolling from top */
  }

  .app {
    padding: 16px;
    border-radius: 16px;
  }

  .back-button {
    top: 12px;
    left: 12px;
    width: 36px;
    height: 36px;
  }

  h1 {
    font-size: 1.5rem;
    margin-top: 2rem; /* Space for back button */
  }

  .subtitle {
    font-size: 0.9rem;
  }
}

