:root {
  --blue:#1e6fff;
  --blue2:#3d9fff;
  --bg:#f6f8fc;
  --surface:#ffffff;
  --ink:#0f1e33;
  --muted:#5b6b82;
  --line:#dbe4f0;
  --radius:14px;
  --green:#1a9e54;
  --amber:#b7791f;
  --red:#c0392b;
  color-scheme: light;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  color: #1457ce;
  text-decoration: underline;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgb(30 111 255 / 30%);
  outline-offset: 2px;
}

img,
video,
svg {
  max-width: 100%;
}

.topnav {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 16px;
}

.brand {
  flex: 0 0 auto;
  color: var(--blue);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  text-decoration: none;
}

.brand:hover {
  color: var(--blue);
  text-decoration: none;
}

.navlinks {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 18px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  white-space: nowrap;
}

.navlinks::-webkit-scrollbar {
  display: none;
}

.navlinks a {
  position: relative;
  flex: 0 0 auto;
  padding: 8px 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.navlinks a:hover,
.navlinks a.active {
  color: #1457ce;
}

.navlinks a.active::after {
  position: absolute;
  right: 0;
  bottom: 2px;
  left: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--blue);
  content: "";
}

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

.section {
  padding: 32px 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: -0.035em;
}

h1 {
  margin-bottom: 16px;
  font-size: clamp(2rem, 8vw, 2.8rem);
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.5rem, 5vw, 2rem);
}

h3 {
  margin-bottom: 8px;
  font-size: 1.15rem;
}

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

.hero {
  padding: 56px 0;
  background: linear-gradient(145deg, #e7f1ff 0%, #f2f7ff 48%, #fff 100%);
}

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

.hero p {
  max-width: 640px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 1.05rem;
}

.btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  text-decoration: none;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.btn-primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.btn-primary:hover {
  border-color: #1457ce;
  background: #1457ce;
  color: #fff;
}

.btn-ghost {
  border-color: var(--blue);
  background: #fff;
  color: var(--blue);
}

.btn-ghost:hover {
  background: #f0f6ff;
  color: #1457ce;
}

.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px;
  box-shadow: 0 4px 16px rgb(15 30 51 / 5%);
}

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

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #e8f1ff;
  color: #1457ce;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.4;
}

.badge {
  padding: 4px 10px;
}

.badge-pro {
  background: #e8f1ff;
  color: #1457ce;
}

.badge-free {
  background: #e6f6ec;
  color: #16733f;
}

.pill {
  padding: 6px 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
  color: var(--ink);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #8996a8;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 3px rgb(30 111 255 / 14%);
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.tabs button {
  flex: 0 0 auto;
  border: 0;
  border-radius: 9px;
  background: transparent;
  padding: 8px 14px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.tabs button:hover {
  background: #eef4fc;
  color: var(--ink);
}

.tabs button.active {
  background: var(--blue);
  color: #fff;
}

.price-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 22px;
  box-shadow: 0 4px 16px rgb(15 30 51 / 5%);
}

.price-card.featured {
  border: 2px solid var(--blue);
  box-shadow: 0 10px 28px rgb(30 111 255 / 13%);
}

.price-card .price {
  color: var(--ink);
  font-size: 2.3rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1.1;
}

.price-card ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.price-card li::before {
  margin-right: 9px;
  color: var(--green);
  content: "✓";
  font-weight: 800;
}

.task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.task-row:last-child {
  border-bottom: 0;
}

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

.st-processing {
  color: var(--blue);
}

.st-succeeded {
  color: var(--green);
}

.st-failed {
  color: var(--red);
}

.alert {
  border-radius: 12px;
  padding: 14px 16px;
}

.alert-warn {
  border: 1px solid #e8c97d;
  background: #fff7df;
  color: #795512;
}

.footer {
  margin-top: 32px;
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 24px 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer a {
  color: var(--blue);
}

.toast {
  position: fixed;
  z-index: 50;
  right: 16px;
  bottom: 20px;
  left: 16px;
  width: max-content;
  max-width: calc(100% - 32px);
  margin: 0 auto;
  border-radius: 999px;
  background: #142033;
  padding: 11px 18px;
  color: #fff;
  box-shadow: 0 8px 28px rgb(15 30 51 / 22%);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 180ms ease, visibility 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (min-width: 640px) {
  .container {
    padding-right: 24px;
    padding-left: 24px;
  }

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

  .hero {
    padding: 76px 0;
  }

  .topnav {
    padding-right: 24px;
    padding-left: 24px;
  }

  .footer {
    padding-right: 24px;
    padding-left: 24px;
  }
}

@media (min-width: 960px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hero {
    padding: 96px 0;
  }

  .hero h1 {
    font-size: clamp(3rem, 5vw, 4.25rem);
  }

  .navlinks {
    overflow: visible;
  }
}

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

/* === Studio + Story — gộp từ <style> inline 18/11/2026 (Bước 2) === */
.studio-page { width: min(920px, calc(100% - 32px)); margin: 34px auto 48px; }
.studio-intro { margin: 6px 0 22px; color: var(--muted); }

.studio-tabs { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 18px; }
.studio-tabs .tab {
  flex: 1;
  min-width: 105px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.studio-tabs .tab.active { color: white; border-color: var(--blue); background: var(--blue); }

.mode-panel { display: none; }
.mode-panel.active { display: block; }
.mode-description { margin: 0 0 20px; color: var(--muted); }
.field-title { display: block; margin-bottom: 8px; font-weight: 700; }

.studio-page textarea,
.studio-page input[type="url"] {
  display: block;
  width: 100%;
  padding: 13px 14px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  outline: none;
}
.studio-page textarea { min-height: 150px; resize: vertical; }
.studio-page textarea:focus,
.studio-page input:focus {
  border-color: var(--blue2);
  box-shadow: 0 0 0 3px rgba(61, 159, 255, .12);
}
.hint, .subnote { margin: 7px 0 0; color: var(--muted); font-size: 13px; }

.studio-ratio-grid { display: grid; grid-template-columns: repeat(5, minmax(52px, 1fr)); gap: 8px; }
.studio-ratio {
  padding: 9px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.studio-ratio.active { color: white; background: var(--blue); border-color: var(--blue); }

.studio-upload-box { padding: 15px; border: 1px dashed #aebed2; border-radius: 11px; background: #fbfdff; }
.studio-page input[type="file"] { max-width: 100%; color: var(--muted); font: inherit; }
.studio-file-count { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.studio-file-error { min-height: 20px; margin: 4px 0 0; color: #c53030; font-size: 13px; }
.studio-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.studio-previews img { width: 68px; height: 68px; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; }

.studio-submit-row { margin-top: 18px; }
.studio-task-section { margin-top: 26px; }
.studio-task-section h2 { margin: 0 0 12px; font-size: 20px; }
.studio-task-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.studio-task-main { min-width: 0; }
.studio-task-meta { color: var(--muted); font-size: 12px; }
.studio-task-prompt { overflow-wrap: anywhere; font-size: 14px; }
.studio-status-free { display: inline-block; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #245a9f; background: #eaf3ff; }
.studio-limit-note { margin-top: 20px; padding: 14px; color: var(--muted); background: #f4f7fb; border-radius: 10px; font-size: 13px; }

.story-intro { max-width: 680px; margin: 0 0 26px; color: var(--muted); }
.story-main { width: min(1180px, calc(100% - 36px)); margin: 42px auto 64px; }
.story-thumb {
  height: 180px;
  display: grid;
  place-items: center;
  margin-bottom: 13px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #1e6fff, #3d9fff);
  color: white;
  font-size: 20px;
  font-weight: 750;
  text-align: center;
  padding: 16px;
}
.story-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.story-note { margin: 22px 0 0; color: var(--muted); font-size: 14px; }
#recipePanel { display: none; margin-top: 24px; }
#recipeText { white-space: pre-wrap; color: var(--ink); }

@media (max-width: 560px) {
  .studio-page { margin-top: 26px; }
  .studio-ratio-grid { gap: 5px; }
  .studio-ratio { padding: 8px 4px; font-size: 13px; }
  .story-actions .btn { flex: 1 1 auto; }
}
/* === TTS + Upscale + Watermark — gộp từ <style> inline 18/11/2026 (Bước 2) === */
.tts-page {
  width: min(760px, calc(100% - 32px));
  margin: 16px auto;
  display: grid;
  gap: 16px;
}

.upscale-page {
  width: min(760px, calc(100% - 32px));
  margin: 24px auto;
  display: grid;
  gap: 16px;
}

.upscale-page small {
  display: block;
  color: var(--muted);
  margin-top: 8px;
}

.watermark-page .card {
  width: min(900px, calc(100% - 28px));
  margin: 24px auto;
  padding: 22px;
}

.tts-page #demoNote {
  background: #eef5ff;
}

.watermark-page #wmNote {
  background: #eef5ff;
  border: 1px solid #d5e6ff;
  color: #26476f;
}

.dropzone {
  border: 2px dashed var(--border);
  padding: 24px;
  text-align: center;
  border-radius: var(--radius);
  color: var(--muted);
}

.upscale-preview-img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
}

#preview {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  touch-action: none;
}