* {
  box-sizing: border-box;
}

:root {
  --bg: #060914;
  --panel: rgba(12, 18, 34, 0.78);
  --panel-strong: rgba(8, 13, 27, 0.94);
  --line: rgba(126, 216, 255, 0.22);
  --line-strong: rgba(126, 216, 255, 0.42);
  --cyan: #71e6ff;
  --violet: #9b7cff;
  --gold: #e7c16f;
  --text: #f7fbff;
  --muted: #99a7bd;
  --danger: #ff7d90;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 14% 8%, rgba(113, 230, 255, 0.18), transparent 32%),
    radial-gradient(circle at 88% 4%, rgba(155, 124, 255, 0.2), transparent 30%),
    linear-gradient(135deg, #050711 0%, #08101d 46%, #070914 100%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.8), transparent 78%);
}

.shell {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(520px, 1.12fr) minmax(360px, 0.72fr);
  gap: 22px;
  padding: 28px;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--panel-strong));
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255,255,255,.08);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(113,230,255,.08), transparent 36%, rgba(155,124,255,.08));
}

.studio-panel,
.output {
  display: flex;
  flex-direction: column;
}

.head,
.status-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 4.2vw, 58px);
  line-height: 1.02;
}

h2 {
  font-size: 24px;
}

.lede {
  margin: 14px 0 0;
  max-width: 760px;
  color: var(--muted);
  line-height: 1.65;
}

.signal {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 8px);
  gap: 7px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 7px;
  background: rgba(255,255,255,.04);
}

.signal span {
  width: 8px;
  height: 34px;
  border-radius: 99px;
  background: linear-gradient(var(--cyan), var(--violet));
  opacity: 0.45;
}

.signal span:nth-child(2) { height: 52px; opacity: 0.8; }
.signal span:nth-child(3) { height: 24px; opacity: 0.6; }

form {
  position: relative;
  display: grid;
  gap: 16px;
}

label {
  color: #d8e2f2;
  font-size: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.input-card-head label {
  color: #ccd6e7;
  font-size: 13px;
  font-weight: 700;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.file-row input[type="file"] {
  display: none;
}

.file-picker {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px dashed rgba(113, 230, 255, 0.48);
  background: rgba(113, 230, 255, 0.07);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.file-picker:hover {
  border-color: rgba(113, 230, 255, 0.82);
  background: rgba(113, 230, 255, 0.11);
  transform: translateY(-1px);
}

.file-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 52px;
  height: 42px;
  border-radius: 7px;
  color: #06101c;
  font-weight: 900;
  font-size: 12px;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
}

.file-picker strong,
.file-picker small {
  display: block;
}

.file-picker small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

#template-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  min-width: 0;
}

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

select,
input,
textarea {
  width: 100%;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(2, 6, 16, .72);
  color: var(--text);
  border-radius: 7px;
  padding: 12px 13px;
  font: inherit;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(113, 230, 255, .08);
  background: rgba(4, 10, 22, .88);
}

textarea {
  min-height: 420px;
  resize: vertical;
  line-height: 1.62;
}

.input-card {
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(2, 6, 16, .42);
  border-radius: 8px;
  padding: 14px;
}

.input-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

button,
.download-button {
  min-height: 42px;
  border-radius: 7px;
  font-weight: 800;
  cursor: pointer;
}

button {
  border: 1px solid rgba(113, 230, 255, .56);
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  color: #06101c;
  padding: 10px 16px;
}

button:disabled {
  cursor: wait;
  opacity: .76;
}

.generate-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.button-spinner,
.status-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.28);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

.button-spinner {
  display: none;
  border-color: rgba(6,16,28,.24);
  border-top-color: #06101c;
}

.status-spinner {
  display: none;
  width: 34px;
  height: 34px;
  border-width: 3px;
  border-color: rgba(113,230,255,.18);
  border-top-color: var(--cyan);
  box-shadow: 0 0 28px rgba(113,230,255,.16);
}

body.is-generating .button-spinner {
  display: inline-block;
}

body.is-generating .status-spinner {
  display: block;
}

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

.progress-wrap {
  position: relative;
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #d8e2f2;
  font-size: 13px;
}

#progress-node {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track {
  width: 100%;
  height: 10px;
  border: 1px solid rgba(113, 230, 255, .24);
  background: rgba(255,255,255,.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--gold));
  transition: width .25s ease;
}

pre {
  position: relative;
  flex: 1;
  min-height: 260px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  line-height: 1.55;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(0,0,0,.22);
  border-radius: 8px;
  padding: 14px;
}

#links {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.download-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 1px solid rgba(113, 230, 255, .5);
  color: var(--cyan);
  text-decoration: none;
  padding: 10px 14px;
  background: rgba(113, 230, 255, .06);
}

.download-button.primary {
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  color: #06101c;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .file-row,
  .font-grid {
    grid-template-columns: 1fr;
  }

  .head,
  .status-head,
  .input-card-head {
    align-items: stretch;
    flex-direction: column;
  }
}
