/* Fily Studio — dark, mobile-first */
:root {
  --bg: #0b0d12;
  --bg-2: #12151d;
  --bg-3: #1a1e29;
  --line: #262b38;
  --text: #eef0f5;
  --muted: #9aa3b5;
  --accent: #7c5cff;
  --accent-2: #ff5c8a;
  --ok: #34d399;
  --warn: #fbbf24;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; display: flex; flex-direction: column; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 650; margin-bottom: 12px; }
h2 small { color: var(--muted); font-weight: 400; font-size: .85rem; margin-left: 6px; }
a { color: inherit; text-decoration: none; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.logo { width: 28px; height: 28px; border-radius: 8px; }
.badge { font-size: .65rem; font-weight: 700; letter-spacing: .06em; padding: 3px 7px; border-radius: 999px; background: var(--bg-3); color: var(--muted); }
.badge.pro { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.top-actions { display: flex; gap: 8px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-3); color: var(--text); font-weight: 600; min-height: 44px; transition: transform .08s ease, background .15s ease; }
.btn:hover { background: #222736; }
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; min-height: 36px; font-size: .9rem; }
.btn.big { width: 100%; padding: 15px; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: default; }

/* home */
.screen { flex: 1; }
.home { padding: 28px 16px 40px; max-width: 760px; margin: 0 auto; width: 100%; }
.hero h1 { font-size: clamp(1.7rem, 5vw, 2.5rem); font-weight: 800; line-height: 1.1; }
.lead { color: var(--muted); font-size: 1.02rem; line-height: 1.5; margin: 12px 0 22px; }
.drop { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 30px 18px; border: 1.5px dashed #3a4157; border-radius: var(--radius); background: var(--bg-2); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: #151a28; }
.drop-icon { width: 44px; height: 44px; color: var(--accent); margin-bottom: 4px; }
.drop strong { font-size: 1.05rem; }
.drop small { color: var(--muted); }
.drop.small { padding: 16px; gap: 2px; }
.drop.small strong { font-size: .95rem; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 22px; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.card b { font-size: .95rem; }
.card span { color: var(--muted); font-size: .85rem; line-height: 1.4; }
.soon { color: var(--muted); font-size: .85rem; margin-top: 22px; line-height: 1.5; }
@media (min-width: 700px) { .cards { grid-template-columns: repeat(4, 1fr); } }

/* editor layout */
.editor { display: flex; flex-direction: column; }
.stage { padding: 12px 16px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.stage-box { position: relative; background: #000; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); width: 100%; height: 46dvh; max-width: 100%; }
.stage-box canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.play { position: absolute; inset: 0; margin: auto; width: 64px; height: 64px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; backdrop-filter: blur(6px); transition: opacity .2s; }
.play svg { width: 30px; height: 30px; }
.play .ic-pause { display: none; }
.stage-box.playing .play { opacity: 0; }
.stage-box.playing:hover .play { opacity: 1; }
.stage-box.playing .play .ic-play { display: none; }
.stage-box.playing .play .ic-pause { display: block; }
.stage-status { position: absolute; left: 10px; right: 10px; bottom: 10px; background: rgba(11,13,18,.85); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: .8rem; text-align: center; }
.stage-time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.stage-time .sep { margin: 0 6px; opacity: .6; }

.side { display: flex; flex-direction: column; flex: 1; }
.tools { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 6px 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg-2); position: sticky; top: 49px; z-index: 4; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: .72rem; font-weight: 600; }
.tool svg { width: 22px; height: 22px; }
.tool.active { color: var(--text); background: var(--bg-3); }
.tool-primary { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.tool-primary.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); filter: brightness(1.1); }
.panel { padding: 16px 16px calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; }
.hint { color: var(--muted); font-size: .82rem; line-height: 1.45; margin: 0; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.gap > * { flex: 1; }
.row.three { justify-content: space-between; font-size: .8rem; color: var(--muted); }
.row.three b { display: block; color: var(--text); font-size: .95rem; font-variant-numeric: tabular-nums; }

/* trim */
.trim { display: flex; flex-direction: column; gap: 10px; }
.filmstrip { display: grid; grid-template-columns: repeat(10, 1fr); height: 52px; border-radius: 10px 10px 0 0; overflow: hidden; background: var(--bg-3); }
.filmstrip canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.range { position: relative; height: 34px; margin-top: -4px; background: var(--bg-3); border-radius: 0 0 10px 10px; }
.range-sel { position: absolute; top: -52px; bottom: 0; border: 2.5px solid var(--accent); border-radius: 8px; pointer-events: none; box-shadow: 0 0 0 200vmax rgba(11,13,18,.0); }
.range-cursor { position: absolute; top: -52px; bottom: 0; width: 2px; background: #fff; pointer-events: none; opacity: .9; }
.range input[type=range] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; appearance: none; -webkit-appearance: none; background: transparent; pointer-events: none; }
.range input[type=range]::-webkit-slider-runnable-track { background: transparent; }
.range input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 22px; height: 34px; border-radius: 8px; background: var(--accent); border: 2px solid #fff; cursor: ew-resize; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.range input[type=range]::-moz-range-track { background: transparent; }
.range input[type=range]::-moz-range-thumb { pointer-events: auto; width: 22px; height: 34px; border-radius: 8px; background: var(--accent); border: 2px solid #fff; cursor: ew-resize; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 9px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font-weight: 600; font-size: .9rem; min-height: 40px; justify-content: center; }
.chip small { color: var(--muted); font-weight: 400; font-size: .72rem; }
.chip.active { border-color: var(--accent); background: #1c1a33; box-shadow: inset 0 0 0 1px var(--accent); }
.chip.file { cursor: pointer; }

/* sliders & switches */
.slider { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.slider span { float: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.slider > input[type=range] { width: 100%; accent-color: var(--accent); height: 32px; }
.switch { display: flex; align-items: center; gap: 10px; font-size: .92rem; padding: 6px 0; cursor: pointer; }
.switch small { color: var(--muted); }
.switch input { display: none; }
.switch span { width: 42px; height: 24px; border-radius: 999px; background: var(--bg-3); border: 1px solid var(--line); position: relative; flex: none; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
input[type=color] { width: 44px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); padding: 2px; margin-left: 8px; }
input[type=text] { padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); min-height: 44px; outline: none; }
input[type=text]:focus { border-color: var(--accent); }

/* export */
.summary { list-style: none; margin: 0; padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); display: grid; gap: 6px; font-size: .9rem; }
.summary li { display: flex; justify-content: space-between; gap: 12px; }
.summary li span:first-child { color: var(--muted); }
.progress { position: relative; height: 34px; border-radius: 10px; background: var(--bg-3); overflow: hidden; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s linear; }
.progress span { position: absolute; inset: 0; display: grid; place-items: center; font-size: .85rem; font-weight: 700; }
.result { display: flex; flex-direction: column; gap: 10px; }
.result video { width: 100%; max-height: 42dvh; background: #000; border-radius: 12px; }
.pro { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); padding: 10px 14px; }
.pro summary { cursor: pointer; font-weight: 650; }
.pro p { color: var(--muted); font-size: .88rem; }
.pro .row input { flex: 2; }
.pro .row .btn { flex: 1; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translateX(-50%); background: #1f2433; color: #fff; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); box-shadow: var(--shadow); font-size: .9rem; max-width: min(92vw, 420px); text-align: center; z-index: 50; }
.toast.err { border-color: var(--accent-2); }

/* desktop: two columns */
@media (min-width: 900px) {
  .editor { flex-direction: row; align-items: stretch; }
  .stage { flex: 1; justify-content: center; padding: 20px; }
  .side { width: 420px; border-left: 1px solid var(--line); }
  .tools { top: 0; position: static; border-top: 0; }
  .panel { overflow: auto; }
}
