/* =====================================================
   LinearScope — Style Sheet
   Aesthetic: Scientific instrument · Warm ivory · Slate blue
   ===================================================== */

:root {
  --bg:            #F7F5F0;
  --bg-panel:      #FFFFFF;
  --bg-sidebar:    #FDFCFA;
  --bg-input:      #F0EDE8;
  --bg-hover:      #EAE7E1;

  --text-primary:  #1A1814;
  --text-secondary:#5A5650;
  --text-muted:    #9A9590;
  --text-label:    #7A7570;

  --accent:        #2B4C7E;
  --accent-light:  #3D6199;
  --accent-muted:  #D6E4F7;
  --accent-glow:   rgba(43, 76, 126, 0.12);

  --train-color:   #2B4C7E;
  --test-color:    #D97B4A;
  --line-color:    #1A9E6B;
  --loss-color:    #8B3DBE;

  --border:        #E2DED8;
  --border-strong: #C8C4BE;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);

  --header-h: 58px;
  --sidebar-w: 230px;
  --sidebar-r: 240px;

  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'JetBrains Mono', 'Courier New', monospace;
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--accent-muted);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.header-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.title-main {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--text-primary);
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.title-sub {
  font-size: 10.5px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  font-family: var(--font-mono);
  font-weight: 400;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg-input);
  border-radius: 20px;
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}
.status-pill.training .status-dot { background: var(--test-color); animation: pulse 1s infinite; }
.status-pill.done .status-dot     { background: var(--line-color); }
.status-pill.ready .status-dot    { background: var(--text-muted); }

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

.header-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.meta-sep { color: var(--border-strong); }

/* ── Layout ─────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--sidebar-r);
  height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* ── Sidebars ────────────────────────────────────────── */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-right {
  border-right: none;
  border-left: 1px solid var(--border);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.panel-section {
  padding: 4px 0;
}

.section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.label-icon {
  font-size: 11px;
  color: var(--accent);
  opacity: 0.7;
}

/* ── Controls ────────────────────────────────────────── */
.control-group {
  margin-bottom: 13px;
}

.control-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
}

.ctrl-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.ctrl-value {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 600;
  min-width: 36px;
  text-align: right;
}

/* ── Slider ──────────────────────────────────────────── */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-input);
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-panel);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s;
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-panel);
  cursor: pointer;
}
.slider:hover { background: var(--bg-hover); }

/* ── Radio Group ─────────────────────────────────────── */
.radio-group {
  display: flex;
  gap: 8px;
}

.radio-opt {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  transition: all 0.15s;
}
.radio-opt:hover { border-color: var(--accent); color: var(--accent); }
.radio-opt input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.1px;
  margin-bottom: 8px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(43, 76, 126, 0.28);
}
.btn-primary:hover  { background: var(--accent-light); box-shadow: 0 4px 14px rgba(43, 76, 126, 0.38); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-input); color: var(--text-secondary); }

/* ── Params grid ─────────────────────────────────────── */
.param-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.param-item {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.param-label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.2px;
  margin-bottom: 3px;
}

.param-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.progress-bar-wrap {
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--line-color));
  border-radius: 2px;
  transition: width 0.1s linear;
}

/* ── Center Panel ────────────────────────────────────── */
.center-panel {
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.panel-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Legend ──────────────────────────────────────────── */
.legend {
  display: flex;
  align-items: center;
  gap: 14px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.legend-dot.train { background: var(--train-color); }
.legend-dot.test  { background: var(--test-color); }

.legend-line {
  width: 16px;
  height: 2.5px;
  background: var(--line-color);
  border-radius: 1px;
}

/* ── Canvas Wrappers ─────────────────────────────────── */
.canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  padding: 12px 14px;
}

.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.loss-wrap {
  flex: 1;
  min-height: 160px;
  padding: 10px 12px;
  max-height: 240px;
}

/* ── Loss Stats ──────────────────────────────────────── */
.loss-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 0 14px 10px;
  flex-shrink: 0;
}

.loss-stat-item {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  text-align: center;
}

.loss-stat-label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.loss-stat-val {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--loss-color);
}

/* ── Info Section ────────────────────────────────────── */
.info-section {
  padding: 4px 0;
  flex-shrink: 0;
}

.info-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.formula-block {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-left: 2px solid var(--accent);
}

.formula {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent);
  letter-spacing: 0.2px;
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE — Tablet / Mobile
   ══════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 200px;
    --sidebar-r: 210px;
  }
  html, body { overflow: auto; }
  .app-layout {
    height: auto;
    overflow: auto;
  }
  .param-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  html, body { overflow: auto; }

  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow: visible;
  }
  .sidebar-right {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .center-panel {
    min-height: 360px;
    height: 360px;
  }

  .loss-wrap {
    max-height: 200px;
    min-height: 180px;
  }

  .header-meta { display: none; }
  .title-sub   { display: none; }

  .param-grid { grid-template-columns: 1fr 1fr 1fr; }
}

@media (max-width: 480px) {
  .app-header { padding: 0 14px; }
  .param-grid { grid-template-columns: 1fr 1fr; }
  .loss-stats { grid-template-columns: 1fr 1fr 1fr; }
  .center-panel { min-height: 300px; height: 300px; }
}

/* ── Animations ──────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-section { animation: fadeIn 0.3s ease both; }
.panel-section:nth-child(1) { animation-delay: 0.05s; }
.panel-section:nth-child(3) { animation-delay: 0.10s; }
.panel-section:nth-child(5) { animation-delay: 0.15s; }

.app-header { animation: fadeIn 0.25s ease both; }
