/* ===== Luxury Burgundy Themes ===== */
:root,
[data-theme="burgundy-dark"] {
  --bg: #0b0507;
  --panel: rgba(24, 10, 15, 0.88);
  --panel-solid: #16090e;
  --panel-2: #241018;
  --editor-bg: #11070b;
  --io-bg: #0d0508;
  --border: #3d1c27;
  --border-strong: #5c2838;
  --text: #faf3f4;
  --muted: #bfa0aa;
  --accent: #8f1636;
  --accent-bright: #b8254c;
  --accent-hover: #a81c41;
  --accent-soft: rgba(143, 22, 54, 0.24);
  --accent-glow: rgba(184, 37, 76, 0.34);
  --champagne: #e8cfd5;
  --run: #22c55e;
  --run-hover: #16a34a;
  --run-text: #052e16;
  --danger: #fda4af;
  --danger-bg: rgba(225, 29, 72, 0.18);
  --warn: #f59e0b;
  --shadow: rgba(0, 0, 0, 0.65);
  --code-bg: rgba(255, 240, 244, 0.08);
  --backdrop-code: rgba(240, 195, 207, 0.22);
  --backdrop-kw: rgba(244, 114, 148, 0.42);
  --backdrop-str: rgba(245, 208, 175, 0.36);
  --radius: 11px;
  --mono: "Cascadia Code", "Fira Code", Consolas, "Courier New", monospace;
}

[data-theme="burgundy-light"] {
  --bg: #f8f2f4;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-solid: #ffffff;
  --panel-2: #f2e6ea;
  --editor-bg: #fffcfd;
  --io-bg: #fcf8f9;
  --border: #e3cdd4;
  --border-strong: #cca9b4;
  --text: #240b12;
  --muted: #785560;
  --accent: #7a122c;
  --accent-bright: #981b3b;
  --accent-hover: #630c22;
  --accent-soft: rgba(122, 18, 44, 0.11);
  --accent-glow: rgba(122, 18, 44, 0.22);
  --champagne: #591023;
  --run: #15803d;
  --run-hover: #166534;
  --run-text: #ffffff;
  --danger: #be123c;
  --danger-bg: rgba(190, 18, 60, 0.11);
  --warn: #b45309;
  --shadow: rgba(54, 12, 25, 0.12);
  --code-bg: rgba(122, 18, 44, 0.07);
  --backdrop-code: rgba(84, 18, 36, 0.24);
  --backdrop-kw: rgba(138, 18, 52, 0.45);
  --backdrop-str: rgba(145, 78, 35, 0.36);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  transition: background-color 0.28s ease, color 0.28s ease;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

code {
  font-family: var(--mono);
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.9em;
}

/* Brand & Logo */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
  border-radius: 8px;
  filter: drop-shadow(0 3px 10px var(--accent-glow));
  transition: transform 0.2s ease;
}

.brand:hover .brand-logo {
  transform: scale(1.06) rotate(-3deg);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-name {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Sliding Theme Switcher */
.theme-switcher {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
  min-width: 128px;
}

.theme-pill-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  border-radius: 6px;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 2px 10px var(--accent-glow);
}

[data-theme="burgundy-light"] .theme-pill-slider {
  transform: translateX(100%);
}

.theme-btn {
  position: relative;
  z-index: 1;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.2s ease;
}

.theme-btn.active {
  color: #ffffff;
}

/* Login Screen + Animated C++ Backdrop */
.center-screen {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, var(--accent-soft), transparent 48%),
    radial-gradient(circle at 84% 82%, var(--accent-soft), transparent 45%),
    var(--bg);
}

.code-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.code-backdrop-window {
  width: min(980px, 96vw);
  min-height: 540px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--panel-solid);
  opacity: 0.55;
  box-shadow: 0 30px 90px var(--shadow);
  padding: 18px 24px;
  transform: rotate(-1.2deg) scale(1.02);
}

.code-backdrop-dots {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.code-backdrop-dots span:nth-child(1),
.code-backdrop-dots span:nth-child(2),
.code-backdrop-dots span:nth-child(3) {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-strong);
}

.code-backdrop-dots span:nth-child(1) {
  background: var(--accent-bright);
}

.code-backdrop-filename {
  margin-left: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.code-backdrop-pre {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(13px, 1.5vw, 16px);
  line-height: 1.7;
  color: var(--backdrop-code);
  white-space: pre-wrap;
  word-break: break-word;
}

.code-backdrop-pre .tok-kw {
  color: var(--backdrop-kw);
  font-weight: 600;
}

.code-backdrop-pre .tok-str {
  color: var(--backdrop-str);
}

.typing-cursor {
  display: inline-block;
  width: 9px;
  height: 1.15em;
  vertical-align: text-bottom;
  background: var(--accent-bright);
  margin-left: 2px;
  animation: blink 0.85s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.auth-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 435px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 28px 70px var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  animation: fadeUp 0.32s ease;
}

.auth-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.auth-tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 18px 0 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: var(--radius);
}

.auth-tab-indicator {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  border-radius: 7px;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 4px 14px var(--accent-glow);
  z-index: 0;
}

.auth-tabs.register-active .auth-tab-indicator {
  transform: translateX(100%);
}

.auth-tab {
  position: relative;
  z-index: 1;
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 9px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 600;
  transition: color 0.2s ease;
}

.auth-tab.active {
  color: #ffffff;
}

/* Swipe Slider */
.auth-slider-viewport {
  overflow: hidden;
  width: 100%;
}

.auth-slider-track {
  display: flex;
  width: 200%;
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-slider-track.show-register {
  transform: translateX(-50%);
}

.auth-slide {
  width: 50%;
  padding: 2px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 500;
}

.field input,
.input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.field input:focus,
.input:focus {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-message {
  font-size: 13px;
  padding: 9px 11px;
  border-radius: 8px;
  margin: 0 0 14px;
  background: var(--danger-bg);
  color: var(--danger);
}

/* Modal Popups */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 3, 6, 0.68);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  width: 100%;
  max-width: 370px;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 28px 70px var(--shadow);
  animation: popIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-card-confirm {
  text-align: left;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.modal-check {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.16);
  color: #22c55e;
  border: 2px solid #22c55e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
}

.modal-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.modal-card p {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.5;
}

/* Buttons & Pills */
.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.1s ease, opacity 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.96);
}

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

.full-width {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-run {
  background: var(--run);
  color: var(--run-text);
  font-weight: 700;
}
.btn-run:hover:not(:disabled) {
  background: var(--run-hover);
  color: #fff;
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.35);
}

.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent-bright);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: var(--panel-2);
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: var(--border-strong);
}
.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.btn-mini {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.btn-mini:hover {
  color: var(--text);
  border-color: var(--accent-bright);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.pill-neutral {
  background: var(--panel-2);
  color: var(--muted);
}

.pill-accent {
  background: var(--accent-soft);
  color: var(--champagne);
}

.pill-ok {
  background: rgba(34, 197, 94, 0.16);
  color: #22c55e;
}

.pill-err {
  background: var(--danger-bg);
  color: var(--danger);
}

.pill-warn {
  background: rgba(245, 158, 11, 0.18);
  color: var(--warn);
}

/* App Shell */
.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn 0.25s ease;
}

.topbar {
  min-height: 56px;
  background: var(--panel-solid);
  border-bottom: 1px solid var(--border);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-left,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.save-indicator {
  font-size: 12px;
  color: var(--muted);
  margin-right: 4px;
}

.save-indicator.dirty {
  color: var(--warn);
  font-weight: 600;
  animation: pulseSoft 1.5s ease-in-out infinite;
}

@keyframes pulseSoft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* Workspace Grid */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 285px minmax(0, 1.35fr) minmax(305px, 0.9fr);
}

/* Sidebar */
.sidebar {
  background: var(--panel-solid);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.project-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-item {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  width: 100%;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.14s ease, box-shadow 0.16s ease;
}

.project-item:hover {
  border-color: var(--accent-bright);
  transform: translateX(3px);
}

.project-item.active {
  border-color: var(--accent-bright);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent-bright);
}

.project-item-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.project-tag {
  background: var(--panel-2);
  padding: 2px 7px;
  border-radius: 6px;
  color: var(--text);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Editor Pane */
.editor-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--border);
}

.editor-pane.panel-flash {
  animation: fadeIn 0.22s ease;
}

.meta-panel {
  padding: 10px 12px;
  background: var(--panel-solid);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meta-row {
  display: grid;
  grid-template-columns: 1fr 165px;
  gap: 8px;
}

.meta-row-secondary {
  grid-template-columns: 145px 1fr auto auto;
}

.input-title {
  font-weight: 600;
}

.notes-wrap {
  width: 100%;
  animation: fadeUp 0.18s ease;
}

.notes-input {
  resize: vertical;
  min-height: 52px;
  font-family: inherit;
}

.editor-wrapper {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

#code-textarea {
  width: 100%;
  height: 100%;
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: var(--editor-bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  padding: 14px;
}

.CodeMirror {
  height: 100% !important;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  background: var(--editor-bg) !important;
}

.CodeMirror-gutters {
  background: var(--editor-bg) !important;
  border-right: 1px solid var(--border) !important;
}

[data-theme="burgundy-light"] .CodeMirror {
  color: #240b12;
}

[data-theme="burgundy-light"] .CodeMirror-cursor {
  border-left: 2px solid var(--accent);
}

/* Editor Statusbar */
.editor-statusbar {
  height: 28px;
  padding: 0 12px;
  background: var(--panel-solid);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

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

.statusbar-sep {
  opacity: 0.45;
}

.status-shortcut {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 5px;
  transition: color 0.15s ease, background 0.15s ease;
}

.status-shortcut:hover {
  color: var(--text);
  background: var(--panel-2);
}

/* IO Pane */
.io-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
  padding: 10px;
  gap: 10px;
}

.io-card {
  position: relative;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.io-input-card {
  flex: 0 0 36%;
}

.io-output-card {
  flex: 1;
}

.run-progress-bar {
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, transparent, var(--accent-bright), #22c55e, transparent);
  background-size: 200% 100%;
  animation: shimmer 1.1s linear infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.io-header {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.io-title-group,
.io-header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.io-textarea {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: var(--io-bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 12px;
}

.output-view {
  flex: 1;
  margin: 0;
  padding: 12px;
  overflow: auto;
  background: var(--io-bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

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

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

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--panel-solid);
  color: var(--text);
  border: 1px solid var(--accent-bright);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 14px 36px var(--shadow), 0 0 18px var(--accent-soft);
  z-index: 60;
  animation: fadeUp 0.2s ease;
}

/* Spinner */
.spin {
  display: inline-block;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

/* Mobile */
.mobile-only {
  display: none;
}

.mobile-tabs {
  background: var(--panel-solid);
  border-bottom: 1px solid var(--border);
  padding: 6px 10px;
  gap: 6px;
}

.mobile-tab {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.mobile-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (max-width: 960px) {
  .mobile-only {
    display: inline-flex;
  }

  .mobile-tabs {
    display: flex;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .editor-pane,
  .io-pane {
    display: none;
    border-right: none;
  }

  .sidebar.active-pane,
  .editor-pane.active-pane,
  .io-pane.active-pane {
    display: flex;
  }

  .meta-row {
    grid-template-columns: 1fr;
  }

  .meta-row-secondary {
    grid-template-columns: 1fr 1fr;
  }

  .statusbar-right {
    display: none;
  }
}
