/* ---------- Base / reset ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f172a;
  --card-bg: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --border: #e5e7eb;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 16px;
}

/* ---------- Card layout ---------- */
.card {
  background: var(--card-bg);
  width: 100%;
  max-width: 880px;
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "header  header"
    "controls preview";
  gap: 28px;
}

.card__header {
  grid-area: header;
  text-align: center;
}

.card__header h1 {
  font-size: 1.9rem;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 540px;
  margin: 0 auto;
}

/* ---------- Controls ---------- */
.controls {
  grid-area: controls;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field__label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
}

textarea:focus,
input[type="range"]:focus,
input[type="color"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.clear-btn {
  align-self: flex-start;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f9fafb;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.clear-btn:hover {
  background: #f3f4f6;
  color: var(--text);
}

.colors {
  display: flex;
  gap: 16px;
}

.field--color {
  flex: 1;
}

input[type="color"] {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: none;
  cursor: pointer;
}

/* ---------- Preview ---------- */
.preview {
  grid-area: preview;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.preview__frame {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 2px dashed var(--border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: #f9fafb;
}

canvas {
  max-width: 90%;
  max-height: 90%;
  height: auto;
  display: none; /* hidden until there's something to show */
}

.empty-hint {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 0 20px;
}

.error-message {
  display: none;
  color: #b91c1c;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  padding: 0 20px;
}

/* ---------- Download buttons ---------- */
.download-row {
  display: flex;
  gap: 12px;
  width: 100%;
}

.download-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.download-btn--secondary {
  background: #475569;
}

.download-btn__hint {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.85;
}

.download-btn:hover:not(:disabled) {
  background: var(--accent-dark);
}

.download-btn--secondary:hover:not(:disabled) {
  background: #334155;
}

.download-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  opacity: 0.7;
}

/* ---------- WorldTech call-to-action ---------- */
.cta {
  width: 100%;
  max-width: 880px;
  background: #ffffff;
  border-radius: 16px;
  border: 2px solid #0159fb; /* WorldTech blue */
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 10px 30px rgba(1, 89, 251, 0.18);
}

.cta__logo {
  height: 38px;
  width: auto;
  flex-shrink: 0;
}

.cta__text {
  flex: 1;
}

.cta__title {
  font-size: 1rem;
  font-weight: 700;
  color: #001134; /* WorldTech navy */
}

.cta__sub {
  font-size: 0.88rem;
  color: #51607a;
  margin-top: 2px;
}

.cta__btn {
  flex-shrink: 0;
  background: #0159fb;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 11px 22px;
  border-radius: 10px;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.cta__btn:hover {
  background: #0146c8;
}

/* ---------- Footer ---------- */
.page-footer {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
}

.page-footer a {
  color: #fff;
  font-weight: 600;
}

/* ---------- CTA on mobile ---------- */
@media (max-width: 680px) {
  .cta {
    flex-direction: column;
    text-align: center;
    gap: 14px;
  }
}

/* ---------- Mobile ---------- */
@media (max-width: 680px) {
  .card {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "preview"
      "controls";
    padding: 24px;
  }
}
