:root {
  --bg-primary: #1A1D23;
  --bg-secondary: #22262E;
  --bg-tertiary: #2A2F38;
  --text-primary: #E0E0E0;
  --text-secondary: #9CA3AF;
  --accent-petrol: #006B7D;
  --accent-teal: #097C94;
  --accent-ice: #DFEEF1;
  --accent-pink: #B00463;
  --sidebar-width: 280px;
  --header-height: 56px;
  --font-stack: system-ui, -apple-system, Arial, sans-serif;
}

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

body {
  font-family: var(--font-stack);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

/* Header */
.header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  font-size: 1.5rem;
  text-decoration: none;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-tertiary);
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-petrol);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: var(--accent-ice);
}

/* Buttons */
.btn {
  padding: 0.4rem 0.8rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: var(--font-stack);
  transition: background 0.15s;
}

.btn-primary {
  background: var(--accent-petrol);
  color: white;
}

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

.btn-danger {
  background: var(--accent-pink);
  color: white;
}

.btn-danger:hover { opacity: 0.85; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--bg-tertiary);
}

.btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-sm {
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
}

/* Layout */
.layout {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--bg-tertiary);
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  padding: 0.5rem 0;
  z-index: 50;
}

.sidebar-item {
  display: flex;
  align-items: center;
  padding: 0.6rem 1rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: background 0.1s;
  gap: 0.5rem;
}

.sidebar-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.sidebar-item.active { background: var(--accent-petrol); color: white; }

.sidebar-number {
  min-width: 24px;
  height: 24px;
  border-radius: 4px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar-item.active .sidebar-number { background: rgba(255,255,255,0.2); }

.sidebar-title { flex: 1; min-width: 0; }

.sidebar-title-input {
  background: var(--bg-primary);
  border: 1px solid var(--accent-teal);
  color: var(--text-primary);
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-size: 0.9rem;
  width: 100%;
  font-family: var(--font-stack);
}

/* Admin controls in sidebar */
.sidebar-admin-btns {
  display: none;
  flex-shrink: 0;
  gap: 2px;
}

.admin-mode .sidebar-admin-btns { display: flex; }

.sidebar-arrow {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 4px;
  border-radius: 3px;
}

.sidebar-arrow:hover { background: var(--bg-tertiary); color: var(--text-primary); }

/* Content */
.content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 2rem;
  max-width: calc(800px + 4rem);
}

.content-empty {
  color: var(--text-secondary);
  font-style: italic;
  padding: 2rem;
}

/* Exercise card */
.exercise {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--bg-tertiary);
}

.exercise:last-child { border-bottom: none; }

.exercise-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.exercise-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent-ice);
}

.exercise-title-input {
  background: var(--bg-secondary);
  border: 1px solid var(--accent-teal);
  color: var(--text-primary);
  padding: 0.3rem 0.5rem;
  border-radius: 3px;
  font-size: 1.15rem;
  font-weight: 600;
  width: 100%;
  font-family: var(--font-stack);
}

/* Markdown content */
.exercise-description {
  line-height: 1.7;
  margin-bottom: 1rem;
}

.exercise-description h1,
.exercise-description h2,
.exercise-description h3 {
  margin: 1rem 0 0.5rem;
  color: var(--accent-ice);
}

.exercise-description h1 { font-size: 1.4rem; }
.exercise-description h2 { font-size: 1.2rem; }
.exercise-description h3 { font-size: 1.05rem; }

.exercise-description p { margin-bottom: 0.75rem; }

.exercise-description ul,
.exercise-description ol {
  margin-bottom: 0.75rem;
  padding-left: 1.5rem;
}

.exercise-description li { margin-bottom: 0.25rem; }

.exercise-description code {
  background: var(--bg-tertiary);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.9em;
}

.exercise-description pre {
  background: var(--bg-tertiary);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: 0.75rem;
}

.exercise-description pre code {
  background: none;
  padding: 0;
}

.exercise-description strong { color: var(--accent-ice); }

.desc-textarea {
  width: 100%;
  min-height: 150px;
  background: var(--bg-secondary);
  border: 1px solid var(--accent-teal);
  color: var(--text-primary);
  padding: 0.75rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9rem;
  resize: vertical;
  line-height: 1.5;
}

.desc-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Prompts */
.prompt-section { margin-bottom: 1rem; }

.prompt-card {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: 6px;
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--bg-tertiary);
}

.prompt-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-teal);
}

.prompt-label-input {
  background: var(--bg-primary);
  border: 1px solid var(--accent-teal);
  color: var(--text-primary);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.85rem;
  font-family: var(--font-stack);
}

.prompt-actions {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.copy-btn {
  background: var(--accent-petrol);
  color: white;
  border: none;
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-stack);
  transition: background 0.15s;
}

.copy-btn:hover { background: var(--accent-teal); }
.copy-btn.copied { background: #2d8a4e; }

.prompt-content {
  padding: 0.75rem;
  font-family: monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  line-height: 1.5;
  color: var(--text-primary);
}

.prompt-content-input {
  width: 100%;
  min-height: 80px;
  background: var(--bg-primary);
  border: 1px solid var(--accent-teal);
  color: var(--text-primary);
  padding: 0.75rem;
  font-family: monospace;
  font-size: 0.9rem;
  resize: vertical;
  line-height: 1.5;
  border-radius: 0;
  border-top: none;
}

/* Files */
.file-section { margin-top: 1rem; }

.file-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.file-icon { font-size: 1.25rem; }

.file-name {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.file-size {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Admin-only elements */
.admin-only { display: none; }
.admin-mode .admin-only { display: flex; }
.admin-mode .admin-only-block { display: block; }
.admin-mode .admin-only-inline { display: inline; }

.admin-border {
  border: 1px dashed var(--bg-tertiary);
  border-radius: 4px;
  padding: 0.5rem;
}

.admin-mode .admin-border {
  border-color: var(--accent-teal);
}

/* Login page */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-owl {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.login-input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg-primary);
  border: 1px solid var(--bg-tertiary);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font-stack);
  margin-bottom: 1rem;
}

.login-input:focus {
  outline: none;
  border-color: var(--accent-teal);
}

.login-btn {
  width: 100%;
  padding: 0.6rem;
  background: var(--accent-petrol);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  font-family: var(--font-stack);
  transition: background 0.15s;
}

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

.login-error {
  color: var(--accent-pink);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  min-height: 1.2em;
}

.login-switch {
  margin-top: 1.25rem;
  font-size: 0.85rem;
}

.login-switch a {
  color: var(--accent-teal);
  cursor: pointer;
  text-decoration: none;
}

.login-switch a:hover { text-decoration: underline; }

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

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--bg-tertiary);
  border-radius: 8px;
  padding: 1.5rem;
  width: 90%;
  max-width: 400px;
}

.modal h3 {
  margin-bottom: 1rem;
  color: var(--accent-ice);
}

.modal input[type="text"],
.modal input[type="password"] {
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: var(--bg-primary);
  border: 1px solid var(--bg-tertiary);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font-stack);
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--accent-teal);
  color: var(--text-primary);
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  z-index: 300;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error { border-color: var(--accent-pink); }

/* Upload */
.upload-area {
  margin-top: 0.5rem;
}

.upload-input { display: none; }

/* Responsive */
@media (max-width: 768px) {
  .hamburger { display: block; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s;
    width: 100%;
    max-width: var(--sidebar-width);
  }

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

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    top: var(--header-height);
    background: rgba(0,0,0,0.5);
    z-index: 40;
    display: none;
  }

  .sidebar-backdrop.visible { display: block; }

  .content {
    margin-left: 0;
    padding: 1rem;
  }

  .toggle-label { display: none; }
}

/* Touch targets */
@media (pointer: coarse) {
  .sidebar-item { padding: 0.75rem 1rem; min-height: 44px; }
  .btn { min-height: 44px; min-width: 44px; }
  .sidebar-arrow { min-width: 36px; min-height: 36px; font-size: 1rem; }
}
