/* Vim/Gruvbox-inspired theme — extracted from hded_engine templates.
   All engine templates shared this CSS inline; now it's one file. */

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

:root {
  --bg0-hard: #1c2028;
  --bg0: #22262e;
  --bg1: #262b34;
  --bg2: #3e4451;
  --bg3: #4b5263;
  --bg4: #636d80;
  --fg: #c8cfd8;
  --fg2: #b5bdcc;
  --fg3: #959ba8;
  --fg4: #717b8a;
  --red: #ef7b84;
  --green: #a5d67e;
  --yellow: #f0cc80;
  --blue: #70bbff;
  --purple: #d485ee;
  --aqua: #65c8d6;
  --orange: #dea870;
  --green-dim: #88b268;
  --blue-dim: #5a9ad4;
  --orange-dim: #c49258;
  --red-dim: #c46a72;
  --gutter-bg: #1c2028;
  --gutter-fg: #5a6377;
  --statusline-bg: #1c2028;
  --statusline-fg: #c8cfd8;
  --cursor: #6499ff;
}

body {
  background: var(--bg0);
  color: var(--fg);
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', 'Courier New', monospace;
  font-size: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.45;
}

/* ── Vim line structure ────────────────────────────── */

.vim-line {
  display: flex;
  min-height: 20px;
}

.vim-gutter {
  min-width: 48px;
  text-align: right;
  padding-right: 12px;
  color: var(--gutter-fg);
  background: var(--gutter-bg);
  font-size: 15px;
  user-select: none;
  flex-shrink: 0;
}

.vim-gutter-active { color: var(--yellow); }

.vim-content-line {
  flex: 1;
  padding-left: 8px;
  min-width: 0;
}

.vim-tilde { color: var(--blue); padding-left: 8px; }

/* ── Syntax highlighting classes ──────────────────── */

.syn-comment { color: var(--fg4); font-style: italic; }
.syn-keyword { color: var(--red); }
.syn-identifier { color: var(--fg); }
.syn-type { color: var(--yellow); }
.syn-operator { color: var(--fg3); }
.syn-string { color: var(--green); }
.syn-special { color: var(--blue); }
.syn-heading { color: var(--yellow); font-weight: bold; }
.syn-title { color: var(--green); font-weight: bold; }
.syn-number { color: var(--purple); }
.syn-constant { color: var(--orange); }
.syn-error { color: var(--red); font-weight: bold; }
.syn-success { color: var(--green); font-weight: bold; }
.syn-warning { color: var(--yellow); }

/* ── Editor layout ────────────────────────────────── */

.vim-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.vim-editor-scroll {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 8px;
}

/* ── Top bar (buffer tabs) ────────────────────────── */

.vim-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg1);
  padding: 0;
  min-height: 22px;
  font-size: 15px;
  border-bottom: 1px solid var(--bg2);
}

.vim-topbar-title {
  color: var(--green);
  font-weight: bold;
  padding: 2px 10px;
}

.vim-topbar-right {
  display: flex;
  align-items: center;
  gap: 0;
}

.vim-topbar-user {
  color: var(--blue);
  padding: 2px 10px;
}

.vim-topbar-link {
  color: var(--fg3);
  text-decoration: none;
  padding: 2px 10px;
  transition: color 0.15s;
}

.vim-topbar-link:hover { color: var(--blue); }
.vim-topbar-link.active { color: var(--yellow); }

/* ── Status line (bottom) ─────────────────────────── */

.vim-statusline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--statusline-bg);
  color: var(--statusline-fg);
  padding: 0;
  font-size: 15px;
  min-height: 22px;
  flex-shrink: 0;
}

.vim-statusline-left, .vim-statusline-right {
  display: flex;
  align-items: center;
}

.vim-sl-mode {
  background: var(--green-dim);
  color: var(--bg0);
  font-weight: bold;
  padding: 2px 10px;
}

.vim-sl-mode-insert { background: var(--blue-dim); }
.vim-sl-mode-visual { background: var(--orange-dim); }

.vim-sl-file { padding: 2px 10px; color: var(--fg2); }
.vim-sl-modified { color: var(--red); padding: 0 4px; }
.vim-sl-filetype { background: var(--bg3); padding: 2px 10px; color: var(--fg3); }
.vim-sl-percent { background: var(--statusline-bg); padding: 2px 10px; color: var(--fg3); }
.vim-sl-position { background: var(--bg4); padding: 2px 10px; color: var(--fg); }

/* ── Command line ─────────────────────────────────── */

.vim-cmdline {
  background: var(--bg0);
  padding: 2px 8px;
  font-size: 15px;
  min-height: 22px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.vim-cmdline-prompt { color: var(--fg); }
.vim-cmdline-text { color: var(--fg3); }

.vim-cursor {
  background: var(--cursor);
  color: var(--bg0);
  padding: 0 1px;
  animation: vimCursorBlink 1.2s step-end infinite;
}

@keyframes vimCursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── ASCII art title ──────────────────────────────── */

.ascii-title {
  white-space: pre;
  font-size: 15px;
  line-height: 1.2;
  color: var(--green);
}

/* ── Form inputs ──────────────────────────────────── */

.vim-form-input {
  background: var(--bg1);
  border: 1px solid var(--bg3);
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  padding: 4px 8px;
  outline: none;
  width: 220px;
  max-width: 100%;
}

.vim-form-input:focus {
  border-color: var(--blue);
  background: var(--bg0-hard);
}

.vim-form-input-wide { width: 100%; }

textarea.vim-form-input {
  resize: vertical;
  min-height: 60px;
}

select.vim-form-input {
  cursor: pointer;
}

/* ── Buttons ──────────────────────────────────────── */

.vim-btn {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  color: var(--fg);
  font-family: inherit;
  font-size: 15px;
  padding: 5px 20px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-block;
}

.vim-btn:hover {
  background: var(--blue-dim);
  border-color: var(--blue);
  color: var(--fg);
}

.vim-btn-primary {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--bg0);
  font-weight: bold;
}

.vim-btn-primary:hover { background: var(--green); }

.vim-btn-danger {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--fg);
}

.vim-btn-danger:hover { background: var(--red); color: var(--bg0); }

.vim-btn-small {
  font-size: 13px;
  padding: 2px 10px;
}

/* ── Tables ───────────────────────────────────────── */

.vim-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}

.vim-table th {
  background: var(--bg2);
  color: var(--yellow);
  text-align: left;
  padding: 4px 8px;
  font-weight: normal;
  border-bottom: 1px solid var(--bg3);
}

.vim-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--bg1);
}

.vim-table tr:hover td {
  background: var(--bg1);
}

/* ── Cards / panels ───────────────────────────────── */

.vim-panel {
  background: var(--bg1);
  border: 1px solid var(--bg2);
  padding: 8px;
  margin: 4px 0;
}

.vim-panel-header {
  color: var(--yellow);
  font-weight: bold;
  margin-bottom: 4px;
}

/* ── Progress bar ─────────────────────────────────── */

.vim-progress {
  background: var(--bg2);
  height: 8px;
  overflow: hidden;
  margin: 4px 0;
}

.vim-progress-fill {
  background: var(--green-dim);
  height: 100%;
  transition: width 0.3s ease;
}

.vim-progress-fill-active {
  background: var(--blue);
}

/* ── Drag and drop area ───────────────────────────── */

.vim-dropzone {
  border: 2px dashed var(--bg3);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.vim-dropzone:hover, .vim-dropzone.drag-over {
  border-color: var(--blue);
  background: var(--bg1);
}

/* ── Utility classes ──────────────────────────────── */

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--fg4); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blue { color: var(--blue); }
.text-orange { color: var(--orange); }
.hidden { display: none; }

/* ── HTMX indicators ─────────────────────────────── */

.htmx-indicator {
  opacity: 0;
  transition: opacity 0.2s;
}

.htmx-request .htmx-indicator {
  opacity: 1;
}

/* ── Admin / ML-config form editor ─────────────── */

.admin-section {
  margin: 6px 56px;
  background: var(--bg0-hard);
  border: 1px solid var(--bg2);
}

.admin-section-header {
  background: var(--bg1);
  padding: 6px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--bg2);
}

.admin-section-header:hover { background: var(--bg2); }

.admin-section-header h3 {
  color: var(--yellow);
  font-size: 14px;
  font-weight: bold;
}

.admin-section-header .toggle-icon {
  color: var(--fg4);
  font-size: 14px;
}

.admin-section-body { padding: 10px 12px; }
.admin-section-body.collapsed { display: none; }

.admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
  flex-wrap: wrap;
}

.admin-label {
  color: var(--fg3);
  font-size: 14px;
  min-width: 180px;
}

.admin-input {
  background: var(--bg1);
  border: 1px solid var(--bg2);
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  padding: 3px 8px;
  width: 80px;
}

.admin-input:focus { outline: none; border-color: var(--blue); }
.admin-input:disabled { opacity: 0.5; cursor: not-allowed; }
.admin-input-wide { width: 160px; }
.admin-input-text { width: 200px; }

.admin-toggle {
  position: relative;
  width: 36px;
  height: 18px;
  cursor: pointer;
  display: inline-block;
  flex-shrink: 0;
}

.admin-toggle input { display: none; }

.admin-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: 9px;
  transition: background 0.2s;
}

.admin-toggle input:checked + .admin-toggle-track {
  background: var(--green-dim);
  border-color: var(--green);
}

.admin-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--fg4);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
  pointer-events: none;
}

.admin-toggle input:checked ~ .admin-toggle-knob {
  transform: translateX(18px);
  background: var(--green);
}

.admin-toggle input:disabled ~ .admin-toggle-track { opacity: 0.4; cursor: not-allowed; }
.admin-toggle input:disabled ~ .admin-toggle-knob { opacity: 0.4; }

.model-card {
  background: var(--bg1);
  border: 1px solid var(--bg2);
  padding: 8px 12px;
  margin-bottom: 8px;
}

.model-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.model-card-header .model-id {
  color: var(--aqua);
  font-size: 14px;
  font-weight: bold;
}

.model-card-header .model-variant {
  color: var(--fg4);
  font-size: 13px;
}

.model-card-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 0;
  flex-wrap: wrap;
}

.model-card-row .label {
  color: var(--fg4);
  font-size: 13px;
  min-width: 130px;
}

.conf-slider { width: 120px; accent-color: var(--aqua); }
.conf-slider:disabled { opacity: 0.4; cursor: not-allowed; }

.level-checks { display: flex; gap: 8px; align-items: center; }

.level-check {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 13px;
  color: var(--fg3);
}

.level-check input { accent-color: var(--aqua); }

.classes-grid { display: flex; flex-wrap: wrap; gap: 6px; }

.class-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg1);
  border: 1px solid var(--bg2);
  padding: 3px 10px;
  font-size: 13px;
}

.class-chip .class-name { color: var(--fg3); }
.class-chip .class-models { color: var(--fg4); font-size: 12px; }

.weight-sum {
  font-size: 14px;
  padding: 4px 10px;
  border: 1px solid var(--bg3);
  background: var(--bg1);
}

.weight-sum.ok { color: var(--green); border-color: var(--green-dim); }
.weight-sum.bad { color: var(--red); border-color: var(--red); }

.tile-count { color: var(--aqua); font-size: 14px; }

.save-bar {
  position: fixed;
  bottom: 48px;
  left: 0;
  right: 0;
  background: var(--bg1);
  border-top: 1px solid var(--bg3);
  padding: 6px 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 100;
  font-size: 15px;
}

.save-btn {
  background: var(--green-dim);
  border: 1px solid var(--green);
  color: var(--bg0);
  font-family: inherit;
  font-size: 15px;
  font-weight: bold;
  padding: 5px 20px;
  cursor: pointer;
  transition: all 0.15s;
}

.save-btn:hover { background: var(--green); }
.save-btn:disabled {
  background: var(--bg2);
  border-color: var(--bg3);
  color: var(--fg4);
  cursor: not-allowed;
}

.reset-btn {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  color: var(--fg);
  font-family: inherit;
  font-size: 15px;
  padding: 5px 20px;
  cursor: pointer;
}

.reset-btn:hover { background: var(--blue-dim); border-color: var(--blue); }

.dirty-indicator { color: var(--yellow); font-size: 14px; }
.saved-flash { color: var(--green); font-size: 14px; display: none; }

.demo-warning {
  margin: 6px 56px;
  padding: 6px 12px;
  background: rgba(240, 204, 128, 0.1);
  border-left: 3px solid var(--yellow);
  color: var(--yellow);
  font-size: 14px;
}

@media (max-width: 600px) {
  .admin-section, .demo-warning, .save-bar { margin-left: 12px; margin-right: 12px; }
  .save-bar { padding: 6px 12px; }
}
