:root {
  --base: #1e1e2e;
  --mantle: #181825;
  --crust: #11111b;
  --surface0: #313244;
  --surface1: #45475a;
  --surface2: #585b70;
  --overlay0: #6c7086;
  --overlay1: #7f849c;
  --text: #cdd6f4;
  --subtext0: #a6adc8;
  --subtext1: #bac2de;
  --blue: #89b4fa;
  --green: #a6e3a1;
  --peach: #fab387;
  --mauve: #cba6f7;
  --red: #f38ba8;
  --yellow: #f9e2af;
  --teal: #94e2d5;
  --sky: #89dceb;
  --lavender: #b4befe;
  --flamingo: #f2cdcd;
  --rosewater: #f5e0dc;
  --font-code: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
  --font-ui: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
  --transition: 150ms ease;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--crust);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#root {
  height: 100%;
  position: relative;
}

::selection {
  background: rgba(137, 180, 250, .3);
  color: var(--text);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--surface1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--surface2);
}
::-webkit-scrollbar-corner {
  background: transparent;
}

/* ── IDE Shell ── */
.ide-shell {
  display: grid;
  grid-template-rows: 30px 36px 1fr 22px;
  grid-template-columns: 48px 240px 1fr 220px;
  grid-template-areas:
    "menubar  menubar  menubar  menubar"
    "activity tabs     tabs     tabs"
    "activity sidebar  editor   outline"
    "status   status   status   status";
  height: 100vh;
  width: 100vw;
  background: var(--base);
  filter: blur(3px) brightness(.7);
  pointer-events: none;
  user-select: none;
  transition: filter .4s ease;
}

/* ── Menu Bar ── */
.menubar {
  grid-area: menubar;
  display: flex;
  align-items: center;
  background: var(--mantle);
  border-bottom: 1px solid var(--surface0);
  padding: 0 12px;
  gap: 2px;
  font-size: 12px;
}
.menubar-item {
  padding: 2px 8px;
  border-radius: 3px;
  color: var(--subtext0);
  cursor: default;
}
.menubar-brand {
  margin-right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--blue);
  font-weight: 600;
  font-size: 12px;
}
.menubar-brand svg {
  width: 14px;
  height: 14px;
}
.menubar-spacer {
  flex: 1;
}
.menubar-title {
  color: var(--overlay1);
  font-size: 11px;
}

/* ── Activity Bar ── */
.activity-bar {
  grid-area: activity;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--mantle);
  border-right: 1px solid var(--surface0);
  padding-top: 4px;
  gap: 2px;
}
.activity-icon {
  width: 48px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--overlay0);
  position: relative;
}
.activity-icon.active {
  color: var(--text);
}
.activity-icon.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--blue);
  border-radius: 0 2px 2px 0;
}
.activity-icon svg {
  width: 22px;
  height: 22px;
}

/* ── Sidebar ── */
.sidebar {
  grid-area: sidebar;
  background: var(--mantle);
  border-right: 1px solid var(--surface0);
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--overlay1);
}
.sidebar-header-actions {
  display: flex;
  gap: 4px;
}
.sidebar-header-actions svg {
  width: 14px;
  height: 14px;
  color: var(--overlay0);
}

.file-tree {
  font-size: 12px;
}
.tree-item {
  display: flex;
  align-items: center;
  padding: 2px 0;
  padding-right: 8px;
  cursor: default;
  white-space: nowrap;
  height: 22px;
}
.tree-item:hover {
  background: rgba(137, 180, 250, .08);
}
.tree-item.active {
  background: rgba(137, 180, 250, .15);
}
.tree-chevron {
  width: 16px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: var(--overlay0);
  flex-shrink: 0;
  transition: transform var(--transition);
}
.tree-chevron.open {
  transform: rotate(90deg);
}
.tree-chevron.empty {
  visibility: hidden;
}
.tree-icon {
  width: 16px;
  height: 16px;
  margin-right: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.tree-icon.folder { color: var(--blue); }
.tree-icon.ts { color: #3178c6; }
.tree-icon.tsx { color: #3178c6; }
.tree-icon.json { color: var(--yellow); }
.tree-icon.md { color: var(--subtext0); }
.tree-icon.css { color: var(--blue); }
.tree-icon.env { color: var(--yellow); }
.tree-icon.git { color: var(--peach); }
.tree-icon.lock { color: var(--overlay0); }
.tree-icon.config { color: var(--green); }
.tree-label {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-item.folder-item > .tree-label {
  font-weight: 500;
}

/* ── Tabs ── */
.tab-bar {
  grid-area: tabs;
  display: flex;
  align-items: flex-end;
  background: var(--mantle);
  border-bottom: 1px solid var(--surface0);
  overflow-x: auto;
  overflow-y: hidden;
}
.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 32px;
  font-size: 12px;
  color: var(--overlay1);
  background: transparent;
  border-right: 1px solid var(--surface0);
  cursor: default;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
}
.tab.active {
  background: var(--base);
  color: var(--text);
}
.tab.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--blue);
}
.tab-icon {
  font-size: 12px;
}
.tab-close {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  font-size: 14px;
  color: var(--overlay0);
  opacity: 0;
}
.tab:hover .tab-close {
  opacity: 1;
}
.tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text);
  opacity: 0;
}
.tab.modified .tab-dot {
  opacity: 1;
}
.tab.modified .tab-close {
  display: none;
}

/* ── Editor ── */
.editor-area {
  grid-area: editor;
  background: var(--base);
  overflow: auto;
  position: relative;
}
.editor-breadcrumb {
  display: flex;
  align-items: center;
  padding: 3px 16px;
  font-size: 11px;
  color: var(--overlay0);
  gap: 4px;
  border-bottom: 1px solid var(--surface0);
  background: var(--base);
  position: sticky;
  top: 0;
  z-index: 1;
}
.breadcrumb-sep {
  font-size: 9px;
}
.editor-content {
  display: flex;
  min-height: 100%;
}
.gutter {
  padding: 4px 8px 4px 16px;
  text-align: right;
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 20px;
  color: var(--surface2);
  user-select: none;
  flex-shrink: 0;
  min-width: 52px;
}
.gutter .active-line {
  color: var(--overlay1);
}
.code-lines {
  flex: 1;
  padding: 4px 16px 4px 8px;
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 20px;
  overflow-x: auto;
  white-space: pre;
}
.code-line {
  min-height: 20px;
}
.code-line.active-line {
  background: rgba(137, 180, 250, .06);
}
.code-line.active-line::after {
  content: '';
  display: inline-block;
  width: 1.5px;
  height: 16px;
  background: var(--blue);
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
  margin-left: 1px;
}

/* ── Syntax Highlighting ── */
.keyword { color: var(--mauve); }
.string { color: var(--green); }
.comment { color: var(--overlay0); font-style: italic; }
.function { color: var(--blue); }
.number { color: var(--peach); }
.type { color: var(--yellow); }
.operator { color: var(--sky); }
.punctuation { color: var(--overlay1); }
.variable { color: var(--text); }
.property { color: var(--lavender); }
.decorator { color: var(--peach); }
.tag { color: var(--blue); }
.attr { color: var(--yellow); }
.regex { color: var(--peach); }
.builtin { color: var(--teal); }
.constant { color: var(--peach); font-weight: 500; }

/* ── Outline Panel ── */
.outline-panel {
  grid-area: outline;
  background: var(--mantle);
  border-left: 1px solid var(--surface0);
  overflow-y: auto;
}
.outline-header {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--overlay1);
  border-bottom: 1px solid var(--surface0);
}
.outline-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px 3px 16px;
  font-size: 12px;
  color: var(--subtext0);
  cursor: default;
}
.outline-item:hover {
  background: rgba(137, 180, 250, .08);
}
.outline-icon {
  font-size: 11px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}
.outline-icon.fn { color: var(--mauve); }
.outline-icon.iface { color: var(--yellow); }
.outline-icon.var { color: var(--blue); }
.outline-icon.class { color: var(--peach); }
.outline-item.nested {
  padding-left: 28px;
}

/* ── Terminal Panel ── */
.terminal-panel {
  background: var(--crust);
  border-top: 1px solid var(--surface0);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.terminal-tabs {
  display: flex;
  align-items: center;
  background: var(--mantle);
  border-bottom: 1px solid var(--surface0);
  padding: 0 8px;
  height: 28px;
  gap: 2px;
}
.terminal-tab-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .3px;
  padding: 4px 10px;
  color: var(--overlay1);
  cursor: default;
}
.terminal-tab-label.active {
  color: var(--text);
  border-bottom: 1px solid var(--blue);
}
.terminal-tabs-spacer { flex: 1; }
.terminal-tabs svg {
  width: 14px;
  height: 14px;
  color: var(--overlay0);
  margin-left: 4px;
}
.terminal-body {
  flex: 1;
  padding: 8px 12px;
  font-family: var(--font-code);
  font-size: 12px;
  line-height: 1.6;
  overflow-y: auto;
  color: var(--subtext0);
}
.terminal-line { white-space: pre-wrap; word-break: break-all; }
.terminal-prompt { color: var(--green); }
.terminal-cmd { color: var(--text); }
.terminal-info { color: var(--overlay0); }
.terminal-success { color: var(--green); }
.terminal-warn { color: var(--yellow); }
.terminal-err { color: var(--red); }

/* ── Status Bar ── */
.statusbar {
  grid-area: status;
  display: flex;
  align-items: center;
  background: var(--blue);
  color: var(--crust);
  font-size: 11px;
  padding: 0 8px;
  gap: 2px;
}
.statusbar-section {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  height: 100%;
  cursor: default;
}
.statusbar-section:hover {
  background: rgba(0,0,0,.15);
}
.statusbar-section svg {
  width: 12px;
  height: 12px;
}
.statusbar-spacer { flex: 1; }
.statusbar-remote {
  background: var(--mauve);
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
  margin-left: -8px;
}
.statusbar-remote svg {
  width: 13px;
  height: 13px;
}

/* ── Login Overlay ── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 17, 27, .55);
  backdrop-filter: blur(2px);
}

.login-card {
  width: 420px;
  max-width: calc(100vw - 32px);
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 12px;
  padding: 40px 36px 32px;
  box-shadow: var(--shadow-lg), 0 0 80px rgba(137, 180, 250, .06);
  position: relative;
  z-index: 101;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}
.login-logo svg {
  width: 36px;
  height: 36px;
}
.login-logo-text {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.5px;
}
.login-tagline {
  text-align: center;
  color: var(--overlay1);
  font-size: 13px;
  margin-bottom: 28px;
}

.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--surface1);
  border-radius: var(--radius);
  background: var(--surface0);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  text-decoration: none;
}
.oauth-btn:hover {
  background: var(--surface1);
  border-color: var(--surface2);
}
.oauth-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.oauth-btn.github {
  background: #24292e;
  border-color: #30363d;
  color: #fff;
}
.oauth-btn.github:hover {
  background: #2d333b;
}
.oauth-btn.gitlab {
  background: rgba(252, 109, 38, .12);
  border-color: rgba(252, 109, 38, .3);
  color: var(--peach);
}
.oauth-btn.gitlab:hover {
  background: rgba(252, 109, 38, .2);
}
.oauth-gap {
  height: 10px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  color: var(--overlay0);
  font-size: 12px;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--surface0);
}

.login-field {
  margin-bottom: 14px;
}
.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--subtext0);
  margin-bottom: 5px;
}
.login-field input {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface0);
  border: 1px solid var(--surface1);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.login-field input::placeholder {
  color: var(--overlay0);
}
.login-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(137, 180, 250, .2);
}
.login-field input.input-error {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(243, 139, 168, .15);
}

.login-submit {
  width: 100%;
  padding: 10px 16px;
  background: var(--blue);
  color: var(--crust);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  margin-top: 4px;
}
.login-submit:hover {
  opacity: .9;
}
.login-submit:active {
  transform: scale(.99);
}
.login-submit:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.login-error {
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(243, 139, 168, .1);
  border: 1px solid rgba(243, 139, 168, .25);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 12px;
  display: none;
  align-items: center;
  gap: 8px;
}
.login-error.show {
  display: flex;
}
.login-error svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.login-loading {
  margin-top: 14px;
  text-align: center;
  color: var(--overlay1);
  font-size: 13px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.login-loading.show {
  display: flex;
}

.login-footer {
  margin-top: 22px;
  text-align: center;
}
.login-footer-signup {
  font-size: 13px;
  color: var(--overlay1);
  margin-bottom: 12px;
}
.login-footer-signup a {
  color: var(--blue);
  text-decoration: none;
}
.login-footer-signup a:hover {
  text-decoration: underline;
}
.login-footer-legal {
  font-size: 11px;
  color: var(--overlay0);
}
.login-footer-legal a {
  color: var(--overlay0);
  text-decoration: none;
}
.login-footer-legal a:hover {
  color: var(--subtext0);
  text-decoration: underline;
}

/* ── Floating Code BG ── */
.login-bg-code {
  position: fixed;
  inset: 0;
  z-index: 99;
  overflow: hidden;
  pointer-events: none;
}
.floating-snippet {
  position: absolute;
  font-family: var(--font-code);
  font-size: 11px;
  line-height: 1.6;
  color: var(--surface2);
  opacity: 0;
  animation: floatSnippet 18s linear infinite;
  white-space: pre;
}

/* ── Dots loading ── */
.dots-loading::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

/* ── Keyframes ── */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes floatSnippet {
  0% {
    transform: translateY(105vh) translateX(0);
    opacity: 0;
  }
  5% { opacity: .12; }
  90% { opacity: .12; }
  100% {
    transform: translateY(-10vh) translateX(30px);
    opacity: 0;
  }
}

@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
}

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

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--surface1);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .ide-shell {
    grid-template-columns: 48px 1fr;
    grid-template-areas:
      "menubar  menubar"
      "activity tabs"
      "activity editor"
      "status   status";
  }
  .sidebar,
  .outline-panel {
    display: none;
  }
}

@media (max-width: 640px) {
  .ide-shell {
    display: none;
  }
  .login-card {
    padding: 28px 20px 24px;
  }
  .login-logo-text {
    font-size: 22px;
  }
}

.mobile-notice {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--crust);
  color: var(--text);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
}
.mobile-notice svg {
  width: 48px;
  height: 48px;
  color: var(--blue);
  margin-bottom: 8px;
}
.mobile-notice h2 {
  font-size: 18px;
  font-weight: 600;
}
.mobile-notice p {
  color: var(--overlay1);
  font-size: 13px;
  max-width: 300px;
  line-height: 1.6;
}

@media (max-width: 480px) {
  .mobile-notice {
    display: flex;
  }
  .login-overlay {
    display: none;
  }
  .login-bg-code {
    display: none;
  }
}
