/* ===================================================
   AlgoLab – Główny arkusz stylów
   =================================================== */

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

/* ---------- Motyw ciemny (domyślny) ---------- */
:root,
[data-theme="dark"] {
  --bg:        #1e1e2e;
  --bg2:       #252535;
  --bg3:       #2e2e42;
  --border:    #3a3a52;
  --accent:    #7c6af0;
  --accent2:   #5be0c4;
  --danger:    #f56565;
  --success:   #68d391;
  --warning:   #f6ad55;
  --text:      #e2e8f0;
  --text-muted:#94a3b8;
  --font-code: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --font-ui:   'Segoe UI', system-ui, sans-serif;
  --radius:    8px;
  --shadow:    0 4px 20px rgba(0,0,0,.4);

  /* Podświetlanie składni – ciemny */
  --syn-kw:    #c792ea;
  --syn-str:   #c3e88d;
  --syn-num:   #f78c6c;
  --syn-cmt:   #546e7a;
  --syn-fn:    #82aaff;
  --syn-op:    #89ddff;
}

/* ---------- Motyw jasny ---------- */
[data-theme="light"] {
  --bg:        #f5f5f7;
  --bg2:       #ffffff;
  --bg3:       #eaeaf0;
  --border:    #d0d0dc;
  --accent:    #5c4ee0;
  --accent2:   #0d9488;
  --danger:    #dc2626;
  --success:   #16a34a;
  --warning:   #d97706;
  --text:      #1e1e2e;
  --text-muted:#64748b;
  --shadow:    0 4px 20px rgba(0,0,0,.12);

  /* Podświetlanie składni – jasny */
  --syn-kw:    #7c3aed;
  --syn-str:   #15803d;
  --syn-num:   #c2410c;
  --syn-cmt:   #9ca3af;
  --syn-fn:    #1d4ed8;
  --syn-op:    #0369a1;
}

/* ---------- Prefers-color-scheme (brak localStorage) ---------- */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg:        #f5f5f7;
    --bg2:       #ffffff;
    --bg3:       #eaeaf0;
    --border:    #d0d0dc;
    --accent:    #5c4ee0;
    --accent2:   #0d9488;
    --danger:    #dc2626;
    --success:   #16a34a;
    --warning:   #d97706;
    --text:      #1e1e2e;
    --text-muted:#64748b;
    --shadow:    0 4px 20px rgba(0,0,0,.12);
    --syn-kw:    #7c3aed;
    --syn-str:   #15803d;
    --syn-num:   #c2410c;
    --syn-cmt:   #9ca3af;
    --syn-fn:    #1d4ed8;
    --syn-op:    #0369a1;
  }
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- App shell ---------- */
#app {
  display: flex;
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
}

#app-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* ---------- Sidebar nawigacyjny ---------- */
#app-sidebar {
  display: flex;
  flex-direction: column;
  width: 160px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  transition: width .2s ease;
  overflow: hidden;
  z-index: 10;
}

#app-sidebar.collapsed {
  width: 44px;
}

.sidebar-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 10px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
  line-height: 1;
  width: 24px;
  text-align: center;
}

.sidebar-logo-full {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
  opacity: 1;
  transition: opacity .15s;
  white-space: nowrap;
}

#app-sidebar.collapsed .sidebar-logo-full { opacity: 0; pointer-events: none; }

.sidebar-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 6px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 6px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}

/* --- Przyciski zakładek w sidebarze --- */
.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 8px;
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-ui);
  transition: background .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
  width: 100%;
  text-align: left;
}
.tab-btn:hover { background: var(--bg3); color: var(--text); }
.tab-btn.active { background: var(--accent); color: #fff; }

.tab-icon { font-size: 15px; flex-shrink: 0; width: 20px; text-align: center; line-height: 1; }
.tab-label { opacity: 1; transition: opacity .15s; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

#app-sidebar.collapsed .tab-label { opacity: 0; width: 0; }

/* Samouczek i Blog w bottom */
.sidebar-tutorial-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 7px 8px;
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-ui);
  transition: background .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
  width: 100%;
  text-align: left;
}
.sidebar-tutorial-btn:hover { background: var(--bg3); color: var(--text); }

.sidebar-back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 7px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  transition: color .15s, background .15s;
  white-space: nowrap;
  overflow: hidden;
  width: 100%;
}
.sidebar-back-link:hover { color: var(--accent); background: var(--bg3); }

/* Przycisk hamburger menu (schowany na desktopu) */
#sidebar-menu-btn {
  display: none;
}

/* Dropdown menu (schowany na desktopu) */
.sidebar-menu-overlay,
.sidebar-menu-dropdown {
  display: none;
}

/* Przycisk zwijania */
#sidebar-collapse-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 4px 0;
  cursor: pointer;
  font-size: 14px;
  width: 100%;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
}
#sidebar-collapse-btn:hover { background: var(--bg3); color: var(--text); border-color: var(--accent); }
#app-sidebar.collapsed #sidebar-collapse-btn { transform: scaleX(-1); }

/* Przycisk motywu */
#theme-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 4px 0;
  cursor: pointer;
  font-size: 14px;
  width: 100%;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  font-family: var(--font-ui);
  font-size: 12px;
  justify-content: flex-start;
  margin-top: auto !important;
}
#theme-toggle-btn:hover { background: var(--bg3); color: var(--text); border-color: var(--accent); }
#app-sidebar.collapsed #theme-toggle-btn .tab-label { opacity: 0; width: 0; }

/* ---------- Header (usunięty – zastąpiony sidebarem) ---------- */
#app-header { display: none; }

/* ---------- Tab content ---------- */
.tab-content { display: none; flex: 1; overflow: hidden; min-height: 0; }
.tab-content.active { display: flex; flex-direction: column; }

/* ============================================================
   EDYTOR
   ============================================================ */

/* Zakładka edytora - pionowy flex: górna część + terminal + status */
#tab-editor.active {
  display: flex;
  flex-direction: column;
}

.editor-layout {
  display: flex;
  flex: 1;
  gap: 0;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-editor {
  flex: 1;
  border-right: 1px solid var(--border);
  min-width: 0;
}

/* ---- Terminal na dole ---- */
.terminal-resize-handle {
  height: 6px;
  flex-shrink: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  cursor: row-resize;
  position: relative;
  z-index: 3;
  transition: background .15s;
}
.terminal-resize-handle:hover,
.terminal-resize-handle.dragging {
  background: var(--accent);
}
.editor-terminal {
  display: flex;
  flex-direction: row;
  height: 200px;
  flex-shrink: 0;
  border-top: 2px solid var(--border);
  background: var(--bg2);
  overflow: hidden;
}

.terminal-section {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  padding: 8px 10px;
  overflow: hidden;
  min-width: 0;
}
.terminal-section:last-child { border-right: none; }

.terminal-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 6px;
  flex-shrink: 0;
}

.terminal-controls {
  flex-shrink: 0;
  width: 160px;
}

/* Wiersz: wyjście po lewej + zmienne po prawej */
.terminal-output-col {
  flex: 3;
  min-width: 200px;
  display: flex;
  flex-direction: row;
  padding: 0;
  overflow: hidden;
}

.terminal-output-pane {
  flex: 2;
  display: flex;
  flex-direction: column;
  padding: 8px 10px 4px;
  border-right: 1px solid var(--border);
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}
.terminal-output-pane #output-area {
  flex: 1;
  min-height: 0;
}

.terminal-vars-pane {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  padding: 8px 10px 6px;
  overflow-y: auto;
}

.terminal-stack {
  flex: 1;
  min-width: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#stack-view, #block-props-view {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

#block-props-view .fcv-props-textarea {
  resize: vertical;
  min-height: 60px;
}

/* ---- Panel widoku diagramu (prawy, auto-generowany) ---- */
.panel-fc-view {
  flex: 1;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ---- Separator ze strzałkami między panelami ---- */
.editor-splitter {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 22px;
  flex-shrink: 0;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  z-index: 2;
  cursor: col-resize;
  user-select: none;
}

.splitter-btn {
  width: 18px;
  height: 28px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .15s, color .15s, border-color .15s;
  line-height: 1;
}
.splitter-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Stany ukrycia paneli */
.panel-editor.panel-hidden   { display: none; }
.panel-fc-view.panel-hidden  { display: none; }
.editor-splitter.code-hidden .splitter-btn#splitter-hide-code,
.editor-splitter.diagram-hidden .splitter-btn#splitter-hide-diagram {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---- Właściwości bloku (wewnątrz terminal-stack) ---- */
.fcv-props-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  display: block;
  margin-bottom: 2px;
}

.fcv-props-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 7px;
  outline: none;
  box-sizing: border-box;
  margin-bottom: 5px;
}
.fcv-props-input:focus { border-color: var(--accent); }
.fcv-props-input-wide { width: 100%; }

/* Wiersz 4 komórek dla pętli dla */
.fcv-for-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 6px;
  margin-bottom: 2px;
}
.fcv-for-cell { display: flex; flex-direction: column; min-width: 0; }

/* Wiersz warunku: lewa strona | operator | prawa strona */
.fcv-cond-row {
  display: grid;
  grid-template-columns: 1fr 56px 1fr;
  gap: 4px 5px;
  margin-bottom: 2px;
  align-items: end;
}
.fcv-cond-cell { display: flex; flex-direction: column; min-width: 0; }
.fcv-props-select {
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
  cursor: pointer;
}
.fcv-props-select option { background: var(--bg-dark, #1a1a2e); }
.fcv-cond-toggle-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 10px;
  cursor: pointer;
  padding: 2px 0;
  text-align: left;
  opacity: .75;
  display: block;
  margin-top: 2px;
}
.fcv-cond-toggle-btn:hover { opacity: 1; text-decoration: underline; }

/* Łącznik (i/lub) między wierszami warunku */
.fcv-cond-connector {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 5px 0 2px;
}
.fcv-cond-join {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
  cursor: pointer;
  font-size: 11px;
}
.fcv-cond-join option { background: var(--bg-dark, #1a1a2e); }
.fcv-cond-remove-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted, #888);
  font-size: 13px;
  cursor: pointer;
  padding: 1px 5px;
  border-radius: 3px;
  line-height: 1;
}
.fcv-cond-remove-btn:hover {
  color: #e05555;
  border-color: rgba(220,50,50,.25);
  background: rgba(220,50,50,.07);
}

/* Zakładka Logowanie — w przygotowaniu */
.login-coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
}
.login-lock { font-size: 56px; line-height: 1; opacity: .7; }
.login-title { font-size: 22px; font-weight: 700; color: var(--text); margin: 0; }
.login-msg { font-size: 15px; color: var(--text-muted); margin: 0; }
.login-sub { font-size: 12px; color: var(--text-muted); max-width: 380px; margin: 0; opacity: .7; line-height: 1.6; }

/* ---- Toast powiadomienia ---- */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 380px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 4px 16px rgba(0,0,0,.45);
  pointer-events: all;
  animation: toastIn .2s ease;
  border-left: 4px solid transparent;
  background: var(--bg3);
  color: var(--text);
  word-break: break-word;
}
.toast.toast-error   { border-color: #f56565; background: #2d1a1a; }
.toast.toast-warning { border-color: #f6ad55; background: #2a200d; }
.toast.toast-info    { border-color: #7c6af0; background: #1a1a2e; }
.toast.toast-success { border-color: #68d391; background: #0f2318; }

.toast-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; }
.toast-btns { display: flex; gap: 6px; margin-top: 8px; }
.toast-btns .btn { font-size: 11px; padding: 3px 10px; }
.toast-title { font-weight: 700; margin-bottom: 2px; }
.toast-msg   { color: var(--text-muted); font-size: 12px; }
.toast-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 14px; padding: 0 2px; flex-shrink: 0;
  line-height: 1; border-radius: 3px;
}
.toast-close:hover { color: var(--text); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}
.toast.removing { animation: toastOut .2s ease forwards; }

.fc-view-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.fc-view-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 4px;
  white-space: nowrap;
}

/* Ciało panelu: paleta po lewej + kanwa po prawej */
.fc-view-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.fc-view-palette {
  width: 130px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fc-view-palette-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 0 4px 4px;
}

#fcv-block-palette {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Kompaktowe elementy palety (węższe niż w tab-flowchart) */
.fcv-palette-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: grab;
  font-size: 11px;
  font-weight: 600;
  transition: border-color .15s, background .15s;
  user-select: none;
  color: var(--text);
}
.fcv-palette-item:hover  { border-color: var(--accent); background: var(--bg3); }
.fcv-palette-item:active { cursor: grabbing; }

.fcv-palette-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 12px;
  flex-shrink: 0;
}

.fc-view-canvas {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.fc-view-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
  padding: 20px;
  z-index: 1;
}

#fcv-svg {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: block;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.editor-controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ctrl-sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; flex-shrink: 0; }
.btn-danger { background: #5c2a2a; color: #fc8181; border-color: #7c3a3a; }
.btn-danger:hover { background: #7c3a3a; }

/* Mobile editor tabs – ukryte na desktopie */
.mobile-editor-tabs { display: none; }

/* Mobile selects (viz/tasks/help) – ukryte na desktopie */
.mobile-select-nav { display: none; }

/* Mobile bottom bar – ukryty na desktopie */
#mobile-bottom-bar { display: none; }

/* --- Code editor area --- */
#editor-wrapper {
  flex: 1;
  display: grid;
  grid-template-columns: 42px 1fr;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

#line-numbers {
  background: var(--bg2);
  color: var(--text-muted);
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.6;
  padding: 12px 6px 12px 8px;
  text-align: right;
  user-select: none;
  overflow: hidden;
  border-right: 1px solid var(--border);
  white-space: pre;
}

/* Podświetlanie składni – leży POD textarea */
#code-highlight {
  position: absolute;
  left: 42px;
  top: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.6;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: hidden;
  color: transparent; /* tekst niewidoczny, widoczne tylko span-y */
}

#code-input {
  grid-column: 2;
  position: relative;
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.6;
  padding: 12px;
  background: transparent;
  color: transparent;
  border: none;
  outline: none;
  resize: none;
  white-space: pre;
  overflow-wrap: normal;
  overflow: auto;
  caret-color: var(--accent2);
  z-index: 1;
}

/* Linia aktywna podświetlona */
.hl-line { display: block; white-space: pre; }
.active-line { background: rgba(124,106,240,.12); }

/* Składnia – paleta jak w SVG hero */
.kw   { color: var(--syn-kw);  font-weight: 600; } /* słowa kluczowe */
.kw2  { color: var(--warning); }                   /* przypisanie ← */
.num  { color: var(--syn-num); }                   /* liczby */
.str  { color: var(--syn-str); }                   /* stringi */
.cmt  { color: var(--syn-cmt); font-style: italic; }/* komentarze */
.op   { color: var(--syn-op);  }                   /* operatory */
.func { color: var(--accent2); }                   /* funkcje */
.var  { color: #7c6af0; }                   /* zmienne */

/* ---------- Kontrolki uruchamiania ---------- */
.run-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.speed-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  width: 100%;
  font-size: 12px;
  color: var(--text-muted);
}
.speed-control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}
.speed-control input[type=range] { width: 100%; }

/* ---------- Sekcje panelu prawego ---------- */
.panel-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ---------- Input queue ---------- */
.input-row { display: flex; gap: 6px; margin-top: 8px; }
.input-row input { flex: 1; }

#input-queue-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 28px;
}

.input-chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: var(--font-code);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.input-chip.used { opacity: .35; text-decoration: line-through; }
.input-chip.active { border-color: var(--accent2); color: var(--accent2); }

/* ---------- Output area ---------- */
.panel-output-section { flex: 0 0 auto; }

#output-area {
  background: #0d0d1a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  font-family: var(--font-code);
  font-size: 13px;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.out-line { margin: 0; line-height: 1.6; }
.out-line.error { color: var(--danger); }
.out-line.info  { color: var(--text-muted); }

/* ---------- Tabela zmiennych ---------- */
#variables-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
#variables-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
#variables-table td {
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  font-family: var(--font-code);
}
#variables-table tr.changed td { background: rgba(124,106,240,.15); }
#variables-table tr.changed td:first-child { border-left: 2px solid var(--accent); }

.type-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 20px;
  font-family: var(--font-ui);
}
.type-int    { background: rgba(247,140,108,.2); color: #f78c6c; }
.type-float  { background: rgba(130,170,255,.2); color: #82aaff; }
.type-string { background: rgba(195,232,141,.2); color: #c3e88d; }
.type-bool   { background: rgba(91,224,196,.2);  color: var(--accent2); }
.type-array  { background: rgba(199,146,234,.2); color: #c792ea; }

/* ---------- Stos wywołań ---------- */
#call-stack {
  font-family: var(--font-code);
  font-size: 12px;
}
.stack-frame {
  background: var(--bg3);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
  border-left: 3px solid var(--accent);
}
.stack-frame:first-child { border-color: var(--accent2); }

/* ---------- Pasek stanu ---------- */
#status-bar {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 5px 12px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}
#status-text.running { color: var(--accent2); }
#status-text.error   { color: var(--danger); }
#status-text.done    { color: var(--success); }

/* ---- Stopka aplikacji ---- */
#app-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 4px 16px;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
#app-version-label {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}
.footer-sep { opacity: .35; }
.footer-link { color: var(--text-muted); text-decoration: none; }
.footer-link:hover { color: var(--accent); }

/* ============================================================
   WIZUALIZACJE
   ============================================================ */
.viz-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.viz-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
}

.viz-algo-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }

.viz-algo-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: background .15s, border-color .15s;
}
.viz-algo-btn:hover { background: var(--bg); border-color: var(--accent); }
.viz-algo-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.viz-config label { display: block; font-size: 12px; color: var(--text-muted); margin: 10px 0 4px; }
.viz-config input[type=range] { width: 100%; }
.viz-config input[type=number] { width: 100%; }

.viz-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px;
  gap: 12px;
}

.viz-header h2 { font-size: 18px; }
.viz-header p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

#viz-canvas-wrapper {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 200px;
}
#viz-canvas { width: 100%; height: 100%; display: block; }

#viz-stats {
  display: flex;
  gap: 24px;
  font-size: 13px;
  color: var(--text-muted);
}
#viz-stats strong { color: var(--text); }

#viz-pseudocode-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
}
#viz-pseudocode {
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre;
}
#viz-pseudocode .active-pseudo { background: rgba(124,106,240,.25); border-left: 3px solid var(--accent); padding-left: 6px; display: block; }

/* ============================================================
   ZADANIA
   ============================================================ */
.tasks-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.tasks-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
}

#tasks-list { display: flex; flex-direction: column; gap: 6px; }

.task-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color .15s, border-left-color .15s, background .15s;
}
.task-item:hover { border-color: var(--accent); border-left-color: var(--accent); }
.task-item.active { border-color: var(--border); background: rgba(124,106,240,.10); }
.task-item.solved { border-color: var(--border); }
/* Lewy pasek koloru wg trudności */
.task-item:has(.badge-easy)   { border-left-color: var(--success); }
.task-item:has(.badge-medium) { border-left-color: var(--warning); }
.task-item:has(.badge-hard)   { border-left-color: var(--danger);  }
.task-item.active:has(.badge-easy)   { background: rgba(104,211,145,.08); }
.task-item.active:has(.badge-medium) { background: rgba(246,173, 85,.08); }
.task-item.active:has(.badge-hard)   { background: rgba(245,101,101,.08); }

.task-item-title { font-weight: 600; font-size: 13px; }
.task-item-meta  { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.task-item-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 10px;
  margin-right: 4px;
}
.badge-easy   { background: rgba(104,211,145,.2); color: var(--success); }
.badge-medium { background: rgba(246,173,85,.2);  color: var(--warning); }
.badge-hard   { background: rgba(245,101,101,.2); color: var(--danger); }

.tasks-main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

#task-header h2 { font-size: 20px; margin-bottom: 6px; }
#task-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
#task-description {
  line-height: 1.7;
  margin-bottom: 16px;
  color: var(--text);
}
#task-examples {
  margin-bottom: 20px;
}
.example-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  font-family: var(--font-code);
  font-size: 13px;
}
.example-box .ex-label { font-family: var(--font-ui); font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }

.task-editor-wrap { margin-top: 16px; }

/* ---- Przełącznik trybu (pseudokod / diagram) ---- */
.task-mode-btn {
  opacity: 0.55;
  border: 1px solid var(--border) !important;
  transition: opacity .15s, border-color .15s;
}
.task-mode-btn.active {
  opacity: 1;
  border-color: var(--accent) !important;
  color: var(--accent);
}

/* ---- Diagram blokowy w zadaniach ---- */
.task-fc-layout {
  display: flex;
  height: 320px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}

.task-fc-palette {
  width: 120px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.task-fc-palette-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: background .12s, border-color .12s;
}
.task-fc-palette-item:hover { background: var(--bg3); border-color: var(--border); color: var(--text); }

.task-fc-palette-icon {
  width: 22px;
  height: 16px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}

.task-fc-canvas-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.task-fc-toolbar {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#task-fc-svg {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: block;
  cursor: default;
}

#task-editor-container {
  display: grid;
  grid-template-columns: 42px 1fr;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: 240px;
}

#task-code-area {
  position: relative;
  overflow: hidden;
  display: flex;
}

#task-line-numbers {
  background: var(--bg2);
  color: var(--text-muted);
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.6;
  padding: 12px 6px 12px 8px;
  text-align: right;
  user-select: none;
  overflow: hidden;
  border-right: 1px solid var(--border);
  white-space: pre;
}

#task-code-highlight {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.6;
  padding: 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: transparent;
  overflow: hidden;
}

#task-code-input {
  position: relative;
  flex: 1;
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 1.6;
  padding: 12px;
  background: transparent;
  color: transparent;
  caret-color: var(--accent2);
  border: none;
  outline: none;
  resize: none;
  white-space: pre;
  overflow-wrap: normal;
  overflow: auto;
  caret-color: var(--accent2);
}

.task-run-row { display: flex; gap: 8px; margin-top: 10px; }

#task-result {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius);
  font-size: 13px;
  display: none;
}
#task-result.pass {
  background: rgba(104,211,145,.1);
  border: 1px solid var(--success);
  color: var(--success);
  display: block;
}
#task-result.fail {
  background: rgba(245,101,101,.1);
  border: 1px solid var(--danger);
  color: var(--danger);
  display: block;
}

#task-hint {
  margin-top: 10px;
  background: rgba(246,173,85,.1);
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 13px;
  color: var(--warning);
}

/* ============================================================
   POMOC
   ============================================================ */
.help-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.help-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 12px;
}

.help-link {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.help-link:hover { background: var(--bg3); color: var(--text); }
.help-link.active { background: var(--accent); color: #fff; }

.help-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  line-height: 1.7;
}

.help-content h2 { font-size: 18px; margin: 24px 0 12px; color: var(--accent); }
.help-content h2:first-child { margin-top: 0; }
.help-content p { margin-bottom: 10px; }
.help-content pre {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-family: var(--font-code);
  font-size: 13px;
  margin: 10px 0 16px;
  overflow-x: auto;
  white-space: pre;
}
.help-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}
.help-content th { background: var(--bg2); padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.help-content td { padding: 7px 12px; border-bottom: 1px solid rgba(255,255,255,.04); }
.help-content code {
  background: var(--bg3);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-code);
  font-size: 12px;
  color: var(--accent2);
}

/* ============================================================
   PRZYCISKI i INPUTY (wspólne)
   ============================================================ */
.btn {
  padding: 7px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-ui);
  font-weight: 500;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .88; }
.btn-primary:disabled { opacity: .5; cursor: default; }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background .12s;
}
.btn-secondary:hover { background: var(--bg4, rgba(255,255,255,.13)); }
.btn-sm        { padding: 4px 10px; font-size: 12px; }

input[type=text], input[type=number], select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 5px 10px;
  font-size: 13px;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color .15s;
}
input[type=text]:focus, input[type=number]:focus, select:focus {
  border-color: var(--accent);
}
select option { background: var(--bg2); }

/* ============================================================
   DIAGRAM BLOKOWY
   ============================================================ */
.fc-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* --- Paleta lewa --- */
.fc-palette {
  width: 200px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
}

#fc-block-palette {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fc-palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: grab;
  font-size: 12px;
  font-weight: 600;
  transition: border-color .15s, transform .1s;
  user-select: none;
}
.fc-palette-item:hover {
  border-color: var(--accent);
  transform: translateX(2px);
}
.fc-palette-item:active { cursor: grabbing; transform: scale(.97); }

.fc-palette-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 14px;
  flex-shrink: 0;
}

/* --- Toolbar zoom/pan --- */
.fc-canvas-wrap {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle, rgba(255,255,255,.04) 1px, transparent 1px),
    var(--bg);
  background-size: 30px 30px;
  overflow: hidden;
}

.fc-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 2;
}

.fc-tb-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  padding: 4px 9px;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  line-height: 1;
}
.fc-tb-btn:hover    { background: var(--accent); border-color: var(--accent); color: #fff; }
.fc-tb-btn.fc-tb-active { background: var(--accent2); border-color: var(--accent2); color: #1a1a2e; }
.fc-tb-active { background: var(--accent2) !important; border-color: var(--accent2) !important; color: #1a1a2e !important; }

.fc-tb-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}

.fc-tb-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 6px;
}

.fc-canvas-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.8;
  pointer-events: none;
  z-index: 1;
}

#fc-svg {
  flex: 1;
  width: 100%;
  display: block;
  overflow: visible;
}

/* Bloki SVG */
.fc-block { transition: filter .15s; }
.fc-block:hover .fc-port { opacity: 1 !important; }
.fc-port  { opacity: 0.4; transition: opacity .15s; }
.fc-selected .fc-port { opacity: 1; }

/* Drag-over highlight na SVG */
#fc-svg.drag-over { outline: 2px dashed var(--accent); }

/* --- Panel prawy: właściwości --- */
.fc-props {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
}

#fc-props-content label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin: 10px 0 3px;
}

#fc-props-content input[type=text],
#fc-props-content textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 5px 8px;
  font-size: 12px;
  font-family: var(--font-code);
  outline: none;
  resize: vertical;
}
#fc-props-content input[type=text]:focus,
#fc-props-content textarea:focus { border-color: var(--accent); }

/* Wyjście żółwika */
#fc-output {
  background: #0d0d1a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  font-family: var(--font-code);
  font-size: 12px;
  min-height: 60px;
  max-height: 140px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Aktywny blok highlight */
#fc-active-block {
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 8px;
  font-family: var(--font-code);
  font-size: 12px;
  min-height: 32px;
}

/* Tabela zmiennych */
#fc-vars-table td {
  padding: 3px 6px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  font-family: var(--font-code);
  font-size: 12px;
}
#fc-vars-table tr.changed td { background: rgba(124,106,240,.15); }

/* Dane wejściowe FC */
#fc-input-list {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 6px;
}

/* Animowany blok podczas pracy żółwika */
.fc-block-active rect,
.fc-block-active polygon,
.fc-block-active circle,
.fc-block-active ellipse {
  filter: drop-shadow(0 0 8px gold) !important;
}

/* ---- Modal: wprowadzanie danych ---- */
#fc-input-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
#fc-input-modal.fc-modal-visible {
  display: flex;
}

#interp-input-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
#interp-input-modal.active {
  display: flex;
}

/* ==========================================================
   KONTAKT
   ========================================================== */

.contact-layout {
  display: flex;
  gap: 40px;
  padding: 40px 56px;
  height: 100%;
  overflow-y: auto;
  align-items: flex-start;
  box-sizing: border-box;
}

/* ---- Lewa kolumna ---- */
.contact-info {
  flex: 0 0 280px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.contact-logo {
  font-size: 26px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.contact-heading {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin: 0;
}

.contact-lead {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.65;
  margin: 0;
}

.contact-reasons {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.contact-reasons li {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 10px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.contact-reasons li strong { color: var(--text); }

.contact-alt {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.contact-alt-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.contact-alt-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  padding: 7px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: block;
  transition: border-color .15s, background .15s;
}
.contact-alt-link:hover { border-color: var(--accent); background: var(--bg3); }

/* ---- Prawa kolumna: formularz ---- */
.contact-form-wrap {
  flex: 1;
  min-width: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 40px;
}

.cf-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 16px;
}
.cf-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.cf-required { color: var(--danger); }

.cf-group input,
.cf-group select,
.cf-group textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .15s;
  resize: vertical;
}
.cf-group input:focus,
.cf-group select:focus,
.cf-group textarea:focus { border-color: var(--accent); }
.cf-group select option { background: var(--bg2); }

.cf-error {
  font-size: 11px;
  color: var(--danger);
  min-height: 14px;
}

.cf-counter {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  margin-top: 2px;
}

.cf-submit-btn {
  width: 100%;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
}

#cf-status {
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  display: none;
  line-height: 1.5;
}
#cf-status.success {
  display: block;
  background: rgba(104, 211, 145, .12);
  border: 1px solid var(--success);
  color: var(--success);
}
#cf-status.error {
  display: block;
  background: rgba(245, 101, 101, .12);
  border: 1px solid var(--danger);
  color: var(--danger);
}

@media (max-width: 768px) {
  .contact-layout { flex-direction: column; padding: 20px 16px; gap: 24px; }
  .contact-info { flex: 1; }
  .contact-form-wrap { flex: 1; width: 100%; padding: 20px 16px; }
}

/* ==========================================================
   TUTORIAL – Samouczek
   ========================================================== */

/* Przycisk w sidebarze */
#tutorial-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 7px 8px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
  margin-left: 0;
}
#tutorial-btn:hover { background: var(--bg3); color: var(--text); border-color: var(--accent); }

#accessibility-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 7px 8px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
  margin-left: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}
#accessibility-btn:hover { background: var(--bg3); color: var(--text); }
#accessibility-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#theme-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 7px 8px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
#theme-toggle-btn:hover { background: var(--bg3); color: var(--text); }
#theme-toggle-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Overlay */
#tutorial-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 8000;
  pointer-events: none;
}
#tutorial-overlay.active { display: block; }

/* Przyciemnienie tła */
#tutorial-overlay::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .68);
  pointer-events: all;
}

/* Podświetlony element */
#tutorial-spotlight {
  position: fixed;
  border-radius: 6px;
  box-shadow: 0 0 0 4px var(--accent), 0 0 0 9999px rgba(0,0,0,.68);
  pointer-events: none;
  transition: top .3s ease, left .3s ease, width .3s ease, height .3s ease, opacity .2s;
  z-index: 8001;
  opacity: 0;
}
#tutorial-spotlight.visible { opacity: 1; }

/* Karta tutorialu */
#tutorial-card {
  position: fixed;
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 20px 22px 16px;
  width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  pointer-events: all;
  z-index: 8002;
  transition: top .3s ease, left .3s ease, opacity .2s;
}

/* Strzałka karty */
#tutorial-card::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--bg2);
  border-left: 1px solid var(--accent);
  border-top:  1px solid var(--accent);
  display: none;
}
#tutorial-card.arrow-bottom::before {
  display: block;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%) rotate(225deg);
}
#tutorial-card.arrow-top::before {
  display: block;
  top: -7px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
}
#tutorial-card.arrow-right::before {
  display: block;
  right: -7px;
  top: 50%;
  transform: translateY(-50%) rotate(135deg);
}
#tutorial-card.arrow-left::before {
  display: block;
  left: -7px;
  top: 50%;
  transform: translateY(-50%) rotate(315deg);
}

#tutorial-step-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 6px;
}

#tutorial-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.3;
}

#tutorial-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 14px;
}

#tutorial-dots {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin-bottom: 14px;
}
.tutorial-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border);
  transition: background .2s, border-color .2s;
}
.tutorial-dot.active {
  background: var(--accent);
  border-color: var(--accent);
}

#tutorial-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#tutorial-skip {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  transition: color .15s;
}
#tutorial-skip:hover { color: var(--danger); }

#tutorial-nav { display: flex; gap: 6px; }

#tutorial-prev,
#tutorial-next {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
#tutorial-prev:hover { background: var(--bg); }
#tutorial-next { background: var(--accent); border-color: var(--accent); color: #fff; }
#tutorial-next:hover { filter: brightness(1.1); }
#tutorial-prev:disabled { opacity: .35; cursor: default; }
#tutorial-prev:disabled:hover { background: var(--bg3); }

.fc-modal-box {
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 28px 32px;
  min-width: 320px;
  max-width: 420px;
  width: 90vw;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  animation: fc-modal-pop .18s ease;
}
@keyframes fc-modal-pop {
  from { transform: scale(.9); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

.fc-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.fc-modal-icon { font-size: 22px; }
.fc-modal-header h3 {
  margin: 0;
  font-size: 17px;
  color: var(--text);
}

.fc-modal-desc {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-muted);
}
.fc-modal-desc em { color: var(--accent2); font-style: normal; }

.fc-modal-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.fc-modal-label code {
  background: var(--bg3);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-code);
  font-size: 14px;
}

.fc-modal-input {
  width: 100%;
  background: var(--bg3);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 16px;
  font-family: var(--font-code);
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s;
}
.fc-modal-input:focus { border-color: var(--accent2); }

.fc-modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}
.fc-modal-actions .btn { min-width: 80px; font-size: 15px; padding: 8px 20px; }

/* ---- Przycisk "Następny krok" – wyróżniony podczas pracy ---- */
#fc-next-btn {
  background: linear-gradient(135deg, var(--accent2), #3db8a0);
  border-color: var(--accent2);
  color: #1a1a2e;
  font-weight: 700;
  animation: fc-pulse 1.2s ease-in-out infinite;
}
@keyframes fc-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(91,224,196,.4); }
  50%       { box-shadow: 0 0 0 6px rgba(91,224,196,0); }
}

/* ---- Info o kroku ---- */
#fc-step-info { animation: fc-fade-in .3s ease; }
@keyframes fc-fade-in { from { opacity:0 } to { opacity:1 } }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ---------- Tooltip ---------- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ============================================================
   RESPONSYWNOŚĆ – URZĄDZENIA MOBILNE
   ============================================================ */

/* --- Tablet pionowo i telefony (≤ 768px) --- */
@media (max-width: 768px) {

  /* Używaj dynamic viewport height (iOS Chrome fix) */
  html, body { height: 100%; overflow: hidden; }
  #app { height: 100vh; height: 100dvh; /* dynamic – bez paska przeglądarki */ }

  /* Na mobile sidebar jest ukryty – nawigacja przez hamburger w prawym górnym rogu */
  #app {
    flex-direction: row;
  }

  #app-sidebar {
    display: none !important;
  }

  #app-main {
    flex: 1;
    min-height: 0;
    width: 100%;
    padding-bottom: calc(54px + env(safe-area-inset-bottom, 0px));
  }

  /* Logo schowane w bottom nav */
  .sidebar-top { display: none; }

  /* Zakładki w poziomie z przewijaniem */
  .sidebar-tabs {
    flex-direction: row;
    flex: 1;
    padding: 0;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    display: flex;
    flex-wrap: nowrap;
    align-content: flex-start;
    min-height: 60px;
  }
  .sidebar-tabs::-webkit-scrollbar { display: none; }

  .tab-btn {
    flex-direction: column;
    gap: 2px;
    padding: 6px 4px;
    font-size: 10px;
    flex: 0 0 auto;
    min-width: 52px;
    justify-content: center;
    align-items: center;
    border-radius: 0;
    text-align: center;
    border-top: 2px solid transparent;
    border-bottom: none;
  }
  .tab-btn.active {
    background: transparent;
    color: var(--accent);
    border-top-color: var(--accent);
  }
  .tab-icon { width: auto; font-size: 18px; }
  /* Przywróć widoczność etykiet mimo trybu collapsed */
  .tab-label,
  #app-sidebar.collapsed .tab-label {
    opacity: 1 !important;
    width: auto !important;
    font-size: 10px;
  }

  /* Dolna sekcja sidebaru: połączona z tabami */
  .sidebar-bottom {
    flex-direction: row;
    padding: 0 2px;
    border-top: none;
    border-left: 1px solid var(--border);
    gap: 0;
    align-items: stretch;
    flex-shrink: 0;
    width: auto;
    order: unset;
    flex: 0 0 auto;
    display: none; /* ukryj na mobile */
  }

  .sidebar-tutorial-btn,
  .sidebar-back-link,
  #theme-toggle-btn,
  #accessibility-btn {
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px;
    font-size: 10px;
    justify-content: center;
    align-items: center;
    min-width: 52px;
    flex: 0 0 auto;
    border: none;
    border-top: 2px solid transparent;
    border-radius: 0;
    text-align: center;
  }

  .sidebar-tutorial-btn .tab-label,
  .sidebar-back-link .tab-label,
  #theme-toggle-btn .tab-label,
  #accessibility-btn .tab-label,
  #app-sidebar.collapsed #theme-toggle-btn .tab-label {
    opacity: 1 !important;
    width: auto !important;
    font-size: 10px;
  }

  /* ---- Mobilny pasek dolny ---- */
  #mobile-bottom-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(54px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 1000;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    align-items: center;
  }
  /* Hamburger w pasku dolnym */
  #sidebar-menu-btn {
    display: flex;
    position: static;
    flex-shrink: 0;
    width: 54px;
    height: 54px;
    justify-content: center;
    align-items: center;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
    transition: color .15s, background .15s;
    padding: 0;
  }
  #sidebar-menu-btn:hover { background: var(--bg3); }
  #sidebar-menu-btn.active { color: var(--accent); }
  /* Grupy kontrolek (pokazywane przez JS) */
  .mobile-ctrl-group {
    display: none;
    flex: 1;
    align-items: center;
    padding: 0 8px;
    gap: 8px;
    overflow: hidden;
    height: 100%;
    min-width: 0;
  }
  .mobile-ctrl-group.active { display: flex; }

  /* Overlay – ukryty (pełnoekranowe menu go zastępuje) */
  .sidebar-menu-overlay { display: none !important; }

  /* Pełnoekranowe menu mobile */
  .sidebar-menu-dropdown {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    z-index: 1050;
    background: var(--bg);
    overflow-y: auto;
    border: none;
    border-radius: 0;
    padding: 0;
    min-width: unset;
    max-width: unset;
    box-shadow: none;
    display: none;
  }
  .sidebar-menu-dropdown.active {
    display: flex;
    flex-direction: column;
  }

  /* Nagłówek menu */
  .mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .mobile-menu-logo {
    font-size: 18px;
    font-weight: bold;
    color: var(--text);
    font-family: var(--font-ui);
  }
  .mobile-menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    transition: background .15s, color .15s;
  }
  .mobile-menu-close:hover { background: var(--bg3); color: var(--text); }

  /* Zakładki nawigacyjne w menu */
  .mobile-menu-tabs,
  .mobile-menu-utils {
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 2px;
  }
  .mobile-menu-tab-item,
  .mobile-menu-util-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 15px;
    font-family: var(--font-ui);
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    width: 100%;
    transition: background .15s, color .15s;
  }
  .mobile-menu-tab-item:hover,
  .mobile-menu-util-item:hover { background: var(--bg3); color: var(--text); }
  .mobile-menu-tab-item.active { color: var(--accent); background: var(--bg3); }
  .mobile-menu-util-item { font-size: 14px; padding: 12px 16px; }

  /* Separator między zakładkami a narzędziami */
  .mobile-menu-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 16px;
  }

  /* Przycisk collapse – zbędny na mobile */
  #sidebar-collapse-btn { display: none; }

  /* ---- Edytor: pionowy stack ---- */
  .editor-layout {
    flex-direction: column;
  }

  /* Przyciski Kod/Diagram w pasku dolnym */
  .mobile-editor-panel-tabs {
    display: flex;
    flex-shrink: 0;
    gap: 4px;
  }
  .mobile-editor-tab {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-family: var(--font-ui);
    cursor: pointer;
    white-space: nowrap;
    transition: color .15s, background .15s, border-color .15s;
  }
  .mobile-editor-tab.active {
    background: var(--bg3);
    color: var(--accent);
    border-color: var(--accent);
  }
  /* Select przykładów w pasku dolnym */
  .mobile-example-select {
    flex: 1;
    min-width: 0;
    padding: 7px 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    outline: none;
  }
  /* Ukryj oryginalny select w panelu edytora na mobile */
  #example-select { display: none; }

  /* Splitter – zbędny na mobile */
  .editor-splitter { display: none; }

  /* Na mobile: każdy panel zajmuje pełną wysokość */
  .panel-editor,
  .panel-fc-view {
    flex: 1 !important;
    height: 100% !important;
    min-height: 0 !important;
    border-right: none;
  }
  .panel-editor.mobile-hidden,
  .panel-fc-view.mobile-hidden { display: none !important; }

  /* Ukryj import/export/Wyczyść w nagłówku panelu – są w menu */
  #btn-export-json, #btn-import-label, #btn-clear, .ctrl-sep { display: none; }

  /* ---- Terminal ---- */
  .editor-terminal {
    height: 180px;
    flex-direction: column;
    overflow-y: auto;
    padding-bottom: 16px; /* suwak prędkości nie zasłonięty przez pasek dolny */
  }

  .terminal-controls  { width: 100%; flex-shrink: 0; }
  .terminal-output-col { flex: 1; min-width: 0; }
  .terminal-stack { min-width: 0; width: 100%; max-height: 100px; flex-shrink: 0; }

  .terminal-section {
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .terminal-section:last-child { border-bottom: none; }

  /* ---- Panel headers ---- */
  .panel-header {
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 8px;
  }
  .editor-controls { flex-wrap: wrap; gap: 4px; }
  .btn { min-height: 36px; } /* większe touch target */
  .run-controls .btn { min-height: 44px; padding: 10px 14px; font-size: 13px; }

  /* ---- Toast ---- */
  #toast-container {
    left: 8px;
    right: 8px;
    top: 8px;
    max-width: none;
  }

  /* ---- Wizualizacje ---- */
  .viz-layout { flex-direction: column; overflow: hidden; }
  /* Wykres (viz-main) na górze, sterowanie (viz-sidebar) na dole */
  .viz-main { order: 1; overflow-x: hidden; overflow-y: auto; padding-bottom: 32px; }
  .viz-sidebar {
    order: 2;
    width: 100%;
    overflow-y: visible;
    border-right: none;
    border-top: 1px solid var(--border);
    border-bottom: none;
    padding: 8px;
  }
  /* Na mobile: ukryj przyciski algo (select jest w pasku dolnym) */
  .viz-algo-list { display: none; }
  /* Kanwas o stałej wysokości; pseudokod nie przepełnia w bok */
  #viz-canvas-wrapper { flex: none; height: 220px; width: 100%; }
  #viz-pseudocode { white-space: pre-wrap; word-break: break-word; }

  /* Viz-config: siatka 6 kolumn – etykiety + suwaki obok siebie, przyciski 3 kolumny */
  .viz-config {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 2px 4px;
    align-items: center;
    padding-top: 4px;
  }
  /* Etykiety suwaków – obok siebie (po 3 kolumny) */
  .viz-config label:nth-of-type(1) {
    grid-column: 1 / 4;
    font-size: 10px;
    color: var(--text-muted);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .viz-config label:nth-of-type(2) {
    grid-column: 4 / 7;
    font-size: 10px;
    color: var(--text-muted);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Suwaki – obok siebie (jeden wiersz) */
  .viz-config input[type=range]:nth-of-type(1) {
    grid-column: 1 / 4;
    width: 100%;
    margin: 0;
    height: 22px;
  }
  .viz-config input[type=range]:nth-of-type(2) {
    grid-column: 4 / 7;
    width: 100%;
    margin: 0;
    height: 22px;
  }
  /* Szukana wartość (widoczna przy algorytmach wyszukiwania) */
  #search-target-label { grid-column: 1 / -1; font-size: 10px; color: var(--text-muted); margin: 0; }
  #search-target { grid-column: 1 / -1; margin: 0; }
  /* Przyciski: po 3 na wiersz (span 2 z 6 kolumn) */
  .viz-config button {
    grid-column: span 2;
    min-width: 0;
    width: auto !important;
    margin-top: 0 !important;
    padding: 6px 2px;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 32px;
  }

  /* ---- Zadania ---- */
  .tasks-layout { flex-direction: column; }
  /* Na mobile: ukryj sidebar – select jest w pasku dolnym */
  .tasks-sidebar { display: none !important; }
  #tasks-list { display: none; }
  .tasks-main { padding: 12px 12px 32px; } /* dolny padding: treść nie zasłonięta przez pasek */

  /* ---- Pomoc ---- */
  .help-layout { flex-direction: column; }
  /* Na mobile: ukryj sidebar – select jest w pasku dolnym */
  .help-sidebar { display: none !important; }
  #help-nav { display: none; }
  .help-content { padding: 12px 16px 32px; } /* dolny padding: treść nie zasłonięta przez pasek */
  .contact-layout { padding-bottom: 32px; } /* przycisk wysyłania nie zasłonięty przez pasek */

  /* Select w pasku dolnym */
  .mobile-select-nav {
    display: block; /* nadpisuje globalne display:none */
    width: 100%;
    padding: 7px 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-ui);
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    outline: none;
  }

  /* ---- Paleta bloków węższa ---- */
  .fc-view-palette { width: 90px; }
  .fcv-palette-item { padding: 4px 5px; font-size: 10px; gap: 4px; }
  .fcv-palette-icon { width: 18px; height: 18px; font-size: 10px; }

  /* ---- Footer schowany – oszczędność miejsca ---- */
  #app-footer { display: none; }

  /* ---- Karty tutorialu pełna szerokość ---- */
  #tutorial-card {
    width: calc(100% - 24px);
    max-width: 100%;
    max-height: 85vh;
    padding: 16px 18px 14px;
    overflow-y: auto;
  }
}

/* --- Telefony (<= 480px) --- */
@media (max-width: 480px) {
  /* panel-editor height override usunięty – mobile tabs kontrolują widoczność */

  /* Ukryj palety bloków – za mało miejsca */
  .fc-view-palette { display: none; }
  .task-fc-palette { display: none; }

  /* Mniejsza czcionka kodu */
  #code-input, #code-highlight, #line-numbers,
  #task-code-input, #task-code-highlight, #task-line-numbers {
    font-size: 12px;
  }

  /* Toolbar diagramu: mniejsze przyciski */
  .fc-tb-btn { padding: 4px 7px; font-size: 12px; }
  .fc-view-toolbar { padding: 4px 6px; gap: 4px; }

  /* select przykładów skrócony */
  #examples-select { max-width: 120px; font-size: 12px; }

  /* Stos wywołań schowany – za mało miejsca */
  .terminal-stack { display: none; }

  /* Kontakt: mniejsze pady */
  .contact-form-wrap { padding: 16px; }

  /* Tryb egzaminacyjny banner */
  .exam-mode-banner {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid #ef4444;
    padding: 12px;
    margin-bottom: 12px;
    font-weight: 600;
    color: #ef4444;
  }

  /* Test Results Modal (v2.7.0) */
  .modal-test-results-box {
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
  }

  .test-results-content {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 16px;
  }

  .test-result-item {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border-left: 4px solid #666;
  }

  .test-result-item.passed {
    border-left-color: #22c55e;
    background: rgba(34, 197, 94, 0.08);
  }

  .test-result-item.failed {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
  }

  .test-result-header {
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .test-result-diff {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
  }

  .test-result-expected,
  .test-result-actual {
    padding: 8px;
    background: var(--bg);
    border-radius: 4px;
    border: 1px solid var(--border);
    overflow-x: auto;
  }

  .test-result-label {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
  }

  .test-result-input {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
  }

  /* Version History Modal (v2.8.0) */
  .modal-version-history-box {
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
  }

  .version-history-content {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 16px;
  }

  .version-item {
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
  }

  .version-item:hover {
    background: var(--bg);
    border-color: var(--accent);
  }

  .version-item.selected {
    background: rgba(168, 85, 247, 0.15);
    border-color: var(--accent);
  }

  .version-item-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--accent);
  }

  .version-item-info {
    flex: 1;
  }

  .version-item-number {
    font-weight: 600;
    font-size: 14px;
  }

  .version-item-time {
    font-size: 12px;
    color: var(--text-muted);
  }

  .version-item-preview {
    font-size: 11px;
    color: var(--text-muted);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Courier New', monospace;
  }

  /* Version Diff Modal */
  .modal-version-diff-box {
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
  }

  .version-diff-container {
    flex: 1;
    overflow: auto;
    margin-bottom: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .version-diff-side {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg);
  }

  .version-diff-header {
    background: var(--bg-secondary);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 12px;
  }

  .version-diff-lines {
    padding: 12px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
    max-height: 400px;
    overflow: auto;
  }

  .diff-line {
    padding: 2px 4px;
    margin: 2px 0;
    border-radius: 3px;
  }

  .diff-line.same {
    color: var(--text-muted);
  }

  .diff-line.added {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
  }

  .diff-line.removed {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
  }

  .diff-line-num {
    color: var(--text-muted);
    margin-right: 8px;
    display: inline-block;
    width: 30px;
    text-align: right;
  }
}

/* ═══ v2.9.0: Student Notes (Notatnik ucznia) ═══ */
.notes-section {
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
}

.notes-toggle-btn {
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}

.notes-toggle-btn:hover {
  background: var(--bg3);
}

.notes-toggle-btn::after {
  content: '▼';
  font-size: 12px;
  margin-left: auto;
  transition: transform 0.3s;
}

.notes-toggle-btn.collapsed::after {
  transform: rotate(-90deg);
}

.notes-content {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.notes-content.hidden {
  display: none;
}

#student-notes {
  width: 100%;
  height: 120px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  resize: vertical;
  transition: border-color 0.2s;
}

#student-notes:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 106, 240, 0.2);
}

.notes-autosave-indicator {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: right;
  display: none;
}

.notes-autosave-indicator.saving {
  display: block;
  color: var(--accent2);
}

.notes-autosave-indicator.saved {
  display: block;
  color: var(--success);
}

/* ═══ v3.0.0: Mini-Quiz (Quiz po zadaniu) ═══ */
.modal-quiz-box {
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.quiz-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg);
}

.quiz-question {
  margin-bottom: 20px;
}

.quiz-question-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.5;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.quiz-option:hover {
  border-color: var(--accent);
  background: var(--bg3);
}

.quiz-option input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

.quiz-option-text {
  flex: 1;
  color: var(--text);
  font-size: 14px;
  user-select: none;
}

.quiz-option.selected {
  border-color: var(--accent);
  background: rgba(124, 106, 240, 0.1);
}

.quiz-option.correct {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.1);
}

.quiz-option.incorrect {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.quiz-feedback {
  margin-top: 16px;
  padding: 12px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.5;
}

.quiz-feedback.correct {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  border-left: 3px solid var(--success);
}

.quiz-feedback.incorrect {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border-left: 3px solid var(--danger);
}

/* ═══════════════════════════════════════════════════
   ACCESSIBILITY (v3.1.0) – Ustawienia dostępności
   ═══════════════════════════════════════════════════ */

/* Importuj OpenDyslexic font dla wsparcia dysleksji */
@import url('https://fonts.googleapis.com/css2?family=OpenDyslexic:wght@400;700&display=swap');

/* Zmienne CSS dla trybu wysokiego kontrastu */
[data-accessibility="high-contrast"] {
  --bg:        #000000;
  --bg2:       #1a1a1a;
  --bg3:       #333333;
  --border:    #666666;
  --accent:    #ffff00;
  --accent2:   #00ff00;
  --danger:    #ff0000;
  --success:   #00ff00;
  --warning:   #ffff00;
  --text:      #ffffff;
  --text-muted: #cccccc;
}

[data-theme="light"][data-accessibility="high-contrast"] {
  --bg:        #ffffff;
  --bg2:       #f5f5f5;
  --bg3:       #eeeeee;
  --border:    #000000;
  --accent:    #0000ff;
  --accent2:   #008000;
  --danger:    #cc0000;
  --success:   #008000;
  --warning:   #ff8800;
  --text:      #000000;
  --text-muted: #333333;
}

/* --- Modal Styles (General) --- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  flex-shrink: 0;
}

.modal-close-btn:hover {
  color: var(--text);
  background: var(--bg3);
}

.modal-close-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

/* Accessibility Settings Modal */
.modal-accessibility-box {
  width: 100%;
  max-width: 500px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  color: var(--text);
}

.accessibility-settings {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 20px 0;
}

.accessibility-setting {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  transition: all 0.2s ease;
}

.accessibility-setting:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 106, 240, 0.1);
}

.a11y-label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.a11y-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--accent);
  margin-bottom: 4px;
}

.a11y-label input[type="range"] {
  width: 100%;
  height: 6px;
  cursor: pointer;
  accent-color: var(--accent);
  margin-top: 8px;
}

.a11y-label span:first-of-type {
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
}

.a11y-desc {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Dyslexia Font Support */
[data-accessibility="dyslexia-font"],
[data-accessibility="dyslexia-font"] * {
  font-family: 'OpenDyslexic', 'Segoe UI', system-ui, sans-serif !important;
  letter-spacing: 0.05em;
  line-height: 1.6;
}

[data-accessibility="dyslexia-font"] code,
[data-accessibility="dyslexia-font"] pre,
[data-accessibility="dyslexia-font"] .code-block,
[data-accessibility="dyslexia-font"] #code-editor {
  font-family: 'OpenDyslexic', 'Cascadia Code', 'Fira Code', monospace !important;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

[data-accessibility="reduced-motion"],
[data-accessibility="reduced-motion"] * {
  animation: none !important;
  transition: none !important;
}

/* High Contrast Mode Adjustments */
[data-accessibility="high-contrast"] {
  --shadow: none;
}

[data-accessibility="high-contrast"] * {
  border-width: 2px;
  outline-width: 2px;
}

[data-accessibility="high-contrast"] button,
[data-accessibility="high-contrast"] a {
  border: 2px solid var(--text);
  text-decoration: underline;
}

[data-accessibility="high-contrast"] .btn-primary {
  border: 2px solid var(--accent);
  background: var(--bg2);
  color: var(--accent);
}

/* Font Size Scaling */
[data-font-size="80"] { font-size: calc(var(--base-font, 14px) * 0.8); }
[data-font-size="90"] { font-size: calc(var(--base-font, 14px) * 0.9); }
[data-font-size="100"] { font-size: calc(var(--base-font, 14px) * 1); }
[data-font-size="110"] { font-size: calc(var(--base-font, 14px) * 1.1); }
[data-font-size="120"] { font-size: calc(var(--base-font, 14px) * 1.2); }
[data-font-size="130"] { font-size: calc(var(--base-font, 14px) * 1.3); }
[data-font-size="140"] { font-size: calc(var(--base-font, 14px) * 1.4); }
[data-font-size="150"] { font-size: calc(var(--base-font, 14px) * 1.5); }
[data-font-size="160"] { font-size: calc(var(--base-font, 14px) * 1.6); }
[data-font-size="170"] { font-size: calc(var(--base-font, 14px) * 1.7); }
[data-font-size="180"] { font-size: calc(var(--base-font, 14px) * 1.8); }
[data-font-size="190"] { font-size: calc(var(--base-font, 14px) * 1.9); }
[data-font-size="200"] { font-size: calc(var(--base-font, 14px) * 2); }

/* Focus Indicators */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Skip to Main Link */
.skip-to-main {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: white;
  padding: 8px;
  border-radius: 0 0 var(--radius) 0;
  z-index: 10000;
}

.skip-to-main:focus {
  top: 0;
}


.quiz-explanation {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg3);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.quiz-progress {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
}

/* ═══ v2.10.0: Streak & Goals (Motywacja) ═══ */
.modal-streak-box {
  max-width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.streak-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}

.streak-tab-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

.streak-tab-btn.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  margin-bottom: -1px;
}

.streak-tab-btn:hover {
  color: var(--text);
}

.streak-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg);
}

.streak-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.streak-item-title {
  flex: 1;
  color: var(--text);
  font-weight: 600;
}

.streak-item-value {
  font-size: 24px;
  font-weight: bold;
  color: #ff6b6b;
  margin: 0 12px;
}

.streak-item-badges {
  display: flex;
  gap: 4px;
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge.streak-7 {
  background: rgba(124, 106, 240, 0.2);
  color: var(--accent);
}

.badge.streak-14 {
  background: rgba(92, 224, 196, 0.2);
  color: var(--accent2);
}

.badge.streak-30 {
  background: rgba(255, 193, 7, 0.2);
  color: #ffc107;
}

.goal-item {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

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

.goal-title {
  color: var(--text);
  font-weight: 600;
}

.goal-type {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.goal-progress {
  width: 100%;
  height: 24px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
}

.goal-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 600;
}

.goal-progress-bar.complete {
  background: linear-gradient(90deg, var(--success), #22c55e);
}

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
}

.badge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.badge-card.earned {
  border-color: var(--accent);
  background: rgba(124, 106, 240, 0.1);
}

.badge-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.badge-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.empty-state-message {
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
}

.streak-display {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #ff6b6b;
}

/* ═══ v2.11.0: Feedback Templates (Szablony feedbacku) ═══ */
.feedback-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.feedback-template-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s;
}

.feedback-template-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(124, 106, 240, 0.1);
}

.feedback-template-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.feedback-template-title {
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
  flex: 1;
}

.feedback-template-category {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  margin-left: 8px;
}

.feedback-template-content {
  flex: 1;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.feedback-template-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.feedback-template-global {
  display: inline-block;
  padding: 2px 6px;
  background: rgba(92, 224, 196, 0.2);
  color: var(--accent2);
  border-radius: 3px;
  font-size: 11px;
}

.feedback-template-actions {
  display: flex;
  gap: 8px;
}

.feedback-template-actions button {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.feedback-template-actions .btn-edit {
  background: var(--accent);
  color: white;
}

.feedback-template-actions .btn-edit:hover {
  opacity: 0.9;
}

.feedback-template-actions .btn-delete {
  background: var(--danger);
  color: white;
}

.feedback-template-actions .btn-delete:hover {
  opacity: 0.9;
}

.feedback-template-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.feedback-template-empty p {
  margin-bottom: 16px;
  font-size: 14px;
}

.feedback-template-empty .btn-primary {
  margin-top: 16px;
}





