:root {
  --primary-bg: #ffffff;
  --secondary-bg: #f7f9fc;
  --border-color: #e0e0e0;
  --text-color: #333333;
  --accent-color: #007bff;
  --accent-hover-color: #0056b3;
  --danger-color: #dc3545;
  --danger-hover-color: #c82333;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --border-radius: 8px;
  --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --spacing-unit: 1rem;
  /* 16px */
}

body {
  font-family: var(--font-family);
  margin: 0;
  background-color: var(--secondary-bg);
  color: var(--text-color);
  line-height: 1.6;
  padding: var(--spacing-unit);
  padding-bottom: 80%;
}

.notebook-container {
  max-width: 900px;
  margin: 0 auto;
  padding: calc(var(--spacing-unit) * 1.5);
  background-color: var(--primary-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
}

.notebook-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: calc(var(--spacing-unit) * 1.5);
  padding-bottom: var(--spacing-unit);
  border-bottom: 1px solid var(--border-color);
}

.notebook-title {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--accent-color);
}

.add-cell-btn {
  background-color: var(--accent-color);
  color: white;
  border: none;
  padding: calc(var(--spacing-unit) * 0.6) calc(var(--spacing-unit) * 1.2);
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  gap: calc(var(--spacing-unit) * 0.5);
}

.add-cell-btn:hover {
  background-color: var(--accent-hover-color);
}

.add-cell-btn svg {
  width: 18px;
  height: 18px;
}

.cells-area {
  display: flex;
  flex-direction: column;
  gap: calc(var(--spacing-unit) * 1.5);
}

.cell {
  background-color: var(--primary-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease;
}

.cell:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.cell-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: calc(var(--spacing-unit) * 0.5) calc(var(--spacing-unit) * 0.75);
  background-color: #f8f9fa;
  /* Light grey for toolbar */
  border-bottom: 1px solid var(--border-color);
  border-top-left-radius: var(--border-radius);
  border-top-right-radius: var(--border-radius);
}

.cell-toolbar button {
  background: none;
  border: none;
  cursor: pointer;
  padding: calc(var(--spacing-unit) * 0.25) calc(var(--spacing-unit) * 0.5);
  margin-left: calc(var(--spacing-unit) * 0.5);
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.cell-toolbar button svg {
  width: 18px;
  height: 18px;
  vertical-align: middle;
}


.eval-btn {
  color: var(--accent-color);
}

.eval-btn:hover {
  background-color: rgba(0, 123, 255, 0.1);
}

.delete-btn {
  color: var(--danger-color);
}

.delete-btn:hover {
  background-color: rgba(220, 53, 69, 0.1);
}


.cell-content {
  display: flex;
  flex-direction: column;
  /* Stack input and output vertically */
}

.cell-input-area,
.cell-output-area {
  padding: var(--spacing-unit);
}

.cell-input-area textarea {
  width: 100%;
  min-height: 80px;
  border: none;
  outline: none;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  padding: 0;
  /* Padding is on the parent */
  background-color: transparent;
}

.cm-editor {
    height: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 1rem;
    width: 100%;
}
.cm-editor.cm-focused {
    outline: none;
}

.cell-output-area {
  background-color: var(--secondary-bg);
  border-top: 1px dashed var(--border-color);
  min-height: 30px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  /* Preserve whitespace and wrap lines */
  word-break: break-all;
  border-bottom-left-radius: var(--border-radius);
  border-bottom-right-radius: var(--border-radius);
}

.cell-output-area:empty {
  display: none;
  /* Hide output area if empty */
}

@media (max-width: 768px) {
  body {
    padding: calc(var(--spacing-unit) * 0.5);
  }

  .notebook-container {
    padding: var(--spacing-unit);
    border-radius: 0;
    box-shadow: none;
  }

  .notebook-title {
    font-size: 1.5rem;
  }

  .add-cell-btn {
    font-size: 0.85rem;
    padding: calc(var(--spacing-unit) * 0.5) var(--spacing-unit);
  }
}
