/* Copyright (c) 2026 [你的名字/公司名]. All rights reserved. */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    margin: 0;
    padding: 8px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

.container {
    background-color: #fff;
    padding: 12px 15px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    max-width: 520px;
    width: 100%;
    max-height: 96vh;
    overflow-y: auto;
}

h1 {
    text-align: center;
    margin: 0 0 8px 0;
    color: #667eea;
    font-size: 20px;
    font-weight: 700;
}

/* 頂部控制列 */
.top-controls { margin-bottom: 8px; }

.input-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.input-group-inline {
    display: flex;
    align-items: center;
    gap: 5px;
}

.input-group-inline label {
    font-weight: 600;
    font-size: 12px;
    color: #555;
    white-space: nowrap;
}

.input-group-inline input {
    padding: 5px 6px;
    border: 1.5px solid #e0e0e0;
    border-radius: 5px;
    font-size: 13px;
    width: 55px;
}

.input-group-inline input:focus {
    outline: none;
    border-color: #667eea;
}

.start-button {
    flex: 1;
    padding: 7px 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.start-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.4);
}

/* 拍子顯示 */
#beatDisplay {
    text-align: center;
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 8px;
    padding: 7px 10px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border-radius: 6px;
}

/* 調試 */
.debug-info {
    margin-bottom: 8px;
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1.5px solid #6c757d;
    font-size: 11px;
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid #dee2e6;
}

.debug-content {
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    color: #495057;
    max-height: 100px;
    overflow-y: auto;
    font-size: 10px;
}

.toggle-debug-btn {
    padding: 2px 8px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
}

.debug-button {
    padding: 7px 10px;
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

/* 段落控制按鈕 */
.controls-header { margin-bottom: 6px; }
.controls-footer { margin-top: 8px; }

.instruction-box {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 5px;
    padding: 4px 8px;
    margin-bottom: 8px;
    font-size: 11px;
    color: #856404;
}

.time-signature-controls { display: flex; gap: 6px; }

.time-signature-controls button {
    flex: 1;
    padding: 5px 10px;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

/* ===== 段落卡片（緊湊版）===== */
.time-signature-group {
    margin-bottom: 6px;
    padding: 7px 10px;
    background-color: #f8f9fa;
    border-radius: 7px;
    border-left: 3px solid #667eea;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    transition: border-color 0.3s, box-shadow 0.3s, background-color 0.3s;
    cursor: default;
    user-select: none;
}

.time-signature-group.segment-active {
    border-left: 3px solid #f5576c;
    box-shadow: 0 0 10px rgba(245, 87, 108, 0.4), 0 1px 4px rgba(0, 0, 0, 0.1);
    background-color: #fff8f8;
}

.time-signature-group.segment-pulse {
    animation: beatPulse 0.15s ease-out;
}

@keyframes beatPulse {
    0% { box-shadow: 0 0 16px rgba(245, 87, 108, 0.7), 0 1px 4px rgba(0, 0, 0, 0.1); }
    100% { box-shadow: 0 0 10px rgba(245, 87, 108, 0.4), 0 1px 4px rgba(0, 0, 0, 0.1); }
}

/* 試聽模式反色 */
.time-signature-group.segment-preview {
    background-color: #667eea;
    border-left: 3px solid #f5576c;
    color: #fff;
}

.time-signature-group.segment-preview .segment-label {
    color: #fff;
}

.time-signature-group.segment-preview .input-group-compact label {
    color: #e0e0ff;
}

.time-signature-group.segment-preview .segment-header {
    border-bottom-color: rgba(255,255,255,0.3);
}

.time-signature-group.segment-preview .input-group-compact input,
.time-signature-group.segment-preview .input-group-compact select {
    background-color: rgba(255,255,255,0.9);
    color: #333;
}

/* 試聽時的脈衝 */
.time-signature-group.segment-preview.segment-active {
    background-color: #5a6fd6;
    box-shadow: 0 0 12px rgba(245, 87, 108, 0.5), 0 1px 4px rgba(0, 0, 0, 0.2);
}

.time-signature-group.segment-preview.segment-pulse {
    animation: previewPulse 0.15s ease-out;
}

@keyframes previewPulse {
    0% { box-shadow: 0 0 18px rgba(245, 87, 108, 0.8), 0 1px 4px rgba(0, 0, 0, 0.2); }
    100% { box-shadow: 0 0 12px rgba(245, 87, 108, 0.5), 0 1px 4px rgba(0, 0, 0, 0.2); }
}

.segment-header {
    margin-bottom: 4px;
    padding-bottom: 3px;
    border-bottom: 1px solid #dee2e6;
}

.segment-label {
    font-weight: 700;
    font-size: 11px;
    color: #667eea;
}

/* 段落設定：單行橫排 */
.segment-settings {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: flex-end;
    margin-bottom: 2px;
}

.input-group-compact {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.input-group-compact label {
    font-weight: 600;
    font-size: 10px;
    color: #555;
    white-space: nowrap;
}

.input-group-compact input,
.input-group-compact select {
    padding: 3px 4px;
    border: 1.5px solid #e0e0e0;
    border-radius: 4px;
    font-size: 11px;
    background-color: white;
}

.input-group-compact input:focus,
.input-group-compact select:focus {
    outline: none;
    border-color: #667eea;
}

/* 各欄位寬度 */
.time-signature-input { width: 36px; }
.measures-input { width: 36px; }
.target-bpm-input,
.custom-start-bpm-input { width: 46px; }
.tempo-change-select { width: 76px; }
.bpm-inherit-select { width: 140px; }
.beat-mode-select { width: 74px; }
.curve-type-select { width: 120px; }

/* 曲線區 */
.tempo-curve-container {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px dashed #dee2e6;
}

.curve-controls {
    display: flex;
    gap: 6px;
    margin-bottom: 5px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.custom-curve-controls { min-width: 100px; }

.curve-strength-slider {
    width: 100%;
    height: 4px;
    border-radius: 3px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
}

.curve-strength-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

.curve-strength-slider::-moz-range-thumb {
    width: 12px; height: 12px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

.tempo-visualization {
    background-color: white;
    border-radius: 5px;
    padding: 5px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.canvas-hint {
    font-size: 10px;
    color: #667eea;
    text-align: center;
    margin-bottom: 3px;
    font-weight: 600;
}

.tempo-canvas {
    width: 100%;
    height: 70px;
    display: block;
}

/* 全域隱藏曲線 */
.curves-hidden .tempo-curve-container {
    display: none !important;
}

.viz-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
    font-size: 10px;
    color: #666;
    font-weight: 600;
}

.curve-strength-value {
    color: #667eea;
    font-weight: 700;
}

/* 響應式 */
@media (max-width: 520px) {
    .container { padding: 8px 10px; }
    h1 { font-size: 17px; }
    .input-row { flex-wrap: wrap; }
    #beatDisplay { font-size: 11px; padding: 5px; }
}

/* 滾動條 */
.container::-webkit-scrollbar { width: 4px; }
.container::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
.container::-webkit-scrollbar-thumb { background: #667eea; border-radius: 10px; }

/* 動畫 */
.target-bpm-container,
.tempo-curve-container,
.custom-curve-controls,
.custom-start-bpm-container {
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; max-height: 0; overflow: hidden; }
    to { opacity: 1; max-height: 300px; }
}

/* 延長記號 */
.fermata-container {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px dashed #dee2e6;
}

.fermata-header {
    margin-bottom: 4px;
}

.fermata-add-btn {
    padding: 3px 8px;
    font-size: 11px;
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    color: #333;
}

.fermata-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
    padding: 3px 6px;
    background: #fff8f0;
    border-radius: 4px;
    border: 1px solid #ffecd2;
}

.fermata-item .input-group-compact {
    margin-bottom: 0;
}

.fermata-item input {
    width: 50px;
}

.fermata-remove-btn {
    padding: 2px 6px;
    font-size: 11px;
    background: #f5576c;
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    line-height: 1;
}

/* 拍號下拉+自填 */
.time-signature-preset {
    width: 70px;
}

.time-signature-input {
    width: 60px;
    margin-left: 4px;
}

/* ===== 分享彈窗 ===== */
.share-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.share-modal-content {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    max-width: 480px;
    width: 100%;
    overflow: hidden;
}

.share-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 14px;
}

.share-close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    font-size: 16px;
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    line-height: 1;
}

.share-close-btn:hover { background: rgba(255,255,255,0.3); }

.share-modal-body {
    padding: 16px;
}

.share-hint {
    font-size: 13px;
    color: #555;
    margin: 0 0 10px 0;
}

.share-url {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    resize: none;
    color: #333;
    box-sizing: border-box;
    word-break: break-all;
}

.share-url:focus { outline: none; border-color: #667eea; }

.share-url-info {
    font-size: 11px;
    color: #888;
    margin: 4px 0 10px 0;
}

.share-buttons { display: flex; gap: 8px; }

.share-copy-btn {
    flex: 1;
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

.share-copy-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.4);
}

.share-feedback {
    text-align: center;
    font-size: 13px;
    color: #38a169;
    font-weight: 600;
    margin-top: 8px;
    padding: 6px;
    background: #f0fff4;
    border-radius: 4px;
}
