/* ── Page wrapper ── */
.mlp-wrapper { max-width: 1500px; margin: 0 auto; padding: 20px 24px 40px; }

/* ── Page header ── */
.mlp-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.mlp-header-text { flex: 1; }
.mlp-header-text h1 {
  font-size: 20px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--c-title); margin: 0 0 2px;
}
.mlp-header .subtitle {
  font-size: 12px; color: var(--c-muted); margin: 0;
}
.mlp-header-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(167,139,250,0.1); border: 1px solid rgba(167,139,250,0.2);
  font-size: 11px; font-weight: 500; color: var(--c-violet);
}
/* Arduino source download link (Lite protocol) — replaces the KNN badge */
.mlp-header-download {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(0,151,157,0.10); border: 1px solid rgba(0,151,157,0.35);
  font-size: 12px; font-weight: 600; color: #00979D;
  text-decoration: none; transition: background 0.15s, border-color 0.15s;
}
.mlp-header-download:hover {
  background: rgba(0,151,157,0.18); border-color: rgba(0,151,157,0.55);
}

/* ── Algorithm Explanation ── */
.algo-explain {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-bottom: 12px; padding: 12px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.algo-text {
  grid-column: 1 / -1; display: flex; align-items: baseline; gap: 14px;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 8px 12px; background: var(--bg-item);
}
.algo-text h3 { margin: 0; white-space: nowrap; flex-shrink: 0; font-size: 13px; color: var(--c-blue); }
.algo-text p  { margin: 0; font-size: 13px; color: var(--c-muted); }
html.day .algo-text { border-color: var(--border-2); }
.algo-images { display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; }
.algo-images img {
  max-width: 600px; width: 100%; border-radius: var(--radius-sm);
  border: 1px solid var(--border); object-fit: contain;
  cursor: zoom-in; transition: opacity 0.15s;
}
.algo-images img:hover { opacity: 0.85; }
.algo-images .img-label { font-size: 10px; color: var(--c-muted); text-align: center; margin-top: 2px; }
@media (max-width: 900px) {
  .algo-explain { grid-template-columns: 1fr; }
  .algo-images img { max-width: 260px; }
}

/* ── Lightbox ── */
#lightbox {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.88); z-index: 9999;
  align-items: center; justify-content: center; cursor: zoom-out;
}
#lightbox.open { display: flex; }
#lightbox img {
  max-width: 90vw; max-height: 90vh; border-radius: var(--radius);
  box-shadow: 0 8px 48px rgba(0,0,0,0.7); object-fit: contain;
}

/* ── Controls bar ── */
.mlp-controls {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-bottom: 12px; padding: 8px 12px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.mlp-controls .group-label { font-size: 11px; color: var(--text-label); margin-right: 2px; }
.mlp-controls button, .mlp-controls select {
  height: 32px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-item);
  color: var(--text-primary); font-size: 12px; font-family: inherit;
  padding: 0 10px; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.mlp-controls button:hover { border-color: var(--border-2); background: var(--bg-panel); }
.mlp-controls button.active {
  border-color: var(--accent); background: rgba(59,130,246,0.1); color: var(--c-blue);
}
.ctrl-divider { width: 1px; height: 18px; background: var(--border); margin: 0 2px; }

/* ── 3-column main ── */
.mlp-main { display: grid; grid-template-columns: 1fr 320px 1fr; gap: 12px; align-items: start; }

/* ── Panel card ── */
.mlp-panel {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.panel-title {
  font-size: 14px; font-weight: 600; color: var(--c-title);
  padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid var(--border);
}
.mlp-panel h2 {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; margin-bottom: 10px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border); color: var(--c-muted);
}
.mlp-panel h2.hm-title,
.mlp-panel h2.label-title,
.mlp-panel h2.pred-title { color: var(--c-blue); border-bottom-color: rgba(96,165,250,0.2); }

/* ── Heatmap section ── */
.hm-section {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--bg); display: flex; align-items: stretch;
}
.hm-section canvas { display: block; flex: 1; min-width: 0; }

/* ── Contour legend ── */
.contour-legend {
  display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 6px;
  padding: 6px 10px; background: var(--bg-item);
  border: 1px solid var(--border); border-radius: var(--radius-sm); align-items: center;
}
.contour-legend-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; color: var(--text-muted); font-family: monospace;
}

/* ── Heatmap toolbar ── */
.hm-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 8px 12px;
}
.hm-toolbar .toolbar-sep { width: 1px; height: 20px; background: var(--border); flex-shrink: 0; margin: 0 2px; }
.btn-toggle {
  height: 28px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); font-size: 11px; font-family: inherit; cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-toggle:hover { border-color: var(--border-2); color: var(--text-primary); }
.btn-toggle.active { border-color: var(--accent); color: var(--c-blue); background: rgba(59,130,246,0.08); }
.dl-status { font-size: 11px; font-family: monospace; color: var(--text-muted); margin-left: 4px; }
.dl-status .recording { color: #f87171; font-weight: bold; }

/* ── btn-action ── */
.btn-action {
  height: 34px; padding: 0 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); font-size: 12px; font-family: inherit; cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-action:hover { border-color: var(--border-2); color: var(--text-primary); background: var(--bg-item); }
.btn-action.danger:hover { border-color: rgba(248,113,113,0.4); color: #f87171; }

/* Premium lock: feature gated until paid tier. Put `disabled` + class
   `premium-locked` on a button to lock it; remove both to unlock. The disabled
   attr drives the browser-native not-allowed (🚫) cursor. Glyph uses ::before
   so i18n textContent overwrites don't clear it. */
.premium-locked { opacity: 0.45; cursor: not-allowed; }
.premium-locked::before { content: "🚫 "; }
.premium-locked:hover { border-color: var(--border); color: var(--text-muted); background: transparent; }

/* ── Label manager ── */
.label-add { display: flex; gap: 6px; margin-bottom: 10px; }
.label-add input { flex: 1; min-width: 0; }
.label-add button {
  height: 32px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-item);
  color: var(--text-primary); font-size: 13px; font-family: inherit; cursor: pointer;
  transition: border-color 0.15s, background 0.15s; white-space: nowrap;
}
.label-add button:hover { border-color: var(--accent); background: rgba(59,130,246,0.08); }
.label-list { display: flex; flex-direction: column; gap: 6px; }
.label-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: var(--bg-item); border: 1px solid var(--border);
  border-radius: var(--radius-sm); transition: border-color 0.15s;
}
.label-item:hover { border-color: var(--border-2); }
.label-color { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.label-name { flex: 1; font-size: 12px; font-weight: 600; color: var(--text-primary); }
.label-count { font-size: 11px; color: var(--text-muted); font-family: monospace; min-width: 40px; text-align: right; }
.btn-record {
  padding: 0 10px; height: 26px; border-radius: var(--radius-sm);
  border: 1px solid rgba(248,113,113,0.3); background: transparent;
  color: #f87171; font-size: 10px; font-weight: 600; cursor: pointer; flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s; font-family: inherit;
}
.btn-record:hover { background: rgba(248,113,113,0.06); border-color: rgba(248,113,113,0.55); }
.btn-record.recording { background: rgba(248,113,113,0.1); border-color: #f87171; color: #fca5a5; animation: pulse 0.6s infinite alternate; }
.btn-del {
  padding: 0 8px; height: 26px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); font-size: 11px; cursor: pointer; flex-shrink: 0; font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}
.btn-del:hover { border-color: rgba(248,113,113,0.4); color: #f87171; }

/* ── Section divider ── */
.section-divider { margin: 16px 0 10px; border-top: 1px solid var(--border); padding-top: 12px; }
.section-divider h2 { padding-bottom: 0; border-bottom: none; }
.algo-subtitle {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--c-violet); margin-bottom: 10px;
}
.section-divider .param-row select,
.section-divider .param-row input[type="number"] { width: 120px; flex: none; margin-left: auto; }

/* ── Param rows ── */
.param-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.param-row label { font-size: 13px; color: var(--c-label); min-width: 80px; flex-shrink: 0; }
.param-row select, .param-row input[type="number"] { flex: 1; min-width: 0; }

/* ── Train button ── */
.btn-train {
  height: 38px; border-radius: var(--radius-sm); border: none;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff; font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; width: 100%; margin-top: 12px;
  box-shadow: 0 1px 4px rgba(124,58,237,0.45);
  transition: opacity 0.15s;
}
.btn-train:hover:not(:disabled) { opacity: 0.88; }
.btn-train.training { animation: pulse 0.8s infinite alternate; }
.btn-train:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }

/* ── Training status ── */
.train-status {
  margin-top: 8px; padding: 8px 10px;
  background: var(--bg-item); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 11px; color: var(--text-muted); font-family: monospace; display: none;
}
.train-status.visible { display: block; }
.train-progress-bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.train-progress-fill { height: 100%; background: var(--c-violet); border-radius: 2px; transition: width 0.1s; width: 0%; }

/* ── Classify button ── */
.btn-classify {
  height: 36px; border-radius: var(--radius-sm);
  border: 1px solid rgba(45,212,191,0.3); background: rgba(45,212,191,0.06);
  color: var(--c-teal); font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; width: 100%; margin-top: 8px;
  transition: background 0.15s, border-color 0.15s;
}
.btn-classify:hover:not(:disabled) { border-color: rgba(45,212,191,0.5); background: rgba(45,212,191,0.1); }
.btn-classify.active { border-color: var(--c-teal); animation: pulse 0.8s infinite alternate; }
.btn-classify:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Action bar ── */
.action-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 10px; }

/* ── Prediction ── */
.pred-list { display: flex; flex-direction: column; gap: 5px; }
.pred-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.pred-label { font-size: 11px; font-weight: 600; color: var(--c-title); }
.pred-conf { font-size: 10px; font-family: monospace; color: var(--accent); }
.pred-bar-bg {
  height: 13px; background: var(--bg-item); border-radius: 3px;
  border: 1px solid var(--border); overflow: hidden;
}
.pred-bar-fill { height: 100%; border-radius: 2px; transition: width 0.15s; }
.pred-winner {
  text-align: center; padding: 8px; background: var(--bg-item);
  border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px;
}
.pred-winner-label { font-size: 16px; font-weight: 800; color: var(--c-teal); }
.pred-winner-conf { font-size: 10px; color: var(--text-muted); font-family: monospace; }
.pred-waiting { text-align: center; padding: 12px; font-size: 11px; color: var(--text-muted); }

/* ── Loss chart ── */
.chart-container { margin-top: 12px; }
.chart-container h2 { font-size: 12px; color: var(--c-violet); margin-bottom: 6px; }
.chart-canvas-wrap {
  border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
  background: var(--bg-item);
}
.chart-canvas-wrap canvas { display: block; width: 100%; }
.chart-legend { display: flex; gap: 14px; justify-content: center; margin-top: 4px; font-size: 10px; color: var(--text-muted); }
.chart-legend span::before { content: ''; display: inline-block; width: 10px; height: 3px; border-radius: 1px; margin-right: 4px; vertical-align: middle; }
.chart-legend .leg-loss::before { background: #f87171; }
.chart-legend .leg-acc::before  { background: var(--c-teal); }

/* ── Confusion matrix ── */
.confusion-section { margin-top: 12px; display: none; }
.confusion-section.visible { display: block; }
.confusion-section h2 { font-size: 12px; color: var(--c-violet); margin-bottom: 6px; }
.confusion-table { width: 100%; border-collapse: collapse; font-size: 10px; font-family: monospace; }
.confusion-table th, .confusion-table td { padding: 4px 6px; text-align: center; border: 1px solid var(--border); }
.confusion-table th { background: var(--bg-item); color: var(--text-label); font-weight: 600; }
.confusion-table td { color: var(--text-primary); }
.confusion-table td.diag { background: rgba(45,212,191,0.12); font-weight: 700; color: var(--c-teal); }

/* ── JSON download panel ── */
.json-dl-panel { display: flex; gap: 8px; padding: 10px 12px; }
.btn-json-dl {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; height: 52px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); cursor: pointer; font-family: inherit;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-json-dl:hover { border-color: var(--accent); color: var(--c-blue); background: rgba(59,130,246,0.05); }
.btn-json-dl .btn-line1 { font-size: 12px; font-weight: 600; }
.btn-json-dl .btn-line2 { font-size: 11px; opacity: 0.7; }

/* ── Status bar ── */
.status-bar {
  margin-top: 12px; padding: 8px 16px;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); display: flex; gap: 24px; justify-content: center;
  font-size: 12px; color: var(--text-muted); font-family: monospace;
}
.status-bar span { color: var(--c-blue); }

@media (max-width: 1000px) { .mlp-main { grid-template-columns: 1fr; } }

/* ── SLOT Placeholder (빈 템플릿 안내 카드) ── */
.slot-placeholder {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  background: transparent;
  box-shadow: none;
  position: relative;
}
.slot-placeholder .slot-badge {
  display: inline-block;
  font-size: 9px; font-weight: 700; letter-spacing: 0.12em;
  padding: 2px 9px; border-radius: 999px;
  background: rgba(167,139,250,0.12);
  color: var(--c-violet);
  border: 1px solid rgba(167,139,250,0.3);
  margin-bottom: 10px;
}
.slot-placeholder .slot-title {
  font-size: 14px; font-weight: 600; color: var(--c-title);
  margin: 0 0 8px;
}
.slot-placeholder .slot-desc {
  font-size: 12px; color: var(--text-muted); margin: 0 0 6px;
}
.slot-placeholder .slot-list {
  font-size: 12px; color: var(--c-muted);
  padding-left: 18px; margin: 0 0 12px;
  line-height: 1.7;
}
.slot-placeholder .slot-list li { color: var(--c-muted); }
.slot-placeholder .slot-hint {
  font-size: 11px; color: var(--text-label);
  font-family: monospace; margin: 0;
  padding-top: 8px; border-top: 1px dashed var(--border);
}
.slot-placeholder code {
  background: var(--bg-item); padding: 1px 6px;
  border-radius: 3px; font-size: 11px;
  color: var(--c-blue); font-family: monospace;
}
