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

:root {
  --bg-deep: #050810;
  --bg-base: #080d1a;
  --bg-surface: #0d1526;
  --bg-raised: #111d35;
  --bg-hover: #162240;
  --navy: #0a1628;
  --navy-mid: #0e1f3d;
  --navy-light: #162a52;
  --accent: #3b82f6;
  --accent-dim: #1d4ed8;
  --accent-glow: rgba(59,130,246,0.15);
  --amber: #f59e0b;
  --green: #10b981;
  --red: #ef4444;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-faint: #475569;
  --border: #1e3a5f;
  --border-dim: #162240;
  --mono: 'JetBrains Mono', monospace;
  --display: 'Syne', sans-serif;
}

html, body { height: 100%; overflow: hidden; background: var(--bg-deep); color: var(--text); font-family: var(--mono); }

#splash {
  position: fixed; inset: 0; background: var(--bg-deep);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; transition: opacity 0.4s ease;
}
#splash.fade-out { opacity: 0; pointer-events: none; }

#splash-inner { text-align: center; max-width: 900px; width: 100%; padding: 2rem; }

#splash-logo {
  font-family: var(--display); font-size: 3.5rem; font-weight: 800;
  letter-spacing: -0.03em; margin-bottom: 0.4rem; line-height: 1;
}
.logo-bracket { color: var(--accent); }
.logo-text { color: var(--text); }
.logo-sm { font-family: var(--display); font-weight: 800; font-size: 1.1rem; letter-spacing: -0.02em; }

.splash-tagline {
  font-family: var(--mono); color: var(--text-dim); font-size: 0.85rem;
  letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 2.5rem;
}

#lang-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 2rem;
}

.lang-card {
  background: var(--bg-surface); border: 1px solid var(--border-dim);
  border-radius: 12px; padding: 1.5rem 1rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  transition: all 0.2s ease; position: relative; overflow: hidden;
}
.lang-card::before {
  content: ''; position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--accent-glow), transparent 70%);
  transition: opacity 0.3s;
}
.lang-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.lang-card:hover::before { opacity: 1; }
.lang-card.selected { border-color: var(--accent); background: var(--bg-raised); }
.lang-card.selected::before { opacity: 1; }

.lang-icon { width: 52px; height: 52px; }
.lang-icon svg { width: 100%; height: 100%; }
.lang-name { font-family: var(--display); font-weight: 600; font-size: 0.9rem; color: var(--text); }
.lang-ext { font-family: var(--mono); font-size: 0.7rem; color: var(--text-faint); }

#app { display: flex; flex-direction: column; height: 100vh; }
#app.hidden { display: none; }

#topbar {
  display: flex; align-items: center; height: 44px;
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
  padding: 0 0.75rem; gap: 0.75rem; flex-shrink: 0;
  user-select: none;
}
#topbar-left { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
#project-name {
  font-family: var(--mono); font-size: 0.8rem; color: var(--text-dim);
  border-bottom: 1px solid transparent; outline: none; padding: 1px 3px;
  transition: border-color 0.2s; min-width: 60px;
}
#project-name:focus { border-color: var(--accent); color: var(--text); }

#topbar-center { display: flex; align-items: center; flex: 1; overflow: hidden; }
#tab-bar { display: flex; align-items: stretch; overflow-x: auto; flex: 1; height: 44px; }
#tab-bar::-webkit-scrollbar { height: 2px; }
#tab-bar::-webkit-scrollbar-track { background: transparent; }
#tab-bar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.tab {
  display: flex; align-items: center; gap: 0.4rem; padding: 0 1rem;
  font-size: 0.75rem; color: var(--text-faint); cursor: pointer; flex-shrink: 0;
  border-right: 1px solid var(--border-dim); height: 100%;
  border-top: 2px solid transparent; transition: all 0.15s;
  white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--bg-raised); }
.tab.active { color: var(--text); border-top-color: var(--accent); background: var(--bg-base); }
.tab-close {
  width: 16px; height: 16px; border-radius: 3px; border: none; background: none;
  color: var(--text-faint); cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 10px; transition: all 0.15s; line-height: 1;
}
.tab-close:hover { background: var(--bg-hover); color: var(--red); }

#btn-add-file {
  width: 32px; height: 32px; background: none; border: 1px solid var(--border-dim);
  color: var(--text-dim); border-radius: 6px; cursor: pointer; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin: 0 0.4rem;
  transition: all 0.15s;
}
#btn-add-file:hover { border-color: var(--accent); color: var(--accent); }

#topbar-right { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.hdr-btn {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  font-family: var(--mono); font-size: 0.72rem; padding: 0.3rem 0.7rem;
  border-radius: 6px; cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.hdr-btn:hover { border-color: var(--accent); color: var(--accent); }
.hdr-btn.accent { border-color: var(--accent-dim); color: var(--accent); }
.hdr-btn.accent:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.dropdown-wrap { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0; background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: 8px; min-width: 140px; z-index: 200;
  display: none; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.dropdown-menu.open { display: block; }
.dm-item {
  display: block; width: 100%; background: none; border: none; color: var(--text-dim);
  font-family: var(--mono); font-size: 0.75rem; padding: 0.6rem 0.9rem; cursor: pointer;
  text-align: left; transition: all 0.12s;
}
.dm-item:hover { background: var(--bg-hover); color: var(--text); }

#main-area { display: flex; flex: 1; overflow: hidden; }

#sidebar {
  width: 200px; min-width: 160px; background: var(--bg-surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  flex-shrink: 0;
}
#file-list { flex: 1; overflow-y: auto; padding: 0.5rem 0; }
#file-list::-webkit-scrollbar { width: 3px; }
#file-list::-webkit-scrollbar-thumb { background: var(--border); }

.file-item {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.75rem;
  font-size: 0.73rem; color: var(--text-dim); cursor: pointer; transition: all 0.12s;
  border-left: 2px solid transparent;
}
.file-item:hover { color: var(--text); background: var(--bg-raised); }
.file-item.active { color: var(--text); background: var(--bg-raised); border-left-color: var(--accent); }
.file-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

#sidebar-bottom { border-top: 1px solid var(--border); padding: 0.5rem; }
#btn-upload-asset {
  width: 100%; background: none; border: 1px dashed var(--border); color: var(--text-faint);
  font-family: var(--mono); font-size: 0.7rem; padding: 0.4rem; border-radius: 6px; cursor: pointer;
  transition: all 0.15s;
}
#btn-upload-asset:hover { border-color: var(--accent); color: var(--accent); }
#asset-list { margin-top: 0.4rem; max-height: 120px; overflow-y: auto; }
.asset-item {
  display: flex; align-items: center; gap: 0.4rem; padding: 0.25rem 0.3rem;
  font-size: 0.65rem; color: var(--text-faint); border-radius: 4px; cursor: pointer;
  transition: background 0.12s;
}
.asset-item:hover { background: var(--bg-raised); color: var(--text-dim); }
.asset-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#editor-container { flex: 1; overflow: hidden; position: relative; background: var(--bg-base); }
#monaco-editor { width: 100%; height: 100%; }

#status-bar {
  height: 24px; background: var(--navy-mid); border-top: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 0.75rem; gap: 1rem;
  font-size: 0.68rem; color: var(--text-faint); flex-shrink: 0;
}
#status-msg { margin-left: auto; color: var(--accent); }

#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 500;
}
#modal-overlay.hidden { display: none; }
#modal-box {
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.5rem; min-width: 420px; max-width: 90vw;
}
#modal-title { font-family: var(--display); font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
#modal-body { margin-bottom: 1rem; }
.url-display {
  background: var(--bg-deep); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.6rem 0.8rem; font-size: 0.75rem; color: var(--accent); word-break: break-all;
  font-family: var(--mono); margin-bottom: 0.5rem;
}
.url-label { font-size: 0.7rem; color: var(--text-faint); margin-bottom: 0.4rem; }
#modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
#modal-close, #modal-copy {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  font-family: var(--mono); font-size: 0.75rem; padding: 0.4rem 0.9rem; border-radius: 6px; cursor: pointer;
  transition: all 0.15s;
}
#modal-close:hover { border-color: var(--red); color: var(--red); }
.accent-btn { border-color: var(--accent-dim) !important; color: var(--accent) !important; }
.accent-btn:hover { background: var(--accent) !important; color: #fff !important; }

#new-file-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 600;
}
#new-file-modal.hidden { display: none; }
#nfm-box {
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 12px;
  padding: 1.5rem; width: 380px; max-width: 90vw;
}
.nfm-title { font-family: var(--display); font-weight: 600; font-size: 1rem; margin-bottom: 1rem; }
#nfm-name {
  width: 100%; background: var(--bg-deep); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.5rem 0.7rem; color: var(--text); font-family: var(--mono); font-size: 0.8rem;
  outline: none; margin-bottom: 0.8rem; transition: border-color 0.15s;
}
#nfm-name:focus { border-color: var(--accent); }
#nfm-langs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.nfm-lang {
  background: var(--bg-surface); border: 1px solid var(--border-dim); color: var(--text-dim);
  font-family: var(--mono); font-size: 0.72rem; padding: 0.3rem 0.6rem; border-radius: 5px;
  cursor: pointer; transition: all 0.15s;
}
.nfm-lang:hover, .nfm-lang.selected { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.nfm-btns { display: flex; gap: 0.5rem; justify-content: flex-end; }
#nfm-cancel, #nfm-create {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  font-family: var(--mono); font-size: 0.75rem; padding: 0.4rem 0.9rem; border-radius: 6px; cursor: pointer;
  transition: all 0.15s;
}
#nfm-cancel:hover { border-color: var(--red); color: var(--red); }

.lang-dot-html { background: #E44D26; }
.lang-dot-css { background: #1572B6; }
.lang-dot-javascript { background: #F7DF1E; }
.lang-dot-typescript { background: #007ACC; }
.lang-dot-coffeescript { background: #C0A98B; }
.lang-dot-livescript { background: #336699; }
.lang-dot-scss { background: #CD6799; }
.lang-dot-less { background: #1D365D; }

.spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 700px) {
  #lang-grid { grid-template-columns: repeat(2, 1fr); }
  #sidebar { display: none; }
  #splash-logo { font-size: 2.2rem; }
}

