:root {
  --bg: #0f1419;
  --bg-2: #161b22;
  --bg-3: #1f2630;
  --border: #2d3441;
  --fg: #e6edf3;
  --fg-dim: #9aa5b1;
  --accent: #58a6ff;
  --accent-2: #7ee787;
  --warn: #f0b429;
  --err: #f85149;
  --code-bg: #0b0f14;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  font-size: 14px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand .logo {
  font-size: 20px;
  filter: drop-shadow(0 0 6px var(--accent));
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.brand .subtitle {
  color: var(--fg-dim);
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn {
  background: var(--accent);
  color: #0b0f14;
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s, transform 0.05s;
}

.btn:hover { background: #79b8ff; }
.btn:active { transform: translateY(1px); }

.btn.ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}

.btn.ghost:hover {
  background: var(--bg-3);
  border-color: var(--accent);
}

select {
  background: var(--bg-3);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
}

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
  gap: 16px;
  padding: 16px;
  flex: 1;
  min-height: 0;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
}

.panel-header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--fg-dim);
}

.panel-header .hint {
  font-size: 12px;
  color: var(--fg-dim);
}

.preview-actions {
  display: flex;
  gap: 8px;
}

.modules-root {
  padding: 8px 12px;
  overflow-y: auto;
}

.category {
  margin: 12px 0;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}

.category-header .chevron {
  display: inline-block;
  transition: transform 0.15s;
  color: var(--fg-dim);
}

.category.collapsed .chevron { transform: rotate(-90deg); }
.category.collapsed .category-body { display: none; }

.category-body {
  padding: 8px 4px 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.module {
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 8px 10px;
  transition: background 0.1s, border-color 0.1s;
  cursor: pointer;
}

.module:hover { background: var(--bg-3); }
.module.selected {
  background: var(--bg-3);
  border-color: var(--border);
}

.module.forced {
  cursor: not-allowed;
  border-color: var(--accent-2);
  background: rgba(126, 231, 135, 0.06);
}

.module.forced .module-row,
.module.forced input[type="checkbox"] {
  cursor: not-allowed;
}

.forced-hint {
  font-size: 11px;
  color: var(--accent-2);
  font-style: italic;
  margin-left: 4px;
  opacity: 0.85;
}

.module-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.module-row input[type="checkbox"],
.module-row input[type="radio"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.module-icon { font-size: 16px; }

.module-label {
  font-weight: 500;
  flex: 1;
}

.module-desc {
  color: var(--fg-dim);
  font-size: 12px;
  margin-left: 26px;
  margin-top: 2px;
}

.module-options {
  margin: 8px 0 2px 26px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.module-options.hidden { display: none; }

.module-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--fg-dim);
}

.module-options select,
.module-options input[type="text"] {
  background: var(--bg-3);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 12px;
}

.module-options input[type="checkbox"] {
  accent-color: var(--accent-2);
}

.smolfile-output {
  flex: 1;
  margin: 0;
  padding: 16px;
  background: var(--code-bg);
  color: var(--fg);
  font-family: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  overflow: auto;
  white-space: pre;
  tab-size: 2;
}

.validation {
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  background: var(--bg-3);
  font-size: 13px;
}

.validation.ok { color: var(--accent-2); }
.validation.warn { color: var(--warn); }
.validation.err { color: var(--err); }

.validation ul {
  margin: 4px 0 0 0;
  padding-left: 18px;
}

.hidden { display: none; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-3);
  color: var(--fg);
  border: 1px solid var(--accent);
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 1;
  transition: opacity 0.3s;
  z-index: 100;
}

.toast.hidden { opacity: 0; pointer-events: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border-radius: 5px;
  border: 2px solid var(--bg-2);
}
::-webkit-scrollbar-thumb:hover { background: var(--border); }
