:root {
  --bg: #f2f7fc;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --sky: #0ea5e9;
  --accent: #059669;
  --accent-hover: #047857;
  --orange: #ea580c;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 16px;
  --shadow-card: 0 14px 36px rgba(15, 23, 42, 0.06);
  --shadow-soft: 0 4px 14px rgba(15, 23, 42, 0.05);
  --font: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'Cascadia Code', 'Consolas', 'Courier New', monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top right, #e0f2fe 0%, #f2f7fc 42%, #f8fafc 100%);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.48;
  min-height: 100%;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Top Navbar — matching Portfolio header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 22px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 14px rgba(15, 23, 42, 0.05);
  position: sticky;
  top: 0;
  z-index: 30;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  display: grid;
  place-items: center;
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.28);
}

.brand h1 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.15;
}

.subtitle-tag {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--primary);
  text-transform: uppercase;
}

/* Stepper */
.stepper {
  display: flex;
  gap: 5px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.step-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: #475569;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.16s ease;
}

.step-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.85);
}

.step-btn.active {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.28);
}

.step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e2e8f0;
  color: var(--text);
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

.step-btn.active .step-num {
  background: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Ocean-Blue Hero Strip (Portfolio Signature Header) */
.hero-banner {
  position: relative;
  background: linear-gradient(115deg, #075985 0%, #0284c7 52%, #0ea5e9 100%);
  color: #ffffff;
  padding: 18px 22px 50px;
  margin-bottom: -26px;
  overflow: hidden;
}

.hero-inner {
  position: relative;
  z-index: 2;
  max-width: 1500px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-left {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.32);
  color: #e0f2fe;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.hero-title-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-title {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.hero-role {
  font-size: 13px;
  font-weight: 700;
  color: #fed7aa;
}

.hero-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.hero-curve {
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 36px;
  display: block;
  pointer-events: none;
}

/* Workspace Layout */
.workspace {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr 376px;
  gap: 18px;
  max-width: 1540px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px 26px;
  flex: 1;
  align-items: start;
}

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

.panel-main {
  min-width: 0;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

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

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-card);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
}

.card-head h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Forms */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.form-row label {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

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

.inline-group {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 8px;
}

.palette-builder {
  display: grid;
  grid-template-columns: 1.2fr auto 1.3fr;
  gap: 8px;
  align-items: center;
}

.color-pickers {
  display: flex;
  gap: 4px;
}

.color-pickers input[type="color"] {
  width: 32px;
  height: 34px;
  padding: 2px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  cursor: pointer;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.mini-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
}

.mini-chip:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: #f0f9ff;
}

.flow-steps {
  margin: 10px 0 14px 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--text);
  font-size: 13px;
}

.flow-steps li {
  line-height: 1.5;
}

.mb-8 {
  margin-bottom: 8px;
}

.prompt-summary-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  margin-bottom: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
}

.swatch-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(15, 23, 42, 0.2);
  vertical-align: middle;
}

.model-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 4px;
}

@media (max-width: 760px) {
  .model-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.model-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 7px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.model-card:hover {
  border-color: var(--primary);
  background: #f8fbff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.model-card.active {
  border-color: var(--primary);
  background: #f0f9ff;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.22);
}

.model-card strong {
  font-size: 11.5px;
  line-height: 1.2;
  color: var(--text);
}

.model-card small {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.25;
}

.mc-thumb {
  width: 100%;
  height: 46px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 12px;
  margin-bottom: 3px;
  border: 1px solid rgba(15, 23, 42, 0.12);
}

.mc-kapsul {
  background: linear-gradient(180deg, #38bdf8 0%, #84cc16 42%, #0891b2 43%, #0e7490 100%);
  color: #fef08a;
  text-shadow: 0 1px 3px #000;
  font-size: 11px;
}

.mc-teknik {
  background: linear-gradient(180deg, #f2efe9 0%, #f2efe9 36%, #6ea54f 37%, #6ea54f 66%, #8c6136 67%, #5a748a 100%);
  color: #1f7a6e;
  font-size: 11px;
}

.mc-diorama {
  background: linear-gradient(180deg, #6ca6df 0%, #6ca6df 48%, #4d8b49 49%, #4d8b49 68%, #5c3a21 69%, #3e2412 100%);
  color: #facc15;
  text-shadow: 0 1px 3px #000;
}

.mc-iso {
  background: linear-gradient(135deg, #1e293b 0%, #0284c7 55%, #f59e0b 100%);
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.mc-scribble {
  background: repeating-linear-gradient(0deg, #d7efe6, #d7efe6 7px, #c4e2d7 8px);
  color: #1f2937;
}

.mc-ui {
  background: linear-gradient(135deg, #f8fafc, #e2e8f0);
  color: #0284c7;
}

.mc-blueprint {
  background: linear-gradient(135deg, #0b3b75, #0f4c96);
  color: #e0f2fe;
  font-family: var(--mono);
}

.mc-futuristik {
  background: radial-gradient(circle, #1e293b, #0f172a);
  color: #22d3ee;
  border-color: #22d3ee;
}

.mc-retro {
  background: linear-gradient(180deg, #1a0b2e 0%, #ff2a85 75%, #ffd60a 100%);
  color: #fff;
}

.mc-garissatu {
  background: #ffffff;
  color: #18181b;
  font-size: 20px;
}

.mc-papercut {
  background: linear-gradient(180deg, #f5f2e8 60%, #34a87c 61%);
  color: #1f2937;
}

.mc-custom {
  background: linear-gradient(135deg, #f472b6, #ec4899);
  color: #fff;
}

/* Cerita Berkelanjutan (Series Multi-Part) */
.series-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.series-outline-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 12px;
}

.series-outline-box summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--primary);
}

.series-parts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 410px;
  overflow-y: auto;
  padding-right: 4px;
}

.series-part-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  transition: border-color 0.15s, background 0.15s;
}

.series-part-card.active {
  border-color: var(--accent);
  background: #ecfdf5;
}

.series-part-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.series-part-title {
  font-weight: 700;
  font-size: 12.5px;
  flex: 1;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 8px 11px;
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.14);
}

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

.code-area {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  tab-size: 2;
  background: #0f172a;
  color: #e2e8f0;
  border-color: #334155;
}

.code-area::placeholder {
  color: #64748b;
}

.prompt-output {
  background: #0f172a;
  color: #e2e8f0;
  border-color: #334155;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.16s ease;
  color: var(--text);
  background: #f1f5f9;
  user-select: none;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

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

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-lg {
  padding: 11px 20px;
  font-size: 14px;
  border-radius: 11px;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.24);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
}

.btn-accent {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.24);
}

.btn-danger {
  background: var(--danger);
  border-color: transparent;
  color: #ffffff;
}

.btn-ghost {
  background: #ffffff;
  border-color: var(--border-strong);
  color: #1e293b;
}

.btn-ghost:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn-row-tight {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Pills & Badges */
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.meta-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 7px;
  background: #ffffff;
  border: 1px solid var(--border);
  color: #475569;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 10px 0;
}

code {
  font-family: var(--mono);
  background: #e2e8f0;
  color: #0f172a;
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 11.5px;
}

/* Draft Scenes */
.draft-scenes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 540px;
  overflow-y: auto;
  padding-right: 4px;
}

.draft-scene-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
}

.draft-scene-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.draft-scene-head strong {
  font-size: 13px;
  color: var(--primary);
}

/* Studio Layout */
.studio-layout {
  display: grid;
  grid-template-columns: 245px 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .studio-layout {
    grid-template-columns: 1fr;
  }
}

.compiled-scenes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scene-tile {
  padding: 10px 11px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  cursor: pointer;
  transition: all 0.15s;
}

.scene-tile:hover {
  border-color: #94a3b8;
  background: #f1f5f9;
}

.scene-tile.active {
  border-color: var(--primary);
  background: #f0f9ff;
  box-shadow: 0 0 0 1px rgba(2, 132, 199, 0.25);
}

.scene-tile.has-error {
  border-color: var(--danger);
  background: #fef2f2;
}

.scene-tile-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}

.scene-tile-sub {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Subtabs */
.inspector-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.subtab-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: #475569;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.15s;
}

.subtab-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.subtab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.subtab-panel {
  display: none;
}

.subtab-panel.active {
  display: block;
}

.audio-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px;
  margin-top: 8px;
}

.audio-box-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
}

.code-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.sfx-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.sfx-chip {
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 7px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #047857;
  font-family: var(--mono);
  cursor: pointer;
  font-weight: 600;
}

.toggles-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.toggle-item input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
}

/* Parse Report & Errors */
.parse-report {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 12.5px;
}

.error-box {
  margin-top: 8px;
  padding: 10px;
  border-radius: 9px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-family: var(--mono);
  font-size: 12px;
}

/* Preview Stage */
.panel-preview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 76px;
  box-shadow: var(--shadow-card);
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 11px;
}

.preview-header strong {
  color: var(--text);
  font-size: 14.5px;
}

.preview-header>div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.phone-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 600px;
  margin: 0 auto;
  background: #000000;
  border-radius: 20px;
  overflow: hidden;
  border: 4px solid #1e293b;
  box-shadow: 0 20px 42px rgba(15, 23, 42, 0.18);
}

#stage-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.safe-zone-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.safe-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 7.97%;
  background: rgba(220, 38, 38, 0.22);
  border-bottom: 1px dashed #ef4444;
  color: #ffffff;
  font-size: 10px;
  display: grid;
  place-items: center;
}

.safe-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 12.03%;
  background: rgba(220, 38, 38, 0.22);
  border-top: 1px dashed #ef4444;
  color: #ffffff;
  font-size: 10px;
  display: grid;
  place-items: center;
}

.player-controls {
  margin-top: 12px;
}

.scrubber-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

#timeline-scrubber {
  flex: 1;
  accent-color: var(--primary);
}

.transport-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.safe-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-muted);
  cursor: pointer;
}

/* Export Stats & Progress */
.summary-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 10px;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-box strong {
  font-size: 16px;
  color: var(--text);
}

.progress-wrap {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.progress-bar {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.15s linear;
}

.output-gallery {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.output-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.output-item video {
  width: 100%;
  max-height: 360px;
  border-radius: 9px;
  background: #000000;
  margin-bottom: 8px;
}

.output-item audio {
  width: 100%;
  margin-bottom: 8px;
}

.empty-state {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--bg-input);
}

/* Toast */
.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 99;
}

.toast {
  background: #ffffff;
  color: var(--text);
  padding: 11px 15px;
  border-radius: 11px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  font-size: 13px;
  font-weight: 600;
}

.toast.error {
  border-left-color: var(--danger);
}

/* Wallet Bar inside Ocean-Blue Hero */
.wallet-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 10px 24px rgba(7, 89, 133, 0.22);
}

.wallet-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 4px;
}

.user-avatar,
.user-initial {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.user-initial {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #ffffff;
  font-weight: 800;
  font-size: 13px;
}

.wallet-user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.wallet-user-meta strong {
  font-size: 12px;
  color: var(--text);
}

.wallet-user-meta span {
  font-size: 10.5px;
  color: var(--text-muted);
}

.wallet-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.wallet-pill.trial {
  background: #ecfdf5;
  color: #059669;
  border-color: #a7f3d0;
}

.wallet-pill.trial.exhausted {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}

.wallet-pill.balance {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}

/* Billing Preview Card in Tab 4 */
.billing-preview-box {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 12px;
  padding: 11px 13px;
}

.billing-preview-box.warn {
  background: #fff7ed;
  border-color: #fdba74;
}

.billing-preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.billing-preview-top strong {
  font-size: 13.5px;
  color: var(--text);
}

.billing-cost-line {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(2, 132, 199, 0.25);
  font-size: 12.5px;
  color: #0369a1;
}

.billing-preview-box.warn .billing-cost-line {
  color: #9a3412;
  border-top-color: rgba(234, 88, 12, 0.25);
}

/* Google Login Gate Overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(7, 89, 133, 0.55);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 18px;
}

.auth-overlay[hidden],
.modal-backdrop[hidden] {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 470px;
  background: #ffffff;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 26px 65px rgba(15, 23, 42, 0.35);
}

.auth-card-band {
  background: linear-gradient(125deg, #075985 0%, #0284c7 58%, #0ea5e9 100%);
  color: #ffffff;
  padding: 22px 24px 20px;
}

.auth-card-band h2 {
  margin: 10px 0 4px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-card-band p {
  margin: 0;
  font-size: 13px;
  color: #e0f2fe;
}

.auth-card-body {
  padding: 20px 24px 24px;
}

.auth-benefits {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

@media (max-width: 520px) {
  .auth-benefits {
    grid-template-columns: 1fr;
  }
}

.auth-benefit-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-benefit-item strong {
  font-size: 12.5px;
  color: var(--primary);
}

.auth-benefit-item span {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.38;
}

.google-signin-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 46px;
}

.dev-login-box {
  margin-top: 14px;
  padding: 12px;
  background: #f8fafc;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
}

.dev-login-head {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--orange);
  margin-bottom: 8px;
}

/* Modals (Wallet & Admin) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  background: #ffffff;
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-card-wide {
  max-width: 780px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.modal-body {
  padding: 16px 20px 20px;
  overflow-y: auto;
}

.tx-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 230px;
  overflow-y: auto;
}

.tx-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  border-radius: 9px;
  background: #f8fafc;
  border: 1px solid var(--border);
  font-size: 12px;
}

.tx-row-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tx-row-meta small {
  color: var(--text-muted);
  font-size: 10.5px;
}

.admin-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  font-size: 12px;
}

.mt-6 {
  margin-top: 6px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

/* =========================================================
   RESPONSIVE DESIGN (TABLET & MOBILE)
   ========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

/* Tablet & Layar Menengah (<= 1120px) */
@media (max-width: 1120px) {
  .topbar {
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
  }

  .stepper {
    order: 3;
    width: 100%;
    overflow-x: auto;
    display: flex;
    gap: 6px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .step-btn {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .workspace {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 16px;
  }

  .panel-preview {
    position: static;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
  }

  .studio-layout {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
  }
}

/* Mobile (<= 768px) */
@media (max-width: 768px) {
  .brand h1 {
    font-size: 16px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }

  .hero-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }

  .hero-right,
  .wallet-bar {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .panel-grid,
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr !important;
    display: grid;
    gap: 12px;
  }

  .model-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }

  .summary-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }

  .card-head,
  .card-foot,
  .audio-box-head,
  .code-toolbar,
  .billing-preview-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .btn-row,
  .btn-row-tight,
  .series-mode-tabs,
  .inspector-tabs {
    flex-wrap: wrap;
    width: 100%;
  }

  .btn-row>.btn,
  .card-foot>.btn {
    width: 100%;
    justify-content: center;
  }

  .palette-builder {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .phone-frame {
    max-width: 300px;
    margin: 0 auto;
  }

  .transport-row {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }

  .modal-card,
  .modal-card-wide,
  .auth-card {
    width: 94vw !important;
    max-width: 94vw !important;
    max-height: 90vh;
    overflow-y: auto;
    margin: 16px auto;
  }
}

/* Mobile Kecil (<= 420px) */
@media (max-width: 420px) {
  .model-cards-grid {
    grid-template-columns: 1fr !important;
  }

  .summary-stats {
    grid-template-columns: 1fr !important;
  }
}

/* =========================================================
   FIX RESPONSIVE KHUSUS TAB 3: STUDIO & AUDIO VOICEOVER
   ========================================================= */
#tab-studio,
#tab-studio .studio-layout,
#tab-studio .scene-sidebar,
#tab-studio .scene-inspector,
#tab-studio .subtab-panel,
#tab-studio .audio-box {
  min-width: 0;
  max-width: 100%;
}

/* Mencegah teks panjang & tag <code> mendorong lebar layar */
#tab-studio label,
#tab-studio .hint,
#tab-studio code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

#tab-studio input,
#tab-studio select,
#tab-studio textarea {
  width: 100%;
  max-width: 100%;
}

@media (max-width: 900px) {
  #tab-studio .studio-layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  /* Timeline Scene jadi horizontal scroll compact di atas inspector */
  #tab-studio .compiled-scenes-list {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }

  #tab-studio .compiled-scenes-list>* {
    flex: 0 0 auto;
    min-width: 150px;
  }

  /* Sub-tab (Narasi & Audio / Kode Canvas / Pengaturan Gaya) */
  #tab-studio .inspector-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }

  #tab-studio .inspector-tabs .subtab-btn {
    flex: 1 1 100%;
    text-align: left;
    white-space: normal;
    line-height: 1.35;
    padding: 9px 12px;
  }
}

@media (max-width: 640px) {

  /* Bagian Audio Voiceover Scene Ini */
  #sub-narration .audio-box {
    padding: 12px;
  }

  #sub-narration .audio-box-head {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  /* 4 Tombol Audio (Generate TTS, Rekam Mic, Upload, Hapus) jadi grid 2x2 */
  #sub-narration .audio-box .btn-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  #sub-narration .audio-box .btn-row .btn,
  #sub-narration .audio-box .btn-row label.file-btn {
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 9px 8px;
    font-size: 12.5px;
    text-align: center;
    justify-content: center;
    white-space: normal;
    line-height: 1.25;
  }

  /* Tombol Hitung Ulang Timing Kata & Preview/Hapus Scene */
  #tab-studio .scene-inspector .card-head,
  #tab-studio .scene-inspector .card-head .btn-row-tight {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  #tab-studio .scene-inspector .card-head .btn-row-tight .btn,
  #sub-narration .btn-row-tight .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  /* Subtab Pengaturan Global Audio & TTS */
  #sub-global .btn-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  #sub-global .btn-row .btn {
    width: 100%;
  }
}

@media (max-width: 380px) {

  /* Layar sangat kecil: tombol audio jadi 1 kolom penuh */
  #sub-narration .audio-box .btn-row {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   HARD LOCK VIEWPORT & FIX KARTU SCENE TERPOTONG
   ========================================================= */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden !important;
  margin: 0;
  padding: 0;
}

.app-shell,
.topbar,
.hero-banner,
.hero-inner,
.workspace,
.panel-main,
.panel-preview,
.tab-panel,
.card {
  width: 100%;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box;
}

/* 1. Perbaiki Kartu Scene di Timeline Scene agar tidak memanjang ke samping */
#tab-studio .compiled-scenes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

#tab-studio .compiled-scenes-list>* {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box;
  white-space: normal !important;
}

/* Pastikan teks narasi di dalam kartu Scene 7 membungkus baris (wrap) */
#tab-studio .compiled-scenes-list * {
  white-space: normal !important;
  overflow-wrap: break-word !important;
  word-break: break-word !important;
  max-width: 100%;
}

/* 2. Perbaiki Header Inspector (Tombol Preview & Hapus sejajar rapi) */
@media (max-width: 768px) {
  .workspace {
    padding: 12px !important;
  }

  .card {
    padding: 14px !important;
  }

  #tab-studio .scene-inspector .card-head {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  #tab-studio .scene-inspector .card-head .btn-row-tight {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  #tab-studio .scene-inspector .card-head .btn-row-tight .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  /* 3. Perbaiki subtab & isi form di dalam Inspector */
  #tab-studio .subtab-panel {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  #tab-studio .form-grid-2,
  #tab-studio .form-grid-3 {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
  }

  #tab-studio .form-row {
    width: 100% !important;
    min-width: 0 !important;
  }
}

/* =========================================================
   FIX CHECKBOX & RANGE SLIDER AGAR TIDAK MELAR 100%
   ========================================================= */
/* Hanya input teks/angka, select, dan textarea yang lebar 100% */
#tab-studio input[type="text"],
#tab-studio input[type="number"],
#tab-studio input[type="email"],
#tab-studio input[type="url"],
#tab-studio input[type="search"],
#tab-studio input:not([type]),
#tab-studio select,
#tab-studio textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Kembalikan ukuran asli checkbox & radio agar menempel rapi di kiri teks */
#tab-studio input[type="checkbox"],
#tab-studio input[type="radio"],
.toggle-item input[type="checkbox"] {
  width: auto !important;
  min-width: 16px;
  height: 16px;
  margin: 2px 0 0 0;
  flex-shrink: 0;
  cursor: pointer;
}

/* Pastikan baris checkbox + teks (.toggle-item) sejajar rapi di kiri */
.toggle-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  gap: 10px !important;
  width: 100%;
  text-align: left;
}

.toggle-item span {
  flex: 1;
  min-width: 0;
  line-height: 1.4;
}