:root {
  --bg: #050816;
  --bg2: #071a3a;
  --panel: rgba(5, 10, 26, 0.78);
  --panel2: rgba(15, 23, 42, 0.72);
  --line: rgba(103, 232, 249, 0.18);
  --line-strong: rgba(103, 232, 249, 0.36);
  --text: #f8fafc;
  --muted: #9fb1d4;
  --muted2: #64748b;
  --cyan: #67e8f9;
  --blue: #60a5fa;
  --danger: #fb7185;
  --good: #86efac;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(103, 232, 249, 0.24), transparent 34%),
    radial-gradient(circle at bottom right, rgba(96, 165, 250, 0.18), transparent 38%),
    linear-gradient(145deg, var(--bg), var(--bg2) 55%, #020617);
  color: var(--text);
}

button,
input,
textarea {
  font-family: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app {
  min-height: 100svh;
}

.auth-screen {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-card {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 34px;
  background: rgba(5, 10, 26, 0.84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
  text-align: center;
}

.logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

.app-logo {
  width: 88px;
  height: 88px;
  border-radius: 24px;
  box-shadow: 0 18px 45px rgba(96, 165, 250, 0.25);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(28px, 6vw, 42px);
  letter-spacing: -0.05em;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(24px, 5vw, 36px);
  letter-spacing: -0.05em;
}

h3 {
  margin-bottom: 0;
  font-size: 18px;
}

.auth-desc {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 18px;
}

.config-warning {
  margin-bottom: 14px;
  padding: 11px;
  border: 1px solid rgba(251, 191, 36, 0.22);
  border-radius: 16px;
  background: rgba(251, 191, 36, 0.1);
  color: #fde68a;
  font-size: 13px;
  line-height: 1.45;
}

.input-label {
  display: block;
  margin: 0 0 6px;
  text-align: left;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 17px;
  outline: none;
  background: rgba(2, 6, 23, 0.68);
  color: #e0f2fe;
  font-size: 15px;
}

.input.compact {
  min-height: 42px;
}

.input:focus,
textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(103, 232, 249, 0.07);
}

.primary-btn,
.ghost-btn,
.danger-btn,
.small-btn,
.text-btn,
.circle-btn {
  min-height: 44px;
  border-radius: 16px;
  font-weight: 800;
  transition: transform 0.16s ease, filter 0.16s ease, border-color 0.16s ease;
}

button:active {
  transform: scale(0.98);
}

.primary-btn {
  width: 100%;
  padding: 12px 16px;
  background: linear-gradient(145deg, var(--blue), var(--cyan));
  color: #061224;
  box-shadow: 0 14px 34px rgba(96, 165, 250, 0.22);
}

.ghost-btn {
  width: 100%;
  padding: 12px 16px;
  margin-top: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  color: #dff7ff;
}

.text-btn {
  width: 100%;
  margin-top: 10px;
  background: transparent;
  color: var(--muted);
}

.danger-btn {
  padding: 12px 16px;
  border: 1px solid rgba(251, 113, 133, 0.34);
  background: rgba(251, 113, 133, 0.16);
  color: #fecdd3;
}

.small-btn {
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  color: #dff7ff;
}

.small-btn.danger {
  color: #fecdd3;
  border-color: rgba(251, 113, 133, 0.24);
}

.circle-btn {
  width: 42px;
  height: 42px;
  background: linear-gradient(145deg, var(--blue), var(--cyan));
  color: #061224;
  font-size: 24px;
}

.status-text {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.main-screen {
  min-height: 100svh;
  padding: 18px;
}

.topbar,
.hero-card,
.workspace {
  width: min(1180px, 100%);
  margin-inline: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
}

.topbar h1 {
  margin-bottom: 0;
  font-size: 28px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge,
.save-state {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--good);
  font-size: 12px;
  white-space: nowrap;
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background:
    linear-gradient(135deg, rgba(96, 165, 250, 0.22), rgba(103, 232, 249, 0.08)),
    var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  margin-bottom: 16px;
}

.hero-card p {
  color: var(--muted);
  margin-bottom: 0;
}

.hero-symbol {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 26px;
  background: linear-gradient(145deg, var(--blue), var(--cyan));
  color: #061224;
  font-size: 25px;
  font-weight: 900;
  box-shadow: 0 18px 42px rgba(96, 165, 250, 0.28);
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
}

.project-panel,
.editor-panel,
.preview-panel,
.code-wrap {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.project-panel {
  padding: 16px;
  align-self: start;
  position: sticky;
  top: 18px;
}

.panel-head,
.editor-top,
.preview-head,
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.project-list {
  display: grid;
  gap: 9px;
  margin-top: 10px;
  max-height: 520px;
  overflow: auto;
  padding-right: 3px;
}

.project-card {
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: rgba(2, 6, 23, 0.52);
  color: var(--text);
  text-align: left;
}

.project-card.active {
  border-color: var(--line-strong);
  background: rgba(103, 232, 249, 0.12);
}

.project-card strong {
  display: block;
  margin-bottom: 3px;
  font-size: 15px;
}

.project-card span {
  display: block;
  color: var(--muted2);
  font-size: 12px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.project-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.ghost-btn.small,
.file-label {
  min-height: 40px;
  display: grid;
  place-items: center;
  margin-top: 0;
  font-size: 13px;
}

.editor-panel {
  padding: 16px;
}

.project-title-wrap {
  flex: 1;
}

.editor-actions {
  display: flex;
  gap: 8px;
}

.editor-actions .primary-btn {
  width: auto;
}

.prompt-box {
  width: 100%;
  min-height: 88px;
  margin: 4px 0 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 19px;
  outline: none;
  resize: vertical;
  background: rgba(2, 6, 23, 0.58);
  color: #e0f2fe;
  font-size: 15px;
  line-height: 1.55;
}

.tab-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 12px;
}

.tab-btn {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-weight: 900;
}

.tab-btn.active {
  border-color: var(--line-strong);
  background: rgba(103, 232, 249, 0.14);
  color: var(--text);
}

.code-wrap {
  padding: 14px;
  margin-bottom: 12px;
}

.code-head {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.code-editor {
  width: 100%;
  min-height: 300px;
  padding: 14px;
  border: 1px solid rgba(103, 232, 249, 0.16);
  border-radius: 18px;
  outline: none;
  resize: vertical;
  background: rgba(0, 0, 0, 0.35);
  color: #dff7ff;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 14px;
  line-height: 1.6;
}

.run-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.wide {
  margin-top: 0;
}

.preview-panel {
  padding: 14px;
}

#previewFrame {
  width: 100%;
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .project-panel {
    position: static;
  }

  .editor-top,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .editor-actions {
    width: 100%;
  }

  .editor-actions .primary-btn,
  .editor-actions .danger-btn {
    flex: 1;
  }

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

  .hero-symbol {
    display: none;
  }
}

@media (max-width: 480px) {
  .main-screen {
    padding: 10px;
  }

  .topbar,
  .hero-card,
  .project-panel,
  .editor-panel {
    border-radius: 22px;
  }

  .brand-icon {
    width: 46px;
    height: 46px;
  }

  .topbar h1 {
    font-size: 23px;
  }

  .project-tools,
  .editor-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}
