/* 모달 및 리뉴얼 설정창 */
    .modal-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(4, 4, 8, 0.65);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        z-index: 999999;
        justify-content: center;
        align-items: center;
        padding: 20px;
        pointer-events: none;
    }
    .modal-backdrop.active {
        display: flex !important;
        pointer-events: auto;
    }

    .modal-card {
        background: rgba(18, 19, 26, 0.78);
        border: 1px solid var(--glass-border);
        backdrop-filter: blur(40px);
        -webkit-backdrop-filter: blur(40px);
        border-radius: 26px;
        width: 100%;
        max-width: 520px;
        max-height: 86vh;
        display: flex;
        flex-direction: column;
        box-shadow: 0 30px 90px rgba(0, 0, 0, 0.85);
        overflow: hidden;
        position: relative;
    }
    .modal-header {
        padding: 18px 22px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-shrink: 0;
    }
    .modal-header h3 { font-size: 16.5px; font-weight: 700; letter-spacing: -0.3px; }
    .modal-body-wrap {
        position: relative;
        flex: 1;
        min-height: 0;
        display: flex;
        overflow: hidden;
    }
    .modal-body {
        flex: 1;
        padding: 18px 24px 18px 20px;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: 14px;
    }
    .modal-footer {
        padding: 14px 22px;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        display: flex;
        justify-content: flex-end;
        gap: 10px;
        flex-shrink: 0;
    }

    .settings-section {
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 18px;
        padding: 14px;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }
    .settings-section-title {
        font-size: 11.5px;
        font-weight: 700;
        color: var(--accent);
        letter-spacing: 0.3px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .setting-row {
        display: flex;
        flex-direction: column;
        gap: 7px;
        padding: 10px 12px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.06);
        border-radius: 13px;
    }
    .setting-row-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .setting-label {
        font-size: 13px;
        font-weight: 600;
        color: var(--text-main);
    }
    .display-toggles {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .display-toggle {
        padding: 8px 0;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid var(--glass-border);
        color: var(--text-sub);
        font-family: inherit;
        font-size: 12.5px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.15s;
    }
    .display-toggle[aria-pressed="true"] {
        background: rgba(165, 192, 238, 0.2);
        border-color: var(--accent);
        color: #fff;
    }
    .setting-badge {
        font-size: 11.5px;
        font-weight: 700;
        color: var(--accent);
        background: rgba(165, 192, 238, 0.12);
        border: 1px solid rgba(165, 192, 238, 0.25);
        padding: 2px 9px;
        border-radius: 12px;
        font-variant-numeric: tabular-nums;
    }

    input[type="range"].glass-slider {
        -webkit-appearance: none;
        appearance: none;
        width: 100%;
        height: 6px;
        background: rgba(255, 255, 255, 0.14);
        border-radius: 6px;
        outline: none;
        cursor: pointer;
        margin: 4px 0 2px;
    }
    input[type="range"].glass-slider::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: #ffffff;
        box-shadow: 0 0 10px rgba(165, 192, 238, 0.8), 0 2px 6px rgba(0, 0, 0, 0.5);
        cursor: pointer;
        transition: transform 0.15s ease;
    }

    .form-input {
        width: 100%;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--glass-border);
        color: #fff;
        padding: 10px 12px;
        border-radius: 11px;
        font-size: 13px;
        font-family: inherit;
        outline: none;
        transition: border-color 0.2s;
    }
    .form-input:focus { border-color: rgba(255, 255, 255, 0.4); }
    select.form-input option, select.form-input optgroup {
        background: #161720;
        color: #fff;
    }
    textarea.form-input { resize: vertical; min-height: 64px; }

    .setting-inline-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 9px 12px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.06);
        border-radius: 13px;
    }
    /* ---- 가사 강조 색상 ---- */
    .color-preview {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 16px 12px;
        border-radius: 14px;
        background: radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.35));
        border: 1px solid rgba(255, 255, 255, 0.06);
        text-align: center;
    }
    .color-preview-orig {
        font-size: 22px;
        font-weight: 700;
        color: var(--color-active-orig);
        text-shadow: 0 0 calc(24px * var(--glow-intensity)) var(--color-active-orig);
    }
    .color-preview-pron,
    .color-preview-trans { font-size: 14px; font-weight: 500; }
    .color-preview-pron {
        color: var(--color-active-pron);
        text-shadow: 0 0 calc(20px * var(--glow-intensity)) var(--color-active-pron);
    }
    .color-preview-trans {
        color: var(--color-active-trans);
        text-shadow: 0 0 calc(20px * var(--glow-intensity)) var(--color-active-trans);
    }

    .color-swatch-list {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .color-swatch-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        padding: 12px 6px 10px;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid var(--glass-border);
        color: var(--text-main);
        font-family: inherit;
        cursor: pointer;
        transition: background 0.15s, border-color 0.15s, transform 0.15s;
    }
    .color-swatch-btn:active { transform: scale(0.97); }
    .color-swatch-dot {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        background: var(--swatch-color, #fff);
        border: 2px solid rgba(255, 255, 255, 0.85);
        box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 0 14px var(--swatch-color, transparent);
    }
    .color-swatch-name { font-size: 12.5px; font-weight: 700; }
    .color-swatch-hex {
        font-size: 11px;
        font-weight: 600;
        color: var(--text-sub);
        font-family: ui-monospace, Consolas, monospace;
        text-transform: uppercase;
    }
    @media (hover: hover) and (pointer: fine) {
        .color-swatch-btn:hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(255, 255, 255, 0.28); }
    }

    /* ---- 색상 팔레트 창 ---- */
    #modal-color-picker { z-index: 1000000; }
    .color-picker-card { max-width: 380px; }
    .color-picker-body {
        display: flex;
        flex-direction: column;
        gap: 14px;
        padding: 16px 20px 6px;
    }
    .cp-sample {
        text-align: center;
        font-size: 24px;
        font-weight: 700;
        padding: 6px 0 2px;
        min-height: 40px;
    }
    .cp-sample-pron, .cp-sample-trans { font-size: 19px; font-weight: 600; }
    .cp-sv {
        position: relative;
        width: 100%;
        aspect-ratio: 4 / 3;
        max-height: 42vh;
        border-radius: 14px;
        background:
            linear-gradient(to top, #000, transparent),
            linear-gradient(to right, #fff, var(--cp-hue-color, red));
        cursor: crosshair;
        touch-action: none;
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    }
    .cp-sv-thumb,
    .cp-hue-thumb {
        position: absolute;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        border: 3px solid #fff;
        box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.5);
        transform: translate(-50%, -50%);
        pointer-events: none;
    }
    .cp-hue {
        position: relative;
        height: 18px;
        border-radius: 9px;
        background: linear-gradient(to right, #f00 0%, #ff0 16.66%, #0f0 33.33%, #0ff 50%, #00f 66.66%, #f0f 83.33%, #f00 100%);
        cursor: pointer;
        touch-action: none;
        margin: 0 12px;
    }
    .cp-hue-thumb { top: 50%; }
    .cp-value-row {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .cp-compare {
        display: flex;
        width: 52px;
        height: 36px;
        border-radius: 10px;
        overflow: hidden;
        flex-shrink: 0;
        box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
    }
    .cp-compare span { flex: 1; }
    .cp-hex-wrap {
        flex: 1;
        min-width: 0;
        display: flex;
        align-items: center;
        gap: 4px;
        padding: 0 12px;
        height: 36px;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--glass-border);
        color: var(--text-sub);
        font-family: ui-monospace, Consolas, monospace;
        font-size: 14px;
    }
    .cp-hex-wrap input {
        flex: 1;
        min-width: 0;
        background: transparent;
        border: none;
        outline: none;
        color: #fff;
        font-family: inherit;
        font-size: 16px;
        text-transform: uppercase;
        letter-spacing: 1px;
    }
    .cp-value-row .btn-action { padding: 8px 12px; flex-shrink: 0; }

    .offset-btn-group {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
    }
    .btn-offset {
        flex: 1;
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid var(--glass-border);
        color: var(--text-main);
        font-size: 12px;
        font-weight: 600;
        padding: 8px 6px;
        border-radius: 10px;
        cursor: pointer;
        transition: all 0.15s ease;
    }
    .btn-offset:active { background: rgba(255, 255, 255, 0.22); transform: scale(0.96); }
    .btn-offset.reset { color: var(--accent); }

    details.custom-accordion {
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.06);
        border-radius: 13px;
        padding: 10px 12px;
        transition: background 0.2s ease;
    }
    details.custom-accordion[open] { background: rgba(255, 255, 255, 0.05); }
    details.custom-accordion summary {
        cursor: pointer;
        font-size: 13px;
        font-weight: 600;
        color: var(--text-main);
        display: flex;
        justify-content: space-between;
        align-items: center;
        list-style: none;
        user-select: none;
    }
    details.custom-accordion summary::-webkit-details-marker { display: none; }
    details.custom-accordion summary::after {
        content: '▾';
        font-size: 14px;
        color: var(--text-sub);
        transition: transform 0.2s ease;
    }
    details.custom-accordion[open] summary::after { transform: rotate(180deg); }
    .accordion-content {
        margin-top: 10px;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .btn-action {
        background: rgba(255, 255, 255, 0.07);
        border: 1px solid var(--glass-border);
        color: #fff;
        padding: 9px 16px;
        border-radius: 12px;
        font-size: 12.5px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.18s;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }
    .btn-action:active { transform: scale(0.97); background: rgba(255, 255, 255, 0.18); }
    .btn-action:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
    .btn-action.primary {
        background: #ffffff;
        color: #000000;
        border: none;
    }
    .btn-action.primary:active { background: #dcdcdc; }
    .btn-action.danger {
        background: rgba(239, 71, 111, 0.12);
        border-color: rgba(239, 71, 111, 0.35);
        color: #ff859d;
    }
    .btn-action.danger:active {
        background: rgba(239, 71, 111, 0.25);
    }

    .log-terminal {
        background: rgba(8, 9, 14, 0.8);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 11px;
        height: 120px;
        overflow-y: auto;
        padding: 9px;
        font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
        font-size: 11px;
        line-height: 1.5;
        display: flex;
        flex-direction: column;
        gap: 3px;
    }
    .log-entry {
        word-break: break-all;
        cursor: pointer;
        padding: 2px 5px;
        border-radius: 5px;
        transition: background 0.15s ease;
    }
    .log-entry:active { background: rgba(255, 255, 255, 0.18); }
    .log-info { color: #8892b0; }
    .log-warn { color: #ffd166; }
    .log-error { color: #ef476f; font-weight: 600; }
    .log-success { color: #06d6a0; }

    #toast-msg {
        visibility: hidden;
        background: rgba(255, 255, 255, 0.95);
        color: #000;
        font-weight: 700;
        text-align: center;
        border-radius: 30px;
        padding: 9px 20px;
        position: fixed;
        z-index: 1000000;
        bottom: max(30px, env(safe-area-inset-bottom, 30px));
        left: 50%;
        transform: translateX(-50%);
        font-size: 12.5px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    }
    #toast-msg.show { visibility: visible; animation: popin 0.2s, popout 0.3s 1.4s; }
    @keyframes popin { from { bottom: 15px; opacity: 0; } to { bottom: max(30px, env(safe-area-inset-bottom, 30px)); opacity: 1; } }
    @keyframes popout { from { bottom: max(30px, env(safe-area-inset-bottom, 30px)); opacity: 1; } to { bottom: 15px; opacity: 0; } }
