@font-face {
        font-family: "Homemade Apple";
        src: url("./HomemadeApple-Regular.woff2") format("woff2");
        font-style: normal;
        font-weight: 400;
        font-display: block;
    }
    :root {
        --bg: #000000;
        --surface: #1c1c1e;
        --surface-2: #232325;
        --surface-hover: #2c2c2e;
        --hairline: rgba(255,255,255,0.09);
        --hairline-strong: rgba(255,255,255,0.14);
        --text: #f5f5f7;
        --text-secondary: #98989d;
        --text-tertiary: #6e6e73;
        --accent: #0a84ff;
        --accent-press: #0071e3;
        --danger: #ff453a;
        --success: #30d158;
        --radius-lg: 16px;
        --radius-md: 12px;
        --radius-sm: 9px;
        --shadow-card: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.28);
    }
    * { margin: 0; padding: 0; box-sizing: border-box; }
    html, body { height: 100%; min-height: 100dvh; overflow: hidden; background: var(--bg); color: var(--text); font-family: "Open Sans", Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; user-select: none; }
    button, input, select, textarea { font-family: inherit; }
    .app { display: flex; flex-direction: column; height: 100dvh; min-height: 100dvh; max-height: 100dvh; overflow: hidden; background: var(--bg); }

    header { display: flex; justify-content: space-between; align-items: center; padding: max(14px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 14px max(24px, env(safe-area-inset-left)); background: rgba(28,28,30,0.72); backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6); border-bottom: 1px solid var(--hairline); flex-shrink: 0; min-height: 56px; z-index: 10; }
    .brand { display: flex; width: 92px; flex-direction: column; align-items: stretch; justify-content: center; gap: 1px; color: var(--text); text-decoration: none; cursor: pointer; }
    .brand img { display: block; width: 100%; height: auto; }
    .brand-descriptor { display: flex; width: 100%; justify-content: space-between; padding: 0 1px; box-sizing: border-box; color: var(--text-tertiary); font-size: 8px; font-weight: 700; line-height: 1; letter-spacing: 0; text-transform: uppercase; }
    .header-actions { display: flex; align-items: center; gap: 8px; }

    button { padding: 8px 16px; border: 1px solid var(--hairline); border-radius: 980px; background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 13px; font-weight: 500; letter-spacing: -0.005em; transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease; min-height: 36px; }
    button:hover { background: var(--surface-hover); border-color: var(--hairline-strong); }
    button:active { transform: scale(0.97); }
    button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
    button.primary:hover { background: var(--accent-press); border-color: var(--accent-press); }
    button:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
    button.active-effect, button.active-aspect { border-color: transparent; color: #fff; background: var(--accent); font-weight: 600; }
    #resetBtn.confirming { color: #ff6961; background: rgba(255,69,58,0.14); border-color: rgba(255,69,58,0.42); font-weight: 600; }

    main { display: flex; flex: 1; overflow: hidden; min-height: 0; }
    .sidebar { width: 380px; padding: 14px; background: #0c0c0d; border-right: 1px solid var(--hairline); overflow-y: auto; flex-shrink: 0; min-height: 0; }
    .sidebar::-webkit-scrollbar { width: 5px; }
    .sidebar::-webkit-scrollbar-track { background: transparent; }
    .sidebar::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: 3px; }

    .section { margin-bottom: 10px; padding: 14px; background: var(--surface); border-radius: var(--radius-md); border: 1px solid var(--hairline); }
    .section h3 { font-size: 11px; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 10px; letter-spacing: 0.03em; font-weight: 600; }

    .drop-zone { text-align: center; padding: 14px 10px; border: 1px dashed var(--hairline-strong); border-radius: var(--radius-sm); transition: all 0.2s ease; }
    .drop-zone:hover, .drop-zone.dragover { border-color: var(--accent); background: rgba(10,132,255,0.06); }

    .file-button { display: inline-block; padding: 7px 16px; background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 980px; cursor: pointer; font-size: 12.5px; font-weight: 500; transition: all 0.15s ease; }
    .file-button:hover { background: var(--surface-hover); border-color: var(--hairline-strong); }

    .status { font-size: 11.5px; color: var(--text-tertiary); margin-top: 8px; font-weight: 400; min-height: 14px; line-height: 1.4; }
    .status.success { color: var(--success); }
    .status.error { color: var(--danger); }
    .status.loading { color: var(--accent); }

    .metadata-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }
    .metadata-grid input { width: 100%; min-width: 0; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius-sm); color: var(--text); font: inherit; font-size: 12.5px; outline: none; }
    .metadata-grid input:first-child { grid-column: 1 / -1; }
    .metadata-grid input:focus { border-color: var(--accent); }
    .metadata-grid input::placeholder { color: var(--text-tertiary); }

    .effect-buttons { display: flex; flex-wrap: wrap; gap: 3px; padding: 3px; background: rgba(255,255,255,0.05); border-radius: var(--radius-sm); }
    .effect-buttons button { flex: 1 1 calc(33.333% - 3px); padding: 7px 4px; font-size: 11.5px; border-radius: calc(var(--radius-sm) - 3px); background: transparent; color: var(--text-secondary); border: none; min-height: 30px; font-weight: 500; letter-spacing: 0; line-height: 1.2; }
    .effect-buttons button.active-effect { background: var(--surface-hover); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.5); font-weight: 600; }
    .effect-buttons button:hover:not(.active-effect) { color: var(--text); }

    .aspect-buttons { display: flex; gap: 3px; margin-top: 8px; padding: 3px; background: rgba(255,255,255,0.05); border-radius: var(--radius-sm); }
    .aspect-buttons button { flex: 1; padding: 6px; font-size: 12px; border-radius: calc(var(--radius-sm) - 3px); background: transparent; color: var(--text-secondary); border: none; min-height: 30px; font-weight: 500; }
    .aspect-buttons button.active-aspect { background: var(--surface-hover); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.5); font-weight: 600; }
    .aspect-buttons button:hover:not(.active-aspect) { color: var(--text); }

    .control-row { margin-top: 10px; display: grid; gap: 6px; }
    .control-row label { font-size: 12px; color: var(--text-secondary); text-transform: none; letter-spacing: 0; font-weight: 400; display: flex; justify-content: space-between; align-items: center; }
    .control-row label span { font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }

    input[type="range"] { width: 100%; accent-color: var(--accent); height: 4px; background: var(--hairline-strong); border-radius: 2px; -webkit-appearance: none; appearance: none; }
    input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,0.5); }
    input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; cursor: pointer; border: none; box-shadow: 0 1px 4px rgba(0,0,0,0.5); }

    input[type="color"] { width: 34px; height: 34px; border: 1px solid var(--hairline); border-radius: 8px; padding: 3px; background: var(--surface-2); cursor: pointer; }
    input[type="color"]:hover { border-color: var(--hairline-strong); }

    select { width: 100%; padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--radius-sm); color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; }
    select:focus { outline: none; border-color: var(--accent); }
    select:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

    .full-width { width: 100%; margin-top: 10px; }

    .toggle-row { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
    .toggle-row label { font-size: 13px; color: var(--text); font-weight: 400; text-transform: none; }
    .toggle-switch { position: relative; width: 42px; height: 25px; flex-shrink: 0; }
    .toggle-switch input { opacity: 0; width: 0; height: 0; }
    .toggle-switch .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: var(--hairline-strong); border: none; border-radius: 25px; transition: 0.2s ease; }
    .toggle-switch .slider:before { content: ''; position: absolute; height: 21px; width: 21px; left: 2px; bottom: 2px; background: #fff; border-radius: 50%; transition: 0.2s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.4); }
    .toggle-switch input:checked+.slider { background: var(--success); }
    .toggle-switch input:checked+.slider:before { transform: translateX(17px); }

    #effectControls { margin-top: 10px; border-top: 1px solid var(--hairline); padding-top: 10px; }
    #effectControls .control-row { margin-top: 8px; }
    #effectControls .control-row label { font-size: 12px; color: var(--text-secondary); }
    #effectControls .control-row input[type="range"] { height: 4px; }
    #effectControls .control-row input[type="range"]::-webkit-slider-thumb { width: 16px; height: 16px; }
    #effectControls .control-row input[type="color"] { width: 30px; height: 30px; }
    #effectControls .control-row select { font-size: 12px; padding: 6px 10px; }

    .preview { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 20px; background: var(--bg); min-height: 0; overflow: hidden; }
    .canvas-wrapper { display: flex; align-items: center; justify-content: center; width: 100%; flex: 1 1 auto; height: auto; max-height: none; min-height: 0; background: #000; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--hairline); }
    canvas { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; border-radius: calc(var(--radius-lg) - 2px); background: #000; box-shadow: 0 24px 64px rgba(0,0,0,0.55); }

    .transport { width: 100%; max-width: 800px; display: grid !important; visibility: visible !important; opacity: 1 !important; grid-template-columns: 40px minmax(0,1fr) auto; align-items: center; gap: 12px; margin-top: 14px; padding: 8px 14px; background: var(--surface); border-radius: 980px; border: 1px solid var(--hairline); min-height: 48px; flex: 0 0 auto; position: relative; z-index: 20; box-shadow: var(--shadow-card); }
    .transport button { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; font-size: 13px; padding: 0; display: flex; align-items: center; justify-content: center; background: var(--surface-2); border: 1px solid var(--hairline); min-height: 0; }
    .transport button:hover { border-color: var(--hairline-strong); background: var(--surface-hover); }
    .transport input[type="range"] { flex: 1; min-width: 0; }
    .transport span { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; font-weight: 500; min-width: 74px; text-align: right; font-family: -apple-system, monospace; }

    .overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.68); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4); }
    .overlay.hidden { display: none; }
    .overlay>div { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-lg); padding: 32px 40px; text-align: center; min-width: 280px; max-width: 90vw; box-shadow: var(--shadow-card); }
    .overlay strong { font-size: 40px; display: block; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
    .overlay p { color: var(--text-secondary); margin: 8px 0 16px; font-weight: 400; font-size: 13px; }
    .overlay progress { width: 100%; height: 6px; margin: 12px 0 18px; border-radius: 3px; overflow: hidden; border: none; background: var(--hairline-strong); }
    .overlay progress::-webkit-progress-bar { background: var(--hairline-strong); border-radius: 3px; }
    .overlay progress::-webkit-progress-value { background: var(--accent); border-radius: 3px; }

    .modal { position: fixed; inset: 0; background: rgba(0,0,0,0.68); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4); }
    .modal.hidden { display: none; }
    .modal-content { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-lg); width: 90%; max-width: 520px; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-card); }
    .modal-header { padding: 16px 20px; border-bottom: 1px solid var(--hairline); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
    .modal-header h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
    .modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
    .modal-body textarea { width: 100%; min-height: 160px; padding: 12px; background: #0c0c0d; border: 1px solid var(--hairline); border-radius: var(--radius-sm); color: var(--text); font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; resize: vertical; line-height: 1.6; }
    .modal-body textarea:focus { outline: none; border-color: var(--accent); }
    .modal-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
    .modal-actions button { font-size: 12px; padding: 6px 14px; min-height: 30px; }
    .modal-footer { padding: 14px 20px; border-top: 1px solid var(--hairline); display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; }
    .modal-footer button { min-width: 72px; font-size: 13px; }
    .close-btn { background: none; border: none; color: var(--text-secondary); font-size: 22px; cursor: pointer; padding: 0 6px; min-height: 0; border-radius: 0; }
    .close-btn:hover { color: var(--text); background: none; }

    .toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(80px); padding: 10px 20px; background: var(--surface); backdrop-filter: blur(20px) saturate(1.6); -webkit-backdrop-filter: blur(20px) saturate(1.6); border: 1px solid var(--hairline); border-radius: 980px; color: var(--text); font-size: 13px; font-weight: 500; opacity: 0; transition: all 0.3s cubic-bezier(0.22,1,0.36,1); z-index: 200; pointer-events: none; white-space: nowrap; max-width: 90vw; box-shadow: var(--shadow-card); }
    .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
    .toast.error { border-color: rgba(255,69,58,0.4); color: #ff6259; }
    .toast.success { border-color: rgba(48,209,88,0.4); color: #32e05f; }

    .aspect-info { font-size: 11px; color: var(--text-tertiary); text-align: center; margin-top: 8px; font-weight: 400; }
    .compact-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 8px; }
    .preflight-list { display: grid; gap: 8px; margin: 12px 0; text-align: left; }
    .preflight-row { display: flex; justify-content: space-between; gap: 18px; padding-bottom: 8px; border-bottom: 1px solid var(--hairline); color: var(--text-secondary); font-size: 12px; }
    .preflight-row strong { color: var(--text); font-size: 12px; font-weight: 600; text-align: right; }
    .preflight-warning { padding: 9px 11px; border-radius: var(--radius-sm); background: rgba(255,159,10,0.10); color: #ffb340; font-size: 11px; line-height: 1.45; text-align: left; }
    .effect-label { font-size: 11.5px; color: var(--text-tertiary); text-align: center; margin-top: 8px; font-weight: 400; min-height: 14px; line-height: 1.4; }

    input[type="file"] { display: block; margin: 8px auto; max-width: 100%; color: var(--text); font-size: 11px; }
    #audioInput { position: fixed; left: -9999px; top: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
    #backgroundInput { display: block; width: 100%; margin: 0; padding: 7px; border: 1px solid var(--hairline); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-secondary); font-size: 11px; }
    #backgroundInput::file-selector-button { margin-right: 10px; padding: 7px 14px; border: 0; border-radius: 980px; background: var(--surface-hover); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }

    @media (max-width: 820px) {
        main { flex-direction: column; }
        .sidebar { width: 100%; max-height: 33dvh; border-right: none; border-bottom: 1px solid var(--hairline); padding: 10px; }
        .section { padding: 12px; margin-bottom: 8px; }
        .preview { padding: 10px; min-height: 220px; overflow: hidden; }
        .canvas-wrapper { flex: 1 1 auto; max-height: none; min-height: 0; }
        .transport { display: grid !important; padding: 6px 10px; min-height: 42px; gap: 8px; flex: 0 0 auto; }
        .transport button { width: 30px; height: 30px; font-size: 12px; }
        header { padding: 10px 16px; min-height: 48px; }
        .brand { font-size: 15px; }
        button { font-size: 12px; padding: 6px 12px; min-height: 30px; }
        .effect-buttons button { font-size: 10.5px; padding: 6px 3px; min-height: 26px; }
    }
    @media (max-width: 480px) {
        .brand { width: 84px; }
        .brand-descriptor { font-size: 7px; }
        .sidebar { max-height: 30dvh; padding: 6px; }
        .section { padding: 8px 10px; margin-bottom: 6px; }
        .effect-buttons button { font-size: 9.5px; padding: 5px 2px; min-height: 24px; }
        .transport span { font-size: 10px; min-width: 54px; }
        .canvas-wrapper { flex: 1 1 auto; max-height: none; min-height: 0; }
        .header-actions { gap: 4px; }
        .header-actions button { padding-inline: 9px; }
        .modal-content { width: calc(100% - 20px); max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
        .modal-body { padding: 14px; }
        .modal-footer { padding: 12px 14px max(12px, env(safe-area-inset-bottom)); }
        .toast { bottom: max(18px, env(safe-area-inset-bottom)); white-space: normal; text-align: center; }
    }
