:root {
  --ink: #e9f1f6;
  --ink-soft: #b2c2d3;
  --canvas: #0b0f14; /* nero grafene */
  --primary: #4ace78;
  --primary-strong: #36b46a;
  --accent: #47b5ff;
  --accent-soft: rgba(71, 181, 255, 0.12);
  --muted: #667485;
  --danger: #e05a47;
  --success: #4ace78;
  --card: #0f161e;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  font-family: 'Work Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: 'Work Sans', system-ui, sans-serif;
}

.page-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.side-nav {
  background: linear-gradient(180deg, #0d131a 0%, #0a0f15 100%);
  color: #d8e4ee;
  padding: 24px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.brand-dot {
  width: 14px;
  height: 28px;
  background: linear-gradient(180deg, var(--accent) 0%, var(--primary) 100%);
  border-radius: 8px;
}

.brand-name { font-weight: 700; letter-spacing: 0.5px; }
.brand-sub { font-size: 12px; color: rgba(230, 243, 242, 0.8); }

.nav-block { margin-bottom: 28px; }
.nav-title { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: rgba(230,243,242,0.7); margin-bottom: 8px; }

.nav-link {
  display: block;
  color: #d8e4ee;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-link:hover { background: rgba(255, 255, 255, 0.08); }
.nav-link.active { background: rgba(71,181,255,0.18); color: #fff; border: 1px solid rgba(71,181,255,0.35); }

.main {
  max-width: none;
  width: 100%;
  padding: 32px 40px 64px;
  margin: 0;
}

.folder-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  padding-left: 10px;
}

.folder-tab {
  position: relative;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(135deg, #003b57, #0a4d74);
  color: #e9f1f6;
  padding: 12px 16px 10px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 8px 16px rgba(0,0,0,0.22);
  transform: translateY(4px);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.2s ease;
}

.folder-tab.tutorial-tab { background: linear-gradient(135deg, #003b57, #0a4d74); }
.folder-tab.exercise-tab { background: linear-gradient(135deg, #1c6fa0, #47b5ff); }

.folder-tab::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 6px;
  background: rgba(0,0,0,0.35);
  border-radius: 0 0 4px 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.folder-tab.active {
  transform: translateY(0);
  box-shadow: 0 12px 26px rgba(0,0,0,0.12);
}

.folder-tab.active::after { opacity: 1; }

.top-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

h1 { margin: 4px 0 8px; font-family: 'Sora', system-ui, sans-serif; letter-spacing: -0.4px; }

h2, h3 { font-family: 'Sora', system-ui, sans-serif; letter-spacing: -0.2px; margin: 0; }

.lede { margin: 0; color: var(--ink-soft); max-width: 560px; }

.eyebrow { text-transform: uppercase; letter-spacing: 1px; font-size: 12px; color: var(--muted); margin: 0; }

.tabs { display: flex; gap: 8px; }
.tab {
  border: 1px solid rgba(0,0,0,0.1);
  background: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
  transition: all 0.2s ease;
}
.tab.active { background: linear-gradient(135deg, var(--primary), var(--primary-strong)); color: #f7f3ea; box-shadow: var(--shadow); border-color: transparent; }

.challenge-hero {
  background: var(--card);
  margin-top: 20px;
  border-radius: 18px;
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.hero-image { position: relative; border-radius: 12px; overflow: hidden; }
.hero-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-badge {
  position: absolute; top: 12px; left: 12px;
  background: rgba(15, 28, 27, 0.8);
  color: #fff;
  padding: 6px 10px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 12px;
}

.hero-copy .pill { display: inline-block; background: var(--accent-soft); color: var(--ink); padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.hero-copy h2 { margin: 10px 0 8px; }
.hero-copy p { margin: 0 0 10px; color: var(--ink-soft); }

.keyword-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.keyword-list li { background: #eef4f3; border-radius: 999px; padding: 6px 10px; font-weight: 600; color: var(--ink-soft); font-size: 13px; }

.chat-shell {
  margin-top: 22px;
  background: var(--card);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.05);
  width: 100%;
}

.chat-shell.no-feedback .chat-window {
  max-height: none;
  min-height: 50vh;
}

.chat-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.scenario-meta { display: flex; gap: 8px; align-items: center; }
.pill { display: inline-block; background: var(--accent-soft); color: var(--ink); padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 12px; }
.pill.must { background: #e7f7ef; color: var(--success); }
.pill.nice { background: #fff3d6; color: var(--ink-soft); }
.keyword-pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.keyword-pills .pill { background: #eef4f3; color: var(--ink-soft); }

.theory {
  display: none;
  background: #0f161e;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 12px 14px;
  color: #d6e3ef;
  margin-bottom: 12px;
}

.theory.show { display: block; }
.theory strong { color: #e9f1f6; }
.theory ul { margin: 8px 0 0; padding-left: 18px; color: #b9c8d8; }
.theory li { margin-bottom: 4px; }

.status-pill {
  background: rgba(71,181,255,0.12);
  color: #cfe7ff;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  border: 1px solid rgba(71,181,255,0.25);
}

.chat-window {
  min-height: 260px;
  max-height: min(480px, 60vh);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #0c121a;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.04);
}

.message { padding: 12px 14px; border-radius: 12px; max-width: 90%; box-shadow: 0 4px 14px rgba(0,0,0,0.15); color: #e9f1f6; }
.message.bot { background: #0f161e; border: 1px solid rgba(255,255,255,0.06); align-self: flex-start; max-width: 75%; }
.message.user { background: #1b2734; border: 1px solid rgba(255,255,255,0.08); align-self: flex-end; }
.message .tag { display: inline-block; font-size: 12px; font-weight: 700; margin-bottom: 6px; color: var(--muted); }

.typing { display: none; color: var(--muted); font-size: 13px; margin: 8px 0 0 6px; }
.typing.active { display: block; }

.chat-input { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-input textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: #0c131c;
  color: var(--ink);
  padding: 12px;
  font-family: inherit;
  resize: vertical;
  min-height: 90px;
}
.input-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.tutorial-cta {
  display: none;
  justify-content: flex-end;
  margin-top: 12px;
}

.tutorial-cta.show { display: flex; }

button.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #0b0f14;
  border: none;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(74,206,120,0.35);
}

button.ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.feedback {
  margin-top: 20px;
  background: transparent;
  border-radius: 18px;
  padding: 18px;
  box-shadow: none;
}

.feedback-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.badge { background: rgba(71,181,255,0.12); color: #cfe7ff; padding: 8px 12px; border-radius: 10px; font-weight: 700; border: 1px solid rgba(71,181,255,0.25); }
.badge.pass { background: rgba(74,206,120,0.15); color: var(--success); border-color: rgba(74,206,120,0.4); }
.badge.fail { background: rgba(224,90,71,0.15); color: var(--danger); border-color: rgba(224,90,71,0.3); }

.bars { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bar-top { display: flex; justify-content: space-between; font-weight: 700; color: var(--ink-soft); }
.bar-track { background: #1c2732; border-radius: 12px; height: 12px; overflow: hidden; }
.bar-fill { background: linear-gradient(135deg, var(--success), #3ab96b); height: 100%; width: 0%; transition: width 0.4s ease; }
.bar-fill.alt { background: linear-gradient(135deg, var(--accent), #2a8dd6); }

.results { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.pill-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pill-list li { padding: 6px 10px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.pill-list li.found { background: rgba(74,206,120,0.15); color: var(--success); }
.pill-list li.missing { background: rgba(224,90,71,0.15); color: var(--danger); }
.pill-list.empty::after { content: '—'; color: var(--muted); }

.callout {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  background: linear-gradient(120deg, rgba(71,181,255,0.08), rgba(74,206,120,0.12));
  border: 1px solid rgba(255,255,255,0.08);
  font-weight: 600;
  color: var(--ink-soft);
}

/* Lab image in chat */
.lab-image-block { margin: 0; }
.lab-image-thumb {
  max-width: 100%;
  max-height: 220px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 6px 16px rgba(0,0,0,0.28);
  display: block;
  cursor: zoom-in;
}
.lab-image-caption {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* Image modal overlay */
.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.image-modal.show { display: flex; }
.image-modal-inner {
  max-width: 92vw;
  max-height: 92vh;
}
.image-modal-inner img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}

.feedback.inline {
  margin-top: 18px;
  box-shadow: none;
  padding: 12px 0 0;
  border-top: 1px dashed rgba(255,255,255,0.08);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

@media (max-width: 960px) {
  .page-shell { grid-template-columns: 1fr; }
  .side-nav { position: relative; height: auto; border-bottom: 1px solid rgba(255,255,255,0.08); }
  .main { padding: 26px 20px 40px; }
  .message { max-width: 100%; }
}

@media (max-width: 820px) {
  .folder-tabs { overflow-x: auto; padding-bottom: 4px; }
  .folder-tab { flex: 1; min-width: 150px; text-align: center; font-size: 14px; }
}

@media (max-width: 720px) {
  .bars, .results { grid-template-columns: 1fr; }
  .chat-shell { padding: 14px; }
  .chat-window { max-height: none; min-height: 200px; }
  .input-actions { flex-direction: column; align-items: stretch; }
  .input-actions button { width: 100%; }
  .folder-tabs { padding-left: 0; }
}
