/* Thumbnail Maker — satu viewport (tanpa scroll halaman) + responsif */

/* Pakai kedua kelas agar menang atas body.vtp-app dari visual-to-prompt/style.css */
html:has(body.tm-app) {
  height: 100%;
  overflow: hidden;
}

body.vtp-app.tm-app {
  -webkit-tap-highlight-color: transparent;
  height: 100dvh !important;
  max-height: 100dvh !important;
  min-height: 100dvh !important;
  overflow: hidden !important;
}

body.tm-app {
  -webkit-tap-highlight-color: transparent;
  height: 100dvh !important;
  max-height: 100dvh !important;
  overflow: hidden !important;
}

/* Timpa rules vtp-app mobile yang memanjangkan halaman / overflow:auto */
@media (max-width: 900px) {
  body.vtp-app.tm-app {
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
  }

  body.tm-app {
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
  }

  body.vtp-app.tm-app .app-shell,
  body.tm-app .app-shell {
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 0 !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
}

body.tm-app .tm-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 0.25rem;
}

/* Ruang di atas bottom-nav (tinggi nav + safe area) */
@media (max-width: 899px) {
  body.tm-app .tm-main {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 0.35rem);
  }

  /* VTP default .bottom-nav { display:none }; paksa grid 5 kolom untuk TM */
  body.vtp-app.tm-app .bottom-nav,
  body.tm-app .bottom-nav {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 0.05rem;
    padding-left: 0.2rem;
    padding-right: 0.2rem;
  }

  body.tm-app .bottom-nav-item {
    font-size: 0.58rem;
    padding: 0.35rem 0.12rem;
    min-width: 0;
  }

  body.tm-app .bottom-nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  body.tm-app .bottom-nav-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Panel tunggal: tidak ada scroll pada dokumen */
@media (max-width: 899px) {
  body.tm-app .tm-workspace.tm-workspace--trio {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  body.tm-app .tm-workspace-top {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    align-content: stretch;
  }

  body.tm-app #tm-col-menu,
  body.tm-app #tm-col-center,
  body.tm-app #tm-col-filter {
    grid-area: 1 / 1;
    min-height: 0;
    min-width: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.tm-app #tm-col-menu {
    display: flex;
    flex-direction: column;
  }

  html[data-tm-tab="menu"] body.tm-app #tm-col-menu {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  html[data-tm-tab="menu"] body.tm-app #tm-col-center,
  html[data-tm-tab="menu"] body.tm-app #tm-col-filter {
    display: none !important;
  }

  html[data-tm-tab="canvas"] body.tm-app #tm-col-menu,
  html[data-tm-tab="canvas"] body.tm-app #tm-col-filter {
    display: none !important;
  }

  /* Tab Kanvas (mobile): rantai flex penuh supaya pratinjau tidak kolaps */
  html[data-tm-tab="canvas"] body.tm-app #tm-col-center {
    display: flex !important;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 100%;
  }

  html[data-tm-tab="canvas"] .tm-preview-frame__spacer {
  display: block;
  width: 100%;
  padding-bottom: 56.25%;
  pointer-events: none;
  visibility: hidden;
}

body.tm-app #tm-stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  html[data-tm-tab="canvas"] body.tm-app #tm-stage .tm-canvas-shell.canvas-container {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    margin-inline: auto;
    box-sizing: border-box;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-menu {
    display: none !important;
  }

  /* Tab Filter (mobile): kanvas + filter bertumpuk supaya perubahan kontras terlihat */
  html[data-tm-tab="filter"] body.tm-app .tm-workspace-top {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-center {
    display: flex !important;
    flex: 0 0 auto;
    max-height: min(34vh, 260px);
    min-height: 8rem;
    overflow: hidden;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-center .tm-canvas-hint {
    display: none !important;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter {
    display: flex !important;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden !important;
    -webkit-overflow-scrolling: touch;
    gap: 0;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-preview-frame {
    width: min(100%, calc(min(30vh, 240px) * 16 / 9));
    max-width: 100%;
    margin-inline: auto;
  }


  /* Panel filter: tombol unduh tetap di bawah; area slider yang scroll jika perlu */
  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-panel {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding: 0.45rem 0.65rem 0.35rem;
    gap: 0.3rem !important;
  }

  /* Hilangkan space-y-3 Tailwind (terlalu renggang); jarak pakai gap panel saja */
  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-panel > * + * {
    margin-top: 0 !important;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-filter-sliders {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-filter-sliders > * + * {
    margin-top: 0.3rem !important;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-filter-row > * + * {
    margin-top: 0.12rem !important;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-filter-mobile-hint {
    margin-top: 0;
    margin-bottom: 0.2rem;
    padding: 0.15rem 0 0.15rem 0.45rem;
    font-size: 0.58rem;
    line-height: 1.25;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-export-card {
    margin-top: 0.15rem;
    padding: 0.4rem 0.45rem;
    gap: 0.35rem;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-export-cover-title {
    font-size: 0.48rem;
    letter-spacing: 0.03em;
    line-height: 1.2;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-export-settings {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0.3rem;
    margin-bottom: 0.2rem;
    flex-shrink: 0;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-export-hd-option {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 0.28rem 0.4rem;
    border-radius: 0.45rem;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-export-hd-option:has(input:checked) {
    border-color: rgba(251, 191, 36, 0.55);
    background: rgba(120, 53, 15, 0.35);
    box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.15);
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-export-format {
    flex: 0 0 auto;
    margin: 0;
    display: flex;
    align-items: stretch;
    min-width: 5.5rem;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-export-format-btns {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    gap: 0.12rem;
    padding: 0.12rem;
    border-radius: 0.45rem;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-export-format-opt {
    flex: 1 1 50%;
    min-height: 0;
    height: auto;
    min-width: 2rem;
    padding: 0.2rem 0.15rem;
    font-size: 0.58rem;
    border-radius: 0.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    cursor: pointer;
    color: rgba(148, 163, 184, 0.9);
    background: rgba(30, 41, 59, 0.85);
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-export-format-opt:has(input:checked) {
    color: #fff;
    background: linear-gradient(135deg, #e11d48 0%, #ea580c 100%);
    box-shadow:
      inset 0 0 0 1px rgba(255, 255, 255, 0.2),
      0 2px 8px rgba(244, 63, 94, 0.35);
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-export-format-opt:not(:has(input:checked)) {
    opacity: 0.72;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-export-card .tm-filter-download {
    min-height: 34px !important;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
    margin-top: 0 !important;
    font-size: 0.72rem;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-filter-slider-row {
    min-height: 1.75rem;
    gap: 0.25rem;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-filter-step {
    min-width: 1.8rem;
    min-height: 1.75rem;
    border-radius: 0.45rem;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-filter-reset {
    min-width: 1.45rem;
    min-height: 1.45rem;
    font-size: 0.75rem;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-filter-row-head label {
    font-size: 0.62rem;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-filter-val {
    font-size: 0.62rem;
    min-width: 2.35rem;
    line-height: 1.15;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-filter-range {
    height: 0.35rem;
    padding-top: 0;
    padding-bottom: 0;
    min-height: 0;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-range::-webkit-slider-thumb {
    width: 14px;
    height: 14px;
    margin-top: -5px;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
  }

  html[data-tm-tab="filter"] body.tm-app #tm-col-filter .tm-filter-row-head {
    min-height: 0;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-col-menu,
  html[data-tm-tab="layer"] body.tm-app #tm-col-filter {
    display: none !important;
  }

  html[data-tm-tab="layer"] body.tm-app .tm-workspace-top {
    flex: 0 0 min(32vh, 230px);
  }

  html[data-tm-tab="layer"] body.tm-app #tm-col-layer {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* Tab Layer: tanpa petunjuk di atas kanvas; alat vertikal penuh lebar (bukan kolom sempit geser kanan) */
  html[data-tm-tab="layer"] body.tm-app .tm-canvas-hint {
    display: none !important;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-stage > * + * {
    margin-top: 0 !important;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0.55rem 0.65rem calc(0.5rem + env(safe-area-inset-bottom, 0px)) !important;
    gap: 0.35rem;
  }

  /* .tm-layer-scroll--tools ada di dalam .tm-layer-row-top — parent harus bisa menyusut supaya scroll vertikal jalan */
  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-row-top {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-head {
    flex-shrink: 0;
    gap: 0.35rem;
    padding-bottom: 0.4rem;
    margin-bottom: 0.05rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-head .grid.grid-cols-2 {
    gap: 0.35rem !important;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-head .tm-toggle-row {
    padding: 0.3rem 0.4rem !important;
    gap: 0.3rem;
    border-radius: 0.5rem;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-head button {
    min-height: 28px !important;
    padding-top: 0.15rem !important;
    padding-bottom: 0.15rem !important;
    font-size: 0.62rem !important;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-head .grid.grid-cols-2 > button {
    min-height: 30px !important;
    padding-top: 0.2rem !important;
    padding-bottom: 0.2rem !important;
    font-size: 0.62rem !important;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-scroll--tools {
    flex: 1 1 auto;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    min-height: 0;
    width: 100%;
    overflow-x: visible;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    gap: 0.75rem;
    padding-top: 0.25rem;
    padding-bottom: 0.45rem;
    padding-right: 2px;
    scrollbar-width: auto;
    scrollbar-color: rgba(250, 204, 21, 0.55) rgba(255, 255, 255, 0.07);
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-scroll--tools::-webkit-scrollbar {
    width: 11px;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-scroll--tools::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    margin: 6px 0;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-scroll--tools::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(253, 224, 71, 0.75), rgba(202, 138, 4, 0.55));
    border-radius: 8px;
    border: 2px solid rgba(15, 23, 42, 0.95);
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-scroll--tools .tm-label {
    margin-bottom: 0.28rem;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-scroll--tools > .tm-layer-group--sliders .grid {
    gap: 0.45rem 0.55rem !important;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-scroll--tools > .tm-layer-group--text textarea#textInput {
    min-height: 2.65rem;
    margin-bottom: 0.35rem !important;
    font-size: 0.875rem;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-scroll--tools .tm-font-block {
    margin-bottom: 0.4rem !important;
    padding: 0.35rem 0.4rem;
    border-radius: 0.6rem;
    background: rgba(15, 23, 42, 0.42);
    border: 1px solid rgba(129, 140, 248, 0.22);
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-scroll--tools .tm-font-block .tm-label {
    font-size: 0.7rem !important;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #e2e8f0 !important;
    margin-bottom: 0.3rem !important;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-scroll--tools .tm-layer-group--text .btn-toggle,
  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-scroll--tools .tm-layer-group--text .btn-align {
    min-height: 30px !important;
    font-size: 0.75rem !important;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-download {
    margin-top: 0.25rem;
    flex-shrink: 0;
    min-height: 40px !important;
    padding-top: 0.45rem !important;
    padding-bottom: 0.45rem !important;
    font-size: 0.8125rem !important;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-scroll--tools > .tm-layer-group {
    min-width: 0 !important;
    width: 100%;
    max-width: none;
    flex-shrink: 0;
  }

  /* Urutan sunting layer (mobile): teks+font dalam satu blok → warna → jarak → aset → bentuk */
  html[data-tm-tab="layer"] body.tm-app .tm-layer-group--text {
    order: 1;
  }

  html[data-tm-tab="layer"] body.tm-app .tm-layer-group--colors {
    order: 2;
  }

  html[data-tm-tab="layer"] body.tm-app .tm-layer-group--sliders {
    order: 3;
  }

  html[data-tm-tab="layer"] body.tm-app .tm-layer-group--assets {
    order: 4;
  }

  html[data-tm-tab="layer"] body.tm-app .tm-layer-group--shape {
    order: 5;
  }

  html[data-tm-tab="layer"] body.tm-app .tm-layer-group--colors .tm-color-palette-scroll {
    max-height: min(6rem, 26dvh);
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone #textStyleButtons {
    gap: 0.35rem !important;
    margin-bottom: 0.35rem !important;
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-scroll--tools .tm-font-block .tm-font-select {
    min-height: 44px;
    font-size: 16px;
    padding: 0.4rem 0.55rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(99, 102, 241, 0.4);
    background: rgba(15, 23, 42, 0.88);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
  }

  html[data-tm-tab="layer"] body.tm-app #tm-editor-zone .tm-layer-scroll--tools .tm-layer-group .tm-range {
    min-height: 28px;
    padding: 6px 0;
  }

  /* Tab Kanvas: hanya pratinjau; kontrol Layer di tab Layer */
  html[data-tm-tab="canvas"] body.tm-app #tm-col-layer {
    display: none !important;
  }

  /* Tab Menu / Filter: tanpa bar Layer */
  html[data-tm-tab="menu"] body.tm-app #tm-col-layer,
  html[data-tm-tab="filter"] body.tm-app #tm-col-layer {
    display: none !important;
  }
}

/* Header ringkas di layar pendek */
@media (max-width: 899px) and (max-height: 720px) {
  body.tm-app .byline {
    display: none;
  }

  body.tm-app .nav {
    padding-bottom: 0.35rem;
    margin-bottom: 0.35rem;
  }
}

.tm-workspace {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

body.tm-app .tm-workspace.tm-workspace--trio,
body.tm-app .tm-workspace-top {
  min-width: 0;
}

/* Lebar memakai viewport (padding .app-shell tetap) — hindari “tiang” sempit 1280px di layar lebar */
body.tm-app .app-shell {
  max-width: none;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

#tm-col-menu,
#tm-col-center,
#tm-stage,
.tm-workspace-top,
#tm-col-layer,
#tm-col-filter {
  scroll-margin-top: 0.75rem;
}

.tm-layer-bar {
  width: 100%;
}

#tm-editor-zone.tm-editor-zone--horizontal {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  overflow: visible;
}

.tm-layer-row-top {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.tm-layer-group--colors-side {
  align-self: stretch;
  border-right: none !important;
  padding-right: 0 !important;
}

.tm-colors-side-col {
  height: 100%;
}

.tm-layer-group--colors-side .tm-color-palette {
  scrollbar-width: thin;
  scrollbar-color: rgba(129, 140, 248, 0.4) transparent;
}

.tm-layer-group--colors-side .tm-color-palette::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.tm-layer-group--colors-side .tm-color-palette::-webkit-scrollbar-thumb {
  background: rgba(129, 140, 248, 0.45);
  border-radius: 4px;
}

.tm-color-palette {
  width: 100%;
  max-width: 100%;
}

.tm-color-palette button,
.tm-color-palette .relative {
  flex-shrink: 0;
}

/* Palet kompak: scroll vertikal tipis hanya jika benar-benar penuh */
.tm-color-palette-scroll {
  max-height: min(3.75rem, 15dvh);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(129, 140, 248, 0.35) transparent;
}

.tm-color-palette-scroll::-webkit-scrollbar {
  width: 3px;
}

.tm-color-palette-scroll::-webkit-scrollbar-thumb {
  background: rgba(129, 140, 248, 0.4);
  border-radius: 3px;
}

@media (min-width: 900px) {
  .tm-layer-row-top {
    flex-direction: row;
    align-items: flex-start;
    gap: 0.65rem;
  }

  .tm-layer-head {
    flex: 0 0 auto;
    min-width: 9.5rem;
    max-width: 10.5rem;
    padding-right: 0.5rem;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    gap: 0.35rem !important;
  }

  .tm-layer-scroll--tools {
    flex: 1 1 auto;
    min-width: 0;
    align-self: stretch;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.15rem;
  }

  .tm-layer-group--sliders {
    flex: 1 1 0;
    min-width: 9rem;
    max-width: none;
  }

  .tm-layer-group--colors-side {
    flex: 1.25 1 0;
    min-width: 11rem;
    max-width: none;
  }

  .tm-layer-group--text {
    flex: 0.85 1 0;
    min-width: 9.5rem;
    max-width: 18rem;
  }

  .tm-layer-group--shape.hidden,
  #shapeControlsGroup.hidden {
    display: none !important;
    width: 0;
    min-width: 0;
    padding: 0;
    margin: 0;
    border: none;
  }

  .tm-layer-scroll {
    flex: 1 1 auto;
    min-width: 0;
    align-self: stretch;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.15rem;
  }

  .tm-layer-group {
    padding-right: 0.65rem;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
  }

  .tm-layer-scroll--tools > .tm-layer-group--assets {
    flex-shrink: 0;
  }

  .tm-layer-scroll--tools > .tm-layer-group--text,
  .tm-layer-scroll--tools > .tm-layer-group--sliders,
  .tm-layer-scroll--tools > .tm-layer-group--colors-side {
    flex-shrink: 1;
  }

  .tm-layer-group:last-child {
    border-right: none;
    padding-right: 0;
  }

  .tm-layer-group--text textarea#textInput {
    min-height: 2.6rem;
    max-height: 3.25rem;
  }
}

/* Kompak layer: hanya mobile — jangan sentuh ukuran desktop */
@media (max-width: 899px) {
  .tm-layer-head button {
    min-height: 28px !important;
    padding-top: 0.2rem !important;
    padding-bottom: 0.2rem !important;
  }

  .tm-layer-head .grid.grid-cols-2 {
    gap: 0.3rem !important;
  }

  .tm-layer-head .tm-toggle-row {
    padding-top: 0.35rem !important;
    padding-bottom: 0.35rem !important;
  }

  .tm-layer-group--text .btn-toggle,
  .tm-layer-group--text .btn-align {
    min-height: 30px !important;
  }

  .tm-layer-group .tm-range {
    min-height: 24px;
    padding: 4px 0;
  }
}

/* Tailwind preflight memakai appearance:none pada select — di mobile sering bikin <select> hampir tak kelihatan */
.tm-font-select {
  display: block;
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
  min-height: 2.75rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.5rem;
  background-color: rgba(15, 23, 42, 0.92);
  color: #f1f5f9;
  font-size: 0.95rem;
  line-height: 1.3;
  -webkit-appearance: menulist;
  -moz-appearance: menulist;
  appearance: auto;
}

.tm-font-block {
  width: 100%;
  min-width: 0;
  flex-shrink: 0;
}

.tm-font-select option {
  padding: 0.35rem 0.5rem;
  background: #0f172a;
  color: #f1f5f9;
}

.tm-font-hint {
  margin: 0;
  line-height: 1.25;
  font-size: 9px;
}

/* Aset layer — strip horizontal kompak */
.tm-layer-group--assets {
  padding-right: 0.5rem;
}

.tm-asset-strip {
  min-height: 2rem;
  align-items: center;
}

.tm-asset-btn {
  flex: 0 0 auto;
  width: 2.75rem;
  height: auto;
  aspect-ratio: 16 / 9;
  padding: 0;
  border-radius: 4px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.tm-asset-btn:hover {
  border-color: rgba(129, 140, 248, 0.65);
  transform: scale(1.08);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.tm-asset-btn:active {
  transform: scale(0.94);
}

.tm-asset-btn-swatch,
.tm-asset-btn-label {
  display: none;
}

.tm-layer-group--colors {
  padding-bottom: 0;
}

/* Kolom menu kiri: panel mengisi tinggi kolom; area unggah mengisi sisa ruang (tanpa scroll kolom) */
body.tm-app #tm-col-menu .tm-menu-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.tm-app #tm-col-menu .tm-menu-panel > .tm-menu-block {
  flex-shrink: 0;
}

body.tm-app #tm-col-menu .tm-menu-panel > hr {
  flex-shrink: 0;
}

body.tm-app #tm-col-menu .tm-menu-source {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.tm-app #tm-col-menu .tm-menu-source > .tm-label,
body.tm-app #tm-col-menu .tm-menu-source > .tm-source-tabs {
  flex-shrink: 0;
}

body.tm-app #tm-col-menu .tm-menu-source > #source-file,
body.tm-app #tm-col-menu .tm-menu-source > #source-yt {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.tm-app #tm-col-menu #source-file {
  overflow: hidden;
}

body.tm-app #tm-col-menu #dropZone {
  overflow: hidden;
}

body.tm-app #tm-col-menu .tm-menu-ai {
  flex-shrink: 0;
}

/* Mobile: jangan biarkan .tm-menu-source menyusut ke 0 (flex-shrink pada block hr/ai mengalahkan) */
@media (max-width: 899px) {
  body.tm-app #tm-col-menu .tm-menu-panel {
    flex: 0 0 auto;
    min-height: 0;
    overflow: visible;
  }

  body.tm-app #tm-col-menu .tm-menu-source {
    flex: 0 0 auto;
    min-height: auto;
    overflow: visible;
  }

  body.tm-app #tm-col-menu .tm-menu-source > #source-file,
  body.tm-app #tm-col-menu .tm-menu-source > #source-yt {
    flex: 0 0 auto;
    min-height: auto;
  }

  body.tm-app #tm-col-menu #source-file {
    overflow: visible;
  }

  body.tm-app #tm-col-menu #dropZone {
    overflow: visible;
  }
}

/* Desktop: satu layar — grid atas + layer satu baris */
@media (min-width: 900px) {
  /* VTP mengaktifkan bottom-nav pada max-width:900px; layout TM desktop mulai lebar ≥900px */
  body.tm-app .bottom-nav {
    display: none !important;
  }

  body.tm-app .tm-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body.tm-app .tm-workspace.tm-workspace--trio {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }

  body.tm-app .tm-workspace-top {
    /* Fallback jika Tailwind CDN/config gagal — tetap 12 kolom seperti lg:grid-cols-12 */
    display: grid !important;
    grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
    gap: 0.75rem !important;
    align-items: start !important;
    align-content: start !important;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    width: 100%;
  }

  /* Laptop / desktop sempit: kolom Filter lebih lebar; kanvas tetap proporsional */
  @media (max-width: 1399px) {
    body.tm-app #tm-col-center {
      grid-column: span 6 / span 6 !important;
    }

    body.tm-app #tm-col-filter {
      grid-column: span 3 / span 3 !important;
    }
  }

  body.tm-app #tm-col-menu {
    grid-column: span 3 / span 3 !important;
    grid-row: auto !important;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: hidden;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
  }

  body.tm-app #tm-col-filter {
    grid-column: span 2 / span 2 !important;
    grid-row: auto !important;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    align-self: stretch;
    -webkit-overflow-scrolling: touch;
  }

  body.tm-app #tm-col-filter .tm-export-card {
    margin-top: 0.35rem;
  }

  body.tm-app #tm-col-filter .tm-export-cover-title {
    margin: 0;
  }

  body.tm-app #tm-col-filter .tm-export-settings {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  body.tm-app #tm-col-filter .tm-export-card .tm-filter-download {
    margin-top: 0.15rem;
  }

  body.tm-app #tm-col-filter .tm-export-hd-option {
    margin-top: 0.25rem;
  }

  body.tm-app #tm-col-filter .tm-export-hd-option:hover {
    border-color: rgba(251, 191, 36, 0.45);
    background: rgba(69, 26, 3, 0.35);
  }

  body.tm-app #tm-col-filter .tm-export-hd-option:has(input:checked) {
    border-color: rgba(251, 191, 36, 0.55);
    background: rgba(120, 53, 15, 0.35);
    box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.18);
  }

  body.tm-app #tm-col-filter .tm-export-format-opt {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2rem;
    border-radius: 0.55rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: rgba(148, 163, 184, 0.95);
    background: rgba(30, 41, 59, 0.85);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s, opacity 0.15s;
  }

  body.tm-app #tm-col-filter .tm-export-format-opt:not(:has(input:checked)) {
    opacity: 0.78;
  }

  body.tm-app #tm-col-filter .tm-export-format-opt:has(input:checked) {
    opacity: 1;
    background: linear-gradient(135deg, #e11d48 0%, #ea580c 100%);
    color: #fff;
    box-shadow:
      inset 0 0 0 1px rgba(255, 255, 255, 0.22),
      0 2px 10px rgba(244, 63, 94, 0.35);
  }

  body.tm-app #tm-col-center {
    grid-column: span 7 / span 7 !important;
    grid-row: auto !important;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-self: center;
    justify-content: center;
    align-items: center;
  }

  /*
    Penting: JANGAN flex-grow di #tm-stage (bentrok dengan Tailwind flex-1 + tm-preview-lock).
    Jika stage memanjang vertikal, kotak #dropArea bisa ikut “ditarik” dan rasio 16:9 hilang.
  */
  body.tm-app #tm-stage {
    flex: none;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
  }

  body.tm-app #tm-stage > * + * {
    margin-top: 0 !important;
  }

  body.tm-app #dropArea.tm-canvas-shell.canvas-container {
    flex: 0 0 auto;
    width: min(100%, calc(min(62vh, 720px) * 16 / 9));
    max-width: 100%;
    min-height: 0;
    margin-inline: auto;
    position: relative;
  }

  body.tm-app #dropArea.tm-canvas-shell[data-tm-aspect="16:9"] {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    max-height: none;
  }

  body.tm-app #dropArea.tm-canvas-shell[data-tm-aspect="1:1"] {
    width: min(100%, min(72vh, 640px));
    max-height: min(72vh, 640px);
    height: auto;
    margin-inline: auto;
  }

  body.tm-app #dropArea.tm-canvas-shell[data-tm-aspect="9:16"] {
    width: min(100%, calc(min(72vh, 720px) * 9 / 16));
    max-height: min(72vh, 720px);
    height: auto;
    margin-inline: auto;
  }

  body.tm-app #dropArea.tm-canvas-shell #thumbnailCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  body.tm-app .tm-layer-bar {
    flex: 0 0 auto;
    overflow: visible;
    max-height: none;
  }

  body.tm-app #tm-col-layer {
    overflow: visible;
  }

  body.tm-app #tm-col-layer .tm-panel {
    padding: 0.5rem 0.65rem !important;
    overflow: visible;
  }

  body.tm-app #tm-editor-zone {
    overflow-x: auto;
    overflow-y: hidden;
    flex: 0 0 auto;
  }

  body.tm-app .tm-layer-row-top {
    min-height: 0;
    align-items: stretch;
  }

  @media (min-height: 720px) {
    body.tm-app .tm-layer-row-top:not(.tm-footer-dock) {
      min-height: 5.5rem;
    }
  }

  body.tm-app .tm-layer-scroll,
  body.tm-app .tm-layer-scroll--tools {
    overflow-x: auto;
    overflow-y: hidden;
  }

  body.tm-app .tm-layer-group--colors-side {
    flex: 1.35 1 0 !important;
    min-width: 12rem;
    max-width: none !important;
    max-height: none;
  }

  body.tm-app .tm-layer-scroll--tools > .tm-layer-group--sliders {
    flex: 1 1 0 !important;
    min-width: 10rem;
    max-width: none !important;
  }

  body.tm-app .tm-layer-scroll--tools > .tm-layer-group--text {
    flex: 0.75 1 0 !important;
    max-width: min(22rem, 28vw) !important;
  }

  body.tm-app .tm-colors-modes {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  body.tm-app .tm-colors-side-col .tm-colors-palette {
    width: 100%;
  }

  body.tm-app .tm-color-palette-scroll {
    max-height: min(4.25rem, 20dvh);
  }

  body.tm-app .tm-color-palette button {
    width: 2rem;
    height: 2rem;
  }

  body.tm-app .tm-color-palette .relative .w-10 {
    width: 2rem;
    height: 2rem;
  }
}

@media (max-width: 899px) {
  .tm-layer-scroll {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: visible;
  }

  .tm-layer-group {
    width: 100%;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-right: none !important;
  }

  .tm-layer-group:last-child {
    border-bottom: none;
  }

  .tm-asset-strip {
    flex-wrap: wrap;
    max-height: none;
  }
}

.tm-card {
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.8),
    0 12px 32px rgba(0, 0, 0, 0.35);
}

.tm-canvas-hint {
  margin: 0;
  padding: 0.55rem 0.75rem;
  font-size: 0.74rem;
  line-height: 1.45;
  color: #e2e8f8;
  background: linear-gradient(125deg, rgba(99, 102, 241, 0.14), rgba(15, 23, 42, 0.92));
  border: 1px solid rgba(129, 140, 248, 0.28);
  border-radius: 10px;
}

.tm-canvas-hint strong {
  color: #c7d2fe;
  font-weight: 800;
}

.canvas-container {
  background-color: #0f172a;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.9),
    0 20px 50px -12px rgba(0, 0, 0, 0.55);
  position: relative;
  overflow: hidden;
  touch-action: none;
  width: 100%;
  margin: 0 auto;
}

/* Preview utama: bingkai 16:9 selalu terlihat; kanvas di dalam bisa 16:9 / 1:1 / 9:16 */
.tm-preview-frame {
  --tm-preview-max-h: min(62vh, 720px);
  --tm-frame-letterbox: #12121c;
  position: relative;
  display: block;
  box-sizing: border-box;
  aspect-ratio: 16 / 9;
  width: min(100%, calc(var(--tm-preview-max-h) * 16 / 9));
  max-width: 100%;
  height: auto;
  max-height: var(--tm-preview-max-h);
  flex: 0 0 auto;
  flex-shrink: 0;
  align-self: center;
  margin-inline: auto;
  isolation: isolate;
  background: var(--tm-frame-letterbox);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  outline: 2px solid rgba(99, 102, 241, 0.28);
  outline-offset: 0;
  box-shadow:
    0 28px 56px -16px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

body.tm-app #tm-stage {
  background: #060608;
}

/* Area letterbox (terlihat saat kanvas 1:1 / 9:16 di dalam bingkai 16:9) */
.tm-preview-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(255, 255, 255, 0.03) 0,
      rgba(255, 255, 255, 0.03) 2px,
      transparent 2px,
      transparent 10px
    ),
    linear-gradient(160deg, #161622 0%, #0c0c12 48%, #14141e 100%);
}

.tm-canvas-inner {
  background: #000;
}

.tm-preview-frame > #dropArea.tm-canvas-shell.canvas-container[data-tm-canvas-aspect="16:9"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  transform: none;
  box-sizing: border-box;
}

.tm-preview-frame > #dropArea.tm-canvas-shell.canvas-container[data-tm-canvas-aspect="9:16"],
.tm-preview-frame > #dropArea.tm-canvas-shell.canvas-container[data-tm-canvas-aspect="1:1"] {
  position: absolute;
  top: 50%;
  left: 50%;
  inset: auto;
  transform: translate(-50%, -50%);
  margin: 0;
  box-sizing: border-box;
}

.tm-preview-frame #thumbnailCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

@media (max-width: 899px) {
  body.tm-app #tm-preview-frame {
    width: 100%;
    max-width: 100%;
    margin-inline: auto;
  }
}

@media (max-width: 900px) {
  .canvas-container:not(#dropArea) {
    min-height: min(52vw, 320px);
    max-height: min(58vh, 420px);
  }
}

.tm-range {
  min-height: 28px;
  padding: 6px 0;
  -webkit-tap-highlight-color: transparent;
}

.tm-range::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  background: linear-gradient(145deg, #c7d2fe, #6366f1);
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.tm-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(145deg, #c7d2fe, #6366f1);
}

#dropZone.drag-active {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(129, 140, 248, 0.75) !important;
}

.btn-toggle.active {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
  border-color: rgba(129, 140, 248, 0.6);
}

.btn-align.active {
  background: rgba(99, 102, 241, 0.35);
  color: #f8fafc;
}

.custom-range {
  accent-color: #818cf8;
}

.loader {
  border-top-color: #a5b4fc;
  animation: tm-spinner 0.6s linear infinite;
}

.loader-sm {
  border-top-color: white;
  animation: tm-spinner 0.6s linear infinite;
}

@keyframes tm-spinner {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.tm-canvas-shell.canvas-container {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 24px 48px -16px rgba(0, 0, 0, 0.65);
}

.tm-filter-row {
  gap: 0.35rem;
}

.tm-filter-row-head {
  min-height: 1.35rem;
}

.tm-filter-meta {
  font-variant-numeric: tabular-nums;
}

.tm-filter-val {
  display: inline-block;
  min-width: 2.25rem;
  text-align: right;
  font-size: 0.65rem;
  font-weight: 700;
  color: #e2e8f0;
  line-height: 1.5rem;
}

.tm-filter-slider-row {
  width: 100%;
}

.tm-filter-range {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 4px;
  padding-bottom: 4px;
}

.tm-filter-step,
.tm-filter-reset {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  pointer-events: auto;
  padding: 0;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 23, 42, 0.85);
  color: #cbd5e1;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tm-filter-step:hover,
.tm-filter-reset:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: rgba(129, 140, 248, 0.35);
  color: #f8fafc;
}

.tm-filter-step:active,
.tm-filter-reset:active {
  transform: scale(0.94);
}

.tm-filter-reset {
  font-size: 0.7rem;
  color: #94a3b8;
}

.tm-filter-reset:hover {
  color: #c7d2fe;
}

.tm-label {
  display: block;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 0.35rem;
}

.tm-kbd {
  display: inline-block;
  font-size: 0.65rem;
  font-family: ui-monospace, monospace;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #cbd5e1;
}

.tm-source-tabs .source-tab-active {
  border-bottom: none !important;
  color: #f8fafc !important;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.45), rgba(139, 92, 246, 0.25)) !important;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 4px 14px rgba(79, 70, 229, 0.2);
}

.source-tab-active {
  border-bottom: 3px solid #fde047 !important;
  color: #fde047 !important;
  background: rgba(250, 204, 21, 0.08);
}

select option {
  background: #1e293b;
  color: white;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

@media (max-width: 900px) {
  .nav-actions .btn-ghost[href="/visual-to-prompt/"] {
    display: none;
  }
}

/* Motto header — identik CERITAKU; !important menangkis Tailwind CDN preflight/util */
@keyframes running-light-rtl {
  0%,
  100% {
    background-position: 200% center;
  }
  50% {
    background-position: -200% center;
  }
}

@keyframes ceritaku-motto-glow {
  0%,
  100% {
    filter: drop-shadow(0 0 5px rgba(253, 224, 71, 0.28)) drop-shadow(0 0 16px rgba(250, 204, 21, 0.12));
  }
  50% {
    filter: drop-shadow(0 0 10px rgba(253, 224, 71, 0.5)) drop-shadow(0 0 28px rgba(250, 204, 21, 0.2));
  }
}

body.tm-app .text-running-light {
  background: linear-gradient(
    to left,
    #ca8a04 0%,
    #ca8a04 30%,
    #fef9c3 44%,
    #ffffff 50%,
    #fef9c3 56%,
    #ca8a04 70%,
    #ca8a04 100%
  ) !important;
  background-size: 250% auto !important;
  color: transparent !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
  -webkit-background-clip: text !important;
  animation: running-light-rtl 2.8s linear infinite;
}

body.tm-app .ceritaku-motto {
  animation:
    running-light-rtl 2.8s linear infinite,
    ceritaku-motto-glow 3.2s ease-in-out infinite;
  will-change: background-position, filter;
}

/* Header: hindari overflow horizontal — grid di desktop, fleksibel di mobile */
body.tm-app .tm-header-nav {
  flex-wrap: wrap;
  row-gap: 0.45rem;
}

body.tm-app .tm-header-motto {
  display: none;
  flex: 1 1 auto;
  min-width: 0;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 0 0.35rem;
  order: 3;
  flex-basis: 100%;
}

body.tm-app .tm-header-nav .brand {
  flex: 1 1 auto;
  min-width: 0;
}

body.tm-app .tm-header-nav .nav-actions {
  flex-shrink: 0;
}

/* Motto tengah hanya layar lebar — hindari tabrakan tablet 768–899px */
@media (min-width: 1100px) {
  body.tm-app .tm-motto-mobile {
    display: none !important;
  }

  body.tm-app .tm-header-motto {
    display: flex;
    order: 0;
    flex-basis: auto;
  }

  body.tm-app .tm-header-nav {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.65rem 1rem;
    flex-wrap: unset;
    row-gap: unset;
  }

  body.tm-app .tm-header-nav .brand {
    grid-column: 1;
  }

  body.tm-app .tm-header-motto {
    grid-column: 2;
  }

  body.tm-app .tm-header-nav .nav-actions {
    grid-column: 3;
  }

  body.tm-app .tm-header-nav .brand {
    align-items: center;
  }
}

/* Tablet / desktop sempit: motto di bawah judul (Tailwind md:hidden di-HIRAUkan di sini) */
@media (min-width: 768px) and (max-width: 1099px) {
  body.tm-app .tm-motto-mobile {
    display: block !important;
    max-width: none;
  }
}

@media (min-width: 768px) {
  body.tm-app .tm-header-nav .brand {
    align-items: flex-start;
  }
}

@media (min-width: 1100px) {
  body.tm-app .tm-header-nav .brand {
    align-items: center;
  }
}

body.tm-app .tm-motto-center {
  font-family: 'Caveat', cursive !important;
  font-size: clamp(1rem, 1.85vw, 1.65rem);
  font-weight: 700 !important;
  font-style: italic !important;
  letter-spacing: 0.02em;
  line-height: 1.15;
  text-align: center;
  margin: 0;
}

body.tm-app .tm-motto-mobile {
  display: block;
  font-family: 'Caveat', cursive !important;
  font-size: clamp(0.92rem, 3.2vw, 1.15rem);
  font-weight: 700 !important;
  font-style: italic !important;
  line-height: 1.2;
  margin: 0.15rem 0 0;
  max-width: 16rem;
  letter-spacing: 0.02em;
}

@media (max-width: 767px) {
  body.tm-app .tm-motto-mobile {
    max-width: 14.5rem;
  }
}

@media (max-width: 900px) and (min-width: 768px) {
  body.tm-app .tm-header-nav .nav-actions {
    flex: 0 1 auto;
  }
}

/* ─── Mobile / tablet (≤899px): input & filter lebih enak dipakai; desktop tidak berubah ─── */
@media (max-width: 899px) {
  body.tm-app #tm-col-menu #dropZone {
    min-height: 7.25rem;
    padding: 1rem 0.75rem;
  }

  body.tm-app #tm-col-menu #youtubeUrl {
    min-height: 48px;
    font-size: 16px;
  }

  body.tm-app .tm-font-block .tm-font-select {
    min-height: 44px;
    font-size: 16px;
    -webkit-appearance: menulist;
    -moz-appearance: menulist;
    appearance: auto;
  }

  body.tm-app #tm-col-filter .tm-filter-slider-row {
    min-height: 2.75rem;
    align-items: center;
    gap: 0.35rem;
  }

  body.tm-app #tm-col-filter .tm-filter-step {
    min-width: 2.35rem;
    min-height: 2.35rem;
  }

  body.tm-app #tm-col-filter .tm-filter-reset {
    min-width: 1.75rem;
    min-height: 1.75rem;
  }

  body.tm-app #tm-col-filter .tm-filter-row-head label {
    font-size: 0.7rem;
  }

  body.tm-app #tm-col-filter .tm-filter-val {
    font-size: 0.7rem;
    min-width: 2.6rem;
  }

  body.tm-app #tm-col-filter .tm-panel {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
    padding-top: 0.85rem;
  }

  body.tm-app .bottom-nav-item {
    font-size: 0.63rem;
    letter-spacing: 0.04em;
  }

  body.tm-app .bottom-nav-item svg {
    width: 19px;
    height: 19px;
  }
}

/* ——— Layout adaptasi contohindek.txt ——— */
.tm-canvas-col {
  min-height: 0;
  flex-direction: column;
  border-radius: 10px;
  border: 1px solid rgba(250, 204, 21, 0.22);
  background-color: #0c0c0c;
  background-image:
    linear-gradient(45deg, #1a1a1a 25%, transparent 25%),
    linear-gradient(-45deg, #1a1a1a 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1a1a1a 75%),
    linear-gradient(-45deg, transparent 75%, #1a1a1a 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  overflow: hidden;
}

.tm-canvas-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.35);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tm-canvas-bar-title {
  font-weight: 800;
  color: #facc15;
}

.tm-canvas-bar-meta {
  color: #9ca3af;
  font-weight: 600;
}

.tm-canvas-viewport {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  overflow: hidden;
}

.tm-canvas-viewport #dropArea.tm-canvas-shell {
  flex: 0 0 auto;
  max-height: 100%;
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.55);
}

.tm-sidebar {
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
}

.tm-panel-scroll {
  min-height: 0;
  overflow: auto;
}

.tm-panel-scroll::-webkit-scrollbar,
.tm-footer .tm-panel::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.tm-panel-scroll::-webkit-scrollbar-thumb,
.tm-footer .tm-panel::-webkit-scrollbar-thumb {
  background: rgba(250, 204, 21, 0.22);
  border-radius: 4px;
}

.tm-desktop-only {
  display: none;
}

/* Desktop: checkerboard + bar kanvas (tanpa mengubah grid 12 kolom) */
@media (min-width: 900px) {
  body.tm-app .tm-workspace.tm-workspace--trio {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    gap: 0.5rem;
  }

  body.tm-app .tm-workspace-top {
    display: grid !important;
    grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    width: 100%;
    align-items: stretch;
    gap: 0.65rem;
  }

  body.tm-app .tm-footer.tm-panel-layer-mobile {
    flex: 0 0 auto;
    width: 100%;
    min-height: 0;
    max-height: clamp(150px, 22vh, 172px);
    order: 2;
    padding: 0 0 0.15rem;
    border-top: 1px solid rgba(250, 204, 21, 0.12);
    background: rgba(0, 0, 0, 0.4);
    display: block !important;
  }

  body.tm-app #tm-col-center.tm-canvas-col {
    display: flex !important;
    flex-direction: column;
    min-height: 0;
    align-self: stretch;
  }

  body.tm-app #tm-stage.tm-canvas-viewport {
    flex: 1 1 auto;
    min-height: 0;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
  }

  body.tm-app .tm-canvas-viewport #dropArea.tm-canvas-shell.canvas-container {
    width: min(100%, calc(min(56vh, 680px) * 16 / 9));
    max-width: 100%;
    max-height: min(56vh, 680px);
    margin-inline: auto;
    flex: 0 0 auto;
  }

  body.tm-app .tm-canvas-viewport #dropArea[data-tm-aspect="16:9"] {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
  }

  body.tm-app .tm-canvas-viewport #dropArea[data-tm-aspect="1:1"] {
    width: min(100%, min(56vh, 640px));
    aspect-ratio: 1 / 1;
    height: auto;
  }

  body.tm-app .tm-canvas-viewport #dropArea[data-tm-aspect="9:16"] {
    width: min(100%, calc(min(56vh, 680px) * 9 / 16));
    aspect-ratio: 9 / 16;
    height: auto;
  }

  body.tm-app .tm-desktop-only {
    display: flex !important;
  }

  body.tm-app .tm-footer.tm-panel-layer-mobile {
    max-height: clamp(168px, 25vh, 196px);
  }

  body.tm-app .tm-footer #tm-editor-zone {
    padding: 0.4rem 0.55rem !important;
    height: 100%;
    overflow: hidden;
  }

  body.tm-app .tm-footer .tm-footer-dock {
    display: grid !important;
    grid-template-columns: minmax(7.5rem, 0.82fr) minmax(10rem, 1.05fr) minmax(11rem, 1.15fr) minmax(10rem, 1.08fr);
    gap: 0.45rem;
    align-items: stretch;
    min-height: 0;
    height: 100%;
    flex-direction: row !important;
  }

  body.tm-app .tm-footer .tm-layer-head.tm-dock-card {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    max-width: none;
    border-right: none;
    padding-right: 0;
  }

  body.tm-app .tm-footer .tm-footer-dock-tools {
    grid-column: 2 / -1;
    display: grid !important;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.15fr) minmax(0, 1.08fr);
    gap: 0.45rem;
    overflow: hidden;
    flex: 1 1 auto;
    min-width: 0;
    align-items: stretch;
  }

  body.tm-app .tm-footer .tm-layer-group--text {
    grid-column: 1;
    max-width: none !important;
    flex: none !important;
  }

  body.tm-app .tm-footer .tm-layer-group--sliders {
    grid-column: 2;
  }

  body.tm-app .tm-footer .tm-layer-group--colors-side {
    grid-column: 3;
    flex: none !important;
  }

  body.tm-app .tm-footer .tm-layer-row-top {
    min-height: 0 !important;
  }

  body.tm-app .tm-footer .tm-dock-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    padding: 0.35rem 0.45rem;
    border-radius: 8px;
    background: rgba(12, 12, 18, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-sizing: border-box;
  }

  body.tm-app .tm-footer .tm-dock-card > .tm-label {
    margin-bottom: 0.2rem;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #facc15;
    flex-shrink: 0;
  }

  body.tm-app .tm-footer .tm-layer-head .tm-label {
    color: #facc15;
  }

  body.tm-app .tm-footer .tm-layer-head button {
    min-height: 26px !important;
    padding-top: 0.1rem !important;
    padding-bottom: 0.1rem !important;
    font-size: 9px !important;
  }

  body.tm-app .tm-footer .tm-layer-head .grid.grid-cols-2 {
    gap: 0.25rem !important;
  }

  body.tm-app .tm-footer .tm-toggle-row {
    padding: 0.25rem 0.35rem !important;
    gap: 0.2rem !important;
  }

  body.tm-app .tm-footer .tm-layer-group--text textarea#textInput {
    min-height: 2rem !important;
    max-height: 2.5rem;
    margin-bottom: 0.35rem !important;
    padding: 0.35rem 0.45rem !important;
    font-size: 0.75rem !important;
  }

  body.tm-app .tm-footer .tm-layer-group--text .tm-font-block {
    margin-top: 0 !important;
    padding-top: 0.35rem !important;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }

  body.tm-app .tm-footer .tm-font-select {
    min-height: 28px !important;
    font-size: 11px !important;
    padding: 0.2rem 0.4rem !important;
  }

  body.tm-app .tm-footer #textStyleButtons {
    margin-top: 0.35rem !important;
    gap: 0.25rem !important;
  }

  body.tm-app .tm-footer #textStyleButtons .btn-toggle,
  body.tm-app .tm-footer #textStyleButtons .btn-align {
    min-height: 26px !important;
  }

  body.tm-app .tm-footer .tm-layer-group--sliders {
    flex: none !important;
    justify-content: flex-start;
  }

  body.tm-app .tm-footer .tm-slider-grid {
    flex: 0 0 auto;
    align-content: start;
    align-items: start;
    width: 100%;
  }

  body.tm-app .tm-footer .tm-slider-grid > .space-y-0.5,
  body.tm-app .tm-footer .tm-slider-grid > #lineHeightControl {
    margin: 0;
    min-height: 0;
  }

  body.tm-app .tm-footer .tm-slider-grid .flex.justify-between {
    margin-bottom: 0.1rem;
  }

  body.tm-app .tm-footer .tm-slider-grid .tm-range,
  body.tm-app .tm-footer .tm-slider-grid .custom-range {
    height: 4px !important;
    margin: 0;
  }

  body.tm-app .tm-footer #bg-opacity-control.hidden {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    height: 0 !important;
  }

  body.tm-app .tm-footer .tm-layer-group--assets,
  body.tm-app .tm-footer #shapeControlsGroup {
    display: none !important;
  }

  body.tm-app .tm-footer .tm-dock-card--colors {
    min-width: 0;
    max-width: none !important;
  }

  body.tm-app .tm-footer .tm-colors-modes--dock {
    flex-shrink: 0;
  }

  body.tm-app .tm-footer .tm-colors-modes--dock > div {
    flex: 1 1 0;
    min-width: 0;
    align-items: center;
  }

  body.tm-app .tm-footer .tm-colors-modes--dock .w-8 {
    width: 1.65rem !important;
    height: 1.65rem !important;
  }

  body.tm-app .tm-footer .tm-colors-modes--dock .w-4 {
    width: 0.75rem !important;
    height: 0.75rem !important;
  }

  body.tm-app .tm-footer .tm-colors-palette {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  body.tm-app .tm-footer .tm-color-palette-scroll {
    max-height: 2.65rem;
    overflow-y: auto;
    overflow-x: hidden;
  }

  body.tm-app .tm-footer .tm-color-palette button {
    width: 1.35rem !important;
    height: 1.35rem !important;
  }

  body.tm-app .tm-footer .tm-colors-palette .flex.gap-1 {
    margin-bottom: 0.25rem !important;
  }

  /* Paksa 3 kolom + layer bawah (abaikan sisa aturan grid rusak) */
  body.tm-app #tm-col-menu {
    display: flex !important;
    grid-column: span 3 / span 3 !important;
    grid-row: 1 !important;
  }

  body.tm-app #tm-col-center {
    display: flex !important;
    grid-column: span 7 / span 7 !important;
    grid-row: 1 !important;
  }

  body.tm-app #tm-col-filter {
    display: flex !important;
    grid-column: span 2 / span 2 !important;
    grid-row: 1 !important;
  }

  body.tm-app #tm-col-layer {
    display: block !important;
  }
}

@media (max-width: 899px) {
  body.tm-app .tm-canvas-col {
    border-radius: 8px;
    flex: 0 0 auto;
    height: min(38dvh, 260px);
    min-height: 180px;
    max-height: 280px;
    margin-bottom: 4px;
  }

  body.tm-app .tm-canvas-viewport {
    padding: 6px;
  }
}
