/* ============================================================
   XSS Lab — Design System
   Light theme, professional aesthetic
   ============================================================ */

/* --- Variables -------------------------------------------- */
:root {
  --bg-primary:   #f9fafb;
  --bg-surface:   #ffffff;
  --bg-card:      #ffffff;
  --bg-code:      #1e2433;
  --border:       #e5e7eb;
  --border-light: #d1d5db;

  --text:         #111827;
  --text-muted:   #6b7280;
  --text-dim:     #9ca3af;

  --red:          #ef3340;
  --red-dim:      #fef2f2;
  --red-border:   #fecaca;
  --blue:         #2563eb;
  --blue-dim:     #eff6ff;
  --blue-border:  #bfdbfe;
  --green:        #16a34a;
  --green-dim:    #f0fdf4;
  --green-border: #bbf7d0;
  --yellow:       #d97706;
  --yellow-dim:   #fffbeb;
  --yellow-border:#fde68a;
  --purple:       #7c3aed;
  --purple-dim:   #f5f3ff;
  --purple-border:#ddd6fe;
  --orange:       #ea580c;

  --nav-height:   60px;
  --radius:       8px;
  --radius-sm:    5px;
  --shadow:       0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:    0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg:    0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.05);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg-primary);
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.3; color: var(--text); }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

p { margin-bottom: 0.9rem; }
ul, ol { padding-left: 1.4rem; margin-bottom: 0.9rem; }
li { margin-bottom: 0.3rem; }

hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* --- Navigation ------------------------------------------ */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 0.5rem;
}

.nav-brand {
  font-size: 1rem;
  font-weight: 700;
  color: var(--red);
  letter-spacing: -0.02em;
  margin-right: 1rem;
  white-space: nowrap;
  text-decoration: none;
}
.nav-brand:hover { text-decoration: none; color: var(--red); }
.nav-brand span { color: var(--text-muted); font-weight: 400; }

.nav-links {
  display: flex;
  gap: 0.2rem;
  align-items: center;
  flex-wrap: wrap;
}

.nav-link {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: all 0.15s;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: var(--bg-primary); text-decoration: none; }
.nav-link.active { color: var(--red); background: var(--red-dim); font-weight: 600; }

.nav-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 0.5rem;
}

.nav-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 0 0.5rem;
}

/* --- Page Layout ----------------------------------------- */
.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.page-wide {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* --- Breadcrumb ------------------------------------------ */
.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .sep { color: var(--text-dim); }

/* --- Page header ----------------------------------------- */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  margin-bottom: 0.5rem;
}

.page-header p {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0;
}

/* --- Badges ---------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid;
}

.badge-red    { color: var(--red);    background: var(--red-dim);    border-color: var(--red-border); }
.badge-blue   { color: var(--blue);   background: var(--blue-dim);   border-color: var(--blue-border); }
.badge-green  { color: var(--green);  background: var(--green-dim);  border-color: var(--green-border); }
.badge-yellow { color: var(--yellow); background: var(--yellow-dim); border-color: var(--yellow-border); }
.badge-purple { color: var(--purple); background: var(--purple-dim); border-color: var(--purple-border); }

/* --- Cards ----------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 1rem; }

.card-grid {
  display: grid;
  gap: 1rem;
  align-items: start;
}
.card-grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.card-grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* --- Callouts / Alerts ----------------------------------- */
.callout {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border-left: 3px solid;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.callout-title {
  font-weight: 700;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.callout-info    { background: var(--blue-dim);   border-color: var(--blue);   color: var(--text); }
.callout-danger  { background: var(--red-dim);    border-color: var(--red);    color: var(--text); }
.callout-success { background: var(--green-dim);  border-color: var(--green);  color: var(--text); }
.callout-warn    { background: var(--yellow-dim); border-color: var(--yellow); color: var(--text); }
.callout-purple  { background: var(--purple-dim); border-color: var(--purple); color: var(--text); }

.callout-info    .callout-title { color: var(--blue); }
.callout-danger  .callout-title { color: var(--red); }
.callout-success .callout-title { color: var(--green); }
.callout-warn    .callout-title { color: var(--yellow); }
.callout-purple  .callout-title { color: var(--purple); }

/* --- Tabs ------------------------------------------------ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 2rem;
  overflow-x: auto;
}

.tab-btn {
  padding: 0.65rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--red); border-bottom-color: var(--red); font-weight: 600; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* --- Code blocks ----------------------------------------- */
pre {
  background: var(--bg-code) !important;
  color: #e2e8f0;
  border: 1px solid #2d3748;
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  position: relative;
}

code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
  font-size: 0.82rem;
}

:not(pre) > code {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  color: var(--orange);
  font-size: 0.8rem;
}

.code-block {
  position: relative;
  margin-bottom: 1rem;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #2d3748;
  border: 1px solid #2d3748;
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  color: #a0aec0;
}

.code-block-header .lang {
  color: #63b3ed;
  font-weight: 600;
  font-family: monospace;
}

.code-block pre {
  border-radius: 0 0 var(--radius) var(--radius);
  margin-bottom: 0;
}

.copy-btn {
  background: #3d4f65;
  border: 1px solid #4a5568;
  border-radius: var(--radius-sm);
  color: #a0aec0;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s;
}
.copy-btn:hover { color: #e2e8f0; border-color: #718096; }
.copy-btn.copied { color: #68d391; border-color: #276749; }

/* --- Buttons --------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; filter: brightness(0.95); }
.btn:active { transform: translateY(1px); }

.btn-primary   { background: var(--red);    color: white;       border-color: var(--red); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-secondary { background: var(--bg-card); color: var(--text); border-color: var(--border); box-shadow: var(--shadow); }
.btn-secondary:hover { border-color: var(--border-light); filter: none; background: var(--bg-primary); }
.btn-blue      { background: var(--blue);   color: white;       border-color: var(--blue); }
.btn-green     { background: var(--green);  color: white;       border-color: var(--green); }
.btn-outline   { background: transparent;   color: var(--red);  border-color: var(--red-border); }
.btn-outline:hover { background: var(--red-dim); filter: none; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 0.95rem; }

/* --- Forms ----------------------------------------------- */
.form-group { margin-bottom: 1rem; }

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="url"],
textarea,
select {
  width: 100%;
  min-width: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  transition: border-color 0.15s;
  outline: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

textarea {
  resize: vertical;
  min-height: 80px;
  font-family: 'JetBrains Mono', monospace;
  white-space: pre-wrap;
  overflow: auto;
  text-overflow: clip;
}

.input-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  min-width: 0;
  overflow: hidden;
}
.input-row input, .input-row textarea {
  flex: 1;
  min-width: 0;
}

/* --- Lab panels ------------------------------------------ */
.lab-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
  min-width: 0;
}

.lab-container > * { min-width: 0; overflow: hidden; }

@media (max-width: 720px) {
  .lab-container { grid-template-columns: 1fr; }
}

.lab-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
  box-shadow: var(--shadow);
}

.lab-panel-header {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lab-panel-header.vuln    { background: var(--red-dim);    color: var(--red); }
.lab-panel-header.attack  { background: var(--yellow-dim); color: var(--orange); }
.lab-panel-header.results { background: var(--green-dim);  color: var(--green); }
.lab-panel-header.info    { background: var(--blue-dim);   color: var(--blue); }

.lab-panel-body { padding: 1.25rem; min-width: 0; overflow: hidden; }

/* --- Challenge cards ------------------------------------- */
.challenge {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.challenge-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.challenge-title {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.challenge-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.challenge.solved .challenge-number {
  background: var(--green-dim);
  border-color: var(--green-border);
  color: var(--green);
}

.challenge-desc { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 1rem; }

.validation-result {
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.validation-result.show { display: flex; }
.validation-result.success { background: var(--green-dim); border: 1px solid var(--green-border); color: var(--green); }
.validation-result.error   { background: var(--red-dim);   border: 1px solid var(--red-border);   color: var(--red); }
.validation-result.info    { background: var(--blue-dim);  border: 1px solid var(--blue-border);  color: var(--blue); }

/* --- DOM Tree visualization ------------------------------ */
.dom-tree {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  background: var(--bg-code);
  border: 1px solid #2d3748;
  border-radius: var(--radius);
  padding: 1.5rem;
  line-height: 1.8;
  color: #e2e8f0;
}

.dom-node {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0;
}

.dom-node .tag         { color: #fc8181; }
.dom-node .attr-name   { color: #63b3ed; }
.dom-node .attr-val    { color: #68d391; }
.dom-node .text        { color: #faf089; }
.dom-node .comment-node{ color: #718096; font-style: italic; }

.dom-children { padding-left: 1.5rem; border-left: 1px dashed #4a5568; margin-left: 0.5rem; }

/* --- Cookie diagram -------------------------------------- */
.cookie-diagram {
  display: flex;
  gap: 1rem;
  margin: 1.25rem 0;
  align-items: stretch;
}

.cookie-scenario {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.cookie-scenario h4 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.cookie-scenario.safe h4    { color: var(--green);  border-color: var(--green-border); }
.cookie-scenario.vuln h4    { color: var(--red);    border-color: var(--red-border); }
.cookie-scenario.neutral h4 { color: var(--blue);   border-color: var(--blue-border); }

.flow-step {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  font-size: 0.82rem;
}

.flow-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.flow-icon.ok   { background: var(--green-dim);  color: var(--green);  border: 1px solid var(--green-border); }
.flow-icon.warn { background: var(--red-dim);    color: var(--red);    border: 1px solid var(--red-border); }
.flow-icon.info { background: var(--blue-dim);   color: var(--blue);   border: 1px solid var(--blue-border); }

@media (max-width: 560px) {
  .cookie-diagram { flex-direction: column; }
}

/* --- SameSite table -------------------------------------- */
.samesite-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  margin: 1rem 0;
}

.samesite-table th {
  text-align: left;
  padding: 0.6rem 0.9rem;
  background: var(--bg-primary);
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

.samesite-table td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.samesite-table tr:last-child td { border-bottom: none; }

.flag-yes     { color: var(--green); font-weight: 600; }
.flag-no      { color: var(--red);   font-weight: 600; }
.flag-partial { color: var(--yellow); font-weight: 600; }

/* --- Payload templates ----------------------------------- */
.payload-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
  min-width: 0;
}

.payload-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.payload-card-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--orange);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.payload-card pre {
  border: none;
  border-radius: 0;
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  max-height: 120px;
  white-space: pre;
}

/* --- Result log ------------------------------------------ */
.result-log {
  background: var(--bg-code);
  border: 1px solid #2d3748;
  border-radius: var(--radius);
  padding: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  min-height: 80px;
  max-height: 200px;
  overflow-x: auto;
  overflow-y: auto;
  color: #a0aec0;
  word-break: break-all;
}

.log-entry { margin-bottom: 0.4rem; line-height: 1.5; word-break: break-all; }
.log-entry.success { color: #68d391; }
.log-entry.error   { color: #fc8181; }
.log-entry.info    { color: #63b3ed; }
.log-entry.warn    { color: #faf089; }
.log-ts { color: #4a5568; margin-right: 0.5rem; }

/* --- Attack flow diagram --------------------------------- */
.flow-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 1.5rem 0;
  overflow-x: auto;
  padding: 0.5rem 0;
  flex-wrap: wrap;
}

.flow-node {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.8rem;
  min-width: 100px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.flow-node.actor    { border-color: var(--blue-border);   color: var(--blue); }
.flow-node.attacker { border-color: var(--red-border);    color: var(--red); }
.flow-node.server   { border-color: var(--purple-border); color: var(--purple); }
.flow-node.browser  { border-color: var(--green-border);  color: var(--green); }

.flow-arrow {
  color: var(--text-dim);
  font-size: 1.2rem;
  margin: 0 0.25rem;
  flex-shrink: 0;
}

/* --- Module cards on homepage ---------------------------- */
.module-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.module-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.module-card.prereq::before  { background: var(--blue); }
.module-card.lab-r::before   { background: var(--orange); }
.module-card.lab-p::before   { background: var(--red); }
.module-card.lab-d::before   { background: var(--purple); }
.module-card.concept::before { background: var(--yellow); }
.module-card.intro::before   { background: var(--green); }

.module-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
}

.module-card-icon {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  display: block;
  filter: grayscale(1);
}

.module-card h3 {
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.module-card p {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin: 0;
}

/* --- Hero section ---------------------------------------- */
.hero {
  padding: 4rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fff 0%, var(--bg-primary) 100%);
}

.hero h1 {
  font-size: 2.8rem;
  font-weight: 800;
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
  color: var(--text);
}

.hero h1 .accent { color: var(--red); }
.hero p { color: var(--text-muted); max-width: 560px; margin: 0 auto 1.5rem; font-size: 1.05rem; }

/* --- Explain Modal --------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.modal-close:hover { color: var(--text); background: var(--bg-primary); }

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.explain-step {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.explain-step:last-child { margin-bottom: 0; }

.explain-step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--red-dim);
  border: 1px solid var(--red-border);
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
}

.explain-step-content { flex: 1; min-width: 0; }

.explain-step-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
  color: var(--text);
}

.explain-step-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.explain-code {
  margin: 0.5rem 0 0 !important;
  font-size: 0.78rem !important;
  max-height: 150px;
}

/* --- CSRF flow (cookies page) ---------------------------- */
.csrf-flow {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
}
.csrf-step {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  box-shadow: var(--shadow);
}
.csrf-step-num {
  min-width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}
.csrf-step.attacker .csrf-step-num { background: var(--red-dim);    color: var(--red);    border: 1px solid var(--red-border); }
.csrf-step.user     .csrf-step-num { background: var(--blue-dim);   color: var(--blue);   border: 1px solid var(--blue-border); }
.csrf-step.server   .csrf-step-num { background: var(--purple-dim); color: var(--purple); border: 1px solid var(--purple-border); }
.csrf-step.bad      { border-color: var(--red-border);   background: var(--red-dim); }
.csrf-step.good     { border-color: var(--green-border); background: var(--green-dim); }

/* --- XSS Intro page -------------------------------------- */
.attack-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 2rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 1.5rem 0;
  overflow-x: auto;
  box-shadow: var(--shadow);
}

.diag-node {
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.2rem;
  text-align: center;
  font-size: 0.78rem;
  min-width: 110px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}
.diag-node .label    { font-weight: 700; font-size: 0.85rem; display: block; margin-bottom: 0.2rem; }
.diag-node .sublabel { color: var(--text-dim); font-size: 0.7rem; }
.diag-node.attacker  { border-color: var(--red-border);    background: var(--red-dim); }
.diag-node.server    { border-color: var(--purple-border); background: var(--purple-dim); }
.diag-node.victim    { border-color: var(--blue-border);   background: var(--blue-dim); }
.diag-node.db        { border-color: var(--yellow-border); background: var(--yellow-dim); }

.diag-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  margin: 0 0.25rem;
  flex-shrink: 0;
}
.diag-arrow-line {
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
}
.diag-arrow-label {
  font-size: 0.62rem;
  color: var(--text-dim);
  text-align: center;
  white-space: nowrap;
}

.xss-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.xss-type-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  border-top: 3px solid;
  box-shadow: var(--shadow);
}
.xss-type-card.reflected { border-top-color: var(--orange); }
.xss-type-card.stored    { border-top-color: var(--red); }
.xss-type-card.dom       { border-top-color: var(--purple); }
.xss-type-card h3 { font-size: 0.95rem; margin-bottom: 0.4rem; }
.xss-type-card p  { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.6rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-number {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--red);
  line-height: 1.1;
  display: block;
  margin-bottom: 0.3rem;
}
.stat-label  { font-size: 0.78rem; color: var(--text-muted); }

.case-study {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.case-study-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 0.25rem; }
.case-study-meta  { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.4rem; }

.owasp-bar-chart { margin: 1.5rem 0; }
.owasp-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
}
.owasp-label { width: 130px; flex-shrink: 0; color: var(--text-muted); }
.owasp-bar-wrap { flex: 1; background: var(--bg-primary); border-radius: 999px; height: 10px; border: 1px solid var(--border); }
.owasp-bar-fill { height: 100%; border-radius: 999px; background: var(--text-dim); }
.owasp-bar-fill.highlight { background: var(--red); }
.owasp-row.highlight .owasp-label { color: var(--red); font-weight: 600; }
.owasp-val { width: 35px; text-align: right; color: var(--text-muted); }

/* --- Bot indicator (persistent lab) ---------------------- */
.bot-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  background: var(--purple-dim);
  border: 1px solid var(--purple-border);
  border-radius: 999px;
  font-size: 0.7rem;
  color: var(--purple);
}

/* --- Source/Sink badges (dom lab) ------------------------ */
.source-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--blue-dim);
  color: var(--blue);
  border: 1px solid var(--blue-border);
  font-family: monospace;
}
.sink-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red-border);
  font-family: monospace;
}

/* --- Vulnerable demo app (dom lab) ----------------------- */
#vuln-app {
  background: #fff;
  color: #111;
  border-radius: var(--radius);
  padding: 1.5rem;
  font-family: Arial, sans-serif;
  min-height: 120px;
  border: 1px solid var(--border);
}
#vuln-app h2 { color: #1a56db; font-size: 1.1rem; margin-bottom: 0.5rem; }
#vuln-app p  { color: #374151; font-size: 0.9rem; margin: 0; }
#vuln-app #greeting { font-size: 1rem; margin-top: 0.5rem; padding: 0.5rem; background: #f3f4f6; border-radius: 4px; }

/* --- Comment items (persistent lab) ---------------------- */
.comment-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  margin-bottom: 0.6rem;
  box-shadow: var(--shadow);
}
.comment-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.comment-author { color: var(--blue); font-weight: 600; }
.comment-body   { font-size: 0.88rem; }

/* --- Cookie strip (cookies page) ------------------------- */
.cookie-strip {
  background: var(--bg-code);
  border: 1px solid #2d3748;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.83rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  white-space: nowrap;
  color: #e2e8f0;
}
.ck-name  { color: #f6ad55; font-weight: 700; }
.ck-val   { color: #faf089; }
.ck-eq    { color: #718096; }
.ck-attr  { color: #63b3ed; }
.ck-flag  { color: #68d391; font-weight: 700; }
.ck-flag.bad { color: #fc8181; text-decoration: line-through; opacity: 0.6; }
.ck-sep   { color: #718096; margin: 0 0.3rem; }

/* --- Utility --------------------------------------------- */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.83rem; }
.text-xs { font-size: 0.75rem; }
.font-mono { font-family: 'JetBrains Mono', monospace; }

/* --- Scrollbar ------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
