:root {
  --bg: #111319;
  --bg-accent: #171a21;
  --panel: rgba(21, 24, 31, 0.9);
  --panel-strong: rgba(27, 31, 40, 0.96);
  --panel-soft: rgba(255, 255, 255, 0.03);
  --panel-hover: rgba(255, 255, 255, 0.055);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #c9c9c9;
  --muted: #9ca6b7;
  --muted-strong: #c7d0dc;
  --primary: #78a7ff;
  --primary-strong: #4c86ff;
  --primary-soft: rgba(120, 167, 255, 0.18);
  --danger: #ff6f7f;
  --success: #8fd6bf;
  --warning: #ffd38a;
  --shadow-xl: 0 24px 80px rgba(0, 0, 0, 0.38);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.28);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  font-family: "Segoe UI", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(120, 167, 255, 0.14), transparent 28%),
    radial-gradient(circle at top right, rgba(100, 211, 186, 0.08), transparent 24%),
    linear-gradient(180deg, #111319, #111319 45%, #161922 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 85%);
  opacity: 0.35;
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 1360px;
  margin: 0 auto;
  padding: 22px;
}

.hero,
.panel,
.loading-card {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  margin-bottom: 18px;
  padding: 24px 26px;
  /* border: 1px solid var(--border); */
  border-radius: var(--radius-xl);
  /* background: linear-gradient(180deg, rgba(21, 24, 31, 0.92), rgba(27, 31, 40, 0.94)); */
  /* box-shadow: var(--shadow-xl); */
}

.brand-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  display: block;
  width: min(240px, 60vw);
  height: auto;
  max-height: 72px;
  object-fit: contain;
}

.brand-beta-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 18px;
  padding: 0 7px;
  border: 1px solid rgba(120, 167, 255, 0.4);
  border-radius: 999px;
  background: rgba(120, 167, 255, 0.2);
  color: #b9d1ff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
  margin-left: auto;
}

.hero-copy {
  max-width: 760px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  color: #d8e6f1;
  font-size: 0.9rem;
  font-weight: 600;
}

.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 16px rgba(120, 167, 255, 0.8);
}

h1,
h2 {
  margin: 0;
  color: #f5f7fb;
  letter-spacing: -0.04em;
}

h1 {
  font-size: clamp(2.4rem, 5vw, 4.4rem);
  line-height: 1.02;
}

h2 {
  font-size: 1.35rem;
  font-weight: 600;
}

.hero-copy p:last-child {
  max-width: 720px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.75;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.pill,
.panel-tag,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.pill {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted-strong);
}

.hero-actions {
  display: flex;
  min-width: 220px;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 14px;
}

.status-badge {
  color: var(--muted-strong);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
}

.status-idle { color: var(--muted-strong); }
.status-active { color: #b9d1ff; }
.status-success { color: var(--success); }
.status-fallback { color: var(--warning); }
.status-error { color: #ffb4bd; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.panel {
  /* background: linear-gradient(180deg, rgba(21, 24, 31, 0.92), rgba(27, 31, 40, 0.96)); */
  /* background: linear-gradient(180deg, rgba(18, 20, 27, 0.94), rgba(15, 17, 22, 0.9)); */
  /* border: 1px solid var(--border); */
  border-radius: var(--radius-xl);
  padding: 20px;
  /* box-shadow: var(--shadow-lg); */
}

.files-panel {
  grid-column: 1 / -1;
}

.preview-panel {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-tag {
  color: var(--muted);
  /* border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03); */
}

label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

label + input,
label + textarea {
  margin-bottom: 14px;
}

textarea + .single-action,
input + .single-action {
  margin-top: 6px;
}

input,
textarea,
pre,
.file-list {
  font: inherit;
}

input,
textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.025));
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

input::placeholder,
textarea::placeholder {
  color: #8c96a8;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(120, 167, 255, 0.28);
  box-shadow: 0 0 0 1px var(--border-strong);
  transform: translateY(-1px);
}

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

button {
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 12px 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

#analyzeBtn,
#planBtn,
#generateBtn {
  border-color: rgba(120, 167, 255, 0.3);
  background: linear-gradient(45deg, #7b4ffe, #52bef8);
  color: #08111f;
  box-shadow: 0 8px 10px 0 rgb(93 143 255 / 20%);
}

.secondary-button {
  border-color: var(--border);
  background: rgb(33 36 39);
  color: var(--text);
}

.secondary-button:hover:not(:disabled) {
  background: rgba(33, 36, 39, 0.8);
  border-color: var(--border-strong);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  margin-bottom: 18px;
}

.actions button {
  flex: 1 1 0;
}

.single-action {
  display: flex;
  margin-top: 18px;
  margin-bottom: 18px;
}

.single-action button {
  width: 100%;
}

.schema-box,
.plan-box,
.code-preview {
  margin: 16px 0 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.025));
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.schema-box {
  min-height: 140px;
  white-space: pre-wrap;
}

.plan-box {
  min-height: 280px;
  white-space: pre-wrap;
}

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

.files-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  min-height: 460px;
}

.file-list {
  margin: 0;
  padding: 8px;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.03);
  overflow: auto;
}

.file-list li {
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--muted-strong);
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  transition: background-color 160ms ease, transform 160ms ease;
}

.file-list li + li {
  margin-top: 4px;
}

.file-list li:hover,
.file-list li.active {
  background: var(--panel-hover);
  transform: translateX(2px);
}

.code-preview {
  margin: 0;
  min-height: 460px;
  white-space: pre;
}

.preview-frame-wrap {
  margin-top: 6px;
  min-height: 620px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.015)), var(--panel);
}

.preview-action {
  margin-top: 18px;
  margin-bottom: 0;
}

.preview-placeholder {
  min-height: 620px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.preview-frame {
  display: block;
  width: 100%;
  min-height: 620px;
  border: 0;
  background: #fff;
}

.hidden {
  display: none !important;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transition: opacity 160ms ease, visibility 160ms ease;
}

.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: linear-gradient(291deg, rgb(26 28 33), rgb(15 17 22 / 95%));
  box-shadow: 0 0 5px 0 rgb(0 0 0 / 20%);
  text-align: center;
}

.loading-card h3 {
  margin: 0 0 10px;
  color: #f5f7fb;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.loading-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 14px;
}

.spinner {
  width: 54px;
  height: 54px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 4px solid rgba(120, 167, 255, 0.16);
  border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
}

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

@media (max-width: 980px) {
  .hero,
  .grid,
  .files-layout {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 14px;
  }

  .hero,
  .panel {
    padding: 18px;
  }

  .actions {
    flex-direction: column;
  }

  .actions button,
  .secondary-button {
    width: 100%;
  }

  .brand-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .brand-logo {
    width: min(240px, 80vw);
    max-height: 56px;
  }

  .brand-beta-badge {
    margin-left: 0;
  }
}
