/* Kalima Montaj: caption editor. Prefix .ce- */
.ce-layer { position: absolute; z-index: 5; pointer-events: none; overflow: hidden; display: none; }
.ce-mask { position: absolute; left: 0; right: 0; background: rgba(26, 26, 26, .55); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.ce-safe { position: absolute; left: 0; right: 0; bottom: 0; background: repeating-linear-gradient(135deg, rgba(255, 120, 100, .22) 0 6px, rgba(255, 120, 100, .08) 6px 12px); border-top: 1px dashed rgba(255, 160, 140, .8); display: flex; align-items: flex-end; justify-content: center; }
.ce-safe span { font-size: 10px; color: #FFD3C8; padding: 2px 6px; }
.ce-cap { position: absolute; transform: translateX(-50%); width: max-content; text-align: center; cursor: grab; touch-action: none; user-select: none; }
.ce-cap:active { cursor: grabbing; }
.ce-ci { display: block; white-space: pre-wrap; line-height: 1.2; outline: 1px dashed rgba(200, 134, 10, .95); outline-offset: 4px; transform-origin: 50% 60%; }
.ce-ci .l, .ce-pv .l { display: inline-block; white-space: pre; }
.ce-frame { position: absolute; border: 1px dashed rgba(255, 255, 255, .35); pointer-events: none; }
.ce-frame span { position: absolute; left: 50%; top: 4px; transform: translateX(-50%); font-size: 10px; color: rgba(255, 255, 255, .8); background: rgba(26, 26, 26, .45); padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.ce-guide { position: absolute; pointer-events: none; opacity: 0; transition: opacity .1s; }
.ce-gv { top: 0; bottom: 0; width: 0; border-left: 1px dashed rgba(255, 255, 255, .5); }
.ce-gh { left: 0; right: 0; height: 0; border-top: 1px dashed rgba(255, 255, 255, .5); }
.ce-gh span { position: absolute; right: 4px; top: 2px; font-size: 10px; color: #fff; }
.ce-guide.show { opacity: 1; }
.ce-gv.on { border-left: 2px solid #FF3B6B; }
.ce-gh.on { border-top: 2px solid #FF3B6B; }
.ce-hit { position: absolute; z-index: 4; background: transparent; border: 0; padding: 0; margin: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ce-hit:focus-visible { outline: 2px solid var(--amber); }
.ce-edit { width: 100%; margin-top: 10px; }

.ce-panel { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 0; max-height: calc(100vh - var(--head-h) - 24px); }
.ce-handle { display: none; }
.ce-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.ce-body { padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.ce-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface); border-radius: 0 0 var(--radius) var(--radius); }
.ce-foot .btn.primary { flex: 1; }
.ce-linebar { display: flex; align-items: center; gap: 8px; }
.ce-navtxt { flex: 1; text-align: center; font-size: 13px; color: var(--muted); }
.ce-text { min-height: 56px; font-size: 14px; }
.ce-lab { font-size: 13px; color: var(--muted); }
.ce-row { display: flex; align-items: center; gap: 12px; }
.ce-row .ce-lab { flex: 0 0 84px; }
.ce-row .ce-ctl { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.ce-row.ce-stack { align-items: flex-start; }
.ce-nobox .ce-boxonly, .ce-panel.nobox .ce-boxonly { display: none; }
.ce-range { flex: 1; min-width: 0; width: 100%; accent-color: var(--amber); height: 24px; touch-action: pan-y; }
.ce-num { width: 64px; min-height: 32px; padding: 0 8px; text-align: center; }
.ce-val { width: 44px; text-align: right; font-size: 13px; color: var(--muted); }
.ce-seg { display: inline-flex; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.ce-scope .ce-seg { display: flex; }
.ce-scope .ce-seg button { flex: 1; }
.ce-seg button { min-height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; }
.ce-seg button.on { background: #fff; color: var(--fg); box-shadow: 0 1px 3px rgba(26,26,26,.12), 0 0 0 1px var(--line); }
.ce-tgs { display: flex; gap: 8px; }
.ce-tg { min-width: 38px; min-height: 32px; border-radius: 9px; border: 1px solid var(--line); background: var(--field); color: var(--fg); cursor: pointer; font-size: 14px; }
.ce-tg.on { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.ce-tab { display: flex; flex-direction: column; gap: 10px; }
.ce-sub { font-weight: 700; color: var(--fg); margin-top: 2px; }
.ce-fsearch { width: 100%; min-height: 32px; font-size: 14px; }
.ce-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ce-chip { min-height: 28px; padding: 0 11px; border-radius: 14px; border: 1px solid var(--line); background: var(--field); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.ce-chip.on { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.ce-fonts { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--field); padding: 0 0 4px; overscroll-behavior: contain; }
.ce-fsec { position: sticky; top: 0; z-index: 1; padding: 5px 10px; font-size: 12px; font-weight: 700; color: var(--gold-ink); background: var(--raise); border-bottom: 1px solid var(--line); }
.ce-fempty { padding: 12px; font-size: 13px; }
.ce-font { display: flex; align-items: center; min-height: 36px; border-bottom: 1px solid var(--line); }
.ce-font:last-child { border-bottom: 0; }
.ce-font.on { background: var(--pale); box-shadow: inset 3px 0 0 var(--amber); }
.ce-fname { flex: 1; min-width: 0; min-height: 36px; padding: 0 10px; border: 0; background: transparent; color: var(--fg); font-size: 16px; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ce-star { flex: 0 0 36px; min-height: 36px; border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; }
.ce-star.on { color: var(--amber); }
.ce-snaprow { display: flex; gap: 8px; }
.ce-agrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.ce-tile { display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: transparent; cursor: pointer; text-align: center; color: var(--fg); }
.ce-pvbox { height: 64px; border-radius: 10px; background: #232323; border: 2px solid transparent; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ce-tile.on .ce-pvbox { border-color: var(--amber); box-shadow: 0 0 0 2px rgba(200, 134, 10, .25); }
.ce-tname { font-size: 12px; line-height: 1.2; color: var(--muted); min-height: 2.4em; }
.ce-tile.on .ce-tname { color: var(--gold-ink); font-weight: 700; }
.ce-pv { color: #fff; font: 700 15px/1 var(--font); transform-origin: 50% 60%; }
.ce-pv.none { color: #8a8a8a; } .ce-noic { font-size: 26px; }

/* animation presets: tiles loop (class a-<group>-<id>), the big preview plays once (class p-<group>-<id>) */
.ce-pv, .ce-ci[class*="p-"] { animation-duration: 1.8s; animation-timing-function: ease-out; }
.ce-pv { animation-iteration-count: infinite; }
.ce-ci[class*="p-"] { animation-iteration-count: 1; animation-fill-mode: none; }
.a-in-fade, .p-in-fade { animation-name: ce-in-fade; }
.a-in-pop, .p-in-pop { animation-name: ce-in-pop; }
.a-in-slide_up, .p-in-slide_up { animation-name: ce-in-up; }
.a-in-slide_down, .p-in-slide_down { animation-name: ce-in-down; }
.a-in-slide_left, .p-in-slide_left { animation-name: ce-in-left; }
.a-in-zoom_in, .p-in-zoom_in { animation-name: ce-in-zoom; }
.a-in-typewriter, .p-in-typewriter { animation-name: ce-in-type; animation-timing-function: steps(10, end); }
.a-in-blur_in, .p-in-blur_in { animation-name: ce-in-blur; }
.a-in-bounce, .p-in-bounce { animation-name: ce-in-bounce; }
.a-out-fade, .p-out-fade { animation-name: ce-out-fade; animation-timing-function: ease-in; }
.a-out-slide_down, .p-out-slide_down { animation-name: ce-out-down; animation-timing-function: ease-in; }
.a-out-zoom_out, .p-out-zoom_out { animation-name: ce-out-zoom; animation-timing-function: ease-in; }
.a-out-blur_out, .p-out-blur_out { animation-name: ce-out-blur; animation-timing-function: ease-in; }
.a-combo-pulse, .p-combo-pulse { animation-name: ce-pulse; animation-duration: .9s; animation-timing-function: ease-in-out; }
.ce-ci.p-combo-pulse { animation-iteration-count: 3; }
.a-combo-wave .l, .p-combo-wave .l { animation: ce-wave .9s ease-in-out infinite; }
.a-combo-karaoke .l, .p-combo-karaoke .l { animation: ce-kara 1.8s linear infinite; }
.ce-ci.p-combo-wave, .ce-ci.p-combo-karaoke { animation: none; }
@keyframes ce-in-fade { 0% { opacity: 0; } 30%, 100% { opacity: 1; } }
@keyframes ce-in-pop { 0% { transform: scale(.3); opacity: 0; } 18% { transform: scale(1.18); opacity: 1; } 30% { transform: scale(.94); } 40%, 100% { transform: scale(1); opacity: 1; } }
@keyframes ce-in-up { 0% { transform: translateY(70%); opacity: 0; } 30%, 100% { transform: none; opacity: 1; } }
@keyframes ce-in-down { 0% { transform: translateY(-70%); opacity: 0; } 30%, 100% { transform: none; opacity: 1; } }
@keyframes ce-in-left { 0% { transform: translateX(60%); opacity: 0; } 30%, 100% { transform: none; opacity: 1; } }
@keyframes ce-in-zoom { 0% { transform: scale(.4); opacity: 0; } 32%, 100% { transform: none; opacity: 1; } }
@keyframes ce-in-type { 0% { clip-path: inset(0 100% 0 0); } 45%, 100% { clip-path: inset(0 0 0 0); } }
@keyframes ce-in-blur { 0% { filter: blur(10px); opacity: 0; } 35%, 100% { filter: none; opacity: 1; } }
@keyframes ce-in-bounce { 0% { transform: translateY(-90%); opacity: 0; } 14% { transform: none; opacity: 1; } 22% { transform: translateY(-22%); } 30% { transform: none; } 36% { transform: translateY(-7%); } 42%, 100% { transform: none; opacity: 1; } }
@keyframes ce-out-fade { 0%, 55% { opacity: 1; } 85%, 100% { opacity: 0; } }
@keyframes ce-out-down { 0%, 55% { transform: none; opacity: 1; } 85%, 100% { transform: translateY(70%); opacity: 0; } }
@keyframes ce-out-zoom { 0%, 55% { transform: none; opacity: 1; } 85%, 100% { transform: scale(.4); opacity: 0; } }
@keyframes ce-out-blur { 0%, 55% { filter: none; opacity: 1; } 85%, 100% { filter: blur(10px); opacity: 0; } }
@keyframes ce-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes ce-wave { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-.28em); } }
@keyframes ce-kara { 0% { color: inherit; } 8%, 30% { color: #F6DF86; } 40%, 100% { color: inherit; } }
.ce-sw { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ce-dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #D9D5CA; cursor: pointer; padding: 0; }
.ce-dot.on { border-color: #fff; box-shadow: 0 0 0 2px var(--amber); }
.ce-pick { width: 32px; height: 28px; padding: 0; border: 2px solid var(--line); border-radius: 8px; background: none; cursor: pointer; }
.ce-pick.on { border-color: var(--amber); }
.ce-hint { font-size: 12px; }
.ce-msg { font-size: 13px; min-height: 0; }
.ce-msg:empty { display: none; }

@media (max-width: 999px) {
  .ce-panel.phone { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); z-index: 60; max-height: 52vh; border-radius: 18px 18px 0 0; border-bottom: 0; box-shadow: 0 -10px 30px rgba(26, 26, 26, .18); }
  .ce-panel.phone .ce-handle { display: block; background: none; border: 0; padding: 8px 0 2px; cursor: pointer; }
  .ce-panel.phone .ce-handle span { display: block; width: 44px; height: 5px; border-radius: 3px; background: #D9D5CA; margin: 0 auto; }
  .ce-panel.phone .ce-head { padding: 4px 12px 8px; }
  .ce-panel.phone .ce-foot { border-radius: 0; }
  .ce-panel.phone.collapsed .ce-body { display: none; }
  .ce-row .ce-lab { flex-basis: 74px; }
  .ce-panel.phone .ce-fonts { max-height: 150px; }
  .ce-agrid { grid-template-columns: repeat(4, 1fr); }
}

/* undo / redo buttons in the editor header */
.ce-histbox { display: flex; gap: 4px; margin-left: auto; }
.ce-hist { min-width: 36px; font-size: 18px; line-height: 1; }
.ce-hist:disabled { opacity: .35; cursor: default; }

.ce-endnote { flex: 0 0 100%; order: 9; margin: 0; font-size: 12px; color: var(--muted, #6b6657); text-align: center; }
.ce-endnote:empty { display: none; }
