* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #0b0d12;
  color: #e5e7eb;
}

body.tutorial-body {
  height: auto;
  min-height: 100%;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 16px;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

header h1 {
  margin: 0;
  font-size: 22px;
}

header p {
  margin: 4px 0 0;
  color: #9ca3af;
  font-size: 14px;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-link {
  text-decoration: none;
  background: #151821;
  color: #cbd5e1;
  border: 1px solid #262b38;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

.nav-link:hover {
  background: #232838;
  color: #ffffff;
}

.nav-link.active {
  background: #10b981;
  border-color: #10b981;
  color: #04130d;
  font-weight: 600;
}

.layout {
  flex: 1;
  display: flex;
  gap: 16px;
  min-height: 0;
}

.panel {
  width: 295px;
  flex-shrink: 0;
  background: #151821;
  border: 1px solid #262b38;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.label {
  font-size: 13px;
  color: #cbd5e1;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  background: #232838;
  color: #e5e7eb;
  border: 1px solid #333a4d;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: #2d3448;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.primary,
button.active-btn {
  background: #10b981;
  border-color: #10b981;
  color: #04130d;
  font-weight: 600;
}

button.primary:hover:not(:disabled),
button.active-btn:hover:not(:disabled) {
  background: #34d399;
}

button.secondary-accent {
  width: 100%;
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.45);
  color: #7dd3fc;
  font-weight: 600;
}

button.secondary-accent:hover:not(:disabled) {
  background: rgba(56, 189, 248, 0.24);
  color: #e0f2fe;
}

button.recording {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
  font-weight: 600;
}

select {
  background: #232838;
  color: #e5e7eb;
  border: 1px solid #333a4d;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 14px;
}

.hint {
  font-size: 12px;
  color: #9ca3af;
}

input[type="range"] {
  width: 100%;
  accent-color: #10b981;
}

.sub-slider {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  background: #10131b;
  border: 1px solid #262b38;
  border-radius: 8px;
}

.sub-slider[hidden] {
  display: none;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.info {
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.5;
  border-top: 1px solid #262b38;
  padding-top: 12px;
}

.info p {
  margin: 0 0 6px;
}

.canvas {
  flex: 1;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  border: 1px solid #262b38;
  touch-action: none;
}

.canvas.drawing {
  cursor: crosshair;
}

/* --- Style strony edukacyjnej (teoria.html) --- */
.tutorial-page {
  max-width: 1220px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: #151821;
  border: 1px solid #262b38;
  border-radius: 14px;
  padding: 20px;
}

.control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
  justify-content: space-between;
  position: sticky;
  top: 10px;
  z-index: 20;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
}

.control-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pill-link {
  text-decoration: none;
  background: #232838;
  color: #cbd5e1;
  border: 1px solid #333a4d;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
}

.pill-link:hover {
  background: #2d3448;
  color: #ffffff;
}

.step-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid #262b38;
  padding-bottom: 12px;
}

.step-header h2 {
  margin: 0;
  font-size: 19px;
  color: #f3f4f6;
}

.step-badge {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.4);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.step-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 20px;
  align-items: start;
}

.step-text {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 14px;
  line-height: 1.6;
  color: #d1d5db;
}

.step-text p {
  margin: 0;
}

.step-text .muted {
  color: #9ca3af;
  font-size: 13px;
}

.formula-box {
  background: #0f1117;
  border: 1px solid #2b3245;
  border-left: 3px solid #10b981;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  color: #f9fafb;
}

.bullet-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sub-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #10131b;
  border: 1px solid #262b38;
  border-radius: 10px;
  padding: 12px;
}

.readout-box {
  background: #0f1117;
  border: 1px solid #262b38;
  border-radius: 10px;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #e5e7eb;
}

.readout-box .highlight-green {
  color: #34d399;
  font-weight: 600;
}

.readout-box .highlight-pink {
  color: #f472b6;
  font-weight: 600;
}

.readout-box .highlight-amber {
  color: #fbbf24;
  font-weight: 600;
}

.readout-box .highlight-blue {
  color: #60a5fa;
  font-weight: 600;
}

.canvas-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.canvas-title {
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
}

.tut-canvas {
  width: 100%;
  height: 360px;
  border-radius: 12px;
  border: 1px solid #262b38;
  background: #0f1117;
  display: block;
}

#canvas-step3 {
  cursor: pointer;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: #9ca3af;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot.green { background: #34d399; }
.dot.blue { background: #60a5fa; }
.dot.pink { background: #f472b6; }
.dot.amber { background: #fbbf24; }
.dot.cyan { background: #38bdf8; }
.dot.gray { background: #94a3b8; }

.step2-toolbar {
  display: grid;
  grid-template-columns: 1.2fr 1.1fr 0.9fr;
  gap: 16px;
  background: #10131b;
  border: 1px solid #262b38;
  border-radius: 10px;
  padding: 14px;
  align-items: end;
}

.step2-toolbar button {
  padding: 6px 10px;
  font-size: 13px;
}

.dual-canvas-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.table-scroll {
  max-height: 230px;
  overflow-y: auto;
  border: 1px solid #262b38;
  border-radius: 10px;
}

.coeff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.coeff-table th,
.coeff-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #232838;
}

.coeff-table th {
  background: #10131b;
  color: #9ca3af;
  position: sticky;
  top: 0;
  font-family: system-ui, -apple-system, sans-serif;
}

.coeff-table tbody tr {
  cursor: pointer;
}

.coeff-table tbody tr:hover,
.coeff-table tbody tr.hovered-row {
  background: rgba(251, 191, 36, 0.16);
}

.coeff-table tbody tr.selected-row {
  background: rgba(16, 185, 129, 0.16);
}

.fft-compare-table tbody tr {
  cursor: default;
}

code {
  background: #232838;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

@media (max-width: 900px) {
  .step-grid,
  .dual-canvas-grid,
  .step2-toolbar {
    grid-template-columns: 1fr;
  }

  .control-bar {
    position: static;
  }
}

@media (max-width: 760px) {
  .layout {
    flex-direction: column;
  }

  .panel {
    width: 100%;
  }

  .canvas {
    min-height: 60vh;
  }

  .tut-canvas {
    height: 300px;
  }
}
