@import url("https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Outfit:wght@300;400;500;600;700;800&display=swap");

:root {
  --black: #030303;
  --black2: #0a0a0a;
  --yellow: #facc15;
  --yellow2: #fde047;
  --yellow-soft: #fef08a;
  --yellow-dim: #ca8a04;
  --stroke: rgba(250, 204, 21, 0.35);
  --stroke-soft: rgba(250, 204, 21, 0.18);
  --text: #fafafa;
  --muted: #a3a3a3;
  --radius: 14px;
  --font: "Outfit", system-ui, sans-serif;
  --font-display: "Bebas Neue", sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "Cascadia Code", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--text);
  background: var(--black);
  background-image:
    radial-gradient(ellipse 100% 70% at 50% -25%, rgba(250, 204, 21, 0.16), transparent 52%),
    radial-gradient(ellipse 50% 45% at 100% 40%, rgba(250, 204, 21, 0.05), transparent 50%),
    linear-gradient(180deg, var(--black2) 0%, var(--black) 50%, #000 100%);
}

.grid-glow {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(250, 204, 21, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(250, 204, 21, 0.028) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 75% 55% at 50% 15%, black, transparent);
  z-index: 0;
}

/* Layout shell: full viewport with two columns */
.app-shell {
  position: relative;
  z-index: 1;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(0.45rem + env(safe-area-inset-top, 0px)) calc(0.65rem + env(safe-area-inset-right, 0px))
    calc(0.5rem + env(safe-area-inset-bottom, 0px)) calc(0.65rem + env(safe-area-inset-left, 0px));
  max-width: 1280px;
  margin: 0 auto;
}

.nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.45rem;
  margin-bottom: 0.45rem;
  border-bottom: 1px solid var(--stroke);
  box-shadow: 0 1px 0 rgba(250, 204, 21, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-mark {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--yellow2), var(--yellow-dim));
  display: grid;
  place-items: center;
  box-shadow:
    0 0 20px rgba(250, 204, 21, 0.5),
    0 0 40px rgba(250, 204, 21, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.brand-mark svg {
  width: 26px;
  height: 26px;
  color: var(--black);
}

.app-title {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 4.2vw, 2.65rem);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
  line-height: 1;
  color: var(--yellow2);
  text-shadow:
    0 0 10px rgba(253, 224, 71, 0.85),
    0 0 24px rgba(250, 204, 21, 0.45),
    0 0 48px rgba(202, 138, 4, 0.28);
}

.byline {
  margin: 0.28rem 0 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.tag {
  margin: 0.15rem 0 0;
  font-size: 0.66rem;
  color: var(--yellow-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.65rem;
  align-items: stretch;
}

.col {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.card {
  background: linear-gradient(165deg, rgba(250, 204, 21, 0.055), rgba(0, 0, 0, 0.52));
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.45),
    0 12px 36px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(250, 204, 21, 0.1);
}

.card-source,
.card-output {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding-right: 2px;
}

.card-footer {
  flex-shrink: 0;
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(250, 204, 21, 0.22);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  flex-shrink: 0;
}

.card-head-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/**
 * Card-head khusus untuk Prompt Hasil: 3 kolom (title · hero Salin · actions).
 * Salin sengaja diletakkan di tengah dengan warna emas + neon glow agar
 * jadi call-to-action utama setelah prompt jadi.
 */
.card-head-result {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.6rem;
}

.card-head-result h2 {
  grid-column: 1;
}

.card-head-result .btn-copy-hero {
  grid-column: 2;
  justify-self: center;
}

.card-head-result .card-head-actions {
  grid-column: 3;
}

/* Tombol Salin hero — emas dengan neon glow */
.btn-copy-hero {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1.15rem;
  border-radius: 999px;
  border: 1px solid rgba(253, 224, 71, 0.55);
  background: linear-gradient(135deg, #fde047 0%, #facc15 55%, #ca8a04 100%);
  color: #0a0a0a;
  font-family: var(--font);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 0 0 2px rgba(250, 204, 21, 0.18) inset,
    0 0 14px rgba(250, 204, 21, 0.55),
    0 0 28px rgba(250, 204, 21, 0.25);
  transition:
    transform 0.15s ease,
    box-shadow 0.25s ease,
    filter 0.2s ease;
  white-space: nowrap;
}

.btn-copy-hero svg {
  color: #0a0a0a;
}

.btn-copy-hero:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow:
    0 0 0 2px rgba(250, 204, 21, 0.28) inset,
    0 0 22px rgba(253, 224, 71, 0.85),
    0 0 44px rgba(250, 204, 21, 0.4);
  filter: brightness(1.06);
}

.btn-copy-hero:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
  box-shadow:
    0 0 0 2px rgba(250, 204, 21, 0.32) inset,
    0 0 18px rgba(253, 224, 71, 0.7);
}

.btn-copy-hero:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.35);
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.15) inset;
}

/* Animasi pulse halus saat tombol baru aktif (prompt jadi). */
.btn-copy-hero:not(:disabled) {
  animation: copyHeroPulse 2.6s ease-in-out infinite;
}

@keyframes copyHeroPulse {
  0%, 100% {
    box-shadow:
      0 0 0 2px rgba(250, 204, 21, 0.18) inset,
      0 0 14px rgba(250, 204, 21, 0.5),
      0 0 28px rgba(250, 204, 21, 0.2);
  }
  50% {
    box-shadow:
      0 0 0 2px rgba(250, 204, 21, 0.22) inset,
      0 0 20px rgba(253, 224, 71, 0.75),
      0 0 38px rgba(250, 204, 21, 0.35);
  }
}

.btn-reset {
  color: #fde047;
  border-color: rgba(250, 204, 21, 0.35);
  background: rgba(250, 204, 21, 0.04);
}

.btn-reset:hover:not(:disabled) {
  background: rgba(250, 204, 21, 0.12);
  border-color: rgba(253, 224, 71, 0.6);
  color: #fef9c3;
}

#resultBox[contenteditable="true"] {
  outline: none;
  cursor: text;
  background: rgba(250, 204, 21, 0.04);
  border: 1px solid rgba(250, 204, 21, 0.45);
  box-shadow:
    0 0 0 2px rgba(250, 204, 21, 0.12),
    0 0 14px rgba(250, 204, 21, 0.08);
  caret-color: #fde047;
}

.card-head--tight {
  margin-top: 0.35rem;
  margin-bottom: 0.35rem;
}

.card-head h2 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--yellow2);
  text-shadow: 0 0 12px rgba(250, 204, 21, 0.3);
}

/* Tab toggle (file / youtube) */
.tab-toggle {
  display: inline-flex;
  padding: 3px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--stroke-soft);
  border-radius: 999px;
}

.tab-toggle .tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.2s, background 0.2s, box-shadow 0.2s;
}

.tab-toggle .tab:hover {
  color: var(--yellow2);
}

.tab-toggle .tab[aria-selected="true"] {
  background: linear-gradient(120deg, var(--yellow), var(--yellow2));
  color: var(--black);
  box-shadow: 0 0 18px rgba(250, 204, 21, 0.45);
}

.tab-pane.hidden {
  display: none;
}

/* Model selector */
.model-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  margin-bottom: 0.55rem;
  background: linear-gradient(145deg, rgba(250, 204, 21, 0.08), rgba(0, 0, 0, 0.4));
  border: 1px solid var(--stroke-soft);
  border-radius: 10px;
}

.model-label {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--yellow-dim);
  margin: 0;
  padding-right: 0.35rem;
  border-right: 1px solid var(--stroke-soft);
}

.model-label svg {
  color: var(--yellow2);
}

.model-select {
  padding: 0.4rem 0.6rem !important;
  background:
    rgba(0, 0, 0, 0.55)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fde047' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>")
    no-repeat right 0.55rem center / 14px 14px !important;
  background-size: 14px 14px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--yellow2);
  padding-right: 2rem !important;
}

.model-select option {
  background: #0a0a0a;
  color: #fef9c3;
}

/* Dropzone — kompak */
.dropzone {
  border: 1.5px dashed var(--stroke);
  border-radius: 12px;
  background:
    radial-gradient(ellipse at top, rgba(250, 204, 21, 0.05), transparent 60%),
    rgba(0, 0, 0, 0.42);
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.25s, box-shadow 0.25s, transform 0.15s;
  outline: none;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--yellow);
  background:
    radial-gradient(ellipse at top, rgba(250, 204, 21, 0.1), transparent 60%),
    rgba(20, 16, 0, 0.45);
  box-shadow: 0 0 18px rgba(250, 204, 21, 0.18);
}

.dropzone.is-dragging {
  border-color: var(--yellow);
  background: rgba(250, 204, 21, 0.1);
  box-shadow: 0 0 24px rgba(250, 204, 21, 0.32);
}

.dropzone-inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.7rem;
  text-align: left;
}

.dropzone-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(253, 224, 71, 0.22), rgba(202, 138, 4, 0.18));
  color: var(--yellow2);
  border: 1px solid rgba(250, 204, 21, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.dropzone-text {
  min-width: 0;
  flex: 1;
}

.dropzone-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.dropzone-sub {
  margin: 0.15rem 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.3;
}

.yt-row {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}

.yt-row input[type="text"] {
  flex: 1;
  min-width: 0;
}

.yt-row .btn {
  white-space: nowrap;
}

@media (max-width: 520px) {
  .yt-row {
    flex-direction: column;
  }
  .yt-row .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Preview block */
.preview {
  margin-top: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.preview.hidden {
  display: none;
}

.preview-frame {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--stroke);
  box-shadow: 0 0 18px rgba(250, 204, 21, 0.1);
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
}

.preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.preview-clear {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  border: 1px solid rgba(248, 113, 113, 0.5);
  background: rgba(0, 0, 0, 0.65);
  color: #fecaca;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.2s, transform 0.12s;
}

.preview-clear:hover {
  background: rgba(248, 113, 113, 0.25);
}

.preview-clear:active {
  transform: scale(0.95);
}

.preview-badge {
  position: absolute;
  left: 0.55rem;
  bottom: 0.55rem;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--yellow2);
  border: 1px solid var(--stroke);
  text-transform: uppercase;
  backdrop-filter: blur(6px);
}

.preview-meta {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--font-mono);
  word-break: break-all;
}

/* Prompt customizers (instruksi tambahan & negative prompt) */
.prompt-grid {
  margin-top: 0.65rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

@media (max-width: 720px) {
  .prompt-grid {
    grid-template-columns: 1fr;
  }
}

.field-sm {
  margin-bottom: 0;
}

.field-sm label {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--yellow-dim);
  margin-bottom: 0.3rem;
}

.field-sm label svg {
  color: var(--yellow2);
  flex-shrink: 0;
}

.field-sm label.label-danger {
  color: #fca5a5;
}

.field-sm label.label-danger svg {
  color: #fca5a5;
}

.field-sm textarea {
  resize: vertical;
  min-height: 54px;
  max-height: 160px;
  font-size: 0.78rem;
  line-height: 1.4;
  padding: 0.45rem 0.6rem;
}

.field-sm:has(.label-danger) textarea {
  border-color: rgba(248, 113, 113, 0.32);
}

.field-sm:has(.label-danger) textarea:focus {
  border-color: rgba(248, 113, 113, 0.85);
  box-shadow:
    0 0 0 2px rgba(248, 113, 113, 0.18),
    0 0 14px rgba(248, 113, 113, 0.12);
}

/* Inputs */
textarea,
select,
input[type="password"],
input[type="text"] {
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus,
select:focus,
input:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.18), 0 0 16px rgba(250, 204, 21, 0.1);
}

.field {
  margin-bottom: 0.55rem;
}

.field label {
  display: block;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--yellow-dim);
  margin-bottom: 0.28rem;
}

.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--muted);
}

/* Buttons */
.btn {
  border: 1px solid var(--stroke);
  background: rgba(250, 204, 21, 0.06);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: box-shadow 0.2s, border-color 0.2s, background 0.2s, transform 0.12s, opacity 0.2s;
  text-decoration: none;
}

.btn:hover:not(:disabled) {
  border-color: var(--yellow);
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.22);
  background: rgba(250, 204, 21, 0.09);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(120deg, var(--yellow), var(--yellow2));
  color: var(--black);
  border: none;
  font-weight: 800;
  box-shadow: 0 0 18px rgba(250, 204, 21, 0.4);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 0 26px rgba(250, 204, 21, 0.55);
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
  background: rgba(248, 113, 113, 0.08);
}

.btn-sm {
  padding: 0.28rem 0.55rem;
  font-size: 0.72rem;
}

.btn-generate {
  flex: 1;
  justify-content: center;
  padding: 0.65rem 1rem;
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.btn-generate .spinner {
  margin-right: 0.35rem;
}

/* Key status pill */
.key-pill {
  font-size: 0.68rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.12);
  color: var(--yellow2);
  border: 1px solid var(--stroke);
}

.key-pill.missing {
  background: rgba(248, 113, 113, 0.1);
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.4);
}

/* Credit pill */
.credit-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem 0.25rem 0.45rem;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.16), rgba(202, 138, 4, 0.1));
  color: var(--yellow-soft);
  border: 1px solid rgba(250, 204, 21, 0.4);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  letter-spacing: 0.02em;
}

.credit-pill:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(253, 224, 71, 0.28), rgba(202, 138, 4, 0.18));
  border-color: rgba(253, 224, 71, 0.7);
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.25);
}

.credit-pill:active:not(:disabled) {
  transform: scale(0.97);
}

.credit-pill:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.credit-pill-icon,
.credit-pill-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--yellow2);
}

.credit-pill-label {
  text-transform: uppercase;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  color: var(--yellow-dim);
}

.credit-pill-value {
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--yellow2);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  min-width: 1.5em;
  text-align: right;
}

.credit-pill.is-loading .credit-pill-value {
  animation: creditShimmer 1.1s ease-in-out infinite;
}

.credit-pill.is-loading .credit-pill-refresh svg {
  animation: creditSpin 0.85s linear infinite;
}

.credit-pill.is-error {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}

.credit-pill.is-error .credit-pill-icon,
.credit-pill.is-error .credit-pill-refresh,
.credit-pill.is-error .credit-pill-value {
  color: #fca5a5;
}

.credit-pill.is-error .credit-pill-label {
  color: #fca5a5;
}

.credit-pill.is-low {
  background: linear-gradient(135deg, rgba(251, 146, 60, 0.22), rgba(202, 138, 4, 0.15));
  border-color: rgba(251, 146, 60, 0.5);
}

.credit-pill.is-low .credit-pill-value {
  color: #fdba74;
}

@keyframes creditShimmer {
  0%,
  100% { opacity: 1; }
  50%   { opacity: 0.45; }
}

@keyframes creditSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}

/* Output result */
.result-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.6);
  padding: 0.85rem 1rem;
  scrollbar-gutter: stable;
}

#resultBox {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.55;
  color: #fef3c7;
  white-space: pre-wrap;
  word-break: break-word;
}

#resultBox.result-empty {
  font-family: inherit;
  color: var(--muted);
  display: grid;
  place-items: center;
  min-height: 120px;
}

#resultBox.result-empty p {
  margin: 0;
  text-align: center;
  font-size: 0.86rem;
  line-height: 1.55;
}

#resultBox.result-error {
  color: #fecaca;
  font-family: inherit;
  font-size: 0.88rem;
}

#resultBox.result-error strong {
  color: #fee2e2;
}

/* Kolom hasil — state "generate" ala tombol fry + efek proses */
#resultBox.result-loading {
  font-family: inherit;
  display: block;
  min-height: min(220px, 38vh);
  padding: 0.25rem 0.15rem 0.5rem;
}

.result-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.65rem;
  padding: 0.5rem 0.35rem 0.35rem;
}

.result-loading-visual {
  position: relative;
  width: 88px;
  height: 88px;
  margin-bottom: 0.15rem;
}

.result-loading-orbit {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px dashed rgba(250, 204, 21, 0.35);
  animation: resultOrbitSpin 10s linear infinite;
  box-shadow: 0 0 24px rgba(250, 204, 21, 0.12);
}

.result-loading-orbit::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid transparent;
  border-top-color: rgba(253, 224, 71, 0.55);
  border-right-color: rgba(250, 204, 21, 0.15);
  animation: resultOrbitSpin 2.8s linear infinite reverse;
}

.result-loading-core {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, rgba(253, 224, 71, 0.35), rgba(15, 12, 8, 0.92));
  border: 1px solid rgba(250, 204, 21, 0.55);
  box-shadow:
    0 0 20px rgba(250, 204, 21, 0.35),
    inset 0 0 18px rgba(0, 0, 0, 0.45);
  animation: resultCorePulse 1.6s ease-in-out infinite;
}

.result-loading-bolt {
  font-size: 1.75rem;
  line-height: 1;
  filter: drop-shadow(0 0 10px rgba(250, 204, 21, 0.9));
  animation: resultBoltShake 2.2s ease-in-out infinite;
}

.result-loading-title {
  font-size: clamp(0.95rem, 2.8vw, 1.15rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fde047;
  text-shadow:
    0 0 18px rgba(250, 204, 21, 0.55),
    0 0 40px rgba(250, 204, 21, 0.2);
  line-height: 1.25;
  max-width: 22rem;
}

.result-loading-sub {
  font-size: 0.84rem;
  line-height: 1.45;
  color: #fef9c3;
  max-width: 24rem;
  text-decoration: underline;
  text-decoration-color: rgba(250, 204, 21, 0.45);
  text-underline-offset: 0.2em;
}

.result-loading-bar {
  width: min(100%, 280px);
  height: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
  margin-top: 0.15rem;
}

.result-loading-bar > span {
  display: block;
  height: 100%;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(250, 204, 21, 0.15), #fde047, rgba(253, 224, 71, 0.2));
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.65);
  animation: resultBarSweep 1.35s ease-in-out infinite;
}

.result-loading-foot {
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(253, 224, 71, 0.55);
  margin-top: 0.15rem;
  max-width: 26rem;
  line-height: 1.4;
}

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

@keyframes resultCorePulse {
  0%,
  100% { transform: scale(1); box-shadow: 0 0 20px rgba(250, 204, 21, 0.35), inset 0 0 18px rgba(0, 0, 0, 0.45); }
  50%    { transform: scale(1.04); box-shadow: 0 0 28px rgba(250, 204, 21, 0.5), inset 0 0 14px rgba(0, 0, 0, 0.35); }
}

@keyframes resultBoltShake {
  0%,
  100% { transform: rotate(-4deg) scale(1); }
  50%    { transform: rotate(5deg) scale(1.06); }
}

@keyframes resultBarSweep {
  0%   { transform: translateX(-100%); opacity: 0.85; }
  50%  { transform: translateX(40%); opacity: 1; }
  100% { transform: translateX(220%); opacity: 0.85; }
}

@keyframes resultLoadingTick {
  0%   { opacity: 0.35; transform: translateY(4px); filter: blur(1px); }
  35%  { opacity: 1; transform: translateY(0); filter: blur(0); }
  100% { opacity: 1; transform: translateY(0); filter: blur(0); }
}

@keyframes resultLoadingSubtick {
  0%   { opacity: 0.4; }
  30%  { opacity: 1; }
  100% { opacity: 1; }
}

.result-loading-title.result-loading-tick {
  animation: resultLoadingTick 0.55s ease-out forwards;
}

.result-loading-sub.result-loading-subtick {
  animation: resultLoadingSubtick 0.45s ease-out forwards;
}

@media (prefers-reduced-motion: reduce) {
  .result-loading-orbit,
  .result-loading-orbit::after,
  .result-loading-core,
  .result-loading-bolt,
  .result-loading-bar > span,
  .result-loading-title.result-loading-tick,
  .result-loading-sub.result-loading-subtick {
    animation: none !important;
  }
}

.studio-notice {
  margin: 0 0 0.55rem;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  background: rgba(250, 204, 21, 0.08);
  border: 1px solid rgba(250, 204, 21, 0.42);
  color: #fef9c3;
  font-size: 0.78rem;
  line-height: 1.45;
}

.studio-notice.is-error {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.4);
  color: #fecaca;
}

/* History */
.history-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  scrollbar-gutter: stable;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.history-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 0.55rem;
  align-items: start;
  padding: 0.5rem 0.6rem;
  border-radius: 12px;
  border: 1px solid rgba(250, 204, 21, 0.22);
  background: rgba(0, 0, 0, 0.42);
  transition: border-color 0.2s, transform 0.12s;
}

.history-item:hover {
  border-color: rgba(250, 204, 21, 0.5);
}

.history-thumb {
  width: 64px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: #000;
  border: 1px solid var(--stroke-soft);
}

.history-body {
  min-width: 0;
}

.history-meta {
  font-size: 0.62rem;
  color: var(--yellow-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

.history-meta .src-pill {
  font-size: 0.55rem;
  font-weight: 800;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.18);
  color: var(--yellow2);
  border: 1px solid var(--stroke);
}

.history-meta .src-pill.src-youtube {
  background: rgba(248, 113, 113, 0.16);
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.4);
}

.history-meta .model-tag {
  margin-left: auto;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.08);
  color: var(--yellow-dim);
  border: 1px solid var(--stroke-soft);
}

.history-text {
  font-size: 0.74rem;
  color: var(--text);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-actions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.empty-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  padding: 0.85rem 0.5rem;
  line-height: 1.5;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop--confirm {
  z-index: 60;
}

.modal {
  width: min(440px, 100%);
  max-height: 90dvh;
  overflow-y: auto;
  background: linear-gradient(165deg, #141414, #0a0a0a);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: 0 0 36px rgba(250, 204, 21, 0.12);
}

.modal h3 {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: 0.06em;
  color: var(--yellow2);
  text-shadow: 0 0 12px rgba(250, 204, 21, 0.35);
}

.modal > p {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.modal--keys {
  width: min(500px, 100%);
}

.modal-lead {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.provider-switch {
  display: flex;
  gap: 0.35rem;
  margin: 0 0 0.85rem;
  padding: 0.25rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(250, 204, 21, 0.14);
}

.provider-tab {
  flex: 1;
  margin: 0;
  padding: 0.45rem 0.5rem;
  border: none;
  border-radius: 9px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  transition: background 0.15s, color 0.15s;
}

.provider-tab:hover {
  color: var(--text);
}

.provider-tab.is-active {
  color: #0a0a0a;
  background: linear-gradient(135deg, var(--yellow2), #f59e0b);
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.25);
}

.provider-panel .panel-hint {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.provider-panel .field-google-key {
  margin-bottom: 0.35rem;
}

.modal-key-help {
  margin: 0.4rem 0 0;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: rgba(250, 204, 21, 0.06);
  border: 1px solid rgba(250, 204, 21, 0.22);
  color: #e5e5e5;
  font-size: 0.8rem;
  line-height: 1.5;
}

.modal-key-help a {
  color: var(--yellow2);
  font-weight: 700;
  text-decoration: none;
}

.modal-key-help a:hover {
  text-decoration: underline;
}

.modal-key-help code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--yellow-soft);
  background: rgba(0, 0, 0, 0.45);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

.api-key-list {
  max-height: min(280px, 42vh);
  overflow-y: auto;
  margin: 0 0 0.65rem;
  padding: 0.35rem;
  border-radius: 10px;
  border: 1px solid rgba(250, 204, 21, 0.15);
  background: rgba(0, 0, 0, 0.35);
}

.api-key-empty {
  margin: 0.45rem 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.api-key-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.6rem;
  margin-bottom: 0.4rem;
  border-radius: 10px;
  border: 1px solid rgba(250, 204, 21, 0.18);
  background: rgba(10, 10, 10, 0.85);
}

.api-key-row:last-child {
  margin-bottom: 0;
}

.api-key-row--active {
  border-color: rgba(250, 204, 21, 0.45);
  box-shadow: 0 0 18px rgba(250, 204, 21, 0.12);
}

.api-key-row-main {
  flex: 1 1 200px;
  min-width: 0;
}

.api-key-row-line1 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.22rem;
}

.api-key-mask {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #e8e8e8;
  letter-spacing: 0.03em;
}

.api-key-row-detail {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.42;
  word-break: break-word;
}

.api-key-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
  align-items: center;
}

.key-badge {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.18rem 0.42rem;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.key-badge--ok {
  color: #86efac;
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(74, 222, 128, 0.42);
}

.key-badge--error {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.45);
}

.key-badge--unknown {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}

/* Pill kredit per-key di modal */
.api-key-credit {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.api-key-credit.is-ok {
  color: var(--yellow2);
  background: rgba(250, 204, 21, 0.12);
  border-color: rgba(250, 204, 21, 0.4);
}

.api-key-credit.is-low {
  color: #fdba74;
  background: rgba(251, 146, 60, 0.14);
  border-color: rgba(251, 146, 60, 0.42);
}

.api-key-credit.is-depleted {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.5);
}

.api-key-credit.is-error {
  color: #fca5a5;
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.35);
}

.api-key-credit.loading {
  animation: creditShimmer 1.1s ease-in-out infinite;
}

.field-add-key {
  margin-bottom: 0.25rem;
}

.api-key-add-row {
  display: flex;
  gap: 0.45rem;
  align-items: stretch;
}

.api-key-add-row input[type="password"] {
  flex: 1;
  min-width: 0;
}

.modal-add-error {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: #fecaca;
  line-height: 1.35;
}

.modal-add-error.hidden {
  display: none;
}

@media (max-width: 420px) {
  .api-key-add-row {
    flex-direction: column;
  }
  .api-key-add-row .btn {
    width: 100%;
    justify-content: center;
  }
}

.modal-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}

.modal-confirm {
  text-align: center;
  max-width: 400px;
  padding: 1.5rem 1.35rem 1.25rem;
  border: 1px solid rgba(250, 204, 21, 0.45);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 0 48px rgba(250, 204, 21, 0.12),
    0 24px 48px rgba(0, 0, 0, 0.55);
}

.modal-confirm-visual {
  width: 64px;
  height: 64px;
  margin: 0 auto 0.85rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--black);
  background: linear-gradient(145deg, var(--yellow2), var(--yellow-dim));
  box-shadow:
    0 0 24px rgba(250, 204, 21, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.modal.modal-confirm h3 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.modal-confirm-desc {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
  text-align: center;
  white-space: pre-line;
}

.modal-actions--confirm {
  justify-content: center;
  gap: 0.65rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: max(1.2rem, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: linear-gradient(120deg, var(--yellow), var(--yellow2));
  color: var(--black);
  font-weight: 800;
  font-size: 0.82rem;
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.55),
    0 0 28px rgba(250, 204, 21, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  letter-spacing: 0.04em;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.is-error {
  background: linear-gradient(120deg, #fca5a5, #fecaca);
}

.hidden {
  display: none !important;
}

/* Spinner */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-top-color: var(--black);
  border-radius: 50%;
  animation: vtp-spin 0.65s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

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

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-thumb {
  background: rgba(250, 204, 21, 0.28);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(250, 204, 21, 0.5);
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* Mobile / narrow layout */
@media (max-width: 900px) {
  body.vtp-app {
    overflow: auto;
    height: auto;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
  }

  .app-shell {
    height: auto;
    max-height: none;
    min-height: 100dvh;
    max-width: none;
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
  }

  /* Nav header sengaja dibikin satu baris ringkas — Beranda/Pengaturan
     dipindah ke bottom-nav. Rule detail ada di blok terakhir media query ini. */
  .nav {
    border-radius: 0 0 14px 14px;
    border: 1px solid rgba(250, 204, 21, 0.2);
    border-top: none;
    margin-left: -0.15rem;
    margin-right: -0.15rem;
    margin-bottom: 0.55rem;
    background: linear-gradient(180deg, rgba(250, 204, 21, 0.06), transparent);
  }

  .credit-pill-value {
    font-size: 0.72rem;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: 0;
    gap: 0.85rem;
  }

  .card {
    border-radius: 18px;
    padding: 0.85rem 0.95rem;
    box-shadow:
      0 0 0 1px rgba(250, 204, 21, 0.12),
      0 16px 40px rgba(0, 0, 0, 0.5);
  }

  .card-source,
  .card-output {
    min-height: 0;
    max-height: none;
  }

  .card-body {
    max-height: none;
  }

  .result-wrap {
    min-height: 180px;
  }

  .btn {
    min-height: 44px;
    padding: 0.55rem 1rem;
  }

  .btn-sm {
    min-height: 36px;
    padding: 0.4rem 0.75rem;
  }

  .dropzone {
    padding: 1.4rem 0.85rem;
  }

  .history-item {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .history-thumb {
    width: 100%;
    height: 110px;
  }

  .history-actions {
    flex-direction: row;
    justify-content: flex-end;
  }

  .modal,
  .modal-confirm {
    margin: 0.5rem;
    border-radius: 18px;
  }

  /* Card-head Sumber Visual: title di atas, actions di bawah (mobile) */
  .card-head {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .card-head-actions {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  /* Card-head Prompt Hasil: ubah jadi stack vertikal — title + Salin hero + actions */
  .card-head-result {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    row-gap: 0.55rem;
  }

  .card-head-result h2,
  .card-head-result .btn-copy-hero,
  .card-head-result .card-head-actions {
    grid-column: 1;
  }

  .card-head-result .btn-copy-hero {
    width: 100%;
    justify-self: stretch;
    justify-content: center;
    padding: 0.7rem 1rem;
    font-size: 0.85rem;
    min-height: 48px;
  }

  .card-head-result .card-head-actions {
    justify-content: space-between;
    gap: 0.35rem;
  }

  .card-head-result .card-head-actions .btn-sm {
    flex: 1 1 0;
    justify-content: center;
    min-height: 40px;
  }

  /* Dropzone: kompak — icon di atas, teks di bawah, center alignment */
  .dropzone {
    padding: 1.1rem 0.85rem;
  }

  .dropzone-inner {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
  }

  .dropzone-text {
    text-align: center;
  }

  /* YouTube row: tombol di bawah biar input dapet ruang lega */
  .yt-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .yt-row .btn {
    width: 100%;
  }

  /* Tab-toggle: ikutin lebar penuh, tombol-tombol membesar */
  .tab-toggle {
    width: 100%;
  }

  .tab-toggle .tab {
    flex: 1;
    justify-content: center;
    padding: 0.5rem 0.6rem;
    font-size: 0.7rem;
  }

  /* Result box: bigger padding agar nyaman dibaca di HP */
  #resultBox {
    font-size: 0.8rem;
    line-height: 1.5;
    padding: 0.85rem;
  }

  /* Model selector: stack label di atas select */
  .model-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .model-label {
    border-right: none;
    padding-right: 0;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--stroke-soft);
  }

  /* Tombol generate full-width + lebih besar untuk tap target */
  .btn-generate {
    width: 100%;
    min-height: 52px;
    font-size: 0.9rem;
  }

  /* Congrats banner: kecilkan padding biar muat di layar HP */
  .congrats-banner {
    padding: 1.1rem 1.3rem;
    max-width: 90vw;
  }

  .congrats-text {
    font-size: clamp(1.8rem, 9vw, 3rem);
  }
}

/* ============================================================
 * Bottom navigation (mobile only)
 * Default: tersembunyi di desktop. Aktif di <= 900px lewat media query.
 * ============================================================ */
.bottom-nav {
  display: none;
}

@media (max-width: 900px) {
  /* Sembunyikan tombol "Beranda" & "Pengaturan" di top nav — sudah dipindah ke bottom-nav. */
  .nav-actions > a.btn,
  .nav-actions > button.btn {
    display: none;
  }

  /* Header brand jadi 1 baris kompak — logo + judul saja. By Imam Januar dipertahankan kecil. */
  .nav {
    flex-direction: row;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.7rem;
    margin-bottom: 0.45rem;
  }

  .brand {
    flex: 0 0 auto;
    align-items: center;
    flex-direction: row;
    gap: 0.55rem;
    padding: 0;
  }

  .app-title {
    font-size: 1.1rem !important;
    letter-spacing: 0.06em;
  }

  .byline {
    font-size: 0.6rem !important;
    margin: 0.05rem 0 0;
  }

  .brand-mark {
    width: 36px !important;
    height: 36px !important;
  }

  /* nav-actions sekarang hanya bawa credit pill + key pill, tampilkan inline tight */
  .nav-actions {
    flex: 1;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .nav-actions .credit-pill,
  .nav-actions .key-pill {
    flex: 0 1 auto;
    min-height: 32px;
    font-size: 0.62rem;
    padding: 0.22rem 0.5rem;
  }

  /* Beri ruang di bawah workspace supaya tidak ketutup bottom-nav. */
  .workspace {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 0.5rem);
  }

  /* Bottom navigation muncul */
  .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.2rem;
    padding: 0.4rem 0.5rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(10, 10, 10, 0.92), rgba(3, 3, 3, 0.98));
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid rgba(250, 204, 21, 0.3);
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.55);
  }

  .bottom-nav-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.18rem;
    padding: 0.4rem 0.4rem;
    background: transparent;
    border: 0;
    border-radius: 12px;
    color: var(--muted);
    font-family: var(--font);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.18s, background 0.18s, transform 0.12s;
    -webkit-tap-highlight-color: transparent;
  }

  .bottom-nav-item svg {
    color: inherit;
    transition: transform 0.18s, filter 0.18s;
  }

  .bottom-nav-item:hover,
  .bottom-nav-item:active,
  .bottom-nav-item:focus-visible {
    color: var(--yellow2);
    background: rgba(250, 204, 21, 0.06);
    outline: none;
  }

  .bottom-nav-item:active {
    transform: scale(0.96);
  }

  .bottom-nav-item:active svg {
    transform: scale(0.92);
    filter: drop-shadow(0 0 8px rgba(250, 204, 21, 0.6));
  }

  .bottom-nav-badge {
    position: absolute;
    top: 0.25rem;
    right: 30%;
    min-width: 16px;
    padding: 0 4px;
    height: 16px;
    border-radius: 999px;
    background: var(--yellow);
    color: #0a0a0a;
    font-size: 0.55rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 0, 0, 0.4);
  }
}

/* Ekstra ringkas untuk layar sangat kecil (≤ 420px) */
@media (max-width: 420px) {
  .nav-actions .btn,
  .nav-actions .key-pill,
  .nav-actions .credit-pill {
    flex: 1 1 100%;
  }

  .card-head-result .card-head-actions .btn-sm span {
    font-size: 0.68rem;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }

  .card {
    padding: 0.7rem 0.75rem;
  }
}

/* ============================================================
 * Celebrate — congrats banner + confetti
 * ============================================================ */
.congrats-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.28s ease;
}

.congrats-overlay.is-show {
  opacity: 1;
}

.congrats-banner {
  position: absolute;
  top: 36%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  text-align: center;
  padding: 1.5rem 2.4rem;
  border-radius: 22px;
  background:
    radial-gradient(ellipse at top, rgba(250, 204, 21, 0.32), transparent 65%),
    linear-gradient(160deg, rgba(0, 0, 0, 0.92), rgba(20, 14, 0, 0.88));
  border: 1.5px solid rgba(253, 224, 71, 0.5);
  box-shadow:
    0 0 0 1px rgba(250, 204, 21, 0.18) inset,
    0 30px 60px -20px rgba(0, 0, 0, 0.7),
    0 0 60px rgba(250, 204, 21, 0.35);
  opacity: 0;
  animation-fill-mode: forwards;
}

.congrats-overlay.is-show .congrats-banner {
  animation: congratsPop 2.4s cubic-bezier(0.22, 1.4, 0.42, 1) forwards;
}

@keyframes congratsPop {
  0%   { opacity: 0; transform: translate(-50%, -45%) scale(0.55) rotate(-3deg); }
  18%  { opacity: 1; transform: translate(-50%, -50%) scale(1.08) rotate(1.5deg); }
  35%  { transform: translate(-50%, -50%) scale(0.98) rotate(-0.8deg); }
  55%  { transform: translate(-50%, -50%) scale(1.02) rotate(0deg); }
  85%  { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -56%) scale(0.96) rotate(0deg); }
}

.congrats-glow {
  position: absolute;
  inset: -40px;
  background:
    radial-gradient(circle at 30% 30%, rgba(253, 224, 71, 0.35), transparent 55%),
    radial-gradient(circle at 70% 70%, rgba(248, 113, 113, 0.18), transparent 55%);
  filter: blur(28px);
  z-index: -1;
  border-radius: 50%;
  animation: congratsGlow 1.6s ease-in-out infinite alternate;
}

@keyframes congratsGlow {
  from { opacity: 0.55; transform: scale(0.92); }
  to   { opacity: 0.95; transform: scale(1.08); }
}

.congrats-text {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 7vw, 4.6rem);
  letter-spacing: 0.08em;
  line-height: 1;
  background: linear-gradient(180deg, #fffbeb 0%, #fde047 45%, #ca8a04 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 26px rgba(250, 204, 21, 0.6);
  filter: drop-shadow(0 6px 14px rgba(250, 204, 21, 0.35));
}

.congrats-sub {
  margin-top: 0.45rem;
  font-family: var(--font);
  font-size: clamp(0.7rem, 1.6vw, 0.92rem);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--yellow-soft);
  opacity: 0.85;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  left: 0;
  width: var(--w);
  height: var(--h);
  background: var(--c);
  border-radius: 2px;
  transform: translate(var(--cx), -30px) rotate(0deg);
  opacity: 0;
  animation: confettiFall var(--dur) cubic-bezier(0.18, 0.78, 0.32, 1) var(--delay) forwards;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.25);
  will-change: transform, opacity;
}

@keyframes confettiFall {
  0%   { opacity: 0; transform: translate(var(--cx), -30px) rotate(0deg) scale(0.6); }
  8%   { opacity: 1; transform: translate(var(--cx), 8vh) rotate(calc(var(--rot) * 0.2)) scale(1); }
  100% {
    opacity: 0;
    transform: translate(calc(var(--cx) + var(--ex)), var(--ey)) rotate(var(--rot)) scale(0.85);
  }
}

@media (prefers-reduced-motion: reduce) {
  .congrats-overlay.is-show .congrats-banner {
    animation: none;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  .confetti-piece {
    animation: none;
    display: none;
  }
}
