/* Camera workspace: stable preview and dock, independently scrolling tools. */
.app {
  --dock-size:88px;
  width:min(100%,430px);
  height:var(--tg-viewport-stable-height,100svh);
  min-height:0;
  max-height:none;
  padding:max(8px,var(--tg-content-safe-area-inset-top,0px),env(safe-area-inset-top,0px)) 12px max(8px,var(--tg-content-safe-area-inset-bottom,0px),env(safe-area-inset-bottom,0px));
  gap:8px;
  overflow:hidden;
  border-radius:0;
  font-size:15px;
}

.app .topbar {
  min-height:44px;
  flex:0 0 44px;
}

.topbar h1 {
  text-align:left;
  font-size:21px;
  font-weight:700;
}

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

.icon-button,.pro-link,.mini-button,.text-button {
  min-height:44px;
  min-width:44px;
  font-size:14px;
}

.icon-button {
  border:1px solid var(--line);
  border-radius:50%;
  background:transparent;
  color:var(--text);
  font-size:21px;
}

.pro-link {
  border:1px solid var(--line);
  border-radius:24px;
  background:transparent;
  color:var(--amber);
  padding:8px 16px;
}

.app .stage {
  flex:0 0 auto;
  padding:27px 0 0;
  margin:0;
}

.app .lens {
  width:min(100%,300px,max(180px,calc(var(--tg-viewport-stable-height,100svh) - 428px)));
  height:auto;
  border:1px solid #3a444d;
  box-shadow:none;
  flex-shrink:0;
}

.app .timer {
  position:absolute;
  top:0;
  left:50%;
  transform:translateX(-50%);
  height:22px;
  padding:0;
  background:transparent;
  color:var(--muted);
  font-size:14px;
  line-height:22px;
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}

.app .record-dot {
  display:none;
}

.app[data-mode="recording"] .timer {
  color:var(--coral);
}

.camera-welcome {
  position:absolute;
  inset:0;
  z-index:3;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:5px;
  padding:12% 10%;
  background:#141c22;
  text-align:center;
  touch-action:manipulation;
}

.camera-welcome .welcome-mark {
  font-size:26px;
  color:var(--teal);
  line-height:1;
}

.camera-welcome h2 {
  font-size:18px;
  line-height:1.2;
  margin:2px 0;
  font-weight:600;
}

.camera-welcome p {
  font-size:14px;
  line-height:1.3;
  color:var(--muted);
  margin:2px 0 6px;
}

.camera-welcome button {
  flex-shrink:0;
  padding:8px 14px;
  min-height:44px;
  border-radius:24px;
}

.text-button {
  background:transparent;
  border:0;
  color:var(--text);
}

.preview-tools {
  display:flex;
  justify-content:center;
  gap:8px;
  flex:0 0 44px;
}

.preview-tools button {
  background:transparent;
  border:1px solid var(--line);
  border-radius:24px;
  padding:8px 14px;
  color:var(--muted);
  box-shadow:none;
}

.preview-tools .is-active {
  color:var(--teal);
  border-color:var(--teal);
}

.app .status {
  position:static;
  transform:none;
  max-width:none;
  width:100%;
  min-height:0;
  flex:0 0 auto;
  margin:0;
  padding:8px 10px;
  border:0;
  border-radius:8px;
  background:#1d272c;
  color:#c7d4d7;
  text-align:center;
  font-size:14px;
  line-height:1.4;
  z-index:auto;
  pointer-events:auto;
}

.inline-note {
  font-size:14px;
  line-height:1.4;
  color:var(--muted);
  margin:0;
  padding:4px 2px;
}

.app .effect-strip {
  display:block;
  flex:1 1 0;
  min-height:92px;
  overflow-y:auto;
  overflow-x:hidden;
  padding:0;
  border:0;
  background:none;
  scrollbar-width:thin;
}

.app .effect-tabs {
  position:sticky;
  top:0;
  z-index:4;
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:0;
  flex-wrap:nowrap;
  background:var(--bg);
  padding:0 0 6px;
  margin:0;
}

.app .effect-tab {
  min-height:44px;
  min-width:0;
  padding:8px 3px;
  font-size:15px;
  font-weight:600;
  border:0;
  border-radius:0;
  border-bottom:2px solid transparent;
  background:transparent;
  color:var(--muted);
  box-shadow:none;
}

.app .effect-tab.is-active {
  color:var(--text);
  border-bottom-color:var(--teal);
  background:transparent;
  box-shadow:none;
}

.effect-groups {
  display:flex;
  gap:4px;
  margin:4px 0 10px;
  flex-wrap:wrap;
}

.effect-groups button {
  flex:1;
  padding:6px 8px;
  min-width:0;
}

.app .mini-button {
  background:#1c252d;
  color:var(--text);
  box-shadow:none;
  border:1px solid var(--line);
  border-radius:10px;
  padding:7px 12px;
  font-size:14px;
  min-height:44px;
}

.app .mini-button.is-active {
  border-color:var(--teal);
  color:var(--teal);
  background:#192b29;
  box-shadow:none;
}

.app .effect-list {
  padding:6px 0 10px;
  gap:8px;
  overflow-x:auto;
  scrollbar-width:thin;
}

.app .layer-tile {
  height:auto;
  min-height:58px;
  min-width:92px;
  flex:0 0 92px;
  padding:10px 8px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#1c242c;
  color:var(--text);
  box-shadow:none;
}

.app .layer-tile>span {
  font-size:14px;
}

.app .layer-tile>small {
  font-size:12px;
  color:var(--muted);
}

.app .layer-tile.is-active {
  border-color:var(--teal);
  background:#192b29;
  box-shadow:none;
}

.app .layer-tile.is-locked {
  opacity:1;
}

.app .locked-badge {
  color:var(--amber);
  background:#252820;
  font-size:11px;
  padding:2px 5px;
  top:4px;
  right:3px;
}

.app #layerCustom {
  align-items:start;
}

.app #layerCustom .layer-tile {
  flex-basis:78px;
  min-width:78px;
  padding:2px 2px 6px;
  display:flex;
  align-items:center;
  flex-direction:column;
  gap:6px;
  background:none;
  border-color:transparent;
}

.app #layerCustom .layer-tile>small {
  display:none;
}

.app #layerCustom .layer-tile>span:not(.style-thumbnail) {
  font-size:14px;
  white-space:normal;
  line-height:1.2;
  max-width:76px;
}

.app #layerCustom .is-active .style-thumbnail {
  outline:2px solid var(--teal);
  outline-offset:2px;
}

.style-thumbnail {
  width:68px;
  height:68px;
  position:relative;
  display:block;
  border-radius:50%;
  overflow:hidden;
  flex-shrink:0;
  background:#31434a;
}

.style-thumbnail img {
  display:block;
  width:100%;
  height:100%;
  object-fit:cover;
}

.style-thumbnail.has-ring {
  border:3px solid var(--thumb-ring);
}

.thumb-decoration {
  position:absolute;
  bottom:10px;
  left:0;
  right:0;
  background:#572826a0;
  color:white;
  text-align:center;
  font-size:10px;
  font-style:normal;
}

.thumb-decoration:empty {
  display:none;
}

.style-actions {
  display:flex;
  align-items:start;
  gap:8px;
  margin-top:2px;
}

.style-management {
  flex:1;
}

.style-management summary,.retouch-details summary {
  min-height:44px;
  padding:12px;
  cursor:pointer;
  font-size:14px;
  color:var(--muted);
}

.style-menu {
  display:grid;
  gap:6px;
}

.retouch-presets {
  display:flex;
  gap:8px;
  margin:6px 0;
}

.retouch-presets button {
  flex:1;
}

.face-sliders {
  gap:8px;
  padding:4px 0;
}

.app .slider-row {
  font-size:14px;
  min-height:56px;
}

.slider-row input[type="range"] {
  min-height:28px;
}

.app .screen-sub-title,.app .brand-sub-title {
  font-size:14px;
}

.app input[type="text"],.app select {
  min-height:44px;
  font-size:16px;
  max-width:100%;
}

.app .badge-chip,.app .brand-chip {
  min-height:44px;
  font-size:14px;
  box-shadow:none;
}

.app .brand-chip.is-active {
  background:#192b29;
  color:var(--teal);
  border-color:var(--teal);
  box-shadow:none;
}

.app .controls {
  display:grid;
  grid-template-columns:64px minmax(0,1fr) 64px;
  align-items:center;
  gap:10px;
  flex:0 0 var(--dock-size);
  min-height:var(--dock-size);
  margin-top:auto;
  background:var(--bg);
  border-top:1px solid var(--line);
  z-index:12;
}

.shutter-slot {
  height:76px;
  display:flex;
  justify-content:center;
  align-items:center;
}

.app .controls .file-control {
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  gap:3px;
  position:relative;
  inset:auto;
  transform:none;
  width:64px;
  height:60px;
  min-height:44px;
  border:0;
  border-radius:12px;
  background:transparent;
  color:var(--muted);
  font-size:14px;
  overflow:hidden;
}

.app .controls .file-control::after {
  content:none;
}

.file-control>span:first-child {
  font-size:24px;
  line-height:1;
}

.file-control:has(input:focus-visible) {
  outline:2px solid var(--teal);
}

.app .controls .camera-flip {
  position:static;
  display:flex;
  align-items:center;
  justify-content:center;
  width:56px;
  height:56px;
  transform:none;
  border:1px solid var(--line);
  background:transparent;
  box-shadow:none;
  color:var(--muted);
}

.app .controls .control.primary,.app .controls .control.danger {
  width:72px;
  height:72px;
  border:2px solid var(--teal);
  box-shadow:none;
}

.app .controls .control.primary::after {
  width:56px;
  height:56px;
  background:var(--teal);
}

.app .controls .control.primary:disabled {
  opacity:.4;
}

.app .controls .control.primary:disabled::after {
  background:var(--teal);
}

.app .controls .control.danger {
  border-color:var(--coral);
}

.app #stopButton,.app #convertButton {
  display:none;
}

.app[data-mode="recording"] #stopButton {
  display:flex;
}

.app[data-mode="recording"] #recordButton,.app[data-mode="import-preview"] #recordButton {
  display:none;
}

.app[data-mode="import-preview"] #convertButton {
  display:flex;
  min-height:52px;
  padding:8px 12px;
  text-align:center;
  font-size:14px;
  border-radius:28px;
}

.app[data-mode="preview"] .controls {
  display:none;
}

.app[data-mode="recording"] .effect-strip,.app[data-mode="importing"] .effect-strip {
  display:block;
  visibility:hidden;
  pointer-events:none;
}

.app[data-mode="recording"] .preview-tools,.app[data-mode="importing"] .preview-tools {
  visibility:hidden;
}

.app[data-mode="recording"] .file-control,.app[data-mode="recording"] .camera-flip,.app[data-mode="importing"] .controls>* {
  visibility:hidden;
}

.app[data-mode="recording"] .shutter-slot {
  visibility:visible;
}

.app[data-mode="preview"] .effect-strip {
  visibility:hidden;
  pointer-events:none;
}

.app[data-mode="preview"] .preview-tools {
  visibility:hidden;
}

.app .result-actions {
  display:flex;
  flex-direction:column;
  gap:8px;
  flex:0 0 auto;
  margin-top:auto;
}

.result-actions>.share-button {
  min-height:50px;
  padding:10px 14px;
  border-radius:14px;
  font-weight:600;
  font-size:15px;
}

.result-secondary {
  display:flex;
  justify-content:center;
  gap:6px;
  flex-wrap:wrap;
}

.result-secondary .mini-button {
  font-size:14px;
  flex:1;
  padding:8px;
}

.app-dialog {
  color:var(--text);
  background:#101419;
  border:1px solid #35414b;
  border-radius:22px;
  padding:20px;
  width:min(430px,calc(100vw - 20px));
  max-height:calc(100svh - 32px);
  overflow-y:auto;
  font:15px/1.4 Inter,system-ui,sans-serif;
}

.app-dialog::backdrop {
  background:#0009;
}

.app-dialog header {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:16px;
}

.app-dialog h2 {
  margin:0;
  font-size:21px;
}

.app-dialog .settings-link {
  display:flex;
  align-items:center;
  min-height:48px;
  color:#b3c2c7;
}

.app-dialog .option-row {
  font-size:15px;
  gap:12px;
}

.app-dialog select {
  min-height:44px;
  font:16px system-ui;
}

.app-dialog .icon-button {
  flex:0 0 44px;
}

.app button:focus-visible,.app summary:focus-visible,.app a:focus-visible {
  outline:2px solid var(--teal);
  outline-offset:2px;
}

.app button:disabled {
  cursor:default;
}

.app [data-debug-only] {
  font-size:12px;
}

.app[data-mode="private-beta"] {
  overflow:auto;
}

@media(max-height:700px) {
  .camera-welcome {
    padding:8% 9%;
    gap:2px;
  }

  .camera-welcome .welcome-mark {
    display:none;
  }

  .camera-welcome h2 {
    font-size:16px;
  }

  .camera-welcome p {
    font-size:14px;
  }

  .camera-welcome button {
    padding:5px 10px;
  }

  .app .lens {
    min-width:0;
  }

  .app .stage {
    padding-top:24px;
  }

  .app {
    gap:6px;
  }

  .app .status {
    padding:5px 8px;
  }

  .app #layerCustom .layer-tile {
    gap:4px;
  }

  .style-thumbnail {
    width:58px;
    height:58px;
  }

}

@media(max-height:580px) {
  .app .lens {
    min-width:0;
    width:180px;
  }

  .camera-welcome p {
    display:none;
  }

  .app .effect-strip {
    min-height:90px;
  }

  .app .status {
    max-height:58px;
    overflow-y:auto;
  }

  .app .preview-tools {
    flex-basis:44px;
  }

}

@media(prefers-reduced-motion:reduce) {
  *,*::before,*::after {
    animation-duration:.001ms!important;
    animation-iteration-count:1!important;
    transition-duration:.001ms!important;
    scroll-behavior:auto!important;
  }

}

.app[data-mode="preview"] .effect-strip {
  min-height:0;
  flex:1 1 0;
}

.app[data-mode="preview"] .effect-strip>* {
  display:none;
}

.app[data-mode="preview"] .result-actions {
  margin-top:0;
}

.app .timer {
  border:0;
  box-shadow:none;
}

.app .preview-tools .mini-button {
  background:transparent;
  color:var(--muted);
  border-radius:24px;
}

.app #compareButton {
  touch-action:none;
  user-select:none;
  -webkit-user-select:none;
}

.app [data-layer="face"] {
  padding-top:12px;
  border-top:1px solid var(--line);
}

.app .ring-row input[type="color"] {
  min-height:44px;
  min-width:44px;
}

.app .slider-row input[type="range"] {
  min-height:44px;
}

.app-dialog .payment-content .payment-terms input {
  min-height:22px;
}

.app #layerCustom .layer-tile>small {
  display:none;
}

@media(max-height:700px) {
  .camera-welcome h2 {
    display:none;
  }

  .camera-welcome p {
    margin:4px 0;
    line-height:1.3;
  }

  .app .camera-welcome {
    padding:10% 9%;
  }

}

@media(max-height:580px) {
  .camera-welcome p {
    display:block;
    font-size:14px;
  }

  .app .camera-welcome {
    padding:4px 7%;
    gap:0;
  }

  .camera-welcome button {
    min-height:44px;
    max-width:100%;
    font-size:13px;
  }

}

.app #layerCustom {
  display:block;
  overflow:visible;
}

.style-row {
  display:flex;
  gap:8px;
  overflow-x:auto;
  padding:6px 3px 10px;
  scrollbar-width:thin;
}

.styles-heading {
  font-size:14px;
  font-weight:500;
  color:var(--muted);
  margin:10px 3px 4px;
}

@media (max-height: 580px) {
  .app[data-mode="idle"] .lens { overflow: visible; border-color: transparent; background: transparent; }
  .app[data-mode="idle"] #cameraCanvas { visibility: hidden; }
  .app[data-mode="idle"] .camera-welcome { left: -60px; right: -60px; border-radius: 18px; padding: 10px 20px; }
  .app .camera-welcome p, .app .camera-welcome button { font-size: 14px; }
}

.app[data-mode="preview"] .preview-tools { visibility: visible; }

/* Diagnostic HUD stays inside a narrow phone preview. */
.app .perf-hud { max-width:calc(100% - 16px); white-space:pre-line; text-align:center; line-height:1.3; overflow-wrap:anywhere; }

/* A Pro effect is on and the account is not Pro: the shutter stays a shutter
   but reads "Pro" and opens the unlock page (syncCaptureGate in app.js). */
.app .controls .control.primary.is-pro-locked {
  border-color:var(--amber);
}

.app .controls .control.primary.is-pro-locked::after {
  content:"Pro";
  background:var(--amber);
  color:#1c1600;
  font:800 15px/56px system-ui, sans-serif;
  text-align:center;
  letter-spacing:.02em;
}

.app #convertButton.is-pro-locked {
  border-color:var(--amber);
  color:var(--amber);
}

/* A stable destination row; recording keeps its space so the lens never jumps. */
.destination-button {
  flex:0 0 44px; min-height:44px; min-width:0; width:100%;
  padding:8px 12px; border:1px solid var(--line); border-radius:14px;
  color:var(--text); background:transparent; font-size:14px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-align:left;
}
.app[data-mode="recording"] .destination-button,
.app[data-mode="importing"] .destination-button { visibility:hidden; }
.app:has(.destination-button:not([hidden])) .lens {
  width:min(100%,300px,max(160px,calc(var(--tg-viewport-stable-height,100svh) - 480px)));
}
.destination-row { display:flex; gap:8px; margin:8px 0; min-width:0; }
.destination-choice { flex:1; min-width:0; overflow-wrap:anywhere; text-align:left; }
.destination-choice[aria-pressed="true"] { border-color:var(--teal); color:var(--teal); }
#destinationDialog { overflow-wrap:anywhere; }
#destinationDialog p { color:var(--muted); font-size:14px; line-height:1.5; }
#forwardHelp { margin-top:16px; }
#forwardHelp summary { min-height:44px; cursor:pointer; font-size:14px; }

/* Retouch controls stay inside the existing scrollable tool area. */
.retouch-toolbar { display:flex; align-items:center; gap:12px; }
.retouch-toolbar button { min-height:44px; }
.retouch-switch { display:flex; align-items:center; gap:12px; min-height:44px; flex:1; position:relative; cursor:pointer; font-size:16px; }
.retouch-switch > span { pointer-events:none; }
.retouch-switch input { position:absolute; inset:0; z-index:1; opacity:0; width:100%; height:100%; margin:0; cursor:pointer; }
.retouch-switch-track { width:44px; height:26px; border-radius:20px; background:#555b64; padding:3px; box-sizing:border-box; flex-shrink:0; }
.retouch-switch-track::after { content:""; display:block; width:20px; height:20px; background:white; border-radius:50%; }
.retouch-switch input:checked + .retouch-switch-track { background:#238878; }
.retouch-switch input:checked + .retouch-switch-track::after { transform:translateX(18px); }
.retouch-switch input:focus-visible + .retouch-switch-track { outline:2px solid white; outline-offset:3px; }
#retouchSettings[hidden] { display:none; }
#retouchSettings input:disabled { opacity:.45; }
#retouchReset { min-height:44px; }

/* One-time "How did you find Circlens?" on the first preview: a single
   scrolling row, so short viewports keep Send where it was. */
.app .source-ask {
  display:flex;
  flex-direction:column;
  gap:6px;
}

.app .source-ask p {
  margin:0;
  font-size:13px;
  color:var(--muted);
  text-align:center;
}

.app .source-ask-options {
  display:flex;
  gap:6px;
  overflow-x:auto;
  scrollbar-width:none;
  -webkit-overflow-scrolling:touch;
}

.app .source-ask-options::-webkit-scrollbar {
  display:none;
}

.app .source-ask-options .mini-button {
  flex:0 0 auto;
  min-height:40px;
  padding:6px 12px;
  font-size:13px;
  white-space:nowrap;
}
