:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #15202b;
  --ink-strong: #0b1220;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #e6fffb;
  --blue: #2563eb;
  --green: #15803d;
  --green-soft: #ecfdf3;
  --red: #b91c1c;
  --red-soft: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 18px 45px rgba(15, 23, 42, 0.08);
  --radius: 18px;
  --radius-sm: 11px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand);
}

button,
input,
select {
  font: inherit;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: #eef2f6;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  padding: 1px 5px;
  color: #334155;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.align-right {
  text-align: right !important;
}

/* Top bar */

.topbar {
  min-height: 74px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  color: #e2e8f0;
  background:
    radial-gradient(circle at 12% -80%, rgba(20, 184, 166, 0.42), transparent 52%),
    radial-gradient(circle at 74% -140%, rgba(37, 99, 235, 0.35), transparent 56%),
    #0b1220;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: linear-gradient(135deg, #2dd4bf, #0f766e 52%, #1d4ed8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), 0 8px 20px rgba(13, 148, 136, 0.28);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-copy strong {
  font-size: 16px;
  letter-spacing: -0.2px;
}

.brand-copy small {
  margin-top: 3px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-status {
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.12);
}

.inline-form {
  margin: 0 0 0 8px;
}

/* Layout */

.shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 44px 0 56px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 42px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  color: var(--ink-strong);
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.hero-copy {
  max-width: 660px;
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.stats {
  display: flex;
  flex-shrink: 0;
  gap: 10px;
}

.stat {
  min-width: 138px;
  padding: 14px 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 4px;
  color: var(--ink-strong);
  font-size: 25px;
  line-height: 1;
  letter-spacing: -0.03em;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(310px, 0.9fr);
  gap: 20px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.build-card {
  padding: 26px;
}

.result-card {
  position: sticky;
  top: 20px;
  min-height: 452px;
  padding: 26px;
}

.pages-card {
  margin-top: 20px;
  padding: 26px;
  overflow: hidden;
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.card-heading .eyebrow {
  margin-bottom: 5px;
}

.card-heading h2 {
  margin: 0;
  color: var(--ink-strong);
  font-size: 21px;
  letter-spacing: -0.025em;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 4px 10px;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-success {
  color: var(--green);
  background: var(--green-soft);
  border-color: #bbf7d0;
}

/* Form */

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.field input[type="text"],
.field input[type="password"],
.field select {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field select {
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, #64748b 50%),
    linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 20px,
    calc(100% - 13px) 20px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.field input:focus,
.field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.field input::placeholder {
  color: #94a3b8;
}

.field-hint {
  margin: 7px 0 0;
  color: var(--muted-light);
  font-size: 11.5px;
  line-height: 1.45;
}

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

.file-field {
  min-width: 0;
}

.file-field input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.dropzone {
  min-height: 132px;
  padding: 18px 12px;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.dropzone:hover,
.file-field:focus-within .dropzone {
  background: #f0fdfa;
  border-color: #5eead4;
}

.dropzone.has-file {
  background: var(--brand-soft);
  border-color: #5eead4;
}

.dropzone-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 3px;
  color: var(--brand);
  background: #ffffff;
  border: 1px solid #d5e5e2;
  border-radius: 11px;
  box-shadow: 0 3px 8px rgba(15, 118, 110, 0.08);
}

.dropzone-title {
  max-width: 100%;
  overflow: hidden;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropzone-meta {
  color: var(--muted-light);
  font-size: 10.5px;
  line-height: 1.4;
}

.dropzone.has-file .dropzone-title {
  color: var(--brand-dark);
}

/* Alerts and buttons */

.alert {
  margin: 2px 0 16px;
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.45;
}

.alert-error {
  color: #991b1b;
  background: var(--red-soft);
  border: 1px solid #fecaca;
}

.alert-success {
  color: #166534;
  background: var(--green-soft);
  border: 1px solid #bbf7d0;
}

.button {
  min-height: 40px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.button-primary {
  color: #ffffff;
  background: linear-gradient(180deg, #0f766e, #0d665f);
  border-color: #0b5f58;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.button-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #0d8a80, #0f766e);
}

.button-secondary {
  color: var(--brand-dark);
  background: #ffffff;
  border-color: #b9d9d5;
}

.button-secondary:hover:not(:disabled) {
  background: var(--brand-soft);
}

.button-ghost {
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(226, 232, 240, 0.2);
}

.button-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
}

.button-small {
  min-height: 32px;
  padding: 0 12px;
  font-size: 11.5px;
}

.button-full {
  width: 100%;
  min-height: 46px;
}

.button-publish {
  width: 100%;
  min-height: 48px;
  margin-top: 6px;
  font-size: 13px;
}

.button-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

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

/* Result panel */

.result-empty {
  min-height: 320px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background:
    radial-gradient(circle at 50% 20%, rgba(45, 212, 191, 0.08), transparent 55%),
    var(--surface-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
}

.result-empty h3 {
  margin: 18px 0 5px;
  color: #334155;
  font-size: 15px;
}

.result-empty p {
  max-width: 260px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.result-illustration {
  width: 120px;
  height: 76px;
  position: relative;
}

.result-illustration span {
  position: absolute;
  border-radius: 7px;
  background: linear-gradient(145deg, #ccfbf1, #f1f5f9);
  border: 1px solid #cbd5e1;
}

.result-illustration span:nth-child(1) {
  width: 70px;
  height: 44px;
  left: 8px;
  top: 14px;
  transform: rotate(-7deg);
}

.result-illustration span:nth-child(2) {
  width: 76px;
  height: 48px;
  right: 5px;
  top: 4px;
  background: linear-gradient(145deg, #dbeafe, #f8fafc);
  transform: rotate(5deg);
}

.result-illustration span:nth-child(3) {
  width: 88px;
  height: 52px;
  left: 17px;
  bottom: 2px;
  background: linear-gradient(145deg, #e0f2fe, #ecfdf5);
  border-color: #a7f3d0;
  transform: rotate(-1deg);
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.12);
}

.result-content {
  animation: rise 0.22s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.published-app {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.published-icon {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  object-fit: cover;
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.published-app-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.published-app-copy strong {
  overflow: hidden;
  color: var(--ink-strong);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.published-app-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
}

.result-label {
  display: block;
  margin: 20px 0 7px;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.copy-row {
  display: flex;
  gap: 8px;
}

.url-input {
  min-width: 0;
  width: 100%;
  height: 40px;
  padding: 0 11px;
  color: #0f766e;
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  font-family: var(--mono);
  font-size: 11px;
  outline: none;
}

.url-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.copy-helper {
  position: fixed;
  top: -1000px;
  left: -1000px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.live-link {
  margin-top: 13px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.live-link:hover {
  text-decoration: underline;
}

.result-details {
  margin: 22px 0 0;
  padding: 15px 0 0;
  border-top: 1px solid var(--line);
}

.result-details div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 0;
}

.result-details dt {
  color: var(--muted);
  font-size: 11.5px;
}

.result-details dd {
  margin: 0;
  color: #334155;
  font-family: var(--mono);
  font-size: 11px;
  text-align: right;
}

/* Pages table */

.pages-heading {
  margin-bottom: 16px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.pages-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  font-size: 12.5px;
}

.pages-table th {
  padding: 11px 14px;
  color: var(--muted);
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.pages-table td {
  padding: 13px 14px;
  border-bottom: 1px solid #edf2f7;
  vertical-align: middle;
}

.pages-table tr:last-child td {
  border-bottom: 0;
}

.pages-table tbody tr {
  transition: background 0.12s ease;
}

.pages-table tbody tr:hover {
  background: #fbfdfd;
}

.table-app {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 190px;
}

.table-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  object-fit: cover;
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.table-app-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.table-app-copy strong {
  max-width: 210px;
  overflow: hidden;
  color: #1e293b;
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-app-copy a {
  width: fit-content;
  color: var(--brand);
  font-size: 10.5px;
  font-weight: 600;
  text-decoration: none;
}

.table-app-copy a:hover {
  text-decoration: underline;
}

.template-pill {
  display: inline-block;
  max-width: 150px;
  overflow: hidden;
  padding: 4px 8px;
  color: #475569;
  background: #f1f5f9;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pages-table code {
  color: #475569;
  font-size: 10.5px;
}

.table-downloads {
  color: #334155;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.table-date {
  color: var(--muted);
  white-space: nowrap;
}

.row-actions {
  display: inline-flex;
  gap: 5px;
}

.button-mini {
  min-height: 30px;
  padding: 0 9px;
  color: #475569;
  background: #ffffff;
  border-color: var(--line-strong);
  font-size: 10.5px;
}

.button-mini:hover:not(:disabled) {
  color: var(--brand-dark);
  border-color: #99d5ce;
  background: var(--brand-soft);
}

.button-danger {
  color: var(--red);
  border-color: #fecaca;
}

.button-danger:hover:not(:disabled) {
  color: #991b1b;
  background: var(--red-soft);
  border-color: #fca5a5;
}

.table-loading,
.table-empty {
  padding: 45px 20px !important;
  color: var(--muted);
  text-align: center;
}

.table-empty {
  display: table-cell;
}

.table-empty strong {
  display: block;
  color: #334155;
  font-size: 13px;
}

.table-empty span {
  display: block;
  margin-top: 5px;
  font-size: 11.5px;
}

.table-error {
  color: var(--red) !important;
}

/* Footer and toast */

.footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 0 0 30px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted-light);
  font-size: 11px;
}

.footer code {
  font-size: 10px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 16px;
  color: #ecfdf5;
  background: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  box-shadow: 0 20px 42px rgba(15, 23, 42, 0.24);
  font-size: 12.5px;
  line-height: 1.4;
  animation: toast-in 0.18s ease-out;
}

.toast.toast-error {
  color: #fee2e2;
  background: #450a0a;
  border-color: #7f1d1d;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Login */

.auth-body {
  min-height: 100vh;
  padding: 30px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 18% 12%, rgba(45, 212, 191, 0.18), transparent 32%),
    radial-gradient(circle at 86% 88%, rgba(37, 99, 235, 0.15), transparent 34%),
    #eef2f6;
}

.auth-card {
  width: min(410px, 100%);
  padding: 34px;
  background: #ffffff;
  border: 1px solid rgba(203, 213, 225, 0.86);
  border-radius: 20px;
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.14);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 27px;
  color: var(--ink-strong);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-brand .brand-mark {
  width: 34px;
  height: 34px;
  font-size: 11px;
}

.auth-card h1 {
  margin: 0;
  color: var(--ink-strong);
  font-size: 28px;
  letter-spacing: -0.04em;
}

.auth-copy {
  margin: 10px 0 22px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.auth-form .field {
  margin-bottom: 16px;
}

.auth-form .field input {
  height: 48px;
}

.auth-foot {
  margin: 19px 0 0;
  color: var(--muted-light);
  font-size: 10.5px;
  line-height: 1.5;
  text-align: center;
}

.auth-card .button-full {
  margin-top: 4px;
}

/* Responsive */

@media (max-width: 980px) {
  .hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 20px;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .result-card {
    position: static;
    min-height: 0;
  }

  .result-empty {
    min-height: 230px;
  }
}

@media (max-width: 680px) {
  .topbar {
    min-height: 66px;
    padding: 0 16px;
  }

  .topbar-status,
  .status-dot {
    display: none;
  }

  .brand-copy small {
    display: none;
  }

  .shell {
    width: min(100% - 24px, 1180px);
    padding: 28px 0 42px;
  }

  .hero h1 {
    font-size: 32px;
  }

  .hero-copy {
    font-size: 13.5px;
  }

  .stats {
    width: 100%;
  }

  .stat {
    min-width: 0;
    flex: 1;
  }

  .build-card,
  .result-card,
  .pages-card {
    padding: 18px;
    border-radius: 15px;
  }

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

  .dropzone {
    min-height: 105px;
  }

  .copy-row {
    flex-direction: column;
  }

  .copy-row .button {
    width: 100%;
  }

  .footer {
    width: calc(100% - 24px);
    flex-direction: column;
    gap: 5px;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    max-width: calc(100vw - 24px);
  }

  .auth-card {
    padding: 26px 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
