/* Top Voice Studio: brand colours, Outfit, mobile first. */

@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('fonts/outfit-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
                   U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF,
                   U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('fonts/outfit-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                   U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                   U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --pink: #e8006a;
    --teal: #00c9b1;
    --bg: #0d0d14;
    --surface: #17171f;
    --line: #2a2a36;
    --text: #f4f4f7;
    --muted: #a2a2b3;
    --error: #ff6b8f;
    --radius: 16px;
}

* { box-sizing: border-box; }

/* display rules on classes (.btn, .msg...) must not override the hidden attribute */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font: 400 17px/1.45 'Outfit', system-ui, sans-serif;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.top {
    padding: 18px 20px 6px;
    font-size: 20px;
    letter-spacing: 0.02em;
}
.brand strong { color: var(--pink); font-weight: 700; }

main {
    max-width: 560px;
    margin: 0 auto;
    padding: 8px 16px 40px;
}

h1, h2 { margin: 0 0 6px; font-weight: 700; line-height: 1.15; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.lead, .hint { color: var(--muted); margin: 0 0 16px; }
.hint { font-size: 14px; }

/* ----- forms ----- */

label { display: block; margin: 12px 0 6px; font-weight: 500; }

input[type="password"], input[type="number"] {
    width: 100%;
    padding: 14px 16px;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 12px;
}
input:focus-visible, .btn:focus-visible, .picker:focus-within {
    outline: 3px solid var(--teal);
    outline-offset: 2px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 20px;
    font: 600 16px 'Outfit', system-ui, sans-serif;
    border: 0;
    border-radius: 999px;
    text-decoration: none;
    cursor: pointer;
}
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary { background: var(--pink); color: #fff; }
.btn-secondary { background: transparent; color: var(--teal); border: 2px solid var(--teal); }
.btn-link { background: none; color: var(--muted); text-decoration: underline; min-height: 40px; }

.login .btn { width: 100%; margin-top: 18px; }

/* Big tap target that opens the gallery */
.picker {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 28px 16px;
    border: 2px dashed var(--pink);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
}
.picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.picker-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--pink);
    color: #fff;
    font-size: 34px;
    line-height: 1;
}
.picker-text { font-size: 19px; font-weight: 600; }
.picker:has(input:disabled) { opacity: 0.5; cursor: progress; }

.options { margin-top: 14px; color: var(--muted); }

/* ----- cover image of the montage ----- */

.cover { display: flex; gap: 14px; align-items: flex-start; margin-top: 18px; }
.cover-thumb {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 72px;
    aspect-ratio: 9 / 16;
    margin: 0;
    border: 2px dashed var(--pink);
    border-radius: 10px;
    overflow: hidden;
    color: var(--pink);
    font-size: 26px;
    cursor: pointer;
}
.cover-thumb:has(img:not([hidden])) { border: 2px solid var(--teal); }
.cover-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-thumb img:not([hidden]) + .cover-plus { display: none; }
.cover-thumb input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.cover-thumb:focus-within { outline: 3px solid var(--teal); outline-offset: 2px; }
.cover-thumb.is-busy { opacity: 0.5; cursor: progress; }
.cover-info { min-width: 0; }
.cover-info .hint { margin: 4px 0 0; }
.cover-info .btn-link { padding-left: 0; }
.options summary { cursor: pointer; padding: 6px 0; }
.options label { color: var(--text); font-weight: 400; }

/* ----- progress and messages ----- */

.progress { margin-top: 16px; }
.progress-bar {
    height: 10px;
    border-radius: 999px;
    background: var(--bg);
    overflow: hidden;
}
.progress-bar span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--pink), var(--teal));
    transition: width 0.3s ease;
}
.progress p { margin: 8px 0 0; color: var(--muted); font-size: 15px; }

.msg { margin: 14px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--bg); }
.msg-ok { border-left: 4px solid var(--teal); }
.msg-error { border-left: 4px solid var(--error); color: var(--error); }
.msg-info { border-left: 4px solid var(--muted); }

/* ----- job list ----- */

.job-list { list-style: none; margin: 0; padding: 0; }
.job-list .empty { color: var(--muted); }

.job {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 0;
    border-top: 1px solid var(--line);
}
.job:first-child { border-top: 0; padding-top: 4px; }

.job-info { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
.job-name { font-weight: 600; overflow-wrap: anywhere; }
.job-time { color: var(--muted); font-size: 14px; }
.job-status, .job-error { grid-column: 1 / -1; font-size: 15px; }
.job-status { color: var(--muted); }
.job-error { color: var(--error); }

.job-processing .job-status { color: var(--teal); }
.job-processing .job-status::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 8px;
    border-radius: 50%;
    background: var(--teal);
    animation: pulse 1.2s ease-in-out infinite;
}
.job-done .job-status { color: var(--teal); font-weight: 600; }
.job-expired { opacity: 0.5; }

.job-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.logout { text-align: center; }

.btn-small { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn-wide { width: 100%; margin-top: 18px; }
.btn-secondary.btn-small { border-width: 1.5px; }
.btn-primary:disabled { background: var(--line); color: var(--muted); }

.btn-icon {
    flex: none;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-size: 17px;
    cursor: pointer;
}
.btn-icon:disabled { opacity: 0.3; cursor: default; }

/* ----- shelf: uploaded videos ----- */

.shelf {
    list-style: none;
    margin: 0 -20px;
    padding: 4px 20px 8px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scroll-padding-left: 20px;
}
/* positioned, so the hidden file input stays inside the scrolling row instead
   of widening the whole page (absolute elements escape overflow otherwise) */
.shelf > li { position: relative; flex: none; width: 112px; scroll-snap-align: start; }

.shelf-open, .shelf-add {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.shelf-thumb {
    position: relative;
    display: block;
    width: 100%; /* children of a <button> do not stretch on their own */
    aspect-ratio: 9 / 16;
    border-radius: 10px;
    background: var(--bg) center / cover;
    border: 2px solid var(--line);
    overflow: hidden;
}
.shelf-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* no thumbnail (yet, or the browser cannot decode the video) */
.shelf-thumb:not(:has(img))::after, .piece-thumb:not(:has(img))::after {
    content: '▶';
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--line);
    font-size: 28px;
}
.piece-thumb:not(:has(img))::after { font-size: 14px; }
.shelf-open.is-open .shelf-thumb { border-color: var(--pink); }
.shelf-count {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 12px;
    background: var(--pink);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 24px;
    text-align: center;
}
.shelf-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shelf-meta { font-size: 12px; color: var(--muted); line-height: 1.25; }
[data-state="done"] .shelf-meta { color: var(--teal); }
[data-state="paused"] .shelf-meta, [data-state="incomplete"] .shelf-meta { color: #f5b14c; }
[data-state="error"] .shelf-meta { color: var(--error); }
.shelf-bar { display: block; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.shelf-bar span { display: block; height: 100%; width: 0; background: var(--teal); transition: width 0.3s; }

.shelf-add .picker-icon {
    aspect-ratio: 9 / 16;
    width: 100%;
    height: auto;
    border-radius: 10px;
    border: 2px dashed var(--pink);
    background: transparent;
    color: var(--pink);
}
.shelf-add > span:last-of-type { font-size: 13px; font-weight: 600; text-align: center; }
.shelf-add input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.shelf-add:focus-within .picker-icon { outline: 3px solid var(--teal); outline-offset: 2px; }

/* ----- editor ----- */

.editor-head, .montage-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.montage-head { flex-wrap: wrap; gap: 2px 10px; }
.editor-head h2 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 19px; }

.player-wrap { position: relative; margin: 10px 0 12px; }
.player {
    display: block;
    width: 100%;
    max-height: 45vh;
    background: #000;
    border-radius: 10px;
}

.timeline {
    position: relative;
    height: 40px;
    border-radius: 8px;
    background: var(--bg);
    border: 1px solid var(--line);
    cursor: pointer;
    overflow: hidden;
}
.timeline-piece {
    position: absolute;
    top: 4px;
    bottom: 4px;
    display: grid;
    place-items: center;
    border-radius: 5px;
    background: var(--pink);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    overflow: hidden;
}
.timeline-mark {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(0, 201, 177, 0.35);
    border-left: 2px solid var(--teal);
    border-right: 2px solid var(--teal);
}
.timeline-head {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: #fff;
    pointer-events: none;
}
.timeline-legend { margin: 4px 0 12px; font-size: 13px; color: var(--muted); text-align: right; }

.mark-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mark-range { margin: 10px 0; font-weight: 600; color: var(--teal); }
.editor .hint { margin: 12px 0 0; }

/* ----- montage ----- */

.montage-total { font-size: 14px; color: var(--muted); text-align: right; }
.pieces { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }

.piece {
    display: grid;
    grid-template-columns: auto auto 1fr;
    grid-template-areas: "num thumb info" "actions actions actions";
    align-items: center;
    gap: 8px 10px;
    padding: 10px;
    border-radius: 12px;
    background: var(--bg);
    border: 1px solid var(--line);
}
.piece-number {
    grid-area: num;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--pink);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
}
.piece-thumb {
    position: relative;
    grid-area: thumb;
    width: 40px;
    aspect-ratio: 9 / 16;
    border-radius: 6px;
    background: var(--surface);
    overflow: hidden;
}
.piece-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.piece-info { grid-area: info; min-width: 0; display: flex; flex-direction: column; }
.piece-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.piece-range { font-size: 14px; color: var(--muted); }
.piece-wait { font-size: 13px; color: #f5b14c; }
.piece-actions { grid-area: actions; display: flex; gap: 6px; justify-content: flex-end; }
.piece-actions .btn-icon { background: var(--surface); }

@media (min-width: 420px) {
    .piece { grid-template-columns: auto auto 1fr auto; grid-template-areas: "num thumb info actions"; }
}

.montage .empty { color: var(--muted); margin: 12px 0 0; }

@keyframes pulse {
    50% { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
    .job-processing .job-status::before { animation: none; }
    .progress-bar span, .shelf-bar span { transition: none; }
}
.cover-info .is-error { color: var(--error); }
.cover-length { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.cover-length label { margin: 0; font-weight: 400; }
.cover-length input { width: 5.5em; margin: 0; }

/* ----- on-screen texts ----- */

.caption-preview { position: absolute; pointer-events: none; }
.timeline-texts { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; pointer-events: none; }
.timeline-text { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: var(--teal); }
.captions { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.captions h3 { margin: 0 0 8px; font-size: 17px; }
.caption-row { display: flex; gap: 8px; align-items: center; }
.caption-row input { flex: 1; min-width: 0; margin: 0; }
.caption-row .btn { flex: none; }
.caption-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.caption-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 6px 6px 12px;
    border-radius: 10px;
    background: var(--bg);
}
.caption-time { color: var(--teal); font-size: 14px; font-variant-numeric: tabular-nums; }
.caption-words { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
