@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-dim: #ca8a04;
  --stroke: rgba(250, 204, 21, 0.35);
  --text: #fafafa;
  --muted: #a3a3a3;
  --radius: 14px;
  --font: "Outfit", system-ui, sans-serif;
  --font-display: "Bebas Neue", sans-serif;
}

*,
*::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;
}

/* Satu layar: header + grid dua kolom */
.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: 1240px;
  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.68rem;
  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-text {
  flex: 1.15;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.card-studio > .card-head {
  flex-shrink: 0;
}

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

.card-studio-scroll .field {
  flex-shrink: 0;
}

.card-studio-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(250, 204, 21, 0.22);
  background: linear-gradient(180deg, rgba(8, 8, 8, 0.65) 0%, rgba(5, 5, 5, 0.98) 40%);
}

.card-studio-footer .actions {
  margin-top: 0;
}

.card-studio-footer .actions--generate-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

/* Tombol Generate utama — besar, tengah, menonjol */
.btn-generate-main {
  width: 100%;
  justify-content: center;
  gap: 0.55rem;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.85rem 1.5rem;
  border-radius: 14px;
  box-shadow:
    0 0 24px rgba(250, 204, 21, 0.5),
    0 0 48px rgba(250, 204, 21, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: box-shadow 0.2s, transform 0.12s, filter 0.2s;
}

.btn-generate-main:hover:not(:disabled) {
  box-shadow:
    0 0 32px rgba(250, 204, 21, 0.65),
    0 0 64px rgba(250, 204, 21, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transform: translateY(-1px);
}

.btn-generate-main:active:not(:disabled) {
  transform: translateY(0) scale(0.99);
}

.btn-generate-main:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

/* Tombol Batal — kecil, di bawah */
.btn-generate-cancel {
  font-size: 0.78rem;
  padding: 0.3rem 0.85rem;
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
  min-height: unset;
}

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

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

.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);
}

.card-head--text {
  align-items: flex-start;
}

.card-head-text-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.char-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--yellow-dim);
  letter-spacing: 0.04em;
}

.char-count strong {
  color: var(--yellow2);
  font-weight: 800;
  text-shadow: 0 0 8px rgba(250, 204, 21, 0.35);
}

.char-count .char-count-limit {
  font-weight: 600;
  color: var(--muted);
}

.char-count.char-count--split strong {
  color: #fde68a;
}

.char-count.char-count--split .char-count-limit,
.char-count .char-count-split {
  color: #fcd34d;
  font-weight: 600;
}

.text-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

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);
}

.card-text textarea {
  flex: 1;
  min-height: 0;
  resize: none;
  line-height: 1.5;
  overflow-y: auto;
}

.field {
  margin-bottom: 0.55rem;
}

.field:last-of-type {
  margin-bottom: 0.35rem;
}

.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);
}

.field-hint.hidden {
  display: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

.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;
  text-decoration: none;
}

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

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

.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 {
  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);
}

/* Tombol Stop di riwayat */
.btn-history-stop {
  background: linear-gradient(120deg, #f87171, #ef4444) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.4) !important;
}

.btn-history-stop:hover {
  box-shadow: 0 0 22px rgba(239, 68, 68, 0.55) !important;
}

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

.key-pill {
  font-size: 0.68rem;
  padding: 0.25rem 0.5rem;
  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);
}

.preview-wrap {
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.62);
  padding: 0.5rem 0.6rem;
}

.preview-wrap audio {
  width: 100%;
  display: block;
  min-height: 36px;
}

.preview-actions {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 0.55rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(250, 204, 21, 0.12);
}

/* Tombol unduh output: tengah, gaya glass + neon (terpisah dari .btn biasa) */
.btn-download-audio {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin: 0 auto;
  padding: 0.58rem 1.35rem 0.58rem 1.1rem;
  max-width: 100%;
  border: 1px solid rgba(253, 224, 71, 0.55);
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #0a0a0a;
  cursor: pointer;
  background: linear-gradient(145deg, #fef08a 0%, var(--yellow2) 38%, var(--yellow) 72%, #ca8a04 130%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(0, 0, 0, 0.35),
    0 0 24px rgba(250, 204, 21, 0.35),
    0 0 48px rgba(250, 204, 21, 0.12);
  transition: transform 0.18s ease, box-shadow 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
}

.btn-download-audio__icon {
  flex-shrink: 0;
  opacity: 0.92;
}

.btn-download-audio:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1),
    0 6px 22px rgba(0, 0, 0, 0.4),
    0 0 32px rgba(250, 204, 21, 0.5),
    0 0 64px rgba(250, 204, 21, 0.18);
}

.btn-download-audio:active:not(:disabled) {
  transform: translateY(0);
}

.btn-download-audio:focus-visible {
  outline: 2px solid var(--yellow2);
  outline-offset: 3px;
}

.btn-download-audio:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: saturate(0.65) brightness(0.95);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.link-quiet {
  flex-shrink: 0;
  margin: 0.4rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.link-quiet a {
  color: var(--yellow2);
}

.credits-banner {
  flex-shrink: 0;
  margin: 0 0 0.45rem;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.42);
  color: #fecaca;
  font-size: 0.78rem;
  line-height: 1.45;
}

.credits-banner a {
  color: #fde047;
  font-weight: 700;
}

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

/* Custom instructions textarea */
#fieldCustomInstructions textarea {
  resize: vertical;
  min-height: 68px;
  font-size: 0.82rem;
  line-height: 1.5;
}

/* Chunk preview info */
.chunk-preview {
  margin: 0 0 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  background: rgba(250, 204, 21, 0.06);
  border: 1px solid rgba(250, 204, 21, 0.28);
  font-size: 0.76rem;
  line-height: 1.5;
  color: #e5e5e5;
}

.chunk-preview strong {
  color: var(--yellow2);
}

.chunk-preview .chunk-preview-warn {
  display: block;
  margin-top: 0.3rem;
  color: #fcd34d;
  font-size: 0.72rem;
}

.chunk-preview.hidden {
  display: none;
}

.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: 1fr auto;
  gap: 0.4rem;
  align-items: start;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  border: 1px solid rgba(250, 204, 21, 0.22);
  background: rgba(0, 0, 0, 0.42);
}

.history-item-meta {
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.history-item-text {
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

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

.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-backdrop--download {
  z-index: 62;
}

.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-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;
}

.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.modal-confirm h3 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

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

.modal > p.modal-key-help {
  margin: 0 0 0.85rem;
  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;
  text-underline-offset: 2px;
}

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

.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: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.78rem;
  color: #e8e8e8;
  letter-spacing: 0.03em;
}

.api-key-row-detail {
  font-size: 0.74rem;
  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.6rem;
  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--exhausted {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.45);
}

.key-badge--invalid {
  color: #fde047;
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.38);
}

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

.key-badge--checking {
  color: var(--yellow2);
  background: rgba(250, 204, 21, 0.1);
  border-color: rgba(250, 204, 21, 0.32);
}

.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%;
  }
}

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

.hidden {
  display: none !important;
}

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

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

@media (max-height: 560px) and (min-width: 901px) {
  body.suaraku-app {
    overflow: auto;
    height: auto;
  }

  .app-shell {
    height: auto;
    max-height: none;
    min-height: 100dvh;
  }
}

/* ===== BOTTOM NAVBAR — mobile only ===== */
.sra-bottom-nav {
  display: none;
}

/* ===== MOBILE (≤ 900px): full-screen tab layout + bottom nav ===== */
@media (max-width: 900px) {
  body.suaraku-app {
    overflow: hidden;
    height: 100dvh;
    min-height: unset;
    -webkit-tap-highlight-color: transparent;
  }

  .suaraku-app .app-shell {
    height: 100dvh;
    max-height: 100dvh;
    min-height: unset;
    max-width: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* ruang untuk bottom nav + safe area */
    padding-bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
    padding-top: calc(0.35rem + env(safe-area-inset-top, 0px));
  }

  /* Header: 1 baris kompak */
  .suaraku-app .nav {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.75rem;
    margin: 0 -0.75rem;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid rgba(250, 204, 21, 0.15);
    background: rgba(3, 3, 3, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    gap: 0.5rem;
    flex-shrink: 0;
    margin-bottom: 0;
  }

  /* Brand lebih kecil di mobile */
  .suaraku-app .brand-mark {
    width: 36px !important;
    height: 36px !important;
    border-radius: 9px !important;
  }

  .suaraku-app .brand-mark img {
    border-radius: 9px !important;
  }

  .suaraku-app .app-title {
    font-size: 1.55rem;
  }

  .suaraku-app .byline {
    font-size: 0.72rem;
    margin-top: 0.1rem;
  }

  .suaraku-app .tag {
    display: none;
  }

  /* Sembunyikan nav-actions — digantikan bottom nav */
  .suaraku-app .nav-actions {
    display: none;
  }

  /* Workspace: 1 kolom, flex, isi sisa tinggi */
  .suaraku-app .workspace {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    grid-template-columns: 1fr;
    gap: 0;
    margin-top: 0.5rem;
  }

  /* Sembunyikan semua kolom */
  .suaraku-app .col-left,
  .suaraku-app .col-right {
    display: none;
  }

  /* Tampilkan kolom aktif — bisa di-scroll */
  .suaraku-app .col-left.sra-tab-active,
  .suaraku-app .col-right.sra-tab-active {
    display: flex;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    flex-direction: column;
    gap: 0;
  }

  /* Tab TEKS: 3 zona — Teks (atas), Studio (scroll tengah), Generate (bawah fixed) */
  .suaraku-app .col-left.sra-tab-active .card-text {
    flex: 1 1 0;
    min-height: 0;
    max-height: none;
    margin-bottom: 0.5rem;
  }

  .suaraku-app .col-left.sra-tab-active .card-studio {
    flex: 1.4 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 0;
  }

  /* Studio scroll: isi sisa ruang */
  .suaraku-app .col-left.sra-tab-active .card-studio .card-studio-scroll {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    max-height: none;
  }

  /* Footer Generate: selalu terlihat di bawah card studio */
  .suaraku-app .col-left.sra-tab-active .card-studio .card-studio-footer {
    flex-shrink: 0;
    padding: 0.55rem 0.9rem 0.6rem;
  }

  .suaraku-app .btn-generate-main {
    font-size: 0.9rem;
    padding: 0.7rem 1.2rem;
    border-radius: 12px;
  }

  /* Tab Output: scroll normal */
  .suaraku-app .col-right.sra-tab-active {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.75rem;
    gap: 0.65rem;
  }

  .suaraku-app .col-right.sra-tab-active .card-output {
    flex: 0 0 auto;
    min-height: 0;
  }

  /* Card umum di mobile */
  .suaraku-app .card {
    border-radius: 16px;
    padding: 0.8rem 0.9rem;
    box-shadow:
      0 0 0 1px rgba(250, 204, 21, 0.12),
      0 12px 32px rgba(0, 0, 0, 0.5);
  }
  .suaraku-app .btn {
    min-height: 38px;
    padding: 0.42rem 0.85rem;
    font-size: 0.82rem;
  }

  .suaraku-app .btn-sm {
    min-height: 32px;
    padding: 0.28rem 0.6rem;
    font-size: 0.72rem;
  }

  .suaraku-app .btn-download-audio {
    min-height: 42px;
    padding: 0.55rem 1.35rem 0.55rem 1.1rem;
    width: 100%;
    max-width: 320px;
  }

  .suaraku-app .preview-wrap audio {
    min-height: 48px;
  }

  /* History item: 1 kolom */
  .suaraku-app .history-item {
    grid-template-columns: 1fr;
    gap: 0.55rem;
    padding: 0.75rem 0.8rem;
  }

  .suaraku-app .history-item-actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  /* Modal */
  .suaraku-app .modal-confirm,
  .suaraku-app .modal {
    margin: 0.5rem;
    border-radius: 18px;
    max-height: 92dvh;
  }

  /* ===== Bottom navbar ===== */
  .sra-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(8, 8, 8, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(250, 204, 21, 0.15);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.55);
  }

  .sra-kbn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.22rem;
    padding: 0.5rem 0.25rem 0.45rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #6b7280;
    text-decoration: none;
    font-family: inherit;
    transition: color 0.18s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    min-height: 54px;
  }

  .sra-kbn-item:active {
    transform: scale(0.92);
  }

  .sra-kbn-item--active {
    color: var(--yellow2);
  }

  .sra-kbn-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform 0.18s;
  }

  .sra-kbn-item--active .sra-kbn-icon {
    filter: drop-shadow(0 0 6px rgba(250, 204, 21, 0.5));
  }

  .sra-kbn-label {
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1;
  }

  /* Dot indikator */
  .sra-kbn-dot {
    position: absolute;
    top: 7px;
    right: calc(50% - 13px);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f87171;
    border: 1.5px solid #080808;
  }

  .sra-kbn-dot.hidden {
    display: none;
  }

  /* Active indicator — garis atas */
  .sra-kbn-item--active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 18%;
    right: 18%;
    height: 2px;
    border-radius: 0 0 2px 2px;
    background: var(--yellow2);
    box-shadow: 0 0 8px rgba(250, 204, 21, 0.6);
  }

  /* Layar sangat kecil (≤ 360px) */
  @media (max-width: 360px) {
    .suaraku-app .app-title {
      font-size: 1.35rem;
    }

    .suaraku-app .brand-mark {
      width: 30px !important;
      height: 30px !important;
    }

    .suaraku-app .col-left.sra-tab-active .card-text {
      min-height: 110px;
      max-height: 30vh;
    }
  }
}


/* ===== MIXER PANEL ===== */
.mixer-panel {
  margin: 0.55rem 0 0;
  padding: 0.7rem 0.85rem 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(250, 204, 21, 0.3);
  background: linear-gradient(160deg, rgba(250, 204, 21, 0.05), rgba(0, 0, 0, 0.45));
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(250, 204, 21, 0.08);
}

.mixer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.mixer-title {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--yellow2);
  text-shadow: 0 0 10px rgba(250, 204, 21, 0.3);
}

.mixer-sliders {
  display: flex;
  flex-direction: column;
  gap: 0.48rem;
  margin-bottom: 0.65rem;
}

.mixer-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.2rem;
}

.mixer-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: default;
}

.mixer-val {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--yellow2);
  font-variant-numeric: tabular-nums;
  min-width: 3.8em;
  text-align: right;
}

/* Range slider — custom styled */
.mixer-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.18);
  outline: none;
  cursor: pointer;
  border: none;
  padding: 0;
  transition: background 0.15s;
}

.mixer-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--yellow2), var(--yellow));
  box-shadow: 0 0 8px rgba(250, 204, 21, 0.55), 0 1px 3px rgba(0,0,0,0.5);
  cursor: pointer;
  border: none;
  transition: transform 0.12s, box-shadow 0.15s;
}

.mixer-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.75), 0 1px 4px rgba(0,0,0,0.5);
}

.mixer-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--yellow2), var(--yellow));
  box-shadow: 0 0 8px rgba(250, 204, 21, 0.55);
  cursor: pointer;
  border: none;
}

.mixer-slider:focus-visible {
  outline: 2px solid rgba(250, 204, 21, 0.6);
  outline-offset: 2px;
  border-radius: 999px;
}

/* Track fill color — via CSS custom property set by JS */
.mixer-slider {
  background: linear-gradient(
    to right,
    rgba(250, 204, 21, 0.7) 0%,
    rgba(250, 204, 21, 0.7) var(--pct, 50%),
    rgba(250, 204, 21, 0.18) var(--pct, 50%),
    rgba(250, 204, 21, 0.18) 100%
  );
}

.mixer-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.mixer-status {
  margin: 0.45rem 0 0;
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--muted);
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  background: rgba(250, 204, 21, 0.06);
  border: 1px solid rgba(250, 204, 21, 0.2);
}

.mixer-status.mixer-status--error {
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.38);
  color: #fecaca;
}

.mixer-status.hidden {
  display: none;
}

/* Download button untuk mixer */
.btn-mixer-download-main {
  width: 100%;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-top: 0.3rem;
}

/* Toggle mixer button — di samping tombol download */
.btn-mixer-toggle {
  font-size: 0.7rem;
  padding: 0.28rem 0.6rem;
  letter-spacing: 0.04em;
  border-color: rgba(250, 204, 21, 0.35);
  color: var(--yellow-dim);
  gap: 0.3rem;
}

.btn-mixer-toggle.active {
  border-color: rgba(250, 204, 21, 0.65);
  color: var(--yellow2);
  background: rgba(250, 204, 21, 0.1);
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.18);
}

/* Mobile adjustments */
@media (max-width: 900px) {
  .mixer-panel {
    padding: 0.65rem 0.75rem 0.7rem;
  }

  .mixer-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .mixer-actions .btn {
    width: 100%;
    justify-content: center;
  }
}
/* ===== END MIXER PANEL ===== */
