:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --input-bg: #2c2c2c;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --accent-color: #0DB376;
    --danger-color: #ff5252;
    --border-radius: 8px;
    --spacing: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding-bottom: 120px;
    /* Space for bottom bar */
}

.app-container {
    width: 100%;
    max-width: 600px;
    /* Increased for tablets/large phones */
    padding: var(--spacing);
    margin: 0 auto;
    /* Center on larger screens */
}

/* Header */
.header-section {
    margin-bottom: 24px;
}

.title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.section-label {
    font-size: 1.1rem;
    font-weight: bold;
}

/* Input Wrapper */
.input-wrapper {
    position: relative;
    margin-bottom: 8px;
}

.input-wrapper input {
    width: 100%;
    background-color: var(--input-bg);
    border: none;
    border-radius: var(--border-radius);
    padding: 10px 40px 10px 16px;
    color: var(--text-primary);
    font-size: 1rem;
}

.input-wrapper input:focus {
    outline: 1px solid var(--accent-color);
}

.clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-55%);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    transition: color 0.2s, transform 0.2s;
    /* Larger touch target */
}

.clear-btn:hover {
    color: #ff5252;
    transform: translateY(-55%) scale(1.1);
}

.composer-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

#composer-name {
    color: var(--text-primary);
    font-weight: bold;
}

/* Upload & Controls */
.upload-section {
    background-color: var(--input-bg);
    border-radius: var(--border-radius);
    padding: 30px 20px;
    /* More vertical padding */
    text-align: center;
    cursor: pointer;
    margin-bottom: 10px;
    border: 2px dashed #444;
    transition: border-color 0.3s;
}

.upload-section:hover {
    border-color: var(--accent-color);
}

.upload-text {
    margin-top: 10px;
}

.upload-hint {
    font-size: 0.75rem;
    color: #888;
    margin-top: 12px;
    line-height: 1.5;
}

.upload-hint strong {
    color: #aaa;
}

.controls-area {
    margin-bottom: 0px;
}

.control-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
}

.time-input,
.bpm-input,
.quant-select {
    background-color: var(--input-bg);
    border: none;
    border-radius: 8px;
    /* Softer corners */
    padding: 10px;
    color: var(--text-primary);
    flex: 1 1 80px;
    /* Grow, shrink, min-width */
    text-align: center;
    font-size: 1rem;
    min-width: 0;
    /* Fix flexbox overflow */
}

/* Specific adjustments for labels inside control rows */
.control-row label {
    flex: 0 0 auto;
    /* Don't shrink labels */
    margin-right: 4px;
}

.action-btn {
    width: 100%;
    padding: 10px;
    border-radius: var(--border-radius);
    border: none;
    font-weight: bold;
    cursor: pointer;
    font-size: 1.05rem;
    transition: transform 0.15s, background-color 0.2s, box-shadow 0.2s;
    color: #fff !important
}

.action-btn:active {
    transform: scale(0.98);
}

.action-btn.primary {
    background-color: var(--accent-color);
    color: #fff;
}

.action-btn.primary:hover {
    background-color: #00c96b;
    box-shadow: 0 4px 12px rgba(0, 230, 118, 0.3);
}

.action-btn.secondary {
    background-color: #333;
    color: var(--text-primary);
}

.action-btn.secondary:hover {
    background-color: #444;
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
}

/* MML Cards */
.mml-card {
    background-color: transparent;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.icon-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.speaker-icon {
    background-color: var(--accent-color);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-size: 0.9rem;
}

.part-name {
    font-weight: bold;
    font-size: 1.1rem;
}

.char-count {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.card-body {
    position: relative;
}

.card-body textarea {
    width: 100%;
    height: 55px;
    /* Slightly taller */
    background-color: var(--input-bg);
    border: none;
    border-radius: var(--border-radius);
    padding: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
    /* Readable size */
    resize: none;
    line-height: 1.5;
    font-family: monospace;
    /* Better for code/MML */
}

.copy-btn {
    position: absolute;
    right: 12px;
    top: 12px;
    background-color: var(--bg-color);
    border: 1px solid #444;
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 8px;
    transition: background-color 0.2s, border-color 0.2s, transform 0.15s;
}

.copy-btn:hover {
    background-color: #2a2a2a;
    border-color: var(--accent-color);
    transform: scale(1.05);
    backdrop-filter: blur(4px);
}

/* Bottom Bar */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 16px;
    background: linear-gradient(to top, var(--bg-color) 90%, transparent);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    pointer-events: none;
    /* Let clicks pass through transparent area */
}

.bottom-content {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
    /* Re-enable clicks */
}

.copyright {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    opacity: 0.7;
    font-weight: 400;
    letter-spacing: 0.5px;
}

.disclaimer-link {
    color: #ffab40;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
}

.disclaimer-link:first-of-type {
    margin-left: 8px;
}

.disclaimer-link:hover {
    color: #ffc570;
    text-decoration: underline;
}

.copyright-separator {
    color: #555;
    margin: 0 4px;
}

/* 면책조항 모달 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: linear-gradient(145deg, #1e1e1e, #2a2a2a);
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 171, 64, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 171, 64, 0.2);
    background: rgba(255, 171, 64, 0.1);
}

.modal-title {
    color: #ffab40;
    font-size: 1.1rem;
    margin: 0;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 20px;
    color: #ccc;
    font-size: 0.85rem;
    line-height: 1.6;
}

.modal-body h3 {
    color: #ffab40;
    font-size: 0.95rem;
    margin: 16px 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 171, 64, 0.2);
}

.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body p {
    margin: 8px 0;
}

.modal-body ul {
    margin: 8px 0;
    padding-left: 20px;
}

.modal-body li {
    margin: 4px 0;
}

.modal-notice {
    margin-top: 20px;
    padding: 12px;
    background: rgba(255, 171, 64, 0.15);
    border-radius: 8px;
    border-left: 3px solid #ffab40;
    color: #ffab40;
    font-weight: 500;
}

/* 라이선스 텍스트 박스 */
.license-text {
    margin: 10px 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.75rem;
    color: #999;
    line-height: 1.6;
}

.license-link-external {
    color: #4facfe;
    text-decoration: none;
}

.license-link-external:hover {
    text-decoration: underline;
}

/* 면책조항 요약 (WebGL 하단) */
.disclaimer-summary {
    margin-top: 12px;
    padding: 12px 14px;
    background: linear-gradient(145deg, rgba(255, 152, 0, 0.1), rgba(255, 87, 34, 0.08));
    border: 1px solid rgba(255, 152, 0, 0.3);
    border-radius: 8px;
    border-left: 3px solid #ff9800;
}

.disclaimer-summary-title {
    color: #ff9800;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.disclaimer-summary-content {
    font-size: 0.78rem;
    color: #bbb;
    line-height: 1.7;
}

.disclaimer-no {
    color: #ff5252;
}

.disclaimer-yes {
    color: #69f0ae;
}

.disclaimer-notice {
    color: #ffab40;
}

.disclaimer-server {
    color: #4facfe;
}

.disclaimer-more {
    color: #888;
    font-size: 0.72rem;
    font-style: italic;
}

/* 트랙 분산 힌트 */
.share-track-hint {
    color: #ff5252;
    font-size: 0.7rem;
    margin-left: 6px;
}

.share-track-hint.hidden {
    display: none;
}

/* 트랙 분산 비활성화 상태 */
.share-track-disabled .opt-checkbox {
    opacity: 0.4;
    cursor: not-allowed;
}

.share-track-disabled .opt-label-share-track {
    opacity: 0.4;
    cursor: not-allowed;
}

.create-btn {
    width: 100%;
    max-width: 600px;
    background-color: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    padding: 18px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 230, 118, 0.4);
    transition: transform 0.15s, background-color 0.2s, box-shadow 0.2s;
}

.create-btn:hover {
    background-color: #00c96b;
    box-shadow: 0 6px 24px rgba(0, 230, 118, 0.4);
    transform: translateY(-2px);
}

.create-btn:active {
    transform: scale(0.98);
}

.error-banner {
    background-color: rgba(255, 82, 82, 0.15);
    color: #ff8a80;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    text-align: center;
    font-weight: bold;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 82, 82, 0.3);
}

/* Track List Items */
.track-item {
    background: var(--card-bg);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    /* Wrap on small screens */
    gap: 8px;
}

.track-item span {
    font-size: 0.9rem;
    flex: 1 1 auto;
}

.track-item select {
    background: #333;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 8px;
    flex: 0 0 auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Help Tooltip */
.help-tooltip {
    background: linear-gradient(135deg, #1a3a2a 0%, #1e1e1e 100%);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #e0e0e0;
    display: none;
    animation: tooltipFadeIn 0.2s ease-out;
}

.help-tooltip.active {
    display: block;
}

.help-tooltip .tooltip-title {
    color: var(--accent-color);
    font-weight: bold;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.help-tooltip .tooltip-desc {
    color: #b0b0b0;
}

.help-tooltip .tooltip-tip {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #333;
    color: #888;
    font-size: 0.8rem;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Highlight active input */
.bpm-input:focus,
.quant-select:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 1px;
}

/* Floating Tooltip */
#floating-tooltip {
    animation: tooltipFadeIn 0.15s ease-out;
}

#floating-tooltip .tooltip-title {
    color: var(--accent-color);
    font-weight: bold;
    margin-bottom: 4px;
    font-size: 0.85rem;
}

#floating-tooltip .tooltip-desc {
    color: #b0b0b0;
    margin-bottom: 6px;
}

#floating-tooltip .tooltip-tip {
    padding-top: 6px;
    border-top: 1px solid #333;
    color: #888;
    font-size: 0.78rem;
}

#quantization-select option {
    color: #fff;
    background: #222;
}

/* === 옵션 영역 스타일 === */

/* 로딩 오버레이 */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    z-index: 1000;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.loading-spinner {
    border: 4px solid #00e676;
    border-top: 4px solid transparent;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.progress-container {
    width: 300px;
    height: 6px;
    background: #333;
    border-radius: 3px;
    margin-top: 15px;
    overflow: hidden;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: #00e676;
    transition: width 0.3s ease;
}

.progress-text {
    margin-top: 5px;
    font-size: 0.9rem;
    color: #ccc;
}

/* 파일명 표시 */
.file-name-display {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #00e676;
}

/* WebGL 안내 박스 */
.info-box {
    margin-top: 20px;
    padding: 12px;
    background: linear-gradient(135deg, #1a2a3a 0%, #1e1e1e 100%);
    border: 1px solid #4a90d9;
    border-left: 3px solid #4a90d9;
    border-radius: 8px;
    font-size: 0.82rem;
    line-height: 1.5;
    color: #a0c4e8;
}

.info-box-title {
    font-weight: bold;
    color: #4a90d9;
    margin-bottom: 6px;
}

.info-box-content {
    color: #8ab4d8;
}

.info-box-footer {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(74, 144, 217, 0.3);
    color: #7aa8d0;
    font-size: 0.75rem;
}

.info-box-footer strong {
    color: #4a90d9;
}

/* 옵션 컨테이너 */
.options-container {
    position: relative;
}

/* 옵션 영역 (플로팅 패널) */
.options-area {
    display: block;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: linear-gradient(135deg, #1a2a1a 0%, #1e1e1e 100%);
    border: 1px solid rgba(0, 230, 118, 0.3);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
    margin-bottom: 0;
}

/* 옵션 행 */
.options-row {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

/* 옵션 컬럼 (1/3 너비) */
.opt-col {
    flex: 1;
    min-width: 0;
}

/* 구간 입력 컬럼 (내부 flex) */
.opt-col-range {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 4px;
    align-items: flex-end;
}

.opt-col-range > div {
    flex: 1;
}

.range-separator {
    color: #5a8a6a;
    font-size: 0.9rem;
    padding-bottom: 10px;
}

/* 옵션 라벨 */
.opt-label {
    display: block;
    font-size: 0.72rem;
    color: #7ac99a;
    margin-bottom: 4px;
    font-weight: 600;
    cursor: pointer;
}

.opt-label-left {
    text-align: left;
}

/* 옵션 인풋 (공통) */
.opt-input-field {
    width: 100%;
    height: 32px;
    padding: 0 6px;
    font-size: 0.9rem;
    background: #222;
    border: 1px solid #444;
    border-radius: 8px;
    color: #fff;
    text-align: center;
    font-weight: 600;
}

.opt-input-field:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 1px;
}

/* 옵션 셀렉트 */
.opt-select {
    width: 100%;
    height: 32px;
    padding: 0 6px;
    font-size: 0.9rem;
    background: #222;
    border: 1px solid #444;
    border-radius: 8px;
    color: #fff;
    text-align: center;
    cursor: pointer;
}

/* 정제 옵션 박스 */
.refine-options-box {
    padding: 10px;
    background: rgba(0, 230, 118, 0.05);
    border: 1px solid rgba(0, 230, 118, 0.15);
    border-radius: 8px;
}

.refine-options-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.opt-group-flex {
    flex: 1;
    min-width: 0;
}

.separator {
    color: #555;
}

/* 옵션 그룹 (인라인) */
.opt-group {
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    gap: 4px;
    cursor: pointer;
}

.opt-group-label {
    font-size: 0.78rem;
    color: #8fbfa3;
    cursor: pointer;
    user-select: none;
}

.opt-group-input {
    width: 50px;
    padding: 4px;
    background: #222;
    border: 1px solid #444;
    color: #fff;
    border-radius: 8px;
    font-size: 0.8rem;
    text-align: center;
}

.opt-group-unit {
    font-size: 0.7rem;
    color: #666;
}

/* 스마트 멜로디 + 베이스 영역 */
.smart-voice-section {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* 2단 분리 + 트랙 분산 영역 */
.two-part-section {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 6px;
}

.two-part-section .spacer {
    flex: 1;
}

.two-part-section .separator {
    color: #555;
}

.opt-label-highlight {
    color: #ffab40;
    font-weight: bold;
}

.opt-checkbox {
    accent-color: #00e676;
    cursor: pointer;
}

.opt-desc {
    font-size: 0.7rem;
    color: #666;
}

/* 스마트 옵션 라벨 색상 */
.opt-label-melody {
    color: #ffab40;
    min-width: auto;
    cursor: pointer;
}

.opt-label-bass {
    color: #fb8c00;
    min-width: auto;
    cursor: pointer;
}

.opt-label-two-part {
    color: #4facfe;
    min-width: auto;
    cursor: pointer;
}

.opt-label-share-track {
    color: #00f2c3;
    min-width: auto;
    cursor: pointer;
}

.opt-label-optimize {
    min-width: auto;
    cursor: pointer;
}

.opt-label-velocity {
    color: #ff5252;
}

/* 슬라이더 스타일 */
.opt-range {
    width: 80px;
    height: 6px;
    margin-left: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #333, #444);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.opt-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: linear-gradient(145deg, #00e676, #00c853);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.opt-range::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.opt-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: linear-gradient(145deg, #00e676, #00c853);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    border: none;
    cursor: pointer;
}

.opt-range::-moz-range-track {
    background: linear-gradient(to right, #333, #444);
    border-radius: 3px;
    height: 6px;
}

.opt-sensitivity-val {
    min-width: 14px;
    font-size: 0.7rem;
    color: #fff;
}

/* 버튼 행 */
.btn-row {
    display: flex;
    gap: 10px;
}

.btn-row > button {
    flex: 1;
}

/* 플로팅 툴팁 */
.floating-tooltip {
    display: none;
    position: fixed;
    z-index: 9999;
    width: 280px;
    padding: 10px;
    background: linear-gradient(135deg, #1a3a2a 0%, #1e1e1e 100%);
    border: 1px solid rgba(0, 230, 118, 0.3);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    animation: tooltipFadeIn 0.15s ease-out;
}

.tooltip-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.tooltip-icon {
    font-size: 1rem;
}

.tooltip-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: #00e676;
}

.tooltip-desc {
    font-size: 0.78rem;
    color: #a0d8b8;
    line-height: 1.5;
}

.tooltip-tip {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 230, 118, 0.2);
    font-size: 0.72rem;
    color: #7aaa8a;
}

/* 유틸리티 */
.hidden {
    display: none !important;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.w-full {
    width: 100%;
}