/* ── Editor page layout ── */
.editor-page {
  margin-top: var(--header-height);
  height: calc(100vh - var(--header-height));
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle, rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(160deg, rgba(60,80,220,0.08) 0%, transparent 45%, rgba(199,64,64,0.08) 100%),
    #04040f;
  background-size: 28px 28px, auto, auto;
  overflow: hidden;
}

.ctrl-btn--ai {
  background: linear-gradient(135deg, rgb(120,60,220), rgb(60,160,220));
  box-shadow: 0 0 10px rgba(100,80,220,0.3);
}
.ctrl-btn--ai:hover { opacity: 0.88; }
.ctrl-btn--ai.loading { opacity: 0.6; pointer-events: none; }

.ctrl-btn--icon {
  padding: 5px 9px;
}

/* ── AI prompt bar ── */
.ai-bar {
  flex-shrink: 0;
  background: rgba(6,6,22,0.97);
  border-bottom: 1px solid rgba(100,80,220,0.35);
  padding: 8px 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: slide-down 0.18s ease;
}
.ai-bar[hidden] { display: none; }

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-bar-icon {
  color: rgba(120,100,255,0.7);
  flex-shrink: 0;
}

#ai-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(100,80,220,0.3);
  border-radius: 8px;
  color: rgba(255,255,255,0.9);
  font-family: inherit;
  font-size: 0.83rem;
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}
#ai-input:focus { border-color: rgba(100,80,220,0.7); background: rgba(100,80,220,0.06); }
#ai-input::placeholder { color: rgba(255,255,255,0.2); }

.ai-target-btns {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.ai-target {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.1);
  background: transparent;
  color: rgba(255,255,255,0.35);
  font-size: 0.7rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.ai-target:hover { border-color: rgba(100,80,220,0.4); color: rgba(255,255,255,0.7); }
.ai-target.active {
  background: rgba(100,80,220,0.2);
  border-color: rgba(100,80,220,0.6);
  color: rgba(200,190,255,0.95);
}

.ai-send {
  padding: 7px 14px;
  border-radius: 7px;
  border: none;
  background: linear-gradient(135deg, rgb(100,80,220), rgb(60,140,220));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, transform 0.12s;
  flex-shrink: 0;
}
.ai-send:hover  { opacity: 0.88; transform: translateY(-1px); }
.ai-send:active { transform: scale(0.96); }
.ai-send:disabled { opacity: 0.35; pointer-events: none; }

.ai-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.25);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 5px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.ai-close:hover { color: rgba(199,64,64,0.8); background: rgba(199,64,64,0.08); }

.ai-status {
  font-size: 0.75rem;
  padding: 4px 8px 2px;
  border-radius: 5px;
  line-height: 1.4;
}
.ai-status[hidden] { display: none; }
.ai-status.thinking { color: rgba(180,170,255,0.8); }
.ai-status.streaming { color: rgba(100,200,120,0.9); }
.ai-status.error { color: rgba(220,90,90,0.9); background: rgba(199,60,60,0.07); padding: 5px 8px; border: 1px solid rgba(199,60,60,0.2); border-radius: 6px; }

/* ── Settings modal ── */
.settings-backdrop[hidden] { display: none; }
.settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.settings-card {
  background:
    linear-gradient(rgba(8,8,24,0.98), rgba(8,8,24,0.98)) padding-box,
    linear-gradient(135deg, rgba(100,80,220,0.8), rgba(60,140,220,0.6)) border-box;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 1.75rem 2rem;
  max-width: 440px;
  width: 94%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
}

.settings-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.3);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 5px;
  transition: all 0.15s;
}
.settings-close:hover { color: rgba(199,64,64,0.8); background: rgba(199,64,64,0.08); }

.settings-desc {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.45);
  line-height: 1.65;
  margin: 0;
}
.settings-desc code { color: rgba(180,170,255,0.8); background: rgba(100,80,220,0.1); padding: 1px 5px; border-radius: 4px; font-size: 0.77rem; }
.settings-desc strong { color: rgba(255,255,255,0.65); }

.settings-row {
  display: flex;
  gap: 0.6rem;
}

#api-key-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(100,80,220,0.3);
  border-radius: 8px;
  color: rgba(255,255,255,0.9);
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 0.82rem;
  padding: 9px 12px;
  outline: none;
  letter-spacing: 0.5px;
  transition: border-color 0.15s;
}
#api-key-input:focus { border-color: rgba(100,80,220,0.7); }
#api-key-input::placeholder { color: rgba(255,255,255,0.2); letter-spacing: 0; font-family: inherit; }

.settings-status {
  font-size: 0.78rem;
  padding: 6px 10px;
  border-radius: 7px;
}
.settings-status[hidden] { display: none; }
.settings-status.ok    { color: rgba(100,220,120,0.9); background: rgba(60,180,80,0.08); border: 1px solid rgba(60,180,80,0.2); }
.settings-status.error { color: rgba(220,90,90,0.9);  background: rgba(199,60,60,0.08); border: 1px solid rgba(199,60,60,0.2); }

/* ── Projects modal ── */
.projects-card {
  width: min(520px, 94vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.projects-save-row {
  display: flex;
  gap: 8px;
  padding: 0 0 12px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 12px;
}

.projects-save-row input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: #fff;
  font-size: 0.88rem;
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.projects-save-row input:focus { border-color: rgba(100,80,220,0.7); }

.projects-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  gap: 10px;
  transition: background 0.12s;
}
.project-item:hover { background: rgba(255,255,255,0.07); }

.project-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.project-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-date {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.35);
}

.project-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.project-btn {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.15s;
}
.project-btn:hover { opacity: 0.8; }
.project-btn--load   { background: rgba(60,80,220,0.7); color: #fff; }
.project-btn--delete { background: rgba(199,64,64,0.6); color: #fff; }

.projects-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: rgba(255,255,255,0.3);
  font-size: 0.85rem;
}

/* ── Top bar ── */
.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  height: 46px;
  flex-shrink: 0;
  background: rgba(4,4,15,0.95);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  gap: 1rem;
  z-index: 10;
}

.editor-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
}

.editor-title svg {
  color: rgb(60,80,220);
  flex-shrink: 0;
}

.editor-title .red {
  color: rgb(199,64,64);
  text-shadow: 0 0 14px rgba(199,64,64,0.5);
}

.editor-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 5px 14px;
  border-radius: 7px;
  border: none;
  background: linear-gradient(135deg, rgb(60,80,220), rgb(199,64,64));
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.12s;
  box-shadow: 0 0 10px rgba(60,80,220,0.2);
  white-space: nowrap;
}
.ctrl-btn:hover  { opacity: 0.88; transform: translateY(-1px); }
.ctrl-btn:active { transform: scale(0.96); }

.ctrl-btn--ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.5);
  box-shadow: none;
}
.ctrl-btn--ghost:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.85); border-color: rgba(255,255,255,0.18); }

/* ── Split pane ── */
.editor-split {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ── Left side: stacked editor panels ── */
.editor-panels {
  display: flex;
  flex-direction: column;
  width: 50%;
  min-width: 200px;
  min-height: 0;
  overflow: hidden;
  flex-shrink: 0;
}

/* ── Individual panel ── */
.panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.panel.collapsed .panel-body { display: none; }
.panel.collapsed { flex: 0 0 auto; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 34px;
  flex-shrink: 0;
  background: rgba(6,6,20,0.9);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  user-select: none;
}

.panel-lang {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.panel-lang::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.html-dot { color: rgba(255,160,80,0.85); }
.html-dot::before { background: rgb(255,140,60); box-shadow: 0 0 6px rgba(255,140,60,0.5); }

.css-dot { color: rgba(100,160,255,0.85); }
.css-dot::before { background: rgb(80,140,255); box-shadow: 0 0 6px rgba(80,140,255,0.5); }

.js-dot { color: rgba(240,210,60,0.9); }
.js-dot::before { background: rgb(240,200,30); box-shadow: 0 0 6px rgba(240,200,30,0.5); }

.panel-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,0.25);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.panel-toggle:hover { color: rgba(255,255,255,0.7); background: rgba(255,255,255,0.06); }
.panel.collapsed .panel-toggle svg { transform: rotate(180deg); }

.panel-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ── CodeMirror overrides ── */
.panel-body .CodeMirror {
  font-size: 0.82rem;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  line-height: 1.65;
  background: transparent;
  /* height is set explicitly by JS via setSize() */
}

.panel-body .CodeMirror-scroll {
  min-height: 0 !important;
}

/* Match dracula but tweak to site bg */
.CodeMirror-gutters {
  background: rgba(6,6,20,0.95) !important;
  border-right: 1px solid rgba(255,255,255,0.05) !important;
}

.CodeMirror-linenumber {
  color: rgba(255,255,255,0.15) !important;
  font-size: 0.72rem;
}

.CodeMirror-cursor {
  border-left-color: rgb(199,64,64) !important;
}

.CodeMirror-selected {
  background: rgba(60,80,220,0.25) !important;
}

.CodeMirror-focused .CodeMirror-selected {
  background: rgba(60,80,220,0.3) !important;
}

/* ── Autocomplete hint dropdown ── */
.CodeMirror-hints {
  background: rgba(8, 8, 24, 0.97) !important;
  border: 1px solid rgba(60,80,220,0.4) !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 0 1px rgba(60,80,220,0.15) !important;
  padding: 4px !important;
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace !important;
  font-size: 0.78rem !important;
  z-index: 900 !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.CodeMirror-hint {
  color: rgba(255,255,255,0.75) !important;
  padding: 4px 10px !important;
  border-radius: 5px !important;
  line-height: 1.5 !important;
}

/* Snippet items get the ✦ diamond icon styled */
.cm-hint-tag {
  color: rgba(120,100,255,0.7);
  font-size: 0.65em;
  margin-right: 5px;
  vertical-align: middle;
}

li.CodeMirror-hint-active {
  background: linear-gradient(90deg, rgba(60,80,220,0.35), rgba(199,64,64,0.2)) !important;
  color: #fff !important;
}

/* ── Panel divider ── */
.panel-divider {
  height: 4px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.04);
  border-top: 1px solid rgba(255,255,255,0.05);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  cursor: row-resize;
  transition: background 0.15s;
}
.panel-divider:hover,
.panel-divider.dragging { background: rgba(60,80,220,0.35); }

/* ── Vertical resize handle ── */
.resize-handle {
  width: 5px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.04);
  border-left: 1px solid rgba(255,255,255,0.05);
  border-right: 1px solid rgba(255,255,255,0.05);
  cursor: col-resize;
  transition: background 0.15s;
  position: relative;
  z-index: 5;
}
.resize-handle::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(60,80,220,0.4), transparent);
}
.resize-handle:hover,
.resize-handle.dragging { background: rgba(60,80,220,0.3); }

/* ── Preview pane ── */
.preview-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 200px;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 34px;
  flex-shrink: 0;
  background: rgba(6,6,20,0.9);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.preview-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
}

.live-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: rgb(80,200,120);
  text-shadow: 0 0 8px rgba(80,200,120,0.5);
  animation: pulse-live 2s ease-in-out infinite;
}

@keyframes pulse-live {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

#preview-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
  display: block;
}

/* ── Mobile: stack vertically ── */
@media (max-width: 700px) {
  .editor-split {
    flex-direction: column;
  }
  .editor-panels {
    width: 100%;
    height: 50%;
    flex-shrink: 0;
  }
  .resize-handle {
    width: 100%;
    height: 5px;
    cursor: row-resize;
  }
  .preview-pane {
    flex: 1;
    height: auto;
  }
  .ctrl-btn span,
  .ctrl-btn--ghost span { display: none; }
}
