/* Film lab. Colour comes only from GM3 tokens (gm3-color-tokens.css).
   z-index ladder: stage status 5 -> toast 1200 -> error overlay 1300. */

:root {
  --md-ref-typeface-brand: 'Google Sans Flex', 'Google Sans', sans-serif;
  --md-ref-typeface-plain: 'Inter', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  font: 14px/1.5 var(--md-ref-typeface-plain);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, select, textarea { font-family: inherit; }
button { border: none; background: transparent; color: inherit; cursor: pointer; }
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined' !important;
  font-feature-settings: 'liga';
  white-space: nowrap;
  font-size: 20px;
}

/* ---- top bar ---- */
.top-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 24px;
  min-height: 64px;
  background: var(--md-sys-color-surface-container-low);
}
.title { display: flex; align-items: center; gap: 12px; font: 500 22px/1.2 var(--md-ref-typeface-brand); margin: 0; white-space: nowrap; }
.app-icon { display: block; width: 32px; height: 32px; border-radius: 8px; }
.meta { color: var(--md-sys-color-on-surface-variant); font-size: 12px; margin: 0; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }

/* ---- buttons ---- */
.btn, .btn-tonal, .btn-outlined {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 9999px;
  font: 500 14px/1 var(--md-ref-typeface-brand);
  white-space: nowrap;
  transition: filter 150ms ease, transform 150ms ease;
}
.btn { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.btn-tonal { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.btn-outlined { box-shadow: inset 0 0 0 1px var(--md-sys-color-outline-variant); color: var(--md-sys-color-on-surface); }
.btn:hover, .btn-tonal:hover, .btn-outlined:hover { filter: brightness(1.08); }
.btn:active, .btn-tonal:active, .btn-outlined:active { transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: default; }

/* ---- shell ---- */
.shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 168px 1fr 352px;
  gap: 16px;
  padding: 0 16px 16px;
}
.pane {
  background: var(--md-sys-color-surface-container);
  border-radius: 16px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--md-sys-color-outline-variant) transparent;
}
.pane::-webkit-scrollbar { width: 8px; }
.pane::-webkit-scrollbar-thumb { background: var(--md-sys-color-outline-variant); border-radius: 4px; }

/* ---- filmstrip ---- */
.strip { display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.thumb {
  position: relative;
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--md-sys-color-surface-container-high);
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.thumb-canvas { display: block; width: 100%; height: auto; background: var(--md-sys-color-surface-container-high); }
.thumb:hover { transform: translateY(-2px); }
.thumb.active { box-shadow: 0 0 0 3px var(--md-sys-color-primary); }
/* ---- empty state / drop zone ---- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 24px;
  text-align: center;
}
.empty-icon { font-size: 48px; color: var(--md-sys-color-on-surface-variant); }
.empty-title { margin: 0; font: 500 20px/1.3 var(--md-ref-typeface-brand); }
body.dragging .stage { box-shadow: inset 0 0 0 3px var(--md-sys-color-primary); }

.btn-text {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 9999px;
  color: var(--md-sys-color-primary);
  font: 500 14px/1 var(--md-ref-typeface-brand);
  text-decoration: none;
  white-space: nowrap;
}
.btn-text .material-symbols-outlined { font-size: 16px; }
.btn-text:hover { background: var(--md-sys-color-surface-container-high); }
[hidden] { display: none !important; }

/* ---- stage ---- */
.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--md-sys-color-surface-container-lowest);
  border-radius: 16px;
  overflow: hidden;
}
#view { display: block; max-width: 100%; max-height: 100%; }
.stage-status {
  position: absolute;
  z-index: 5;
  top: 16px;
  left: 16px;
  padding: 8px 16px;
  border-radius: 9999px;
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  font-size: 12px;
}

/* ---- controls ---- */
.controls { display: flex; flex-direction: column; gap: 24px; padding: 16px; }
.group { display: flex; flex-direction: column; gap: 12px; }
.section-title { font: 500 16px/1.3 var(--md-ref-typeface-brand); margin: 0; color: var(--md-sys-color-on-surface); }

.m3-pill-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.m3-pill-tabs > button {
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 12px;
  font: 500 13px/1 var(--md-ref-typeface-plain);
  white-space: nowrap;
  flex-shrink: 0;
  background-color: var(--md-sys-color-surface-container-lowest);
  box-shadow: inset 0 0 0 1px var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  transition: background-color 150ms ease, box-shadow 150ms ease;
}
.m3-pill-tabs > button[aria-selected="true"] {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  box-shadow: none;
}
.gm3-connected-dsp { gap: 2px; flex-wrap: nowrap; }
.gm3-connected-dsp > button {
  flex: 1;
  border-radius: 4px;
  box-shadow: none;
  background-color: var(--md-sys-color-surface-container-highest);
}
.gm3-connected-dsp > button:first-child { border-radius: 9999px 4px 4px 9999px; }
.gm3-connected-dsp > button:last-child { border-radius: 4px 9999px 9999px 4px; }
.gm3-connected-dsp > button[aria-selected="true"] { border-radius: 9999px; }

.slider-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  row-gap: 4px;
  font-size: 13px;
  color: var(--md-sys-color-on-surface-variant);
}
.slider-row output { font-variant-numeric: tabular-nums; color: var(--md-sys-color-on-surface); }
.slider-row input { grid-column: 1 / -1; width: 100%; height: 24px; margin: 0; accent-color: var(--md-sys-color-primary); }

.switch-row { display: flex; align-items: center; justify-content: space-between; min-height: 40px; font-size: 13px; }
.m3-switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 44px;
  height: 24px;
  margin: 0;
  border-radius: 9999px;
  background: var(--md-sys-color-surface-container-highest);
  box-shadow: inset 0 0 0 2px var(--md-sys-color-outline);
  cursor: pointer;
  transition: background-color 150ms ease;
}
.m3-switch::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--md-sys-color-outline);
  transition: transform 150ms ease, width 150ms ease;
}
.m3-switch:checked { background: var(--md-sys-color-primary); box-shadow: none; }
.m3-switch:checked::after {
  top: 4px;
  width: 16px;
  height: 16px;
  transform: translateX(18px);
  background: var(--md-sys-color-on-primary);
}

.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.compare { margin-top: auto; justify-content: center; user-select: none; -webkit-user-select: none; }

/* ---- toast & error ---- */
.toast {
  position: fixed;
  z-index: 1200;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 12px;
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.error-overlay {
  position: fixed;
  z-index: 1300;
  inset: 24px;
  padding: 24px;
  border-radius: 16px;
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  overflow: auto;
}
.error-text { white-space: pre-wrap; font-size: 12px; }

.quick-roll { display: none; }

/* Public site: generated leaks and artifacts only. */
body.online [data-mode="real"], body.online [data-mode="mix"],
body.online [data-art-mode="scans"], body.online [data-art-mode="mix"],
body.online #real-tools, body.online #dust-tools { display: none !important; }
body.online [data-mode="generated"]:not([aria-selected="true"]),
body.online [data-art-mode="generated"]:not([aria-selected="true"]) { border-radius: 4px 9999px 9999px 4px; }

/* ---- toggle chips (artifact kinds) ---- */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 12px;
  flex-shrink: 0;
  white-space: nowrap;
  font: 500 13px/1 var(--md-ref-typeface-plain);
  background-color: var(--md-sys-color-surface-container-lowest);
  box-shadow: inset 0 0 0 1px var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  transition: background-color 150ms ease, box-shadow 150ms ease;
}
.chip[aria-pressed="true"] {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  box-shadow: none;
}
.chip[aria-pressed="true"]::before {
  content: "check";
  font-family: 'Material Symbols Outlined';
  font-feature-settings: 'liga';
  font-size: 16px;
}

.stepper.locked .stepper-control { opacity: 0.5; }
.stepper.locked button { cursor: default; }
.stepper-control > button:disabled { opacity: 1; } /* dim the group once, not each button */

/* ---- dropdown menu (z-index 1100: above content, below toast) ---- */
.menu {
  position: fixed;
  z-index: 1100;
  margin: 0;
  padding: 8px 0;
  list-style: none;
  max-height: 60vh;
  overflow-y: auto;
  border-radius: 12px;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
[data-theme="dark"] .menu { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6); }
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 8px 16px 8px 12px;
  text-align: left;
  font: 14px/1.3 var(--md-ref-typeface-plain);
  white-space: nowrap;
}
.menu-item:hover { background: var(--md-sys-color-surface-container-highest); }
.menu-tick { font-size: 18px; visibility: hidden; color: var(--md-sys-color-primary); }
.menu-item[aria-checked="true"] .menu-tick { visibility: visible; }
.menu-item[aria-checked="true"] { font-weight: 600; }
.menu-heading {
  padding: 12px 16px 4px;
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
}

/* ---- shown only when index.html is opened from disk ---- */
.file-notice {
  max-width: 640px;
  margin: 24px auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  border-radius: 16px;
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
}
.file-notice p { margin: 0; color: var(--md-sys-color-on-surface-variant); }
.file-notice .btn { text-decoration: none; }
.file-notice-cmd {
  margin: 0;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--md-sys-color-surface-container-highest);
  font-size: 13px;
}

/* ---- film / grain steppers: ‹ value › ---- */
.stepper-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stepper { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stepper-caption { font-size: 12px; color: var(--md-sys-color-on-surface-variant); }
.stepper-control {
  display: flex;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
}
.stepper-control > button {
  min-height: 40px;
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  transition: filter 150ms ease;
}
.stepper-control > button:hover { filter: brightness(0.94); }
.stepper-arrow {
  flex: 0 0 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.stepper-arrow:first-child { border-radius: 9999px 4px 4px 9999px; }
.stepper-arrow:last-child { border-radius: 4px 9999px 9999px 4px; }
.stepper-value {
  flex: 1;
  min-width: 0;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--md-sys-color-primary-container) !important;
  color: var(--md-sys-color-on-primary-container) !important;
  font: 500 13px/1 var(--md-ref-typeface-plain);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- phones: photo on top, filmstrip, then controls; the page scrolls ---- */
@media (max-width: 840px) {
  html, body { overflow: auto; height: auto; }
  .shell { display: flex; flex-direction: column; }
  .stage { order: 1; min-height: 0; padding: 16px; }
  .strip { order: 2; flex-direction: row; overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
  .strip::-webkit-scrollbar { display: none; }
  .controls { order: 3; overflow: visible; }
  .strip { align-items: center; }
  .thumb { width: 96px; }
  .quick-roll { display: flex; flex-wrap: nowrap; }
  .quick-roll > button { flex: 1; justify-content: center; min-height: 48px; }
  .leak-actions { display: none; }
  .compare { margin-top: 0; }
  .top-bar { padding: 8px 16px; min-height: 56px; }
  .top-bar .meta { display: none; }
  .top-actions .btn-label { display: none; }
  .top-actions > button { padding: 8px 12px; min-width: 44px; justify-content: center; }
}
