@font-face {
  font-family: 'JetBrains Sans';
  src: url('fonts/JetBrainsSans-Regular.woff2');
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('fonts/JetBrainsMono-Regular.woff2');
}

:root {
  --bg: #1e1e2e;
  --bg-surface: #282840;
  --bg-sidebar: #1a1a2e;
  --text: #cdd6f4;
  --text-muted: #a6adc8;
  --accent: #89b4fa;
  --accent-hover: #b4d0fb;
  --border: #45475a;
  --error: #f38ba8;
  --warn: #fab387;
  --info: #89dceb;
  --success: #a6e3a1;
  --sidebar-width: 260px;
}

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

html,
body {
  height: 100%;
}

body {
  font-family: 'JetBrains Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

#app {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* App Shell */
.app-shell {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.sidebar-title {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
}

.sidebar-list {
  padding: 8px 0;
  flex: 1;
}

.sidebar-chapter {
  margin-bottom: 4px;
}

.sidebar-chapter-title {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-page {
  display: block;
  padding: 6px 16px 6px 28px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background 0.15s;
}

.sidebar-page:hover {
  background: var(--bg-surface);
}

.sidebar-page.active {
  background: var(--bg-surface);
  border-left-color: var(--accent);
  color: var(--accent);
}

/* Main Content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  min-width: 0;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Content View */
.content-view {
  margin-bottom: 24px;
  line-height: 1.7;
}

.content-view p {
  margin-bottom: 12px;
}

.content-view code {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-surface);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* Landing */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  text-align: center;
}

.landing h1 {
  font-size: 36px;
  margin-bottom: 16px;
}

.landing p {
  color: var(--text-muted);
  font-size: 18px;
}

/* Playground */
.playground {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.playground-toolbar {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

/* Buttons */
.btn {
  font-family: 'JetBrains Sans', system-ui, sans-serif;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}

.btn:hover {
  background: var(--bg-surface);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-run {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}

.btn-run:hover {
  background: var(--accent-hover);
}

.btn-small {
  padding: 2px 10px;
  font-size: 12px;
}

/* Split Pane */
.split-pane {
  display: grid;
  grid-template-columns: var(--left-width) 6px 1fr;
  height: 350px;
}

.split-left,
.split-right {
  overflow: hidden;
  min-width: 0;
}

.split-left {
  display: flex;
}

.split-divider {
  background: var(--border);
  cursor: col-resize;
  transition: background 0.15s;
}

.split-divider:hover {
  background: var(--accent);
}

/* Code Editor */
.code-editor {
  width: 100%;
  height: 100%;
}

.code-editor .cm-editor {
  height: 100%;
}

/* Output Panel */
.output-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #1a1a2e;
}

.output-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.output-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
}

.output-line {
  white-space: pre-wrap;
  word-break: break-all;
}

.output-log {
  color: var(--text);
}

.output-warn {
  color: var(--warn);
}

.output-error {
  color: var(--error);
}

.output-info {
  color: var(--info);
}

/* Page Navigation */
.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Completed checkmark */
.completed {
  color: var(--success);
  font-weight: 600;
  font-size: 13px;
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: block;
  }

  .main-content {
    padding: 16px;
  }

  .split-pane {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 6px 1fr;
    height: 500px;
  }

  .split-divider {
    cursor: row-resize;
  }
}
