/* Training metrics cards */
.training-panel {
  background: #0f0f16;
  border: 1px solid #2a2a38;
  border-radius: 12px;
  padding: 12px;
  margin-top: 12px;
}

.training-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.training-panel h4 {
  margin: 0;
}

.state-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.state-badge.training {
  background: #2b6cff;
  color: white;
}

.state-badge.paused {
  background: #ffd166;
  color: #222;
}

.state-badge.done {
  background: #6ef3a5;
  color: #0f0f16;
}

.epoch-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 10px;
  opacity: 0.8;
}

.metric-card {
  margin-bottom: 10px;
}

.metric-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}

.metric-bar {
  height: 6px;
  background: #262636;
  border-radius: 4px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.35s ease;
}

.metric-bar-fill.loss {
  background: linear-gradient(90deg, #ff6b6b, #ff9f9f);
}

.metric-bar-fill.accuracy {
  background: linear-gradient(90deg, #4ecdc4, #7fffe1);
}

.best-metric {
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.9;
}

/* Console styles */
.training-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

.metric-card {
  background: #14141c;
  border: 1px solid #2a2a38;
  border-radius: 8px;
  padding: 10px;
}

.metric-label {
  font-size: 12px;
  opacity: 0.7;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.metric-bar {
  height: 6px;
  background: #262636;
  border-radius: 4px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}

.metric-bar-fill.loss {
  background: linear-gradient(90deg, #ff6b6b, #ff9f9f);
}

.metric-bar-fill.accuracy {
  background: linear-gradient(90deg, #4ecdc4, #7fffe1);
}

/* Console styles */
.console-line {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 12px;
  margin-bottom: 4px;
  padding: 4px 8px;
  border-radius: 4px;
  opacity: 0;
  animation: fadeIn 0.3s ease-in forwards;
}

.console-info { 
  color: #cfd8ff; 
  background: rgba(207, 216, 255, 0.1);
}

.console-success { 
  color: #6ef3a5; 
  background: rgba(110, 243, 165, 0.1);
}

.console-warning { 
  color: #ffd166; 
  background: rgba(255, 209, 102, 0.1);
}

.console-error { 
  color: #ff6b6b; 
  background: rgba(255, 107, 107, 0.1);
}

@keyframes fadeIn {
  to { opacity: 1; }
}

/* Results winner highlighting */
.result-item.winner {
  border-color: #6ef3a5;
  background: rgba(110, 243, 165, 0.1);
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(110, 243, 165, 0.2);
}

.result-item {
  transition: all 0.3s ease;
}

/* Portfolio – main styles */

:root {
  --bg: #0e0e11;
  --fg: #eaeaf0;
  --muted: #9aa0a6;
  --accent: #6cf2c2;
  --card: #16161d;
}

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

body {
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
}

/* ===== Integrated Header Layout ===== */

.site-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--card);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

.photo-wrapper {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.photo-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.identity-text h1 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.identity-text p {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 2px 0 0 0;
  letter-spacing: 0.5px;
}

.main-nav {
  display: flex;
  gap: 1.5rem;
}

.main-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.main-nav a:hover {
  color: var(--accent);
}

/* Mobile */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    gap: 1rem;
  }

  .main-nav {
    gap: 1rem;
  }
}

/* Header */
header {
  padding: 3rem 2rem;
  max-width: 1100px;
  margin: auto;
  text-align: center;
}

header nav {
  margin-top: 2rem;
}

header nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  margin: 0 1rem;
  transition: color 0.2s ease;
}

header nav a:hover {
  color: var(--accent);
}

nav {
  margin-top: 2rem;
  display: flex;
  gap: 1.5rem;
}

nav a {
  color: var(--fg);
  text-decoration: none;
  font-weight: 500;
  position: relative;
}

nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.25s ease;
}

nav a:hover::after {
  width: 100%;
}

/* Sections */
section {
  max-width: 1100px;
  margin: auto;
  padding: 4rem 2rem;
}

section h2 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

/* Project cards */
.projects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.card {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 12px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* Demos section (homepage) */
.demos-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--card);
}

.demos-intro {
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.demo-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.demo-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.5rem;
  background: var(--card);
  border-radius: 12px;
  text-decoration: none;
  color: var(--fg);
  border: 1px solid transparent;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.demo-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.demo-card-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
}

.demo-card-desc {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.5;
  flex: 1;
}

.demo-card-cta {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  margin-top: 0.25rem;
}

/* Demo subpages */
.demo-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.demo-page header {
  padding: 2rem 2rem 1rem;
}

/* Responsive design for profile photo */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 2rem;
  }
  
  .profile-section {
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-width: auto;
  }
  
  .profile-photo {
    width: 70px;
    height: 70px;
  }
  
  .header-text {
    min-width: auto;
  }
  
  header {
    padding: 3rem 1.5rem 2rem;
  }
}

.demo-page .back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  transition: color 0.2s ease;
}

.demo-page .back-link:hover {
  color: var(--accent);
}

.demo-page section {
  flex: 1;
}

.card h3 {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.card p {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Canvas demo */
.canvas-wrap {
  margin-top: 2.5rem;
}

.canvas-caption {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

canvas {
  width: 100%;
  height: 400px;
  display: block;
  border-radius: 16px;
  background: #000;
}

/* WebDNN MobileNet demo */
.webdnn-demo {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--card);
}

.webdnn-demo-title {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.webdnn-demo .canvas-caption {
  margin-bottom: 1rem;
}

.webdnn-file-label {
  display: inline-block;
  position: relative;
  cursor: pointer;
  margin-bottom: 1rem;
}

.webdnn-file-input {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  opacity: 0;
  cursor: pointer;
}

.webdnn-file-btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--card);
  color: var(--accent);
  border-radius: 8px;
  font-weight: 500;
  transition: background 0.2s ease;
}

.webdnn-file-btn:hover {
  background: #1e1e24;
}

.webdnn-canvas {
  width: 224px;
  height: 224px;
  border-radius: 12px;
  background: var(--card);
  display: block;
  margin-top: 0.5rem;
}

.tfjs-draw-label {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.tfjs-draw-wrap {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem;
}

.tfjs-draw-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  padding: 0.5rem 0;
}

.tfjs-toolbar-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  cursor: default;
}

.tfjs-toolbar-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.tfjs-pen-range {
  width: 88px;
  height: 6px;
  accent-color: var(--accent);
  cursor: pointer;
}

.tfjs-pen-color {
  width: 36px;
  height: 36px;
  padding: 2px;
  border: 2px solid var(--card);
  border-radius: 8px;
  cursor: pointer;
  background: var(--card);
}

.tfjs-pen-color:hover {
  border-color: var(--accent);
}

.tfjs-draw-canvas {
  cursor: crosshair;
  touch-action: none;
}

.tfjs-draw-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tfjs-draw-btns .webdnn-file-btn {
  margin-bottom: 0;
}

.webdnn-result {
  margin-top: 0.75rem;
  color: var(--fg);
  font-size: 0.95rem;
}

/* Doodle Classifier demo */
.doodle-demo {
  margin-top: 0;
}

.doodle-canvas {
  display: block;
  width: 224px;
  height: 224px;
  border-radius: 12px;
  background: var(--card);
  cursor: crosshair;
  touch-action: none;
}

.doodle-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.doodle-btns .webdnn-file-btn {
  margin-bottom: 0;
}

/* Live Console Viewer */
.console-viewer {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--card);
  border-radius: 8px;
  border: 1px solid #2a2a33;
}

.console-viewer h4 {
  margin: 0 0 1rem 0;
  color: var(--fg);
  font-size: 0.9rem;
  text-align: center;
}

.console-output {
  background: #0a0a0f;
  border: 1px solid #2a2a33;
  border-radius: 4px;
  padding: 1rem;
  height: 150px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #eaeaf0;
}

.console-output::-webkit-scrollbar {
  width: 8px;
}

.console-output::-webkit-scrollbar-track {
  background: #1a1a22;
}

.console-output::-webkit-scrollbar-thumb {
  background: #4a4a55;
  border-radius: 4px;
}

.console-output::-webkit-scrollbar-thumb:hover {
  background: #5a5a65;
}

/* Training Progress */
.training-progress {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--card);
  border-radius: 8px;
  border: 1px solid #2a2a33;
}

.training-progress h3 {
  margin: 0 0 1rem 0;
  color: var(--fg);
  font-size: 1rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #2a2a33;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

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

.training-status {
  margin: 0;
  color: var(--fg);
  font-size: 0.9rem;
}

/* Metrics chart */
.metrics-chart-container {
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(42, 42, 51, 0.5);
  border-radius: 6px;
  border: 1px solid #2a2a33;
}

.metrics-chart-container h4 {
  margin: 0 0 1rem 0;
  color: var(--fg);
  font-size: 0.9rem;
  text-align: center;
}

#custom-doodle-metrics-chart {
  width: 100%;
  max-width: 400px;
  height: 200px;
  display: block;
  margin: 0 auto;
  border: 1px solid #2a2a33;
  border-radius: 4px;
}

/* Dataset Viewer */
.dataset-viewer {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--card);
  border-radius: 8px;
  border: 1px solid #2a2a33;
}

.dataset-viewer h3 {
  margin: 0 0 1rem 0;
  color: var(--fg);
  font-size: 1rem;
  text-align: center;
}

.dataset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 10px;
  justify-items: center;
}

.dataset-tile {
  position: relative;
  width: 80px;
  height: 80px;
  border: 1px solid #2a2a33;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s ease, opacity 0.3s ease;
}

.dataset-tile:hover {
  transform: scale(1.05);
  border-color: var(--accent);
}

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

.dataset-tile-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: var(--fg);
  font-size: 0.65rem;
  text-align: center;
  padding: 2px 0;
  margin: 0;
}

/* Training Mode Controls */
.training-mode-controls {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--card);
  border-radius: 8px;
  border: 1px solid #2a2a33;
}

.training-mode-controls h4 {
  margin: 0 0 0.75rem 0;
  color: var(--fg);
  font-size: 1rem;
  text-align: center;
}

#custom-doodle-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

#custom-doodle-controls label {
  color: var(--fg);
  font-size: 0.9rem;
  font-weight: 500;
}

#training-mode {
  padding: 0.5rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid #2a2a33;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

#training-mode:hover {
  border-color: var(--accent);
}

#training-mode:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108, 242, 194, 0.2);
}

#begin-training {
  padding: 0.5rem 1.5rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

#begin-training:hover {
  background: #5ee0b0;
  transform: translateY(-1px);
}

#begin-training:active {
  transform: translateY(0);
}

#begin-training:disabled {
  background: var(--muted);
  cursor: not-allowed;
  transform: none;
}

/* Live Classification */
.live-classification {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--card);
  border-radius: 8px;
  border: 1px solid #2a2a33;
}

.live-classification h4 {
  margin: 0 0 0.75rem 0;
  color: var(--fg);
  font-size: 1rem;
  text-align: center;
}

.classification-result {
  padding: 0.75rem;
  background: rgba(108, 242, 194, 0.1);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--fg);
  font-size: 0.9rem;
  text-align: center;
  min-height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}

/* Demo Layout */
.demo-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 1rem;
}

.demo-left-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.demo-right-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.canvas-section {
  background: var(--card);
  border-radius: 8px;
  border: 1px solid #2a2a33;
  padding: 1rem;
}

.canvas-section h4 {
  margin: 0 0 1rem 0;
  color: var(--fg);
  font-size: 1rem;
  text-align: center;
}

.canvas-with-results {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  width: 100%; /* Ensure full width */
}

.doodle-demo {
  flex: 0 0 auto; /* Canvas takes its natural space */
}

.classification-results {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 200px;
  width: 100%; /* Ensure full width */
  flex-wrap: wrap; /* Allow wrapping if needed */
  flex: 1; /* Take remaining space */
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border: 2px solid transparent;
  border-radius: 6px;
  background: var(--card);
  transition: all 0.3s ease;
  flex: 1 1 auto; /* Ensure all items have equal space */
  min-width: 180px; /* Ensure minimum width */
}

.result-item.active {
  border-color: var(--accent);
  background: rgba(108, 242, 194, 0.1);
  transform: scale(1.02);
}

.shape-name {
  color: var(--fg);
  font-weight: 500;
  font-size: 0.9rem;
}

.shape-percentage {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  min-width: 45px;
  text-align: right;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .demo-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .demo-left-column,
  .demo-right-column {
    gap: 1rem;
  }
}

@media (max-width: 768px) {
  .demo-layout {
    gap: 1rem;
  }
  
  .training-mode-controls,
  .canvas-section,
  .live-classification,
  .console-viewer,
  .training-progress,
  .dataset-viewer {
    padding: 0.75rem;
  }
  
  .console-output {
    height: 150px;
    font-size: 0.75rem;
  }
  
  .doodle-canvas {
    width: 100%;
    max-width: 224px;
    height: auto;
    aspect-ratio: 1;
  }
}

/* Console Viewer */
.console-viewer {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--card);
  border-radius: 8px;
  border: 1px solid #2a2a33;
}

.console-viewer h4 {
  margin: 0 0 0.75rem 0;
  color: var(--fg);
  font-size: 1rem;
  text-align: center;
}

.console-output {
  background: #000;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 0.75rem;
  height: 200px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.4;
}

.console-log {
  display: flex;
  align-items: flex-start;
  margin-bottom: 0.25rem;
  padding: 0.25rem 0;
}

.console-timestamp {
  color: #888;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.console-message {
  color: var(--fg);
  flex: 1;
  word-break: break-word;
}

.console-error .console-message {
  color: #ff6b6b;
}

.console-warn .console-message {
  color: #feca57;
}

.console-info .console-message {
  color: var(--accent);
}
.contact-link {
  color: var(--accent);
}

.section-spacer {
  margin-top: 1rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}
