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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1e1e2e;
  color: #cdd6f4;
}

#toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #181825;
  border-bottom: 1px solid #313244;
}

#toolbar button {
  padding: 6px 16px;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

#btn-run {
  background: #a6e3a1;
  color: #1e1e2e;
}

#btn-run:hover {
  background: #94e2d5;
}

#btn-run:disabled {
  background: #585b70;
  color: #6c7086;
  cursor: not-allowed;
}

#btn-stop {
  background: #f38ba8;
  color: #1e1e2e;
}

#btn-stop:hover {
  background: #eba0ac;
}

#btn-stop:disabled {
  background: #585b70;
  color: #6c7086;
  cursor: not-allowed;
}

#btn-clear {
  background: #89b4fa;
  color: #1e1e2e;
}

#btn-clear:hover {
  background: #b4befe;
}

#status {
  margin-left: 12px;
  font-size: 13px;
  color: #a6adc8;
}

#status.error {
  color: #f38ba8;
  font-weight: 600;
}

#link-docs {
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #cdd6f4;
  text-decoration: none;
  background: #313244;
  border: 1px solid #45475a;
  transition: background 0.15s;
}

#btn-about {
  margin-left: auto;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #cdd6f4;
  background: #313244;
  border: 1px solid #45475a;
  cursor: pointer;
  transition: background 0.15s;
}

#btn-about:hover {
  background: #45475a;
}

#link-docs:hover {
  background: #45475a;
}

/* About modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: #1e1e2e;
  border: 1px solid #45475a;
  border-radius: 8px;
  width: 420px;
  max-width: 90vw;
}

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

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #cdd6f4;
}

.modal-close {
  background: none;
  border: none;
  color: #6c7086;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.modal-close:hover {
  color: #cdd6f4;
}

.modal-body {
  padding: 16px;
  font-size: 13px;
  line-height: 1.6;
  color: #bac2de;
}

.modal-body p + p {
  margin-top: 10px;
}

#panels {
  display: flex;
  height: calc(100vh - 45px);
}

/* Sessions pane */
#sessions-pane {
  width: 220px;
  min-width: 0;
  background: #181825;
  border-right: 1px solid #313244;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease;
}

#sessions-pane.collapsed {
  width: 0;
  border-right: none;
}

#sessions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #313244;
  white-space: nowrap;
}

#sessions-header span {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #a6adc8;
}

#btn-new-session {
  padding: 3px 10px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: #a6e3a1;
  color: #1e1e2e;
  transition: background 0.15s;
}

#btn-new-session:hover {
  background: #94e2d5;
}

#sessions-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

#sessions-list li {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.1s;
  white-space: nowrap;
  position: relative;
}

#sessions-list li:hover {
  background: #1e1e2e;
}

#sessions-list li.active {
  border-left-color: #89b4fa;
  background: #1e1e2e;
}

#sessions-list li .session-name {
  flex: 1;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sessions-list li .btn-delete-session {
  display: none;
  border: none;
  background: none;
  color: #f38ba8;
  font-size: 15px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

#sessions-list li:hover .btn-delete-session {
  display: block;
}

#sessions-list li .session-rename-input {
  flex: 1;
  background: #313244;
  border: 1px solid #89b4fa;
  border-radius: 3px;
  color: #cdd6f4;
  font-size: 13px;
  padding: 1px 4px;
  outline: none;
  font-family: inherit;
}

/* Toggle strip */
#btn-toggle-sessions {
  width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #181825;
  border-right: 1px solid #313244;
  cursor: pointer;
  color: #6c7086;
  font-size: 14px;
  user-select: none;
  transition: color 0.15s;
  flex-shrink: 0;
}

#btn-toggle-sessions:hover {
  color: #cdd6f4;
}

#canvas-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #11111b;
  border-right: 1px solid #313244;
  overflow: hidden;
  padding: 12px;
  gap: 8px;
}

#turtle-canvas {
  width: 100%;
  flex: 1;
  min-height: 0;
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
}

#stdout {
  width: 100%;
  height: 120px;
  min-height: 80px;
  background: #181825;
  color: #cdd6f4;
  border: 1px solid #313244;
  border-radius: 4px;
  padding: 8px 10px;
  margin: 0;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  line-height: 1.4;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

#stdout input[type="text"] {
  background: transparent;
  border: none;
  border-bottom: 1px solid #585b70;
  color: #cdd6f4;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  outline: none;
  width: 60%;
  max-width: calc(100% - 1ch);
  padding: 0;
  margin: 0;
}

#editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#editor-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #181825;
  border-bottom: 1px solid #313244;
}

#editor-toolbar button {
  padding: 4px 12px;
  border: 1px solid #45475a;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #313244;
  color: #cdd6f4;
  transition: background 0.15s;
}

#editor-toolbar button:hover {
  background: #45475a;
}

/* Error line highlight */
.line-error {
  background: rgba(243, 139, 168, 0.15) !important;
}

.line-error-gutter {
  color: #f38ba8 !important;
  background: rgba(243, 139, 168, 0.15) !important;
}

/* CodeMirror fills the editor panel */
.CodeMirror {
  flex: 1;
  height: 100% !important;
  font-size: 14px;
  line-height: 1.5;
  font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}

/* Dark theme overrides for CodeMirror */
.CodeMirror {
  background: #1e1e2e;
  color: #cdd6f4;
}

.CodeMirror-gutters {
  background: #181825;
  border-right: 1px solid #313244;
}

.CodeMirror-linenumber {
  color: #6c7086;
}

.CodeMirror-cursor {
  border-left-color: #f5e0dc;
}

.CodeMirror-selected {
  background: #45475a !important;
}

.CodeMirror-focused .CodeMirror-selected {
  background: #45475a !important;
}

.cm-s-default .cm-keyword { color: #cba6f7; }
.cm-s-default .cm-def { color: #89b4fa; }
.cm-s-default .cm-variable { color: #cdd6f4; }
.cm-s-default .cm-variable-2 { color: #f38ba8; }
.cm-s-default .cm-string { color: #a6e3a1; }
.cm-s-default .cm-number { color: #fab387; }
.cm-s-default .cm-comment { color: #6c7086; }
.cm-s-default .cm-builtin { color: #f9e2af; }
.cm-s-default .cm-operator { color: #89dceb; }
.cm-s-default .cm-meta { color: #f5c2e7; }
.cm-s-default .cm-property { color: #89b4fa; }
