/* ============================================================
   MV MAKER — base.css
   Layout, components, animations. Theme-agnostic.
============================================================ */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font-sans, "Inter", "Noto Sans JP", system-ui, sans-serif);
  font-feature-settings: "kern" 1;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  user-select: none;
}

a { color: inherit; text-decoration: none; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
input, select { font: inherit; color: inherit; }

/* ============== LAYOUT ============== */
body {
  display: grid;
  grid-template-rows: var(--topbar-h, 56px) 1fr;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 16px;
  align-items: center;
  padding: 0 16px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}

.grid {
  display: grid;
  grid-template-columns: var(--pane-w, 220px) 1fr var(--pane-w-right, 300px);
  grid-template-rows: 1fr var(--timeline-h, 240px);
  grid-template-areas:
    "left stage right"
    "timeline timeline timeline";
  gap: 1px;
  background: var(--line);
  overflow: hidden;
  min-height: 0;
}

.pane-left  { grid-area: left; }
.stage      { grid-area: stage; }
.pane-right { grid-area: right; }
.timeline   { grid-area: timeline; }

.pane, .stage, .timeline { background: var(--panel); overflow: hidden; }

/* ============== TOP BAR ============== */
.brand {
  display: flex; align-items: center; gap: 8px;
  padding-right: 12px;
  border-right: 1px solid var(--line);
}
.brand-back {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 22px; line-height: 1;
  transition: background .15s, color .15s;
}
.brand-back:hover { background: var(--panel-2); color: var(--text); }

.brand-logo {
  font-family: var(--font-display, "Outfit", sans-serif);
  font-weight: 900;
  letter-spacing: 0.04em;
  font-size: 18px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-logo-dot { opacity: 0.5; padding: 0 2px; }

.title-input {
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  height: 36px;
  width: 100%;
  max-width: 420px;
  font-family: var(--font-display, "Outfit", sans-serif);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.title-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-fade); }
.title-input::placeholder { color: var(--text-muted); }

.aspect-switcher { display: flex; gap: 2px; background: var(--input-bg); padding: 2px; border-radius: 6px; }
.aspect-btn {
  font-family: var(--font-mono, "Space Mono", monospace);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 10px;
  color: var(--text-muted);
  border-radius: 4px;
  transition: background .15s, color .15s;
}
.aspect-btn:hover { color: var(--text); }
.aspect-btn.active { background: var(--accent); color: var(--accent-on); }

.actions { display: flex; gap: 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border-radius: 6px;
  font-weight: 700; font-size: 12px;
  letter-spacing: 0.06em;
  transition: background .15s, color .15s, transform .1s;
}
.btn .ico { font-size: 14px; line-height: 1; }
.btn:active { transform: translateY(1px); }

.btn-ghost { background: var(--input-bg); color: var(--text-muted); border: 1px solid var(--line); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

.btn-primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: var(--accent-on);
  font-weight: 900;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 6px 24px var(--accent-glow); }

/* ============== PANES ============== */
.pane { display: flex; flex-direction: column; }
.pane-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  height: 40px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.pane-title {
  font-family: var(--font-mono, "Space Mono", monospace);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--text-muted);
}
.pane-count {
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  opacity: 0.7;
}
.pane-count.near-limit {
  color: #ffae3c;            /* yellow/amber — warning */
  opacity: 1;
}
.pane-count.over-limit {
  color: #ff3050;            /* red — danger */
  opacity: 1;
  font-weight: 700;
  animation: count-pulse 1.4s ease-in-out infinite;
}
@keyframes count-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
.pane-btn {
  font-family: var(--font-mono, "Space Mono", monospace);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--accent);
  background: var(--accent-fade);
  transition: background .15s;
}
.pane-btn:hover { background: var(--accent-fade-2); }

/* MEDIA */
.media-section { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.section-label {
  margin: 0 0 8px;
  font-family: var(--font-mono, "Space Mono", monospace);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.req { color: var(--accent); margin-left: 4px; }

.media-slot {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 10px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}
.media-slot.empty { padding: 24px 10px; }
.media-slot.has-audio {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-fade);
  text-align: left;
  color: var(--text);
}

.media-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
.media-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  cursor: grab;
}
.media-item:hover { border-color: var(--accent); }
.media-item .thumb {
  width: 40px; height: 28px;
  background: #000;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
}
.media-item .info { flex: 1; overflow: hidden; }
.media-item .info .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-item .info .meta { color: var(--text-muted); font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.05em; }
.media-item .del { color: var(--text-muted); font-size: 13px; padding: 4px; }
.media-item .del:hover { color: var(--danger); }

/* ============== STAGE ============== */
.stage {
  display: flex; flex-direction: column;
  background: var(--stage-bg);
  position: relative;
}
.stage-frame {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 20px;
  position: relative;
  background:
    radial-gradient(ellipse at center, var(--stage-bg) 0%, var(--stage-bg-deep) 90%),
    repeating-linear-gradient(0deg, transparent, transparent 4px, rgba(255,255,255,0.012) 4px, rgba(255,255,255,0.012) 5px);
  overflow: hidden;
}
#canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  background: #000;
  box-shadow:
    0 0 0 1px var(--line),
    0 12px 60px rgba(0,0,0,0.6),
    0 0 80px var(--accent-glow-faint);
  border-radius: 4px;
  transition: filter .25s ease;
}
.canvas-transition { filter: blur(8px) brightness(1.15); }

.dropzone {
  position: absolute; inset: 20px;
  display: grid; place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10;
  animation: dz-pulse 2s ease-in-out infinite;
}
.dropzone.hidden { display: none; }
.dropzone.drag-over { border-color: var(--accent-2); background: rgba(0,0,0,0.7); }
@keyframes dz-pulse {
  0%, 100% { border-color: var(--accent); }
  50% { border-color: var(--accent-2); }
}
.dropzone-inner {
  text-align: center;
  padding: 30px 24px;
  width: 100%;
  max-width: 600px;
  max-height: 100%;
  overflow-y: auto;
}
.dropzone-cta-row {
  display: flex; gap: 10px;
  justify-content: center;
  align-items: center;
  margin: 12px 0 18px;
  flex-wrap: wrap;
}
.dropzone-cta {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 10px 20px;
}
.dropzone-browse {
  color: var(--text-muted);
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.dropzone-browse:hover { color: var(--text); border-color: var(--text-muted); }
.dropzone-divider {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 0.15em;
  color: var(--text-muted);
  margin: 14px 0 12px;
}
.dropzone-divider::before, .dropzone-divider::after {
  content: ""; flex: 1; height: 1px;
  background: var(--line);
}
.dropzone-templates {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 6px;
  max-width: 100%;
}
.dz-template {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .15s, transform .12s;
}
.dz-template:hover { border-color: var(--accent); transform: translateY(-2px); }
.dz-template-swatch {
  width: 100%;
  aspect-ratio: 16/10;
}
.dz-template-name {
  padding: 4px 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dropzone-icon {
  font-size: 64px; line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 24px var(--accent-glow);
  margin-bottom: 12px;
}
.dropzone-title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 28px;
  line-height: 1.2;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.dropzone-sub { color: var(--text-muted); font-size: 13px; margin: 0 0 16px; }
.dropzone-chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}
.link {
  color: var(--accent); text-decoration: underline;
  font-size: 12px; font-family: var(--font-mono); letter-spacing: 0.05em;
}

.transport {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px;
  height: 36px;
  background: var(--panel-2);
  border-top: 1px solid var(--line);
}
.tc {
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.06em;
  color: var(--text-muted);
  min-width: 48px;
}
#seek {
  flex: 1;
  -webkit-appearance: none; appearance: none;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  outline: none;
}
#seek::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ============== RIGHT PANE — TABS ============== */
.tabs {
  display: flex;
  flex-wrap: wrap;     /* tabs wrap to a 2nd row if pane is narrow */
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.tab {
  flex: 1 1 18%;       /* ~5 per row max; will wrap to 2 rows for 9 tabs */
  min-width: 0;
  padding: 9px 4px;
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  border-right: 1px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); background: rgba(255,43,220,0.05); }

.tab-panel { display: none; padding: 14px; overflow-y: auto; flex: 1; min-height: 0; }
.tab-panel.active { display: block; }

/* LOOKS GALLERY */
.looks-head { margin-bottom: 8px; }
.looks-toprow {
  display: flex; gap: 6px; margin-bottom: 8px; align-items: center;
}
.looks-toprow .btn-surprise {
  flex: 0 0 auto;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: var(--accent-on);
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 900;
  letter-spacing: 0.1em;
  padding: 6px 12px;
  border-radius: 6px;
  box-shadow: 0 0 12px var(--accent-glow);
  transition: transform .1s, box-shadow .2s;
}
.looks-toprow .btn-surprise:hover { box-shadow: 0 0 20px var(--accent-glow); }
.looks-toprow .btn-surprise:active { transform: scale(0.96); }
#looks-search { width: 100%; height: 28px; font-size: 11px; padding: 4px 8px; }
.looks-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.looks-tag {
  background: var(--input-bg);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
}
.looks-tag:hover { color: var(--text); }
.looks-tag.active { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }
/* Favorites — share the same accent magenta for visual discipline */
.looks-tag-fav { color: var(--accent); border-color: var(--accent-fade-2); }
.looks-tag-fav.active { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }
.looks-stats { font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); letter-spacing: 0.15em; margin: 6px 0; display: flex; justify-content: space-between; }

.current-look-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--input-bg);
  border: 1px solid var(--accent-fade-2);
  border-radius: 6px;
  padding: 6px 10px;
  margin: 8px 0;
}
.current-look-label {
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--accent);
}
.current-look-text {
  flex: 1; min-width: 0;
  font-size: 11px; font-weight: 700;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.current-look-reset {
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.current-look-reset:hover { color: var(--accent); border-color: var(--accent); }

.recent-row { display: flex; gap: 4px; margin-bottom: 8px; overflow-x: auto; padding-bottom: 4px; }
.recent-row .look-card { flex: 0 0 48px; aspect-ratio: 1 / 1; }
.recent-row.empty { display: none; }
.recent-label {
  font-family: var(--font-mono);
  font-size: 8px; font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin: 4px 0;
}

.looks-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);   /* larger thumbnails */
  gap: 8px;
  max-height: calc(100vh - 440px);
  overflow-y: auto;
}
.look-card {
  position: relative;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  transition: transform .12s, border-color .12s, box-shadow .12s;
  background: #000;
}
.look-card:hover { transform: translateY(-2px); border-color: var(--accent); z-index: 2; }
.look-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 0 16px var(--accent-glow);
}
.look-card .look-preview {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  pointer-events: none;     /* allow click to reach .look-card */
}
.look-card .look-stripes {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 4px;
  display: flex;
}
.look-card .look-stripes span { flex: 1; display: block; }
.look-card .look-swatch { position: absolute; inset: 0; }
.look-card .look-mood {
  position: absolute; top: 4px; left: 4px;
  font-family: var(--font-mono);
  font-size: 8px; font-weight: 700;
  color: #fff; letter-spacing: 0.12em;
  background: rgba(0,0,0,0.7);
  padding: 2px 5px;
  border-radius: 3px;
}
.look-card .look-name {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 4px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(transparent, rgba(0,0,0,0.85) 60%);
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.look-card .look-fav {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  background: rgba(0,0,0,0.6);
  border-radius: 50%;
  color: rgba(255,255,255,0.5);
  font-size: 14px;
  line-height: 1;
  border: 0;
  transition: color .15s, background .15s, transform .1s;
  z-index: 3;
}
.look-card .look-fav:hover { color: var(--accent); background: rgba(0,0,0,0.8); transform: scale(1.15); }
.look-card .look-fav.is-fav { color: var(--accent); background: rgba(0,0,0,0.8); }

.palette-preview {
  display: flex;
  height: 22px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--line);
  margin: 4px 0 12px;
}
.palette-preview span {
  flex: 1;
  display: block;
}
.palette-preview-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  margin-top: 4px;
}

.looks-pager {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

/* SRT panel */
.srt-tools { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
#srt-text { color: var(--text); background: var(--input-bg); border: 1px solid var(--line); border-radius: 4px; }
#srt-text:focus { border-color: var(--accent); outline: none; }

/* TEMPLATES */
.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.template {
  position: relative;
  aspect-ratio: 16/10;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.template:hover { transform: translateY(-2px); border-color: var(--accent); }
.template.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 0 20px var(--accent-glow);
}
.template .swatch { position: absolute; inset: 0; }
.template .label {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 4px 6px;
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.1em;
  background: linear-gradient(transparent, rgba(0,0,0,0.85) 50%);
  color: #fff;
  text-align: left;
}
.template .ar {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.05em;
  padding: 1px 4px;
  border-radius: 2px;
}

/* CTRL ROW */
.ctrl-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.ctrl-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}
.select, .input {
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
  height: 28px;
  font-size: 11px;
  outline: none;
  width: 100%;
}
.select:focus, .input:focus { border-color: var(--accent); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px;
  background: var(--line);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

/* EFFECTS */
.effect-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  margin-bottom: 4px;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color .15s;
}
.effect-row:hover { border-color: var(--text-muted); }
.effect-row.on { border-color: var(--accent); background: var(--accent-fade); }
.effect-row .name { flex: 1; font-size: 12px; font-weight: 700; }
.effect-row .name small { display: block; font-weight: 400; font-size: 9px; color: var(--text-muted); margin-top: 2px; letter-spacing: 0.05em; }
.effect-row .toggle-dot {
  width: 28px; height: 16px;
  background: var(--line);
  border-radius: 999px;
  position: relative;
  transition: background .15s;
}
.effect-row .toggle-dot::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform .15s, background .15s;
}
.effect-row.on .toggle-dot { background: var(--accent); }
.effect-row.on .toggle-dot::after { transform: translateX(12px); background: #fff; }

.effect-row .intensity {
  width: 100%;
  margin-top: 6px;
}
.effect-row-wrap.on .intensity-wrap { display: block; }
.intensity-wrap { display: none; padding: 0 10px 8px; margin-top: -4px; margin-bottom: 4px; background: var(--input-bg); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 6px 6px; }

/* PROPS */
.props-empty { padding: 20px; text-align: center; }
.muted { color: var(--text-muted); font-size: 12px; }
.props-group { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.props-group h5 {
  margin: 0 0 8px;
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 700; letter-spacing: 0.18em;
  color: var(--text-muted);
}
.props-group .ctrl-row { grid-template-columns: 70px 1fr; margin-bottom: 8px; }
.props-row-flex { display: flex; gap: 6px; }
.props-row-flex .input { width: 0; flex: 1; }

/* ============== TIMELINE ============== */
.timeline { display: flex; flex-direction: column; }
.timeline-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px;
  height: 36px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.timeline-title {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700; letter-spacing: 0.2em;
  color: var(--text-muted);
}
.timeline-tools { display: flex; gap: 6px; }
.timeline-body { flex: 1; overflow-y: auto; padding: 6px 0; }

.track {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  margin-bottom: 2px;
}
.track-label {
  font-family: var(--font-mono);
  font-size: 9px; font-weight: 700; letter-spacing: 0.15em;
  color: var(--text-muted);
  text-align: right;
  padding-right: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-area {
  position: relative;
  height: 22px;
  background: var(--input-bg);
  border-radius: 3px;
  overflow: hidden;
}
.track-waveform { height: 64px; }
.track-waveform .track-area { height: 56px; }
#waveform-canvas { display: block; width: 100%; height: 100%; }

.playhead {
  position: absolute; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
  pointer-events: none;
  z-index: 5;
  left: 0;
  box-shadow: 0 0 8px var(--accent-glow);
}

.layer-bar {
  position: absolute;
  top: 2px; bottom: 2px;
  border-radius: 3px;
  cursor: pointer;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.15);
  transition: filter .15s;
}
.layer-bar:hover { filter: brightness(1.2); }
.layer-bar.selected { box-shadow: 0 0 0 2px #fff inset; }
.layer-bar .lb-label {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 9px; font-weight: 700;
  color: #000;
  white-space: nowrap;
  text-shadow: 0 0 4px rgba(255,255,255,0.3);
  letter-spacing: 0.05em;
}
.layer-bar-video     { background: linear-gradient(90deg, #a855f7, #8b5cf6); }
.layer-bar-image     { background: linear-gradient(90deg, #06b6d4, #0891b2); }
.layer-bar-text      { background: linear-gradient(90deg, #facc15, #eab308); }
.layer-bar-shape     { background: linear-gradient(90deg, #22d3ee, #06b6d4); }
.layer-bar-visualizer{ background: linear-gradient(90deg, #ec4899, #db2777); }

/* ============== MODAL ============== */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: grid; place-items: center;
  z-index: 100;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 720px; max-width: 95vw; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  overflow: hidden;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.modal-close { color: var(--text-muted); font-size: 18px; padding: 6px 10px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.preset {
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 8px;
  font-size: 12px; font-weight: 700;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.preset small { display: block; font-size: 9px; font-weight: 400; color: var(--text-muted); letter-spacing: 0.05em; margin-top: 4px; }
.preset:hover { border-color: var(--accent); }
.preset.active {
  border-color: var(--accent);
  background: var(--accent-fade);
  box-shadow: 0 0 0 2px var(--accent);
}

.toggle-row { display: flex; gap: 4px; background: var(--input-bg); padding: 3px; border-radius: 6px; }
.toggle {
  flex: 1;
  padding: 8px 12px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}
.toggle.active { background: var(--accent); color: var(--accent-on); }

.export-status { margin-top: 20px; }
.status-line {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.progress {
  height: 6px;
  background: var(--input-bg);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0%;
  transition: width .2s ease;
}

/* MOBILE FAB — show only on small screens */
.mobile-fab {
  display: none;
  position: fixed;
  right: 16px; bottom: 16px;
  z-index: 50;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-on);
  border: 0;
  border-radius: 999px;
  padding: 14px 22px 14px 18px;
  font-family: var(--font-mono);
  font-weight: 900;
  letter-spacing: 0.12em;
  font-size: 13px;
  box-shadow: 0 8px 24px var(--accent-glow), 0 4px 12px rgba(0,0,0,0.4);
  cursor: pointer;
  align-items: center;
  gap: 10px;
}
.mobile-fab-bars {
  display: inline-flex; flex-direction: column; gap: 3px;
}
.mobile-fab-bars span { width: 16px; height: 2px; background: #fff; border-radius: 1px; }
.pane-right.open ~ .mobile-fab { transform: translateY(120px); opacity: 0; pointer-events: none; }
@media (max-width: 900px) { .mobile-fab { display: inline-flex; } }

/* TOAST */
.toast {
  position: fixed;
  top: 76px; right: 16px;
  background: var(--panel);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px; font-weight: 700;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 0 24px var(--accent-glow);
  animation: toast-in .25s ease-out;
  z-index: 200;
}
.toast[hidden] { display: none; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* SCROLLBARS */
.tab-panel::-webkit-scrollbar,
.media-list::-webkit-scrollbar,
.timeline-body::-webkit-scrollbar,
.modal-body::-webkit-scrollbar { width: 8px; height: 8px; }
.tab-panel::-webkit-scrollbar-track,
.media-list::-webkit-scrollbar-track,
.timeline-body::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track { background: transparent; }
.tab-panel::-webkit-scrollbar-thumb,
.media-list::-webkit-scrollbar-thumb,
.timeline-body::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}
.tab-panel::-webkit-scrollbar-thumb:hover,
.media-list::-webkit-scrollbar-thumb:hover,
.timeline-body::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================================
   MOBILE — bottom-sheet Inspector, scrollable tabs, large touch
============================================================ */
@media (max-width: 900px) {
  body {
    grid-template-rows: var(--topbar-h, 52px) 1fr;
  }
  .topbar {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    padding: 0 10px;
    min-height: 52px;
  }
  .aspect-switcher { display: none; }
  .title-input { max-width: none; font-size: 13px; height: 36px; }
  .brand-logo { font-size: 14px; }
  .brand-back { width: 36px; height: 36px; font-size: 24px; }
  .btn { height: 36px; padding: 0 10px; font-size: 11px; }
  .btn .ico { font-size: 14px; }
  .btn-ghost span:last-child,
  .btn-primary span:last-child { display: none; }   /* show icons only on mobile top bar */
  .btn-ghost .ico,
  .btn-primary .ico { font-size: 16px; }

  /* Stack the grid: stage / left media / timeline; right pane becomes a sheet */
  .grid {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 100px 140px;
    grid-template-areas: "stage" "left" "timeline";
  }
  .pane-left {
    max-height: 100px;
    overflow: hidden;
  }
  .pane-left .media-section { padding: 6px 10px; }
  .pane-left .media-section + .media-section { display: none; }   /* hide images list, only show audio */
  #media-audio.empty { padding: 8px; }

  /* Right pane (Inspector) becomes a bottom sheet overlaying stage */
  .pane-right {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    top: auto;
    height: 60vh;
    max-height: 70vh;
    grid-area: unset;
    z-index: 40;
    transform: translateY(calc(100% - 56px));   /* peek 56px tab strip */
    transition: transform .25s ease;
    background: var(--panel);
    border-top: 2px solid var(--accent);
    box-shadow: 0 -12px 40px rgba(0,0,0,0.5);
    border-radius: 16px 16px 0 0;
  }
  .pane-right.open { transform: translateY(0); }

  /* Drag handle */
  .pane-right::before {
    content: "";
    display: block;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px; height: 4px;
    background: var(--text-muted);
    border-radius: 2px;
    opacity: 0.5;
  }
  .pane-right .tabs {
    margin-top: 18px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }
  .pane-right .tab {
    flex: 0 0 auto;
    padding: 14px 14px;       /* ≥44px tap target */
    min-width: 76px;
    font-size: 10px;
    scroll-snap-align: start;
  }

  /* Timeline collapsed by default on mobile */
  .timeline { font-size: 11px; }
  .timeline-body { padding: 4px 0; }
  .track { height: 26px; padding: 0 8px; gap: 6px; }
  .track-label { font-size: 8px; }
  #track-waveform { height: 44px; }
  .track-waveform { height: 52px; }
  .track-waveform .track-area { height: 44px; }

  /* Controls — larger touch targets */
  input[type="range"] {
    height: 28px;
    -webkit-appearance: none;
    background: transparent;
  }
  input[type="range"]::-webkit-slider-runnable-track {
    height: 4px; background: var(--line); border-radius: 2px;
  }
  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: -9px;
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-glow);
  }
  .select, .input {
    height: 38px;
    font-size: 13px;
    padding: 8px 10px;
  }
  .ctrl-row { grid-template-columns: 90px 1fr; gap: 8px; margin-bottom: 14px; }
  .ctrl-label { font-size: 10px; }
  .pane-btn { padding: 8px 12px; font-size: 11px; min-height: 36px; }

  /* Looks grid: 2 columns of bigger cards (already 2-col, just resize) */
  .looks-grid { max-height: calc(60vh - 320px); }
  .look-card { aspect-ratio: 16/10; }
  .look-card .look-fav { width: 28px; height: 28px; font-size: 16px; }
  .recent-row .look-card { flex: 0 0 56px; }
  .looks-tag { padding: 6px 10px; font-size: 10px; min-height: 30px; }

  /* Dropzone shouldn't cover the whole stage on tiny screens */
  .dropzone-inner { padding: 20px; }
  .dropzone-icon { font-size: 42px; margin-bottom: 8px; }
  .dropzone-title { font-size: 18px; }
  .dropzone-sub { font-size: 11px; }
  .chip { font-size: 10px; }

  /* Modal full-screen on mobile */
  .modal-box {
    width: 100vw; height: 100vh; max-height: 100vh;
    border-radius: 0;
  }
  .preset-grid { grid-template-columns: repeat(2, 1fr); }

  /* Toast bigger */
  .toast { top: 60px; left: 16px; right: 16px; }
}

/* Even smaller — true phone width */
@media (max-width: 480px) {
  .pane-right .tab { min-width: 64px; padding: 14px 8px; }
  .preset-grid { grid-template-columns: 1fr 1fr; }
  .looks-grid { grid-template-columns: 1fr 1fr; }
}

/* ============== MV MAKER QUALITY PASS ============== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.aspect-select { display: none; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.safe-zone-overlay {
  --safe-x: 5%;
  --safe-y: 8%;
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  transform: translate(-50%, -50%);
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.2);
  overflow: hidden;
}
.safe-zone-overlay[hidden] { display: none; }
.safe-zone-overlay[data-aspect="9:16"] { --safe-x: 8%; --safe-y: 14%; }
.safe-zone-overlay[data-aspect="1:1"] { --safe-x: 8%; --safe-y: 8%; }
.safe-zone-overlay[data-aspect="21:9"] { --safe-x: 5%; --safe-y: 12%; }
.safe-zone-overlay[data-aspect="4:3"] { --safe-x: 6%; --safe-y: 8%; }
.safe-zone-inner {
  position: absolute;
  inset: var(--safe-y) var(--safe-x);
  border: 1px dashed rgba(255,255,255,0.78);
  box-shadow: 0 0 0 9999px rgba(4,3,9,0.1);
}
.safe-zone-label {
  position: absolute;
  left: calc(var(--safe-x) + 5px);
  top: calc(var(--safe-y) + 5px);
  color: rgba(255,255,255,0.78);
  font: 700 9px/1 var(--font-mono, monospace);
  letter-spacing: 0.12em;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.template-grid { display: block; }
.template-group + .template-group { margin-top: 18px; }
.template-category {
  margin: 0 0 8px;
  color: var(--text-muted);
  font: 700 9px/1.2 var(--font-mono, monospace);
  letter-spacing: 0.16em;
}
.template-category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.template { min-height: 112px; }
.template .summary {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 23px;
  color: rgba(255,255,255,0.78);
  font-size: 9px;
  line-height: 1.35;
  text-align: left;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}
.template .meta {
  position: absolute;
  top: 5px;
  left: 5px;
  padding: 2px 4px;
  border-radius: 2px;
  background: rgba(0,0,0,0.66);
  color: rgba(255,255,255,0.82);
  font: 700 8px/1.2 var(--font-mono, monospace);
}

.materials-intro .muted { margin: 0 0 12px; font-size: 11px; line-height: 1.55; }
.material-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.material-card {
  min-height: 108px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--input-bg);
  text-align: left;
  transition: border-color .15s, transform .12s;
}
.material-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.material-card[aria-busy="true"] { opacity: 0.62; cursor: wait; }
.material-card img { display: block; width: 100%; aspect-ratio: 3/2; object-fit: cover; }
.material-card span { display: block; padding: 7px 8px; font-size: 10px; font-weight: 700; }
.material-empty {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}
.material-empty[hidden] { display: none; }
.material-empty strong { color: var(--text); }
.material-status { min-height: 18px; margin-top: 10px; font-size: 10px; }

.export-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.export-quick-grid .pane-btn { min-height: 40px; }
.export-note {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.55;
  user-select: text;
}

@media (pointer: coarse), (max-width: 900px) {
  .btn,
  .pane-btn,
  .aspect-btn,
  .tab,
  .modal-close,
  .toggle,
  .preset,
  .media-item .del,
  .look-fav {
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 900px) {
  .aspect-select {
    display: block;
    width: 66px;
    min-width: 0;
    height: 36px;
    padding: 0 5px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text);
    font: 700 10px var(--font-mono, monospace);
  }
  .safe-zone-label { font-size: 8px; }
}

@media (max-width: 480px) {
  html, body { width: 100%; max-width: 100%; overflow: hidden; }
  .topbar {
    grid-template-columns: minmax(70px, 1fr) 62px auto;
    gap: 4px;
    padding-inline: 6px;
  }
  .brand { display: none; }
  .title-input { min-width: 0; padding-inline: 7px; }
  .aspect-select { width: 62px; }
  .actions { min-width: 0; gap: 2px; }
  .actions .btn { width: 44px; min-width: 44px; padding: 0; justify-content: center; }
  .stage-frame { padding: 8px; }
  .dropzone { inset: 8px; }
  .dropzone-inner { padding: 14px 10px; }
  .dropzone-templates { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dz-template-name { font-size: 8px; padding-inline: 2px; }
  .template-category-grid,
  .material-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .template { min-height: 104px; }
  .export-quick-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* layer controls and online fallback */
.props-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.props-actions .pane-btn { min-height: 44px; letter-spacing: 0.08em; }
.props-actions .props-delete { color: var(--danger); border: 1px solid rgba(255,77,106,0.35); background: rgba(255,77,106,0.08); }
.online-optional {
  padding: 9px 10px;
  border-left: 2px solid var(--accent-2);
  background: rgba(0,224,255,0.05);
  line-height: 1.5;
}
.online-optional strong { color: var(--accent-2); font-family: var(--font-mono, monospace); letter-spacing: 0.08em; }