.manual-generation[hidden] { display:none }
.manual-panel:has(.clip-library:not([hidden])) .manual-empty { display:none }
.manual-generation {
  display:flex; flex-direction:column; gap:clamp(14px,2vh,22px);
  min-height:100vh; min-height:100dvh;
  padding-block:clamp(12px,2vh,22px) max(14px,env(safe-area-inset-bottom));
}
.manual-path { display:flex; align-items:center; gap:12px; min-width:0; color:#bdbdbd; font-size:14px }
.manual-back {
  display:inline-flex; flex:none; align-items:center; min-height:40px; gap:8px;
  color:#f2f2f2; text-decoration:none; border-radius:99px; background:#ffffff0c; padding:0 14px;
}
.manual-back span[aria-hidden] { font-size:19px }
#manual-project-name {
  overflow:hidden; white-space:nowrap; text-overflow:ellipsis;
  padding-left:12px; border-left:1px solid #555;
}
.manual-heading small { color:#bdbdbd; font-size:11px; font-weight:600; letter-spacing:.09em }
.manual-heading p { margin:7px 0 0; color:#c6c6c8; font-size:15px; line-height:1.45 }
.manual-heading h1 { margin:4px 0 0; font-size:clamp(26px,2.95vw,40px); line-height:1.14; letter-spacing:-.04em }
.manual-panel {
  flex:1 0 auto; min-width:0; display:flex; flex-direction:column; align-items:center;
  padding:clamp(12px,2vw,30px); border:1px solid #414141; border-radius:22px;
  background:linear-gradient(145deg,#171719,#101012 65%); box-shadow:0 12px 40px #0002;
}
.manual-empty {
  flex:1; display:grid; align-content:center; justify-items:center;
  padding:24px 0 32px; text-align:center;
}
.manual-empty .ap-art { display:block; position:relative; inset:auto; transform:none; width:clamp(60px,6vw,86px); margin-bottom:16px }
.manual-empty h2 { margin:0; font-size:clamp(22px,2vw,30px); line-height:1.15; letter-spacing:-.04em }
.manual-empty p { max-width:34ch; margin:8px 0 0; font-size:15px; line-height:1.5; color:#bcbcbc; text-wrap:balance }
.manual-composer {
  display:grid; grid-template-columns:minmax(0,1fr) auto auto; align-items:center;
  gap:9px 12px; width:min(100%,1100px); padding:10px 14px 14px;
  background:#19191b; border:1px solid #38383b; border-radius:18px; box-shadow:0 5px 18px #0003;
}
.manual-modes { grid-column:1/-1; display:inline-flex; justify-self:start; border:1px solid #ffffff14; border-radius:30px; padding:2px; background:#111113 }
.manual-modes svg { width:16px; height:16px; flex:none }
.manual-modes .manual-upload,.manual-link-mode { display:inline-flex; align-items:center; justify-content:center; gap:7px; padding:0 13px; min-height:32px; border-radius:24px; font:inherit; font-size:13px; color:#ddd; cursor:pointer }
.manual-link-mode { background:transparent }
.manual-link-mode[aria-pressed=true],.manual-modes:has(.manual-link-mode[aria-pressed=false]) .manual-upload { background:#444447; color:white; box-shadow:inset 0 1px #ffffff14 }
.manual-modes .manual-upload:has(input:focus-visible) { outline:1px solid #bbb }
.manual-source { min-width:0 }
.manual-link { display:flex; align-items:center; gap:10px; min-width:0; padding-inline:14px; background:#101012; border:1px solid #4c4c50; border-radius:30px }
.manual-link:focus-within { border-color:#aaa }
.manual-link[hidden],.manual-file[hidden] { display:none }
.manual-file { display:inline-flex; justify-self:start; align-items:center; max-width:100%; min-width:0; gap:4px; padding-left:12px; border:1px solid #ffffff38; border-radius:12px; background:#ffffff09; font-size:14px }
.manual-file span { overflow:hidden; white-space:nowrap; text-overflow:ellipsis }
.manual-file button { flex:none; width:36px; height:36px; background:transparent; color:#ddd; font-size:20px; cursor:pointer }
.manual-composer .manual-send:disabled { background:#474749; color:#a8a8aa; cursor:default }
.manual-link svg { flex:none; width:22px; height:22px; color:#bdbdbd }
.manual-upload { position:relative; display:inline-flex; align-items:center; min-height:44px; padding:0 8px; white-space:nowrap; font-size:14px }
.manual-upload input { position:absolute; width:1px; height:1px; padding:0; margin:0; clip-path:inset(50%); pointer-events:none }

.manual-link input {
  min-width:0; width:100%; min-height:44px; border:0; margin:0; padding:6px 0;
  color:inherit; caret-color:#fafafa; background:transparent; font:inherit; font-size:16px;
}
.manual-link input::placeholder { color:#b1b1b1 }
.manual-link input:focus { outline:none }
.manual-length { position:relative; justify-self:start }
.manual-length summary,.manual-send {
  min-height:44px; display:inline-flex; align-items:center; justify-content:center;
  gap:8px; border-radius:24px; font-size:14px; cursor:pointer; white-space:nowrap;
}
.manual-length summary { padding:0 14px; border:1px solid #595959; list-style:none; user-select:none }
.manual-length summary::-webkit-details-marker { display:none }
.manual-length summary svg { width:16px; height:16px }
.manual-length legend { display:none }
.manual-length[open] summary { background:#313131; border-color:#ccc }
.manual-length[open] summary svg { transform:rotate(180deg) }
.manual-length fieldset {
  position:absolute; z-index:2; bottom:100%; left:0; width:max(100%,124px);
  max-height:min(212px,calc(var(--view-height,100dvh) - 100px)); overflow:auto; overscroll-behavior:contain;
  margin:0 0 6px; padding:4px; border:1px solid #555; border-radius:13px; background:#242424;
  box-shadow:0 10px 24px #0005;
}
.manual-length label { display:block; position:relative; cursor:pointer; user-select:none }
.manual-length input { position:absolute; opacity:0; width:1px; height:1px }
.manual-length label span { min-height:40px; display:flex; align-items:center; justify-content:space-between; padding:0 10px; border-radius:8px }
.manual-length input:checked + span { background:#393939 }
.manual-length input:checked + span::after { content:'✓' }
.manual-length input:focus-visible + span { outline:1px solid #eee; outline-offset:-2px }
.manual-send { justify-self:end; padding:0 16px; background:#fafafa; color:#111; font-weight:650 }
.manual-send svg { width:18px; height:18px }
#manual-feedback,.manual-source .clip-library-note { margin:2px 6px 4px; color:#ffabab; font-size:13px; line-height:1.4; overflow-wrap:anywhere }
#manual-feedback:empty { display:none }
.manual-composer:has(.manual-upload input[aria-invalid=true]) .manual-file { border-color:#cc7777 }
@media (hover:hover) {
  .manual-link-mode[aria-pressed=true] + .manual-upload:hover { background:#303033; color:white }
  .manual-length label:hover span,.manual-length summary:hover { background:#333 }
  .manual-send:hover { background:#dfdfdf }
  .manual-back:hover { color:white; background:#ffffff16 }
}
@media (pointer:coarse), (max-width:700px) {
  html:has(.manual-generation:not([hidden])),body:has(.manual-generation:not([hidden])) { overflow:clip; overscroll-behavior:none }
  body:has(.manual-generation:not([hidden])) { position:static; min-height:0 }
  .manual-generation:not([hidden]) {
    position:absolute; inset-inline:0; top:var(--manual-page-top,0px); height:var(--view-height,100dvh);
    min-height:0; overflow:clip; overscroll-behavior:none; container:manual-view / size;
    padding-bottom:max(10px,env(safe-area-inset-bottom));
  }
}
@media (max-width:700px), (pointer:coarse) and (orientation:landscape) and (max-height:550px) {
  html:has(.manual-generation:not([hidden])),
  body:has(.manual-generation:not([hidden])) {
    --manual-background:#151515;
    background:var(--manual-background);
  }
  .manual-generation:not([hidden]) {
    gap:0; margin:0 auto; padding:4px max(12px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
    background:var(--manual-background);
  }
  .manual-path {
    display:grid; grid-template-columns:44px minmax(0,1fr) 44px; gap:6px; min-height:48px;
  }
  .manual-back { width:44px; height:44px; justify-content:center; border-radius:50% }
  .manual-back span[aria-hidden] { font-size:23px }
  #manual-project-name {
    padding:0; border:0; text-align:center; color:#eee; font-size:16px; font-weight:600;
  }
  .manual-heading,.manual-back-label {
    position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden;
    clip-path:inset(50%); white-space:nowrap;
  }
  .manual-panel {
    flex:1; min-height:0; justify-content:flex-end; padding:0; border:0; border-radius:0; background:none;
  }
  .manual-empty {
    min-height:0; width:100%; padding:0 8px; overflow:clip;
    align-content:start; padding-top:min(12svh,48px);
  }
  .manual-empty,.manual-path { touch-action:pinch-zoom }
  .manual-link,.manual-link input { touch-action:pan-x pinch-zoom }
  .manual-empty .ap-art { display:none }
  .manual-empty h2 { font-size:clamp(24px,6.8vw,30px); font-weight:650 }
  .manual-empty p { max-width:28ch; margin-top:10px; font-size:15px }
  .manual-composer {
    order:1; flex:none; grid-template-columns:auto minmax(0,1fr) 44px; gap:0 8px;
    padding:7px 8px 8px; gap:5px; border-radius:20px; box-shadow:none;
  }
  .manual-modes { grid-row:2; grid-column:1 }
  .manual-modes .manual-upload,.manual-link-mode { padding:0 7px; min-height:36px; gap:4px; font-size:12px }
  .manual-modes svg { width:13px }
  .manual-source { grid-row:1; grid-column:1/-1 }
  .manual-link { padding:0 7px }
  .manual-file { max-width:calc(100% - 6px); margin:4px 3px }
  .manual-link svg,.manual-send span { display:none }
  .manual-send {
    width:44px; height:44px; padding:0; border:0; border-radius:50%;
  }
  .manual-length summary { color:#eee }
  .manual-length fieldset { inset-inline:0 auto; width:148px }
  .manual-length legend { display:block; float:left; width:100%; padding:8px 10px 4px; color:#bbb; font-size:12px }
  .manual-length label { clear:both }
  .manual-length label span { min-height:44px }
  .manual-send svg { width:21px; height:21px }
}
@container manual-view (max-height:420px) {
  .manual-empty p { display:none }
}
@container manual-view (max-height:240px) {
  .manual-empty { visibility:hidden }
}
.manual-generation:has(.clip-library:not([hidden])) { height:var(--view-height,100dvh) }
.manual-panel:has(.clip-library:not([hidden])) { flex:1; min-height:0; gap:12px }
.clip-library { flex:1; min-height:0; width:100%; padding:0 3px 6px }
.clip-library:not([hidden]) { display:flex; flex-direction:column }
.clip-library h2 { display:flex; align-items:center; gap:10px; margin:0 0 20px; font-size:19px; line-height:1.2; letter-spacing:-.025em }
.clip-library h2 svg { width:23px; height:23px }
.clip-count { display:grid; place-items:center; min-width:26px; height:26px; border-radius:20px; padding:0 6px; background:#ffffff14; color:#ddd; font-size:13px }
.clip-detail { font-size:13px; color:#b8b8bc }
.clip-grid { flex:1; min-height:0; overflow:auto; overscroll-behavior:contain; scrollbar-width:thin; scrollbar-color:#555 transparent; container-type:size; display:flex; flex-wrap:wrap; align-content:flex-start; align-items:flex-start; gap:12px }
.clip-card { --tile-width:clamp(148px,56.2cqh,268px); position:relative; isolation:isolate; overflow:hidden; aspect-ratio:9/16; width:min(100%,var(--tile-width)); flex:none; padding:0; border:1px solid #ffffff36; border-radius:15px; background:linear-gradient(145deg,#33343a,#19191c); color:white; text-align:left }
.clip-card img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; transition:transform .32s ease }
.clip-card::after { content:''; position:absolute; inset:38% 0 0; background:linear-gradient(transparent,#070708ce 75%,#070708ef); pointer-events:none }
.clip-open { position:absolute; z-index:2; inset:0; width:100%; height:100%; padding:0; display:grid; place-items:center; color:white; background:transparent; border:0; cursor:pointer }
.clip-play { display:grid; place-items:center; width:47px; height:47px; padding-left:3px; border-radius:50%; font-size:18px; background:#09090ba8; backdrop-filter:blur(6px) }
.clip-ready,.clip-actions { position:absolute; z-index:3; top:9px; display:flex; gap:5px; align-items:center; font-size:11px; font-weight:650 }
.clip-ready { left:9px; padding:4px 8px; border-radius:20px; color:#dcffd3; background:#19571dea; pointer-events:none }
.clip-ready b { color:#124818; background:#a4f16b; border-radius:100%; width:13px; height:13px; line-height:13px; text-align:center }
.clip-actions { right:8px }
.clip-duration,.clip-actions summary { padding:4px 6px; border-radius:8px; background:#08080bd9 }
.clip-actions summary { cursor:pointer; list-style:none; font-size:17px; line-height:17px }
.clip-actions summary::-webkit-details-marker { display:none }
.clip-menu { position:absolute; right:0; top:100%; width:max-content; margin-top:4px; padding:4px; background:#242426; color:white; border:1px solid #555; border-radius:9px }
.clip-menu button { display:block; width:100%; background:transparent; color:inherit; text-align:left; padding:9px; border-radius:6px; cursor:pointer }
.clip-menu button:hover,.clip-menu button:focus-visible { background:#373739 }
.clip-menu .clip-delete,.clip-viewer .clip-delete { color:#ffaaaa }
.clip-viewer .clip-delete { margin-right:auto; background:transparent; padding:0 10px; min-height:44px; white-space:nowrap; cursor:pointer }
.clip-open:focus-visible { outline:2px solid white; outline-offset:-4px }
.clip-caption { position:absolute; z-index:1; inset:auto 12px 13px; display:grid; gap:4px }
.clip-caption strong { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; overflow-wrap:anywhere; font-size:15px; line-height:1.2; letter-spacing:-.02em }
.clip-caption small { color:#eee; font-size:11px; font-variant-numeric:tabular-nums }
.clip-card:focus-visible { outline:2px solid white; outline-offset:-3px }
.clip-job { display:flex; flex-direction:column; justify-content:center; align-items:center; gap:16px; padding:16px; text-align:center; cursor:default; background:radial-gradient(ellipse at 50% 37%,#363639,#202022 70%) }
.clip-job::after { display:none }
.job-spinner { width:30px; height:30px; border:2px solid #ffffff29; border-top-color:#eee; border-radius:50%; animation:job-spin 1s linear infinite }
.job-stage { font-size:14px; line-height:1.4; color:#ddd; overflow-wrap:anywhere }
.clip-job[data-state=failed] .job-spinner { display:none }
@keyframes job-spin { to { transform:rotate(360deg) } }
@media (prefers-reduced-motion:reduce) { .job-spinner { animation:none } }
.clip-job[data-state=failed] .job-stage { color:#ffabab }
.clip-library-note button { text-decoration:underline; color:white; background:transparent; cursor:pointer }
.clip-viewer { box-sizing:border-box; width:min(440px,calc(100% - 24px),calc(34px + 34.875dvh)); max-height:calc(100dvh - 24px); margin:auto; padding:16px; border:1px solid #ffffff38; border-radius:22px; background:linear-gradient(145deg,#303033ed,#171719f7); backdrop-filter:blur(18px); color:#fff; box-shadow:0 22px 80px #0008; overflow:auto }
.clip-viewer::backdrop { background:#0a0a0c9c; backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px) }
.clip-viewer-head { display:flex; align-items:center; justify-content:space-between; gap:16px; margin:0 2px 14px }
.clip-viewer h2 { font-size:20px; letter-spacing:-.035em; line-height:1.16; overflow-wrap:anywhere; margin:0 }
.clip-viewer .clip-detail { margin:5px 0 0 }
.clip-close { flex:none; width:40px; height:40px; border:1px solid #ffffff24; border-radius:50%; background:#ffffff0c; color:inherit; font-size:24px; cursor:pointer }
.clip-stage { position:relative; width:100%; height:auto; aspect-ratio:9/16; display:grid; place-items:center; background:#0b0b0c; border-radius:13px; overflow:hidden }
.clip-stage video { width:100%; height:100%; position:absolute; inset:0; margin:0; object-fit:contain }
.clip-loading { color:#ccc; font-size:14px; padding:12px; text-align:center }
.clip-viewer footer { display:flex; justify-content:flex-end; margin:14px 0 0; padding:0; border:0; background:none }
.clip-download:not([hidden]) { display:inline-flex; gap:9px; align-items:center; justify-content:center; min-height:44px; padding:0 18px; background:#fafafa; color:#121212; border-radius:24px; text-decoration:none; font-weight:650; font-size:14px }
.clip-download svg { width:17px; height:17px }
@media (hover:hover) and (prefers-reduced-motion:no-preference) {
  .clip-card:hover img { transform:scale(1.035) }
}
@media (max-width:700px) {
  .clip-library h2 { margin:8px 0 12px; font-size:17px }
  .clip-grid { gap:8px }
  .clip-card { width:min(calc((100% - 8px)/2),var(--tile-width)); border-radius:12px }
  .clip-caption { inset:auto 9px 10px }
  .clip-viewer .clip-download { width:100% }
}
@media (min-width:701px) and (max-height:760px) {
  .manual-generation { gap:10px }
  .manual-heading p { margin-top:4px }
  .manual-panel { padding:clamp(12px,2vh,18px) }
  .clip-library h2 { margin-bottom:12px }
}
@media (min-width:701px) and (max-height:660px) {
  .manual-heading p { display:none }
  .manual-composer { grid-template-columns:auto minmax(0,1fr) auto auto; padding:8px; gap:8px }
  .manual-composer .manual-modes,.manual-composer .manual-source { grid-area:auto }
}
@media (orientation:landscape) and (max-height:450px) {
  .clip-card { --tile-width:clamp(116px,56.2cqh,210px) }
  .clip-library h2 { margin:3px 0 6px; font-size:16px }
  .clip-ready,.clip-actions { top:5px; gap:3px }
  .clip-ready { left:4px; padding:3px 4px }
  .clip-actions { right:4px }
}
@media (min-width:550px) and (orientation:landscape) and (max-height:450px) {
  .manual-panel:has(.clip-library:not([hidden])) {
    display:grid; grid-template-columns:minmax(0,1fr) minmax(248px,.85fr);
    grid-template-rows:minmax(0,1fr); align-items:stretch;
  }
  .clip-library:not([hidden]) + .manual-composer { align-self:end; grid-template-columns:minmax(0,1fr) auto }
  .clip-library:not([hidden]) + .manual-composer .manual-modes { grid-row:1; grid-column:1/-1 }
  .clip-library:not([hidden]) + .manual-composer .manual-source { grid-row:2; grid-column:1/-1 }
}
@media (max-width:360px) {
  .manual-composer { grid-template-columns:minmax(0,1fr) 44px }
  .manual-modes { grid-row:1; grid-column:1/-1 }
  .manual-source { grid-row:2 }
}

dialog.delete-confirm {
  box-sizing: border-box;
  width: min(380px, calc(100% - 32px));
  height: fit-content;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  margin: auto;
  padding: 24px;
  color: #fafafa;
  background: #202020;
  border: 1px solid #464646;
  border-radius: 20px;
  box-shadow: 0 16px 60px #0006;
}
body:has(.clip-confirm[open]) .clip-viewer::backdrop {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
dialog.delete-confirm h2 { margin: 0; font-size: 21px; letter-spacing: -.03em; }
dialog.delete-confirm p { margin: 10px 0 24px; color: #c5c5c5; line-height: 1.5; overflow-wrap: anywhere; }
dialog.delete-confirm strong { color: #eee; font-weight: 600; }
dialog.delete-confirm .confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
dialog.delete-confirm button { padding: 10px 16px; border: 1px solid #555; border-radius: 24px; background: transparent; color: white; font: inherit; font-weight: 600; cursor: pointer; }
dialog.delete-confirm button:is([value="delete"],[type="submit"]) { background: #b92d36; border-color: #b92d36; }
dialog.delete-confirm button:focus-visible { outline: 2px solid white; outline-offset: 2px; }

dialog.delete-confirm.proj-dialog form { display: block; }
.clip-potential {
  display:grid; place-items:center; width:32px; height:32px; border-radius:50%;
  color:white; font:700 12px/1 system-ui; font-variant-numeric:tabular-nums;
  background:radial-gradient(closest-side,#191515 77%,transparent 80%),conic-gradient(#ff9351 var(--score),#54443e 0);
  box-shadow:0 1px 5px #0008;
}
@media(max-width:600px){.clip-potential{width:26px;height:26px;font-size:10px}}
