.clone-page {
  width: 100%;
  padding: 28px 24px 40px;
  flex: 1;
}
.clone-language {
  margin: 10px 0;
}
.clone-language select {
  width: 100%;
}
#clone-language-status {
  font-size: 12px;
  line-height: 1.5;
  margin: 8px 0;
}
#clone-language-translate {
  font-size: 12px;
  margin-bottom: 10px;
}
.clone-panel {
  width: min(980px, 100%);
  height: min(760px, calc(100vh - 120px));
  height: min(760px, calc(100dvh - 120px));
  min-height: 520px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 18px 55px #00000012;
  background: var(--ground);
  overflow: hidden;
}
.clone-header {
  grid-column: 1/-1;
  display: flex;
  align-items: center;
  padding: 16px 20px;
  gap: 12px;
}
.clone-header h1 {
  font-size: 17px;
  text-align: center;
  flex: 1;
  margin: 0;
}
.clone-header > span {
  width: 32px;
  font-size: 13px;
  color: var(--ink-3);
}
.clone-preview {
  grid-column: 1;
  grid-row: 2/5;
  padding: 12px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.clone-preview video {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: 14px;
  background: var(--ground-2);
}
.clone-preview b {
  font-size: 14px;
}
.clone-progress {
  grid-column: 2;
  display: flex;
  gap: 6px;
  padding: 0 26px 2px;
}
/* Each bar is a button; completed steps are tappable shortcuts back. */
.clone-progress button {
  flex: 1;
  padding: 12px 0;
  border: 0;
  background: none;
  cursor: default;
}
.clone-progress button i {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--ground-2);
}
.clone-progress button.on i {
  background: var(--ink);
}
.clone-progress button:disabled {
  opacity: 1;
}
.clone-progress button:not(:disabled) {
  cursor: pointer;
}
.clone-progress button:not(:disabled):hover i {
  background: var(--accent);
}
.clone-body {
  grid-column: 2;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 26px;
  display: flex;
  flex-direction: column;
}
.clone-step {
  width: 100%;
  max-width: 520px;
  margin: auto;
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 12px;
}
.clone-step h2 {
  font-size: 21px;
  line-height: 1.4;
  margin: 0;
}
.clone-lead {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
  margin: 0;
}
.clone-step p {
  margin: 0;
}
.clone-file {
  position: relative;
  cursor: pointer;
  overflow: hidden;
  min-height: 46px;
  justify-content: center;
}
.clone-file input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.clone-file:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.flow-consent {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
}
.flow-consent input {
  width: 16px;
  height: 16px;
}
.clone-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
/* A returning user sees only the photo used last time. */
.clone-compare.single {
  grid-template-columns: minmax(0, 220px);
}
.clone-compare.single .clone-photo-choice:disabled {
  opacity: 1;
}
.clone-photo-choice {
  display: flex;
  flex-direction: column;
  padding: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  text-align: left;
  background: var(--ground-2);
  min-width: 0;
}
.clone-photo-choice img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: contain;
  background: var(--ground-2);
}
.clone-photo-choice span,
.clone-photo-choice small {
  padding: 5px 10px 0;
}
.clone-photo-choice small {
  color: var(--ink-3);
  font-size: 11px;
}
.clone-photo-choice[aria-pressed="true"] {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.clone-photo-choice[aria-pressed="true"] span::after {
  content: " ✓";
  color: var(--accent);
}
.clone-photo-choice:disabled {
  opacity: 0.65;
}
/* The clean-up takes about half a minute; the wait is shown, not skipped. */
.clone-photo-wait {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-2);
}
.clone-photo-wait .spin {
  flex: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: clone-spin 0.9s linear infinite;
}
@keyframes clone-spin {
  to {
    transform: rotate(360deg);
  }
}
.clone-voice-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.clone-voice-options label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  flex: 1;
  font-size: 13px;
  white-space: nowrap;
}
#clone-own-voice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
#clone-own-voice p,
#clone-own-voice audio {
  width: 100%;
}
#clone-read-text {
  line-height: 1.7;
  font-size: 14px;
  background: var(--ground-2);
  padding: 12px;
  border-radius: 12px;
}
#clone-script {
  min-height: 230px;
  resize: vertical;
  font-size: 16px;
  line-height: 1.65;
}
.clone-script-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.clone-footer {
  grid-column: 2;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 26px 20px;
}
.clone-footer-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
}
.clone-footer-row .primary {
  width: 320px;
  max-width: calc(100% - 90px);
  flex: none;
}
.clone-footer-row > .btn {
  position: absolute;
  left: 0;
  max-width: 76px;
  padding: 0 10px;
}
/* Messages live in the footer so they are visible without scrolling. */
#clone-status {
  font-size: 13px;
  margin: 0 auto;
  max-width: 520px;
  width: 100%;
  text-align: center;
  line-height: 1.5;
  color: var(--ink-2);
}
#clone-status:empty {
  display: none;
}
#clone-status[data-error="true"] {
  color: var(--accent);
}
#clone-upload-retry {
  align-self: center;
}
.flow-consent.need {
  color: var(--accent);
  font-weight: 600;
}
.clone-library {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(620px, 92vw);
  max-height: 82vh;
  max-height: 82dvh;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--ground);
  color: var(--ink);
}
.clone-library::backdrop {
  background: #10131870;
}
.clone-library header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.clone-library h2 {
  font-size: 20px;
  margin: 0;
}
#clone-library-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  max-height: 55vh;
  max-height: 55dvh;
  overflow-y: auto;
}
#clone-library-items button {
  text-align: left;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  line-height: 1.5;
}
#clone-library-items small {
  color: var(--ink-3);
}
.clone-job {
  max-width: 980px;
  margin: 24px auto 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.clone-job audio,
.clone-job progress {
  width: 100%;
  margin: 12px 0;
}
.clone-page [hidden] {
  display: none !important;
}
@media (min-width: 900px) {
  /* Step 1 with both candidates fits the panel without scrolling. */
  .clone-photo-choice img {
    aspect-ratio: auto;
    height: 220px;
  }
}
@media (max-width: 899px) {
  .app[data-page="clone"] > .top,
  .app[data-page="clone"] > .tabs,
  .app[data-page="clone"] > .site-foot,
  .app[data-page="clone"] > .stage-note {
    display: none;
  }
  .clone-page {
    padding: 0;
  }
  .clone-panel {
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }
  .clone-header {
    padding: 14px 16px;
    background: var(--ground);
    position: sticky;
    top: 0;
    z-index: 3;
  }
  .clone-preview {
    display: none;
  }
  .clone-progress {
    padding: 0 20px 4px;
  }
  .clone-body {
    padding: 20px;
    flex: 1;
    overflow: visible;
  }
  .clone-step {
    margin: 0 auto;
  }
  .clone-footer {
    padding: 10px 20px max(16px, env(safe-area-inset-bottom));
    background: var(--ground);
    position: sticky;
    bottom: 0;
    z-index: 2;
  }
  .clone-footer-row > .btn {
    position: static;
    flex: none;
    max-width: none;
  }
  .clone-footer-row .primary {
    flex: 1;
    width: auto;
    max-width: none;
  }
  .clone-library {
    inset: auto 0 0;
    margin: 0;
    width: 100%;
    max-width: none;
    border-radius: 20px 20px 0 0;
    max-height: 85vh;
    max-height: 85dvh;
  }
  #clone-library-items {
    max-height: 60vh;
    max-height: 60dvh;
  }
  .clone-job {
    margin: 20px;
    padding: 16px;
  }
}

.clone-mobile-template {
  display: none;
}
@media (max-width: 899px) {
  .clone-mobile-template {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 0 20px 4px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--ground-2);
  }
  .clone-mobile-template img {
    width: 44px;
    height: 66px;
    object-fit: cover;
    border-radius: 8px;
  }
  .clone-mobile-template b {
    display: block;
    font-size: 14px;
  }
  .clone-mobile-template small {
    display: block;
    margin-top: 5px;
    color: var(--ink-2);
    font-size: 12px;
  }
}
