:root {
  color-scheme: light;
  font-family: 'Avenir Next', Avenir, 'Segoe UI', sans-serif;
  color: #24231e;
  background: #f4f2eb;
  font-synthesis: none;
  --ink: #24231e;
  --muted: #625f54;
  --line: #dedad0;
  --paper: #fcfaf4;
  --accent: #f0cc50;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #a65d11; outline-offset: 3px; }
.header { border-bottom: 1px solid var(--line); }
.header-inner { max-width: 1240px; min-height: 66px; margin: auto; padding: 0 38px; display: flex; align-items: center; justify-content: space-between; }
.brand { color: var(--ink); font-size: 23px; font-weight: 900; text-decoration: none; letter-spacing: -1.6px; display: flex; align-items: center; }
.brand > span:last-child { color: #736545; }
.brand-mark { display: inline-block; background: var(--accent); width: 26px; height: 23px; border: 1.7px solid var(--ink); border-radius: 8px 8px 12px 12px; margin-right: 9px; position: relative; transform: rotate(-10deg); }
.brand-mark::after { content: ''; display: block; width: 14px; height: 6px; position: absolute; top: 7px; left: 4px; border: 1.7px solid var(--ink); border-radius: 2px 2px 9px 9px; }
.browser-label { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; font-weight: 650; }
.browser-label i { width: 7px; height: 7px; border-radius: 50%; background: #648149; }
main { max-width: 1240px; margin: auto; padding: 49px 38px 52px; }
.intro { margin-bottom: 27px; }
h1 { font-size: clamp(48px, 8vw, 83px); line-height: .98; letter-spacing: -.077em; margin: 0 0 12px; font-weight: 900; }
.intro p { margin: 0; font-size: 15px; color: var(--muted); }
.studio { display: grid; grid-template-columns: minmax(0, 1fr) 305px; gap: 20px; align-items: start; }
.preview, .panel { border: 1px solid var(--line); background: var(--paper); border-radius: 14px; }
.preview { padding: 10px; min-width: 0; }
.stage { position: relative; width: min(100%, calc(620px * var(--frame-scale, 1.7778))); aspect-ratio: var(--frame-ratio, 16 / 9); margin-inline: auto; color: var(--paper); border-radius: 8px; overflow: hidden; background-color: #282820; background-image: radial-gradient(#57564a 0.8px, transparent 1px); background-size: 19px 19px; }
canvas { width: 100%; height: 100%; position: absolute; inset: 0; touch-action: none; }
.stage.has-image canvas { cursor: crosshair; }
.stage.has-image[data-mouth-pack="true"]:not([data-editing="crop"]):not([data-picking-focus="true"]) canvas { cursor: default; }
.stage[data-editing="crop"][data-can-pan="true"] canvas { cursor: grab; }
.stage[data-editing="crop"][data-can-pan="true"] canvas:active { cursor: grabbing; }
.stage[data-editing="crop"][data-can-pan="false"] canvas { cursor: default; }
.empty { position: absolute; inset: 0; width: 100%; color: var(--paper); border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 20px; }
.empty strong { font-size: 19px; }
.empty > span:last-child { color: #cecbbe; font-size: 12px; }
.empty-icon { display: block; position: relative; width: 51px; height: 41px; border-radius: 7px; border: 1.5px solid var(--accent); margin: 0 0 10px; transform: rotate(-8deg); }
.empty-icon b { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); top: 7px; right: 8px; }
.empty-icon i { position: absolute; width: 24px; height: 14px; border: 1.5px solid var(--accent); border-bottom: 0; border-right: 0; top: 19px; left: 8px; transform: skew(-12deg) rotate(15deg); border-radius: 3px 0 0; }
.stage-label { position: absolute; left: 10px; bottom: 10px; pointer-events: none; background: #24231ee8; color: white; font-size: 11px; padding: 5px 8px; border-radius: 5px; }
.zoom-marker { position: absolute; width: 16px; height: 16px; border: 2px solid white; border-radius: 50%; box-shadow: 0 0 0 1px #24231e; transform: translate(-50%, -50%); pointer-events: none; }
.transport { display: flex; gap: 14px; align-items: center; min-height: 63px; padding: 10px 8px 1px; }
.play { flex: 0 0 42px; height: 42px; border-radius: 50%; border: 1px solid #93721b; background: var(--accent); display: grid; place-items: center; }
.play:disabled { opacity: .48; }
.play span { display: block; width: 0; height: 0; border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 10px solid var(--ink); margin-left: 3px; }
.play[data-playing="true"] span { width: 11px; height: 12px; border: 0; border-inline: 4px solid var(--ink); margin: 0; }
.timeline { flex: 1; min-width: 0; }
.times { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
input[type="range"] { margin: 0; width: 100%; accent-color: #8f701c; }
.tools { display: grid; gap: 13px; }
.panel { padding: 15px; }
h2 { margin: 0 0 11px; font-size: 16px; letter-spacing: -.028em; }
.file { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fffdf9; min-height: 53px; padding: 8px; margin: 0 0 8px; cursor: pointer; }
.file:hover { border-color: #b7a574; }
.file:has(+ input:focus-visible) { outline: 3px solid #a65d11; outline-offset: 2px; }
.file:last-of-type { margin-bottom: 0; }
.file-icon { flex: 0 0 30px; display: grid; place-items: center; border-radius: 6px; background: #f4ead1; font-size: 19px; height: 31px; color: #5d4814; }
.music-icon { background: #e6eadc; color: #455537; }
.file-text { flex: 1; min-width: 0; }
.file-text b, .file-text small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-text b { font-size: 12px; margin-bottom: 2px; }
.file-text small { font-size: 11px; color: var(--muted); }
.plus { flex: 0 0 20px; color: var(--muted); text-align: center; font-size: 19px; }
.file-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.analysis { margin: 12px 0 0; }
.analysis > div { display: flex; justify-content: space-between; gap: 9px; font-size: 11px; line-height: 1.4; color: var(--muted); }
progress { width: 100%; height: 7px; accent-color: #9b7a20; }
.media-error { color: #9a311b; margin: 9px 0 0; font-size: 12px; }
.retry, .reset { border: 0; background: transparent; padding: 0; color: #715810; text-decoration: underline; font-size: 11px; }
.retry { margin-top: 4px; }
.reset:disabled { opacity: .5; }
.panel-title { display: flex; justify-content: space-between; align-items: baseline; }
.mouth-controls { display: grid; gap: 8px; }
.mouth-pack-controls { display: grid; gap: 8px; }
.mouth-pack-controls > div { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mouth-pack-controls p { margin: 0; overflow-wrap: anywhere; }
.effects-panel { border-top: 1px solid var(--line); margin: 4px 8px 2px; padding-top: 12px; }
.effect-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.control { display: grid; gap: 2px; color: var(--muted); font-size: 11px; }
.control > span { display: flex; justify-content: space-between; gap: 4px; }
.control output { font-variant-numeric: tabular-nums; }
.check-control { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.check-control input { margin: 0; accent-color: #8f701c; }
.visualizer-status { margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.frame-toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; padding: 4px 4px 12px; }
.frame-actions { display: flex; flex: 1; justify-content: end; align-items: center; gap: 12px; }
.frame-actions output { white-space: nowrap; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.frame-actions button { min-width: 100px; }
.control select, .secondary, .export-button { min-height: 36px; padding: 5px 9px; border: 1px solid #cbc3b1; border-radius: 6px; color: var(--ink); background: #fffdf9; font-size: 12px; }
.secondary { white-space: nowrap; }
.secondary[aria-expanded="true"] { border-color: #93721b; background: #f7e6a6; }
.secondary:disabled, .export-button:disabled { opacity: .5; }
.crop-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(105px, 35%) auto; align-items: center; gap: 8px 14px; margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #f5f1e4; }
.crop-hint { margin: 0; color: var(--muted); font-size: 12px; }
.crop-panel .reset { white-space: nowrap; padding-block: 4px; }
.export-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.export-button { width: 100%; border-color: #93721b; background: var(--accent); font-weight: 700; }
.export-status { color: var(--muted); font-size: 11px; line-height: 1.4; margin: 7px 0 0; }
.export-status[data-error="true"] { color: #9a311b; }
.download-link { display: inline-block; margin-top: 7px; color: #715810; font-size: 12px; font-weight: 700; }

@media(min-width: 761px) {
  .stage[data-portrait="true"] { width: min(100%, calc(clamp(345px, 50svh, 570px) * var(--frame-scale))); }
}
select:focus-visible { outline: none; border-color: var(--ink); }

@media(max-width: 760px) {
  main { padding: 32px 19px 42px; }
  .header-inner { padding: 0 19px; min-height: 58px; }
  .intro { margin-bottom: 20px; }
  .studio { grid-template-columns: 1fr; gap: 13px; }
}

@media(max-width: 480px) {
  .frame-toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .frame-actions { grid-column: 1 / -1; justify-content: space-between; }
  .frame-actions button { flex: 0 0 auto; }
  .crop-panel { grid-template-columns: minmax(0, 1fr) auto; }
  .crop-hint { grid-column: 1 / -1; }
}

@media(max-width: 360px) {
  .effect-controls { grid-template-columns: 1fr; gap: 8px; }
}
