:root {
  --bg-app: #f1f5f9;
  --bg-panel: #ffffff;
  --bg-dark: #0f172a;
  --bg-code: #1e293b;
  --text-main: #0f172a;
  --text-sub: #475569;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --exam: #7c3aed;
  --exam-soft: #f5f3ff;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
  font-size: 13.5px;
  line-height: 1.5;
}

code, pre, textarea.cell-editor {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, Menlo, monospace;
}

/* Top Studio Header */
.studio-header {
  height: 48px;
  background: var(--bg-dark);
  color: #fff;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid #1e293b;
}

.studio-header.exam-active {
  background: linear-gradient(90deg, #1e1b4b, #311042);
}

.header-left, .header-center, .header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-badge {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.problem-selector {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  min-width: 230px;
  cursor: pointer;
}

.problem-selector:focus {
  outline: none;
  border-color: #60a5fa;
}

/* Mode Toggle */
.mode-pill-group {
  display: inline-flex;
  background: #1e293b;
  padding: 2px;
  border-radius: 7px;
  border: 1px solid #334155;
}

.mode-pill {
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  border-radius: 5px;
  cursor: pointer;
}

.mode-pill.active-study {
  background: var(--primary);
  color: #fff;
}

.mode-pill.active-exam {
  background: var(--exam);
  color: #fff;
}

/* Timer */
.timer-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #090d16;
  border: 1px solid #334155;
  padding: 3px 9px;
  border-radius: 7px;
}

.timer-digits {
  font-family: "JetBrains Mono", monospace;
  font-size: 15px;
  font-weight: 800;
  color: #38bdf8;
}

.timer-digits.urgent {
  color: #f87171;
}

.btn-timer-icon {
  background: transparent;
  color: #cbd5e1;
  border: none;
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.btn-timer-icon:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* Icon Buttons in Header */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.12s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.btn-icon.active {
  background: rgba(59, 130, 246, 0.25);
  border-color: #60a5fa;
  color: #93c5fd;
}

.header-divider {
  width: 1px;
  height: 20px;
  background: #334155;
  margin: 0 2px;
}

.hw-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.hw-badge.offline-static {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fcd34d;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-submit {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  padding: 6px 13px;
  font-size: 12.5px;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
}

.btn-submit:hover {
  filter: brightness(1.06);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.14);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.16);
}

.btn-outline {
  background: #fff;
  color: var(--text-main);
  border-color: var(--border);
}

.btn-outline:hover {
  background: #f8fafc;
}

.btn-sm {
  padding: 3px 8px;
  font-size: 11.5px;
}

/* Split Studio Layout & Collapsible Left Pane */
.studio-body {
  position: relative;
  height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: 390px 1fr;
  overflow: hidden;
  transition: grid-template-columns 0.18s ease;
}

.studio-body.left-collapsed {
  grid-template-columns: 0px 1fr;
}

.studio-body.left-collapsed .left-pane {
  border-right: none;
  opacity: 0;
  pointer-events: none;
}

.sidebar-expand-float {
  position: fixed;
  top: 58px;
  left: 0;
  z-index: 40;
  background: var(--bg-dark);
  color: #f8fafc;
  border: 1px solid #334155;
  border-left: none;
  padding: 6px 10px;
  border-radius: 0 7px 7px 0;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 2px 2px 8px rgba(15, 23, 42, 0.22);
}

.sidebar-expand-float:hover {
  background: var(--primary);
}

@media (max-width: 1024px) {
  .studio-body {
    grid-template-columns: 340px 1fr;
  }
  .studio-body.left-collapsed {
    grid-template-columns: 0px 1fr;
  }
}

/* Left Guide Panel */
.left-pane {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  min-width: 0;
}

.pane-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  padding: 0 4px;
}

.pane-tab {
  flex: 1;
  padding: 9px 4px;
  border: none;
  background: transparent;
  border-bottom: 2.5px solid transparent;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
}

.pane-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #fff;
}

.pane-collapse-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
}

.pane-collapse-btn:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.pane-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* Right Notebook Pane */
.right-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: #f1f5f9;
}

.notebook-toolbar {
  height: 46px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kernel-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
}

.kernel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

.kernel-dot.busy {
  background: #f59e0b;
  animation: pulse 0.8s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.jupyter-iframe-wrap {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  overflow: hidden;
}

.jupyter-iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

.notebook-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 60px;
}

/* Notebook Cell Card */
.nb-cell {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.nb-cell:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.nb-cell-header {
  background: #f8fafc;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nb-prompt {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

.nb-cell-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  margin-left: 8px;
}

textarea.cell-editor {
  width: 100%;
  min-height: 115px;
  border: none;
  background: #0f172a;
  color: #f8fafc;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
  display: block;
}

textarea.cell-editor:focus {
  outline: none;
}

.nb-output-area {
  border-top: 1px solid var(--border);
  background: #fcfcfd;
  padding: 10px 14px;
  font-size: 12.5px;
}

.nb-stdout {
  font-family: "JetBrains Mono", monospace;
  white-space: pre-wrap;
  color: #1e293b;
  margin-bottom: 6px;
}

.nb-stderr {
  font-family: "JetBrains Mono", monospace;
  white-space: pre-wrap;
  color: #b91c1c;
  background: #fef2f2;
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 3px solid #dc2626;
}

/* Rendered DataFrame Table inside Notebook */
.nb-table-wrap, .table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  margin-top: 4px;
}

table.nb-table, table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

table.nb-table th, table.nb-table td,
table.data-table th, table.data-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

table.nb-table th, table.data-table th {
  background: #f1f5f9;
  font-weight: 700;
  color: var(--text-sub);
  white-space: nowrap;
}

.nb-nan {
  background: #fee2e2;
  color: #991b1b;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.nb-shape {
  font-size: 11px;
  color: var(--text-muted);
  padding: 5px 10px;
  background: #f8fafc;
}

/* Section Boxes in Left Pane */
.info-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.info-box-title {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.alert {
  padding: 10px 12px;
  border-radius: 7px;
  margin-bottom: 10px;
  font-size: 12.5px;
  border-left: 3.5px solid;
}

.alert-info { background: var(--primary-soft); border-left-color: var(--primary); color: #1e3a8a; }
.alert-warn { background: var(--warning-soft); border-left-color: var(--warning); color: #78350f; }
.alert-danger { background: var(--danger-soft); border-left-color: var(--danger); color: #7f1d1d; }
.alert-success { background: var(--success-soft); border-left-color: var(--success); color: #064e3b; }
.alert-exam { background: var(--exam-soft); border-left-color: var(--exam); color: #4c1d95; }

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge-pass { background: #dcfce7; color: #166534; }
.badge-fail { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-warn { background: #fef3c7; color: #92400e; }

/* Checklist */
.step-check-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  margin-bottom: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 12.5px;
}

.step-check-item.done {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
  text-decoration: line-through;
}

/* Doc Card */
.doc-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fff;
}

.doc-signature {
  background: #0f172a;
  color: #38bdf8;
  padding: 7px 10px;
  border-radius: 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  margin: 6px 0;
  overflow-x: auto;
}

.doc-example {
  background: #1e293b;
  color: #e2e8f0;
  padding: 8px 10px;
  border-radius: 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  white-space: pre-wrap;
  margin-top: 6px;
}

/* Modal Overlay */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}

.modal-card {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 820px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

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

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.img-thumb-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.img-thumb-box {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  text-align: center;
  background: #fff;
  width: 92px;
}

.img-thumb-box img {
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
  border: 1px solid #cbd5e1;
}

.hidden {
  display: none !important;
}
