:root {
  color-scheme: light;
  --ink: #0B1220;
  --green: #10B981;
  --green-strong: #059669;
  --teal: #14B8A6;
  --off-white: #F8FAFC;
  --surface: #FFFFFF;
  --neutral-100: #F1F5F9;
  --neutral-200: #E5E7EB;
  --neutral-400: #94A3B8;
  --neutral-600: #475569;
  --danger: #B42318;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --shadow-soft: 0 12px 40px rgba(11, 18, 32, .06);
  --content-max: 1180px;
  font-family: "IBM Plex Sans Arabic", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--off-white);
  color: var(--ink);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--off-white);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -16%, rgba(16, 185, 129, .08), transparent 34rem),
    var(--off-white);
  color: var(--ink);
}

button, textarea, input { font: inherit; }

button { color: inherit; }

a { color: inherit; text-decoration: none; }

button:focus-visible,
a:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(20, 184, 166, .36);
  outline-offset: 3px;
}

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

.app-shell { min-height: 100vh; }

.topbar {
  width: min(calc(100% - 48px), var(--content-max));
  min-height: 72px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid rgba(148, 163, 184, .18);
}

.brand {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px 4px 9px 4px;
  position: relative;
  background: var(--ink);
  overflow: hidden;
}

.brand-mark::after {
  content: "";
  position: absolute;
  width: 34px;
  height: 9px;
  left: -4px;
  top: 10px;
  transform: rotate(-28deg);
  border-radius: 999px;
  background: linear-gradient(90deg, #0F766E, var(--green), #5EEAD4);
}

.brand-name { font-size: 18px; }

.topnav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.nav-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  color: var(--neutral-600);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
}

.nav-link.is-active {
  color: var(--ink);
  background: rgba(255,255,255,.72);
  box-shadow: inset 0 0 0 1px rgba(148,163,184,.18);
}

.topbar-actions {
  justify-self: end;
  display: flex;
  align-items: center;
}

.status-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border: 1px solid rgba(148,163,184,.2);
  border-radius: 999px;
  background: rgba(255,255,255,.66);
  color: var(--neutral-600);
  font-size: 12px;
}

.status-pill.is-ready {
  color: #067647;
  border-color: rgba(16,185,129,.22);
  background: rgba(16,185,129,.08);
}

.status-pill.is-offline {
  color: var(--danger);
  background: rgba(180,35,24,.05);
  border-color: rgba(180,35,24,.16);
}

.create-hero {
  width: min(calc(100% - 48px), var(--content-max));
  margin: 0 auto;
  padding: 84px 0 72px;
  position: relative;
  isolation: isolate;
}

.hero-copy {
  max-width: 760px;
  margin: 0 auto 28px;
  text-align: center;
  position: relative;
  z-index: 2;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green-strong);
  font-size: 13px;
  font-weight: 700;
}

h1, h2, p { text-wrap: pretty; }

h1 {
  margin: 0;
  font-size: clamp(2.35rem, 5vw, 3.6rem);
  line-height: 1.15;
  letter-spacing: -.045em;
}

h1 span { color: var(--green-strong); }

.hero-subtitle {
  max-width: 620px;
  margin: 16px auto 0;
  color: var(--neutral-600);
  font-size: 17px;
  line-height: 1.9;
}

.composer {
  width: min(100%, 820px);
  margin: 0 auto;
  min-height: 196px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid rgba(148,163,184,.24);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.92);
  box-shadow: var(--shadow-soft);
  position: relative;
  z-index: 3;
  transition: border-color .22s ease, box-shadow .22s ease, transform .22s ease;
}

.composer:focus-within {
  border-color: rgba(16,185,129,.46);
  box-shadow: 0 16px 52px rgba(11,18,32,.08), 0 0 0 4px rgba(16,185,129,.06);
}

.composer.is-dragover {
  transform: translateY(-2px);
  border-color: rgba(16,185,129,.62);
  background:
    linear-gradient(rgba(255,255,255,.9), rgba(255,255,255,.9)),
    linear-gradient(115deg, #0F766E, var(--green), #5EEAD4);
}

textarea {
  width: 100%;
  min-height: 96px;
  padding: 0;
  resize: vertical;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.8;
}

textarea::placeholder { color: var(--neutral-400); }

.composer-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.tool-button,
.secondary-button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(148,163,184,.22);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.upload-note {
  color: var(--neutral-400);
  font-size: 12px;
}

.send-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-size: 22px;
  transition: transform .18s ease, background .18s ease, opacity .18s ease;
}

.send-button:not(:disabled):hover {
  transform: translateY(-1px);
  background: var(--green-strong);
}

.send-button:disabled {
  opacity: .28;
  cursor: default;
}

.asset-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.asset-chip {
  max-width: 100%;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 11px;
  background: var(--neutral-100);
  color: var(--neutral-600);
  font-size: 13px;
}

.asset-chip strong {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-weight: 600;
}

.asset-chip button {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--neutral-600);
  cursor: pointer;
}

.starter-section {
  width: min(100%, 980px);
  margin: 54px auto 0;
  position: relative;
  z-index: 2;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -.02em;
}

.section-heading p {
  margin: 0;
  color: var(--neutral-400);
  font-size: 12px;
}

.starter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.starter-card {
  min-height: 148px;
  padding: 14px;
  display: grid;
  grid-template-columns: 76px 1fr;
  align-items: center;
  gap: 14px;
  text-align: right;
  border: 1px solid rgba(148,163,184,.2);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.74);
  cursor: pointer;
  overflow: hidden;
  transition: transform .22s ease, border-color .22s ease, background .22s ease;
}

.starter-card:hover {
  transform: translateY(-2px);
  border-color: rgba(16,185,129,.34);
  background: #fff;
}

.starter-card.is-selected {
  border-color: rgba(16,185,129,.5);
  background: rgba(16,185,129,.055);
}

.starter-visual {
  width: 76px;
  height: 96px;
  position: relative;
  display: block;
  perspective: 220px;
}

.starter-frame {
  position: absolute;
  inset: 8px 10px;
  border-radius: 13px;
  border: 1px solid rgba(16,185,129,.24);
  background:
    linear-gradient(155deg, rgba(11,18,32,.92), rgba(11,18,32,.78)),
    var(--ink);
  transform: rotateY(-9deg) rotateX(4deg);
  box-shadow: 10px 14px 28px rgba(11,18,32,.12);
}

.starter-frame::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 12px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0F766E, var(--green), #5EEAD4);
}

.starter-dot {
  width: 12px;
  height: 12px;
  position: absolute;
  right: 3px;
  top: 18px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 8px rgba(16,185,129,.08);
}

.starter-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.starter-name {
  font-size: 15px;
  line-height: 1.45;
}

.starter-description {
  color: var(--neutral-600);
  font-size: 12px;
  line-height: 1.65;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.starter-meta {
  color: var(--green-strong);
  font-size: 11px;
  font-weight: 700;
}

.ambient-frame {
  position: absolute;
  z-index: -1;
  border: 1px solid rgba(16,185,129,.12);
  border-radius: 30px;
  pointer-events: none;
}

.ambient-frame-one {
  width: 230px;
  height: 310px;
  top: 108px;
  right: -24px;
  transform: perspective(900px) rotateY(-18deg) rotateZ(4deg);
}

.ambient-frame-two {
  width: 180px;
  height: 240px;
  top: 190px;
  left: 12px;
  opacity: .68;
  transform: perspective(900px) rotateY(18deg) rotateZ(-5deg);
}

.flow-line {
  position: absolute;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(20,184,166,.34), rgba(16,185,129,.4), transparent);
  pointer-events: none;
}

.flow-line-one {
  width: 260px;
  left: 4%;
  top: 320px;
  transform: rotate(-11deg);
}

.request-preview {
  width: min(calc(100% - 48px), 820px);
  margin: -24px auto 72px;
}

.preview-panel {
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--ink);
  color: #fff;
  box-shadow: 0 24px 70px rgba(11,18,32,.18);
}

.preview-panel h2 {
  margin: 0 0 12px;
  font-size: 28px;
}

.preview-panel #previewText {
  color: #D7E0EA;
  font-size: 16px;
  line-height: 1.8;
}

.preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.preview-meta > div {
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  background: rgba(255,255,255,.05);
}

.preview-meta dt {
  color: #8FA2B7;
  font-size: 10px;
}

.preview-meta dd {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 700;
}

.preview-note {
  color: #8FA2B7;
  font-size: 12px;
  line-height: 1.7;
}

.preview-panel .secondary-button {
  color: #fff;
  border-color: rgba(255,255,255,.16);
  background: rgba(255,255,255,.07);
}

@media (max-width: 860px) {
  .topbar {
    width: min(calc(100% - 28px), var(--content-max));
    grid-template-columns: 1fr auto;
  }

  .topnav { display: none; }

  .create-hero {
    width: min(calc(100% - 28px), var(--content-max));
    padding-top: 58px;
  }

  .starter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .ambient-frame,
  .flow-line { opacity: .45; }

  .request-preview { width: min(calc(100% - 28px), 820px); }
}

@media (max-width: 560px) {
  body { background: var(--off-white); }

  .topbar {
    min-height: 62px;
    border-bottom-color: rgba(148,163,184,.16);
  }

  .status-pill {
    max-width: 112px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .create-hero { padding: 46px 0 54px; }

  .hero-copy {
    margin-bottom: 22px;
    text-align: right;
  }

  h1 {
    font-size: clamp(2.15rem, 11vw, 2.8rem);
    line-height: 1.22;
  }

  .hero-subtitle {
    margin-top: 12px;
    font-size: 15px;
    line-height: 1.8;
  }

  .composer {
    min-height: 188px;
    padding: 16px;
    border-radius: 20px;
  }

  textarea {
    min-height: 102px;
    font-size: 16px;
  }

  .upload-note { display: none; }

  .starter-section { margin-top: 42px; }

  .section-heading {
    align-items: start;
    flex-direction: column;
    gap: 4px;
  }

  .starter-grid {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: 6px;
    scrollbar-width: none;
  }

  .starter-grid::-webkit-scrollbar { display: none; }

  .starter-card {
    min-width: min(84vw, 320px);
    scroll-snap-align: start;
  }

  .ambient-frame,
  .flow-line { display: none; }

  .preview-panel {
    padding: 22px;
    border-radius: 20px;
  }
}

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

  .starter-frame { transform: none; }
}
