:root {
  --bg: #fff8ec;
  --panel: #ffffff;
  --ink: #073f42;
  --muted: #667085;
  --line: #f1dfc2;
  --primary: #006b70;
  --primary-dark: #004a4f;
  --accent: #f59d1a;
  --accent-soft: #fff1d6;
  --warning: #f59d1a;
  --success: #16a34a;
  --danger: #dc2626;
  --shadow: 0 16px 40px rgba(0, 75, 80, 0.10);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button, input, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 300px;
  background: linear-gradient(180deg, #005b60 0%, #073f42 65%, #022d30 100%);
  color: white;
  padding: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: grid;
  gap: 12px;
}

.brand img {
  width: 190px;
  max-width: 100%;
  height: auto;
  border-radius: 0;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.22));
}

.brand h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 4px 0 0;
  color: #ffe7bd;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: white;
  padding: 13px 14px;
  border-radius: 15px;
  text-align: left;
  transition: 0.2s ease;
}

.nav-btn:hover, .nav-btn.active {
  background: white;
  color: var(--primary-dark);
  transform: translateY(-1px);
}

.sidebar-note {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  color: #fff4dd;
  font-size: 13px;
}

.sidebar-note strong {
  color: var(--accent);
}

.main {
  flex: 1;
  padding: 24px;
  max-width: calc(100vw - 300px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.topbar label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 7px;
}

.topbar input {
  width: min(420px, 60vw);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
}

.topbar input:focus, textarea:focus, input[type="number"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(245, 157, 26, 0.18);
}

.top-actions, .button-row, .hero-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.wrap {
  flex-wrap: wrap;
}

.btn, .file-label {
  border: 0;
  border-radius: 14px;
  padding: 12px 15px;
  font-weight: 700;
  transition: 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.btn:hover, .file-label:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.btn.primary {
  background: var(--primary);
  color: white;
}

.btn.secondary, .file-label {
  background: var(--accent-soft);
  color: var(--primary-dark);
}

.btn.mini {
  padding: 9px 13px;
  font-size: 13px;
}

.btn.full {
  width: 100%;
}

.file-label {
  cursor: pointer;
  position: relative;
}

.file-label input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-label.big {
  min-height: 90px;
  width: 100%;
  border: 2px dashed var(--accent);
}

.screen {
  display: none;
  animation: fadeIn 0.25s ease;
}

.active-screen {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.hero {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 28px;
  align-items: center;
  min-height: 310px;
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  right: -80px;
  top: -80px;
  background: radial-gradient(circle, rgba(245,157,26,0.22), transparent 68%);
}

.hero h2, .section-heading h2 {
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1;
  letter-spacing: -0.04em;
  margin: 16px 0 14px;
}

.hero p, .section-heading p, .feature-card p, .card p {
  color: var(--muted);
  line-height: 1.65;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 13px;
}

.hero-graphic {
  display: grid;
  place-items: center;
  gap: 8px;
  z-index: 1;
}

.node {
  background: var(--primary-dark);
  color: white;
  width: 210px;
  padding: 18px;
  border-radius: 20px;
  text-align: center;
  font-weight: 800;
  box-shadow: 0 12px 25px rgba(0, 75, 80, 0.18);
}

.arrow {
  color: var(--primary);
  font-weight: 900;
  font-size: 24px;
}

.grid {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.feature-card h3, .card h3 {
  margin-top: 0;
}

.steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.steps div {
  background: #fffaf0;
  border: 1px solid #f5e2bd;
  padding: 16px;
  border-radius: 18px;
  display: grid;
  gap: 10px;
}

.steps strong {
  background: var(--primary);
  color: white;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 24px;
  margin-bottom: 20px;
}

.section-heading h2 {
  font-size: clamp(28px, 3vw, 42px);
}

.workspace {
  display: grid;
  grid-template-columns: 310px minmax(340px, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.text-workspace, .number-workspace {
  grid-template-columns: minmax(450px, 1fr) 420px;
}

.class-panel.wide {
  width: auto;
}

.classes {
  display: grid;
  gap: 12px;
}

.class-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: #fffdfa;
  display: grid;
  gap: 10px;
}

.class-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(245, 157, 26, 0.18);
}

.class-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.class-name {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 11px;
  outline: none;
  font-weight: 700;
}

.class-tools {
  display: flex;
  gap: 7px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--primary-dark);
  font-weight: 900;
}

.icon-btn.danger {
  color: var(--danger);
  background: #fff1f2;
}

.example-count {
  font-size: 13px;
  color: var(--muted);
}

.selected-class-box {
  background: linear-gradient(135deg, var(--accent-soft), #ffffff);
  border: 1px solid #ffd38a;
  color: var(--primary-dark);
  border-radius: 14px;
  padding: 11px 13px;
  font-weight: 800;
  margin: 8px 0 14px;
}

.class-card {
  cursor: pointer;
}

.class-card input,
.class-card textarea,
.class-card button {
  cursor: auto;
}

.empty-examples {
  font-size: 12px;
  color: var(--muted);
  background: #fff7e8;
  border: 1px dashed #f8c76e;
  border-radius: 12px;
  padding: 8px 10px;
}

.example-thumb {
  position: relative;
  width: 44px;
  height: 44px;
}

.example-thumb img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: white;
}

.thumb-delete {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: 0 5px 10px rgba(220, 38, 38, 0.28);
}

.examples-preview {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.examples-preview > img {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: white;
}

.camera-box {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 20px;
  overflow: hidden;
  background: #111827;
  border: 1px solid var(--line);
  margin-bottom: 14px;
}

.camera-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.camera-box video.on {
  display: block;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #d1d5db;
  font-weight: 700;
}

.hidden {
  display: none;
}

.tips {
  color: var(--muted);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.status {
  color: var(--muted);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin: 14px 0;
  font-size: 13px;
}

.status.good {
  color: #166534;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.status.bad {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.prediction-card {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  border-radius: 22px;
  padding: 20px;
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.prediction-card span, .prediction-card small {
  color: #fff0d2;
}

.prediction-card strong {
  font-size: 34px;
  line-height: 1;
}

.bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  gap: 5px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  gap: 10px;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #fff1d6;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.2s ease;
}

.draw-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.draw-tools label {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

#drawCanvas {
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1/1;
  border-radius: 20px;
  border: 2px solid #111827;
  background: white;
  touch-action: none;
  display: block;
  margin: 0 auto;
}

.text-classes .class-card textarea {
  width: 100%;
  min-height: 140px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  resize: vertical;
  outline: none;
}

textarea, input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  outline: none;
  margin: 12px 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th, .data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.data-table th {
  color: var(--muted);
  font-size: 13px;
}

.data-table input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  outline: none;
}

#numberChart {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  margin-top: 14px;
}

.note-list {
  color: var(--muted);
  line-height: 1.8;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #111827;
  color: white;
  padding: 13px 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: 0.2s ease;
  z-index: 50;
  max-width: 360px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .workspace, .text-workspace, .number-workspace {
    grid-template-columns: 1fr;
  }

  .grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 850px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main {
    max-width: none;
    padding: 14px;
  }

  .topbar, .section-heading, .hero {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .grid.four, .grid.two, .steps {
    grid-template-columns: 1fr;
  }
}
