:root{
  --bg: #0D1117;
  --panel: #161B22;
  --panel-2: #1C2330;
  --border: #2A3140;
  --text: #E6EDF3;
  --text-dim: #8B96A5;
  --text-faint: #5B6573;

  --html: #58A6FF;
  --html-dim: rgba(88,166,255,.14);
  --css: #F0883E;
  --css-dim: rgba(240,136,62,.14);
  --js: #F2CC60;
  --js-dim: rgba(242,204,96,.14);
  --js-final: #B57BEE;
  --js-final-dim: rgba(181,123,238,.14);

  --accent: var(--html);
  --accent-dim: var(--html-dim);

  --good: #56D364;
  --bad: #F85149;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 10px;
}

*{box-sizing:border-box; margin:0; padding:0;}

body{
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

::selection{ background: var(--accent-dim); color: var(--text); }

::-webkit-scrollbar{ width:10px; height:10px; }
::-webkit-scrollbar-track{ background: transparent; }
::-webkit-scrollbar-thumb{ background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover{ background: var(--text-faint); }

button{ font-family: var(--font-body); cursor:pointer; border:none; background:none; color:inherit; }

/* ============ LAYOUT ============ */
.app{
  display:grid;
  grid-template-columns: 280px 1fr;
  height:100vh;
  width:100vw;
  overflow:hidden;
}

/* ============ SIDEBAR ============ */
.sidebar{
  background: var(--panel);
  border-right: 1px solid var(--border);
  display:flex;
  flex-direction:column;
  height:100vh;
  position:relative;
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--border);
}
.brand-mark{
  font-family: var(--font-mono);
  font-weight:600;
  font-size: 18px;
  color: var(--bg);
  background: linear-gradient(135deg, var(--html), var(--js-final));
  width:38px; height:38px;
  display:flex; align-items:center; justify-content:center;
  border-radius:8px;
  flex-shrink:0;
}
.brand-text{ display:flex; flex-direction:column; line-height:1.3; }
.brand-name{ font-family:var(--font-display); font-weight:700; font-size:15px; letter-spacing:-0.01em; }
.brand-sub{ font-size:11px; color:var(--text-dim); letter-spacing:.04em; text-transform:uppercase; }

/* Derleme hattı (rail) — modüller arası renkli ilerleme çizgisi */
.rail{
  display:flex;
  flex-direction:column;
  padding: 16px 0 0 0;
}

.module-nav{
  flex:1;
  overflow-y:auto;
  padding: 4px 14px 14px;
  display:flex;
  flex-direction:column;
  gap: 4px;
}

.module-group{ margin-bottom: 6px; }

.module-header{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 11px 10px;
  border-radius: 8px;
  cursor:pointer;
  user-select:none;
  transition: background .15s;
}
.module-header:hover{ background: var(--panel-2); }

.module-dot{
  width:9px; height:9px;
  border-radius:50%;
  flex-shrink:0;
  background: var(--border);
  position:relative;
}
.module-dot.active{ background: var(--m-color); box-shadow: 0 0 0 4px var(--m-color-dim); }
.module-dot.complete{ background: var(--m-color); }
.module-dot.complete::after{
  content:'✓';
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  font-size:7px; color:var(--bg); font-weight:700;
}

.module-title{
  font-family: var(--font-display);
  font-weight:600;
  font-size: 13.5px;
  flex:1;
  color: var(--text);
}
.module-meta{
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
}
.module-chevron{
  font-size:10px;
  color: var(--text-faint);
  transition: transform .2s;
}
.module-group.open .module-chevron{ transform: rotate(90deg); }

.lesson-list{
  max-height:0;
  overflow:hidden;
  transition: max-height .25s ease;
  padding-left: 27px;
  display:flex;
  flex-direction:column;
  border-left: 1px solid var(--border);
  margin-left: 14px;
}
.module-group.open .lesson-list{ max-height: 600px; }

.lesson-item{
  display:flex;
  align-items:center;
  gap:9px;
  padding: 8px 10px;
  border-radius:7px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor:pointer;
  transition: background .15s, color .15s;
  position:relative;
}
.lesson-item:hover{ background: var(--panel-2); color: var(--text); }
.lesson-item.active{ background: var(--m-color-dim); color: var(--text); font-weight:600; }
.lesson-item.active::before{
  content:'';
  position:absolute; left:-15px; top:0; bottom:0;
  width:2px;
  background: var(--m-color);
}
.lesson-check{
  width:14px; height:14px;
  border-radius:50%;
  border: 1.5px solid var(--border);
  flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  font-size:8px;
}
.lesson-item.done .lesson-check{ background: var(--good); border-color: var(--good); color: var(--bg); }
.lesson-item.done .lesson-check::after{ content:'✓'; }

.sidebar-foot{
  border-top: 1px solid var(--border);
  padding: 16px 22px 18px;
}
.overall-progress-label{
  display:flex; justify-content:space-between;
  font-size:11px; color:var(--text-dim);
  margin-bottom:8px;
  font-family: var(--font-mono);
}
.overall-bar{
  height:6px;
  background: var(--panel-2);
  border-radius:4px;
  overflow:hidden;
  display:flex;
}
.overall-bar-fill{
  height:100%;
  width:0%;
  background: linear-gradient(90deg, var(--html), var(--css) 50%, var(--js) 80%, var(--js-final));
  transition: width .4s ease;
}
.reset-btn{
  margin-top:14px;
  font-size:11px;
  color: var(--text-faint);
  text-decoration: underline;
  text-underline-offset:2px;
}
.reset-btn:hover{ color: var(--bad); }

/* ============ MAIN ============ */
.main{
  display:flex;
  flex-direction:column;
  height:100vh;
  overflow:hidden;
}

.topbar{
  height:56px;
  flex-shrink:0;
  border-bottom: 1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 0 28px;
}
.topbar-left{
  font-family: var(--font-mono);
  font-size:13px;
  color: var(--text-dim);
  display:flex; align-items:center; gap:8px;
}
.crumb-module{ color: var(--accent); font-weight:600; }
.crumb-sep{ color: var(--text-faint); }

.icon-btn{
  font-size:12.5px;
  color: var(--text-dim);
  border:1px solid var(--border);
  padding:7px 13px;
  border-radius:7px;
  transition: all .15s;
}
.icon-btn:hover{ border-color: var(--accent); color: var(--text); }

.content-scroll{
  flex:1;
  overflow-y:auto;
  padding: 36px 48px 80px;
  max-width: 980px;
  width:100%;
  margin: 0 auto;
}

/* ============ LESSON HEAD ============ */
.lesson-tag{
  font-family: var(--font-mono);
  font-size:12px;
  color: var(--accent);
  font-weight:600;
  letter-spacing:.03em;
}
.lesson-head h1{
  font-family: var(--font-display);
  font-size: 34px;
  font-weight:700;
  letter-spacing:-0.02em;
  margin: 8px 0 12px;
}
.lesson-head p{
  font-size:15px;
  color: var(--text-dim);
  max-width:640px;
  line-height:1.6;
}

/* ============ PANELS ============ */
.panel{
  background: var(--panel);
  border:1px solid var(--border);
  border-radius: var(--radius);
  margin-top:24px;
  overflow:hidden;
}
.theory-panel{ padding: 26px 28px; }
.theory-panel h3{
  font-family: var(--font-display);
  font-size:16px;
  margin: 18px 0 8px;
  color: var(--text);
}
.theory-panel h3:first-child{ margin-top:0; }
.theory-panel p{
  font-size:14.5px;
  line-height:1.75;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.theory-panel code{
  font-family: var(--font-mono);
  background: var(--panel-2);
  border:1px solid var(--border);
  padding: 2px 6px;
  border-radius:5px;
  font-size:13px;
  color: var(--accent);
}
.theory-panel ul{ margin: 10px 0 14px 20px; }
.theory-panel li{ font-size:14.5px; color:var(--text-dim); line-height:1.8; }
.theory-panel li b, .theory-panel strong{ color: var(--text); }
.theory-code-block{
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 14px 0;
  overflow-x:auto;
  line-height:1.7;
  white-space:pre;
  color: var(--text-dim);
}
.theory-code-block .tk-tag{ color: var(--html); }
.theory-code-block .tk-attr{ color: var(--js); }
.theory-code-block .tk-str{ color: var(--good); }
.theory-code-block .tk-prop{ color: var(--css); }
.theory-code-block .tk-cmt{ color: var(--text-faint); font-style:italic; }
.theory-code-block .tk-kw{ color: var(--js-final); }

.panel-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.panel-header-title{ font-family: var(--font-display); font-weight:600; font-size:14px; }
.panel-header-actions{ display:flex; gap:8px; }

.ghost-btn{
  font-size:12px;
  padding:6px 12px;
  border-radius:6px;
  border:1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--font-mono);
  transition: all .15s;
}
.ghost-btn:hover{ border-color: var(--accent); color: var(--text); }

/* ============ EDITOR ============ */
.editor-split{
  display:grid;
  grid-template-columns: 1fr 1fr;
  height: 320px;
}
.editor-pane, .preview-pane{
  display:flex;
  flex-direction:column;
  position:relative;
}
.editor-pane{ border-right:1px solid var(--border); }
.editor-pane-label{
  font-family:var(--font-mono);
  font-size:10.5px;
  color: var(--text-faint);
  text-transform:uppercase;
  letter-spacing:.05em;
  padding: 8px 14px;
  border-bottom:1px solid var(--border);
  flex-shrink:0;
}
#codeInput{
  flex:1;
  width:100%;
  background: var(--bg);
  color: var(--text);
  border:none;
  outline:none;
  resize:none;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height:1.6;
  padding: 16px;
  tab-size: 2;
}
#previewFrame{
  flex:1;
  width:100%;
  border:none;
  background: #fff;
}
.editor-hint{
  font-size:12.5px;
  color: var(--text-faint);
  padding: 12px 20px;
  border-top:1px solid var(--border);
  background: var(--panel-2);
}

/* ============ CHALLENGE ============ */
.challenge-panel{ padding: 22px 28px 26px; }
.challenge-panel .panel-header{ margin: -22px -28px 16px; padding: 14px 28px; }
#challengeText{ font-size:14.5px; color: var(--text-dim); line-height:1.7; margin-bottom:16px; }
#challengeText code{ font-family: var(--font-mono); background: var(--panel-2); border:1px solid var(--border); padding:2px 6px; border-radius:5px; color: var(--accent); font-size:13px; }
.challenge-check-row{ display:flex; align-items:center; gap:14px; }
.primary-btn{
  font-family: var(--font-display);
  font-weight:600;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--bg);
  transition: filter .15s, transform .1s;
}
.primary-btn:hover{ filter:brightness(1.1); }
.primary-btn:active{ transform: scale(.97); }
.challenge-feedback{ font-size:13px; font-weight:600; font-family:var(--font-mono); }
.challenge-feedback.good{ color: var(--good); }
.challenge-feedback.bad{ color: var(--bad); }

/* ============ QUIZ ============ */
.quiz-panel{ padding: 22px 28px 26px; }
.quiz-panel .panel-header{ margin: -22px -28px 18px; padding: 14px 28px; }
.quiz-counter{ font-family:var(--font-mono); font-size:11.5px; color: var(--text-faint); }
.quiz-q{ margin-bottom: 22px; }
.quiz-q:last-child{ margin-bottom:0; }
.quiz-q-text{ font-size:14.5px; font-weight:600; margin-bottom:12px; color:var(--text); }
.quiz-opts{ display:flex; flex-direction:column; gap:8px; }
.quiz-opt{
  display:flex;
  align-items:center;
  gap:11px;
  padding: 11px 14px;
  border:1px solid var(--border);
  border-radius:8px;
  font-size:13.5px;
  color: var(--text-dim);
  transition: all .15s;
  text-align:left;
}
.quiz-opt:hover{ border-color: var(--accent); color:var(--text); }
.quiz-opt .opt-letter{
  font-family:var(--font-mono);
  font-size:11px;
  width:20px; height:20px;
  border-radius:5px;
  border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}
.quiz-opt.correct{ border-color: var(--good); background: rgba(86,211,100,.08); color:var(--text); }
.quiz-opt.correct .opt-letter{ background:var(--good); border-color:var(--good); color:var(--bg); }
.quiz-opt.incorrect{ border-color: var(--bad); background: rgba(248,81,73,.08); color:var(--text); }
.quiz-opt.incorrect .opt-letter{ background:var(--bad); border-color:var(--bad); color:var(--bg); }
.quiz-opt:disabled{ cursor:default; }
.quiz-opt:not(:disabled):active{ transform: scale(.99); }

/* ============ LESSON FOOTER NAV ============ */
.lesson-footer-nav{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-top: 36px;
  gap:12px;
}
.nav-btn{
  font-family: var(--font-display);
  font-weight:600;
  font-size:13.5px;
  padding: 12px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: all .15s;
  white-space:nowrap;
}
.nav-btn:hover:not(:disabled){ border-color:var(--accent); color:var(--text); }
.nav-btn:disabled{ opacity:.35; cursor:default; }
.nav-btn.primary{ background: var(--accent); color: var(--bg); border-color: var(--accent); }
.nav-btn.primary:hover{ filter:brightness(1.1); }
.nav-btn.complete-btn{ flex:1; text-align:center; background: var(--panel-2); }
.nav-btn.complete-btn.done{ background: var(--good); color:var(--bg); border-color:var(--good); }

/* ============ PRESENTATION MODE ============ */
.app.present .sidebar{ display:none; }
.app.present .topbar{ padding: 0 48px; }
.app.present .content-scroll{ max-width: 1200px; padding: 48px 64px 100px; }
.app.present .lesson-head h1{ font-size: 44px; }
.app.present .lesson-head p{ font-size: 17px; max-width: 800px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 980px){
  .app{ grid-template-columns: 1fr; }
  .sidebar{ display:none; }
  .editor-split{ grid-template-columns: 1fr; height: auto; }
  .editor-pane{ border-right:none; border-bottom:1px solid var(--border); height:260px; }
  .preview-pane{ height:260px; }
  .content-scroll{ padding: 24px 18px 60px; }
  .lesson-head h1{ font-size:26px; }
}

/* Focus visibility */
a:focus-visible, button:focus-visible, [tabindex]:focus-visible{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce){
  *{ transition:none !important; animation:none !important; }
}
