:root {
  --bg-primary: #1a1a2e;
  --bg-sidebar: #16213e;
  --bg-input: #0f3460;
  --border-color: #0f3460;
  --border-input: #1a4080;
  --text-primary: #e0e0e0;
  --text-secondary: #ccc;
  --text-muted: #888;
  --accent: #e94560;
  --accent-success: #4ecdc4;
  --modal-overlay: rgba(0, 0, 0, 0.6);
}

html[data-theme="light"] {
  --bg-primary: #f0f0f5;
  --bg-sidebar: #ffffff;
  --bg-input: #e8eaf0;
  --border-color: #d0d0d8;
  --border-input: #c0c0cc;
  --text-primary: #1a1a2e;
  --text-secondary: #333;
  --text-muted: #666;
  --accent: #d63050;
  --accent-success: #2a9d8f;
  --modal-overlay: rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scrollbar-width: none;
}

*::-webkit-scrollbar {
  display: none;
}

body {
  display: flex;
  height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

#sidebar {
  width: 320px;
  min-width: 320px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 12px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h1 {
  font-size: 1.6rem;
  color: var(--accent);
  margin-bottom: 0;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

.slider-info {
  display: flex;
  gap: 12px;
  font-size: 0.7rem;
  color: var(--accent-success);
}

select, input[type="range"] {
  width: 100%;
}

select {
  padding: 8px 12px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

select:focus {
  outline: 2px solid var(--accent);
}

select optgroup {
  font-weight: 600;
  color: var(--text-muted);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  outline: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  margin-top: -6px;
}

input[type="range"]::-moz-range-track {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  border: none;
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  vertical-align: middle;
  margin-right: 8px;
}

.euler-details summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 4px 0;
}

.euler-details summary:hover {
  color: var(--text-primary);
}

.info-box {
  background: var(--bg-input);
  border-radius: 8px;
  padding: 10px;
  margin-top: 6px;
  font-size: 0.75rem;
  line-height: 1.4;
  border-left: 3px solid var(--accent);
}

.info-box .euler-yes {
  color: var(--accent-success);
  font-weight: 700;
}

.info-box .euler-no {
  color: var(--accent);
  font-weight: 700;
}

.btn-primary, .btn-export {
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}

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

.btn-export {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-input);
}

.btn-primary:hover, .btn-export:hover {
  transform: scale(1.02);
  opacity: 0.9;
}

.btn-primary:disabled, .btn-export:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.status {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding-top: 8px;
}

/* --- Footer --- */

/* .version-footer replaced by .sidebar-footer in #sidebar */

.footer-left {
  display: flex;
  gap: 4px;
  position: relative;
}

.icon-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1.4;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.help-btn {
  font-weight: 700;
  width: 24px;
  padding: 3px 0;
  text-align: center;
}

.lang-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 4px;
  z-index: 20;
  min-width: 120px;
}

.lang-dropdown.hidden {
  display: none;
}

.lang-dropdown button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 6px 12px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.82rem;
}

.lang-dropdown button:hover {
  background: var(--bg-input);
}

.changelog-link {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

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

/* --- Modals --- */

.modal {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-content h2 {
  color: var(--accent);
  font-size: 1.2rem;
  margin-bottom: 16px;
}

.modal-content h3 {
  color: var(--accent-success);
  font-size: 0.95rem;
  margin-top: 12px;
  margin-bottom: 4px;
}

.modal-content ul {
  padding-left: 20px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-content p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 10px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--accent);
}

/* --- Canvas --- */

#canvas-container {
  flex: 1;
  position: relative;
}

#threeCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 10;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.spinner.hidden {
  display: none;
}

.spinner-ring {
  width: 48px;
  height: 48px;
  border: 4px solid var(--bg-input);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* --- ln-tip-jar --- */

ln-tip-jar {
  z-index: 50;
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
  }
  #sidebar {
    width: 100%;
    min-width: auto;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
}
