/* CapCut-style timeline (28 Sep 2026): tools on top, the Reel sliding under a fixed playhead, a text sheet above
   the keyboard. Touch first: every target is at least 38 px, nothing here selects text or scrolls the page. */
.timeline.cc { height: 262px; background: linear-gradient(180deg, #12121b, #0d0d14); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.timeline.cc.collapsed { height: 54px; }
.timeline.cc.collapsed .cc-view { display: none; }

.cc-bar { display: flex; align-items: center; gap: 8px; padding: 7px 10px; min-height: 54px; border-bottom: 1px solid var(--line); }
.cc-group { display: flex; align-items: center; gap: 4px; flex: none; }
.cc-tools { flex: 1 1 auto; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding: 0 6px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
.cc-tools::-webkit-scrollbar { display: none; }
/* The tools slide sideways when they do not all fit; an arrow at the edge says there are more (29 Sep). */
.cc-strip { position: relative; flex: 1 1 auto; min-width: 0; display: flex; }
.cc-more { position: absolute; top: 50%; z-index: 3; width: 26px; height: 40px; margin-top: -20px; display: none; place-items: center; color: #0b0b10; background: var(--lime); border-radius: 10px; box-shadow: 0 0 0 4px #12121b, 0 6px 18px rgba(0, 0, 0, 0.5); transition: transform .15s var(--spring); }
.cc-more .ico { width: 14px !important; height: 14px !important; }
.cc-more.l { left: 2px; }
.cc-more.r { right: 2px; }
.cc-more.r .ico { transform: rotate(180deg); }
.cc-more:active { transform: scale(0.9); }
.cc-strip.more-left .cc-more.l, .cc-strip.more-right .cc-more.r { display: grid; }
.cc-strip.more-right .cc-tools { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 64px), transparent calc(100% - 22px)); mask-image: linear-gradient(90deg, #000 calc(100% - 64px), transparent calc(100% - 22px)); }
.cc-strip.more-left .cc-tools { -webkit-mask-image: linear-gradient(270deg, #000 calc(100% - 64px), transparent calc(100% - 22px)); mask-image: linear-gradient(270deg, #000 calc(100% - 64px), transparent calc(100% - 22px)); }
.cc-strip.more-left.more-right .cc-tools { -webkit-mask-image: linear-gradient(90deg, transparent 22px, #000 64px, #000 calc(100% - 64px), transparent calc(100% - 22px)); mask-image: linear-gradient(90deg, transparent 22px, #000 64px, #000 calc(100% - 64px), transparent calc(100% - 22px)); }
.cc-tool { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; flex: none; min-width: 48px; height: 40px; padding: 0 6px; border-radius: 12px; color: var(--text-2); font-size: 10.5px; font-weight: 600; line-height: 1; white-space: nowrap; transition: background .15s, color .15s, transform .15s var(--spring); }
.cc-tool .ico { width: 17px !important; height: 17px !important; }
.cc-tool.bare { min-width: 38px; padding: 0; }
.cc-tool:hover { background: var(--panel-2); color: var(--text); }
.cc-tool:active { transform: scale(0.94); }
.cc-tool.active { color: #0b0b10; background: var(--lime); }
.cc-tool.danger { color: #ff8a8a; }
.cc-tool.danger:hover { background: rgba(255, 92, 92, 0.14); color: var(--danger); }
.cc-tool:disabled { opacity: 0.32; pointer-events: none; }
.cc-tools > * { animation: cc-in .24s var(--ease) both; }
.cc-tools > *:nth-child(2) { animation-delay: .02s; } .cc-tools > *:nth-child(3) { animation-delay: .04s; }
.cc-tools > *:nth-child(4) { animation-delay: .06s; } .cc-tools > *:nth-child(5) { animation-delay: .08s; }
.cc-tools > *:nth-child(6) { animation-delay: .1s; } .cc-tools > *:nth-child(7) { animation-delay: .12s; }
/* Never from invisible: a tool must show even where animations stand still. */
@keyframes cc-in { from { opacity: 0.45; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.cc-hint { font-size: 11.5px; color: var(--text-3); padding: 0 8px; white-space: nowrap; }
/* What the tools belong to ("Clip 3", "Text 2", "Music"), and a thin line between groups of tools. */
.cc-name { flex: none; align-self: center; margin: 0 6px 0 2px; padding: 5px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; color: #0b0b10; background: linear-gradient(135deg, #b6ff3b, #4fc3ff); white-space: nowrap; }
.cc-gap { flex: none; align-self: center; width: 1px; height: 24px; margin: 0 5px; background: var(--line-2); }
.cc-tools { display: flex; align-items: center; }

/* Small panels over the toolbar */
.cc-pop .row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cc-pop .row.between { justify-content: space-between; }
.cc-pop .hint { font-size: 11.5px; line-height: 1.4; color: var(--text-3); }
.cc-pop .mono { font-variant-numeric: tabular-nums; }
.cc-range { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.cc-label { font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.cc-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.cc-options button { height: 38px; padding: 0 10px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font-size: 12.5px; font-weight: 600; transition: transform .12s var(--spring), background .12s; }
.cc-options button:active { transform: scale(0.95); }
.cc-options button.active { background: var(--lime); color: #0b0b10; border-color: transparent; }
.cc-swatches { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.cc-swatches button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.22); transition: transform .12s var(--spring); }
.cc-swatches button:active { transform: scale(0.9); }
.cc-swatches button.active { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.cc-swatches button.auto { width: auto; padding: 0 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: var(--text-2); background: var(--panel); }
.cc-swatches button.auto.active { color: #0b0b10; background: var(--lime); border-color: transparent; box-shadow: none; }

/* ---------- Replace / Add clip: a sheet over the timeline ---------- */
.cc-sheet { position: absolute; inset: 0; z-index: 35; display: flex; flex-direction: column; background: linear-gradient(180deg, #161622, #0d0d14); border-top: 1px solid rgba(139, 108, 255, 0.35); animation: cs-in .24s var(--spring); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.cc-sheet.hidden { display: none; }
@keyframes cs-in { from { opacity: 0.4; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.cs-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; min-height: 54px; border-bottom: 1px solid var(--line); }
.cs-head .spacer, .cs-row .spacer { flex: 1; }
.cs-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: #0b0b10; background: linear-gradient(135deg, #b6ff3b, #4fc3ff); flex: none; }
.cs-title { display: flex; flex-direction: column; min-width: 0; }
.cs-title b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-title span { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 10px; }
.cs-clips { flex: 1; min-height: 0; display: flex; gap: 10px; overflow-x: auto; overflow-y: hidden; padding: 2px 2px 6px; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.cs-clip { flex: none; display: flex; flex-direction: column; gap: 5px; align-items: stretch; height: 100%; aspect-ratio: 9 / 19; min-width: 74px; padding: 0; border-radius: 14px; color: var(--text); transition: transform .14s var(--spring); }
.cs-clip:active { transform: scale(0.95); }
.cs-clip:disabled { opacity: 0.45; pointer-events: none; }
.cs-thumb { position: relative; flex: 1; min-height: 0; border-radius: 12px; overflow: hidden; background: #1d1d28; border: 2px solid transparent; display: grid; place-items: center; color: var(--text-2); }
.cs-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cs-thumb .shimmer { position: absolute; inset: 0; }
.cs-thumb .n { position: absolute; left: 5px; top: 5px; min-width: 20px; height: 18px; padding: 0 5px; border-radius: 6px; background: rgba(0, 0, 0, 0.6); font-style: normal; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }
.cs-thumb .now { position: absolute; right: 5px; top: 5px; height: 18px; padding: 0 6px; border-radius: 6px; background: var(--lime); color: #0b0b10; font-style: normal; font-size: 10px; font-weight: 800; display: grid; place-items: center; }
.cs-clip:hover .cs-thumb, .cs-clip:focus-visible .cs-thumb { border-color: #fff; }
.cs-clip.current .cs-thumb { border-color: var(--lime); }
.cs-clip.add .cs-thumb { border: 2px dashed var(--line-2); background: rgba(255, 255, 255, 0.03); }
.cs-clip.add .cs-thumb .ico { width: 22px !important; height: 22px !important; }
.cs-meta { flex: none; font-size: 11px; font-weight: 600; color: var(--text-2); text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cs-meta em { font-style: normal; color: var(--lime); margin-left: 4px; }
.cs-empty { flex: 1; display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center; text-align: center; color: var(--text-2); font-size: 12.5px; padding: 0 20px; }
.cs-empty b { color: var(--text); font-size: 14px; }
.cs-strip { position: relative; flex: 1; min-height: 72px; border-radius: 12px; overflow: hidden; background: rgba(255, 255, 255, 0.025); }
.cs-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.cs-canvas:active { cursor: grabbing; }
.cs-row { flex: none; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cs-time { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.cs-length { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; font-size: 12px; color: var(--text-2); }
.cs-length b { min-width: 44px; text-align: center; color: var(--text); }

.cc-view { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.cc-view canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.cc-view canvas:active { cursor: grabbing; }
.cc-view::before, .cc-view::after { content: ''; position: absolute; top: 0; bottom: 0; width: 26px; z-index: 2; pointer-events: none; }
.cc-view::before { left: 0; background: linear-gradient(90deg, #0d0d14, transparent); }
.cc-view::after { right: 0; background: linear-gradient(270deg, #0d0d14, transparent); }
.cc-zoom { position: absolute; right: 10px; bottom: 8px; z-index: 3; display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: rgba(12, 12, 19, 0.82); border: 1px solid var(--line-2); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.cc-zoom button { width: 34px; height: 30px; border-radius: 9px; color: var(--text-2); display: grid; place-items: center; }
.cc-zoom button:hover { background: var(--panel-2); color: var(--text); }
.cc-zoom button:active { transform: scale(0.92); }
.cc-tip { position: absolute; z-index: 4; padding: 4px 9px; border-radius: 8px; background: rgba(255, 255, 255, 0.96); color: #0b0b10; font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; pointer-events: none; transform: translate(-50%, -100%); white-space: nowrap; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45); }
.cc-pop { position: absolute; z-index: 40; padding: 14px; border-radius: 16px; background: rgba(20, 20, 29, 0.97); border: 1px solid var(--line-2); box-shadow: var(--shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); animation: toast-in .22s var(--spring); -webkit-user-select: none; user-select: none; }
.cc-pop .slider { height: 6px; margin: 4px 0; }
.cc-pop .slider::-webkit-slider-thumb { width: 24px; height: 24px; }

/* The picture at a trim handle: the text steps aside while an edge is dragged. */
.phone-frame .layer.peeking img { opacity: 0 !important; }
.phone-frame .layer.peeking ~ .text-grab { display: none; }

/* ---------- Text on the phone: the box that holds it (29 Sep) ---------- */
.text-grab { position: absolute; z-index: 6; box-sizing: border-box; border: 1.5px dashed transparent; border-radius: 10px; cursor: grab; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; transition: border-color .15s, box-shadow .15s; }
.text-grab.hidden { display: none; }
.text-grab:hover { border-color: rgba(255, 255, 255, 0.45); }
.text-grab.selected { border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 22px rgba(139, 108, 255, 0.45); }
.text-grab.dragging { cursor: grabbing; border-color: var(--lime); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 26px rgba(182, 255, 59, 0.45); }
.text-grab .tg-btn { position: absolute; width: 30px; height: 30px; border-radius: 50%; display: none; place-items: center; background: #fff; color: #0b0b10; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5); touch-action: none; }
.text-grab .tg-btn .ico { width: 15px !important; height: 15px !important; }
.text-grab.selected .tg-btn { display: grid; }
.text-grab.dragging .tg-del, .text-grab.dragging .tg-edit { display: none; }
.text-grab .tg-del { left: -15px; top: -15px; }
.text-grab .tg-edit { right: -15px; top: -15px; }
.text-grab .tg-scale { right: -15px; bottom: -15px; cursor: nwse-resize; background: var(--lime); }
/* A finger needs more than 30 px: the touch area of each handle is wider than what is drawn. */
.text-grab .tg-btn::after { content: ''; position: absolute; inset: -9px; border-radius: 50%; }
.text-grab[data-size]::before { content: attr(data-size) ' px'; position: absolute; left: 50%; top: -34px; transform: translateX(-50%); padding: 3px 9px; border-radius: 8px; background: rgba(255, 255, 255, 0.96); color: #0b0b10; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.text-guides { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.text-guides i { position: absolute; background: var(--lime); box-shadow: 0 0 10px rgba(182, 255, 59, 0.8); opacity: 0; transition: opacity .1s; }
.text-guides .gv { left: var(--gx, 50%); top: 0; bottom: 0; width: 1.5px; margin-left: -0.75px; }
.text-guides .gh { top: 50%; left: 0; right: 0; height: 1.5px; margin-top: -0.75px; }
.text-guides.v .gv, .text-guides.h .gh { opacity: 1; }
/* While a text is placed the phone shows where Instagram's own buttons and caption will be. */
.phone-frame.placing .safe { opacity: 1; }
.phone-frame.placing .igui { opacity: 0.55; }
.phone-frame.placing.outside .safe { border-color: var(--warn); }
body.presenting .text-grab { display: none; }

/* ---------- Text sheet (edit one text) ---------- */
.text-sheet { position: fixed; left: 50%; bottom: calc(14px + var(--kb, 0px) + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(640px, calc(100vw - 20px)); z-index: 70; padding: 12px 14px 14px; border-radius: 20px; background: rgba(18, 18, 27, 0.97); border: 1px solid var(--line-2); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(139, 108, 255, 0.18); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); animation: sheet-in .26s var(--spring); display: flex; flex-direction: column; gap: 10px; }
@keyframes sheet-in { from { opacity: 0; transform: translate(-50%, 18px) scale(0.98); } to { opacity: 1; transform: translateX(-50%); } }
.text-sheet .ts-head { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.text-sheet .ts-head .dim { font-size: 11.5px; font-variant-numeric: tabular-nums; }
.text-sheet .spacer { flex: 1; }
/* 17 px: iPadOS zooms the page into any field typed in below 16 px. */
.text-sheet .ts-input { width: 100%; min-height: 52px; max-height: 168px; font-size: 17px; line-height: 1.4; border-radius: 14px; background: #0c0c13; border: 1px solid var(--line-2); padding: 12px 14px; resize: none; -webkit-user-select: text; user-select: text; }
.text-sheet .ts-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.text-sheet .ts-size { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.text-sheet .ts-size .mono { min-width: 34px; text-align: center; }
.text-sheet .ts-words { display: flex; flex-wrap: wrap; gap: 6px; max-height: 132px; overflow: auto; padding-top: 2px; }
.text-sheet .ts-word { height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font-size: 14px; font-weight: 600; transition: transform .12s var(--spring), background .12s; }
.text-sheet .ts-word:active { transform: scale(0.94); }
.text-sheet .ts-word.on { background: rgba(255, 226, 39, 0.12); }

/* ---------- Text tab: plain cards ---------- */
.screen .words.plain { font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; padding: 8px 10px; margin: 0 -2px; border-radius: 10px; border: 1px dashed transparent; cursor: text; transition: border-color .15s, background .15s; }
.screen .words.plain:hover { border-color: var(--line-2); background: rgba(255, 255, 255, 0.03); }
.screen .words.plain mark { background: none; font-weight: 700; }
.screen .tools { flex-wrap: wrap; }
.screen .tools .spacer { flex: 1; }
.screen .tools-size { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-2); }
.screen .tools-size .mono { min-width: 30px; text-align: center; }
.script-box { padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.script-box summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.script-box[open] summary { margin-bottom: 10px; color: var(--text); }
.script-box .textarea-big { width: 100%; font-size: 16px; }

@media (max-width: 1100px) {
  .timeline.cc { height: 248px; }
  .cc-bar { padding: 6px 6px; gap: 4px; }
  .cc-tool { min-width: 48px; }
  .cc-hint { display: none; }
}
@media (max-height: 760px) and (min-width: 1101px) {
  .timeline.cc { height: 232px; }
}
