*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #0a0a0a;
  color: #e8e8e8;
  font-family: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.bar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.35rem 0.5rem;
  border-color: #333;
  background: #0a0a0a;
}

.top-bar {
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #333;
}

.top-bar-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.bottom-bar {
  max-height: 40vh;
  overflow-y: auto;
}

.controls-shell {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  border-top: 1px solid #333;
  background: #0a0a0a;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.controls-tab {
  flex: 0 0 auto;
  align-self: flex-start;
  margin: 0.2rem 0.4rem 0;
  padding: 0.2rem 0.55rem;
  font-size: 11px;
  letter-spacing: 0.02em;
  background: #141414;
  border: 1px solid #3a3a3a;
  border-radius: 3px 3px 0 0;
  cursor: pointer;
  color: #9a9a9a;
}

.controls-tab:hover {
  color: #ccc;
  border-color: #555;
}

.controls-drawer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease;
}

.controls-drawer.is-open {
  /* Leave room for top bar + instructions + tab so the strip stays on-screen and easy to tap closed */
  max-height: min(40vh, 400px, calc(100dvh - 12.25rem), calc(100svh - 12.25rem));
  overflow-y: auto;
}

.controls-drawer-inner {
  border-top: 1px solid #2a2a2a;
  padding-top: 0.25rem;
}

.canvas-help {
  margin: 0;
  padding: 0 0 0.05rem;
  font-size: 11px;
  line-height: 1.35;
  color: #6a6a6a;
  text-align: left;
}

.capture-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  width: 100%;
  padding: 0.15rem 0.5rem 0.35rem;
}

.btn-capture {
  min-width: 7.5rem;
  padding: 0.35rem 0.85rem;
}

.capture-hint {
  display: block;
  text-align: center;
  font-size: 11px;
  line-height: 1.35;
  max-width: 22rem;
}

.mono {
  font-family: inherit;
}

.dim {
  color: #888;
}

.hint {
  margin-left: auto;
  flex: 1 1 8rem;
  text-align: right;
  min-width: 0;
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  overflow: hidden;
  container-type: size;
  container-name: stage;
}

.viewfinder-wrap {
  position: relative;
  width: min(96vmin, calc(100vw - 8px));
  height: min(96vmin, calc(100vh - 7rem));
  max-width: 100%;
  max-height: 100%;
}

/* Phone portrait (e.g. 1080×1920): tall viewfinder, 9:16 — size from .stage so footer + drawer always fit */
@media (orientation: portrait), (max-aspect-ratio: 1/1) {
  .viewfinder-wrap {
    aspect-ratio: 9 / 16;
    width: min(calc(100vw - 8px), calc((100svh - 12.25rem) * 9 / 16));
    height: auto;
    max-height: min(100%, calc(100svh - 12.25rem));
    max-width: 100%;
  }
}

@supports (width: 1cqh) {
  @media (orientation: portrait), (max-aspect-ratio: 1/1) {
    .viewfinder-wrap {
      width: min(calc(100vw - 8px), calc(100cqh * 9 / 16));
      max-height: min(100%, 100cqh);
    }
  }
}

#vf {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  image-rendering: pixelated;
  border: 1px solid #444;
  cursor: crosshair;
  background: #000;
}

.reticle {
  pointer-events: none;
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.reticle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
}

.row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.mute-row {
  gap: 0.25rem;
}

.mute-row input {
  margin: 0;
}

.mix-strip-label {
  opacity: 0.75;
}

.mix-fader input[type="range"] {
  width: 4.25rem;
  vertical-align: middle;
}

.mix-val {
  min-width: 1.35rem;
  text-align: right;
}

.inp {
  background: #111;
  color: #e8e8e8;
  border: 1px solid #444;
  padding: 0.15rem 0.35rem;
}

.btn {
  background: #111;
  color: #e8e8e8;
  border: 1px solid #555;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
}

.btn:hover {
  border-color: #888;
  color: #fff;
}

.btn[aria-pressed="true"] {
  border-color: #6a8;
  color: #bfe8c8;
}

.btn:active {
  background: #1a1a1a;
}

input[type="range"] {
  width: 4.5rem;
  accent-color: #ccc;
}
