:root {
    --up-bg: #121212;
    --up-surface: #1e1e1e;
    --up-accent: #FFB020;
    --up-text: #FFFFFF;
    --up-text-dim: #888888;
}

.up-metronome-app {
    background-color: var(--up-bg);
    color: var(--up-text);
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    border-radius: 30px;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    border: 1px solid #333;
    position: relative;
    overflow: hidden;
    user-select: none;
    text-align: center;
    touch-action: none;
}

/* Header */
.up-top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; color: var(--up-text-dim); }
.up-app-title { font-size: 0.9rem; font-weight: 700; letter-spacing: 1px; color: #fff; }
.up-icon-btn { background: none; border: none; color: inherit; font-size: 1.2rem; cursor: pointer; }

/* Visualizer */
.up-visualizer-container {
    display: flex; justify-content: center; gap: 6px; height: 50px; align-items: flex-end; margin-bottom: 5px;
}
.up-beat-bar {
    width: 32px; height: 32px; border-radius: 4px; background: #333; transition: 0.1s;
    position: relative; border: 1px solid transparent;
}
.up-beat-bar[data-accent="2"] { background: var(--up-accent); height: 45px; }
.up-beat-bar[data-accent="1"] { background: #fff; height: 38px; }
.up-beat-bar[data-accent="0"] { background: #222; height: 20px; border-color: #444; }
.up-beat-bar.flash { filter: brightness(1.5); box-shadow: 0 0 15px rgba(255, 176, 32, 0.5); }

/* BPM Section (CORREÇÃO DE ESTABILIDADE) */
.up-bpm-section { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; position: relative; z-index: 2; }
.up-bpm-readout { display: flex; flex-direction: column; line-height: 1; pointer-events: none; align-items: center; }

/* Largura fixa para impedir que os botões se movam */
#bpm-value { 
    font-size: 4.5rem; 
    font-weight: 300; 
    width: 160px; /* Largura suficiente para 3 dígitos */
    text-align: center;
    display: inline-block;
    font-variant-numeric: tabular-nums; /* Faz todos os números terem a mesma largura */
}

#bpm-label { font-size: 0.8rem; color: var(--up-text-dim); margin-top: 5px; font-weight: 600; }
.up-adjust-btn { background: transparent; border: none; color: var(--up-text-dim); font-size: 3rem; font-weight: 200; cursor: pointer; z-index: 10; width: 50px; }
.up-adjust-btn:active { color: var(--up-accent); }

/* Circular Control */
.up-circle-control {
    position: relative; width: 260px; height: 260px; margin: 0 auto 30px auto;
    touch-action: none; 
}

.up-progress-ring { transform: rotate(-90deg); width: 100%; height: 100%; pointer-events: none; }
.up-progress-ring__bg { stroke: #2a2a2a; stroke-width: 12; fill: transparent; }
.up-progress-ring__fill { 
    stroke: var(--up-accent); stroke-width: 12; fill: transparent; 
    stroke-dasharray: 754; stroke-dashoffset: 754; stroke-linecap: round;
}
.up-progress-ring__fill.animate { transition: stroke-dashoffset 0.2s ease-out; }

.up-knob {
    position: absolute; width: 28px; height: 28px; background: #fff;
    border: 4px solid var(--up-accent); border-radius: 50%;
    top: 0; left: 0; cursor: grab; z-index: 20;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
.up-knob.animate { transition: top 0.2s ease-out, left 0.2s ease-out; }
.up-knob:active { cursor: grabbing; transform: scale(1.2); }

/* Play Button */
.up-play-btn {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 90px; height: 90px; border-radius: 50%;
    background: var(--up-accent); border: none; color: #121212;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 10px 30px rgba(0,0,0,0.4); z-index: 5;
    transition: transform 0.1s;
}
.up-play-btn:active { transform: translate(-50%, -50%) scale(0.95); }
.up-play-btn.playing { background: #fff; color: var(--up-accent); }

/* Bottom Toolbar */
.up-bottom-bar {
    display: flex; justify-content: space-between; align-items: center;
    background: #1a1a1a; padding: 15px; border-radius: 20px;
}
.up-bottom-btn {
    background: transparent; border: none; color: #fff; font-size: 1rem; font-weight: 600; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.up-bottom-btn:hover { color: var(--up-accent); }
.small-icon { font-size: 1.4rem; color: var(--up-text-dim); line-height: 1; }

.up-volume-control { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: center; }
.up-volume-control input { width: 80px; accent-color: var(--up-accent); height: 4px; background: #333; border-radius: 2px; }

/* Modal Picker */
.up-modal-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); backdrop-filter: blur(5px);
    z-index: 100; display: none; align-items: flex-end;
}
.up-modal-overlay.active { display: flex; animation: slideUp 0.25s ease-out; }

.up-modal-body {
    width: 100%; background: #1c1c1e; border-top-left-radius: 24px; border-top-right-radius: 24px;
    padding: 20px 0; border-top: 1px solid #333;
}
.up-modal-header { display: flex; justify-content: space-between; padding: 0 20px 20px 20px; border-bottom: 1px solid #2c2c2e; }
.modal-title { font-weight: 700; color: #fff; }
.up-modal-close { background: none; border: none; color: var(--up-accent); font-weight: bold; cursor: pointer; font-size: 1rem; }

.up-setting-row { padding: 0 20px 20px 20px; border-bottom: 1px solid #2c2c2e; text-align: left; }
.up-setting-row label { display: block; color: #888; font-size: 0.8rem; margin-bottom: 10px; text-transform: uppercase; }

.up-segment-control { display: flex; background: #000; border-radius: 8px; padding: 2px; }
.up-segment { flex: 1; background: transparent; border: none; color: #888; padding: 10px; border-radius: 6px; cursor: pointer; font-weight: 600; }
.up-segment.active { background: #333; color: #fff; }

.up-picker-label-row { 
    display: flex; padding: 15px 0 5px 0; color: #666; font-size: 0.7rem; font-weight: bold;
}
.up-picker-label-row span { flex: 1; text-align: center; }

.up-picker-wrapper { display: flex; height: 180px; position: relative; overflow: hidden; background: #000; }
.up-picker-highlight {
    position: absolute; top: 50%; left: 0; width: 100%; height: 40px; margin-top: -20px;
    background: rgba(255,255,255,0.08); pointer-events: none; z-index: 1;
    border-top: 1px solid rgba(255,255,255,0.1); border-bottom: 1px solid rgba(255,255,255,0.1);
}
.up-picker-col { flex: 1; height: 100%; position: relative; text-align: center; overflow-y: scroll; scroll-behavior: smooth; }
.up-picker-col::-webkit-scrollbar { display: none; }
.up-picker-col { -ms-overflow-style: none; scrollbar-width: none; }

.up-picker-content { padding-top: 70px; padding-bottom: 70px; }

.picker-item { 
    height: 40px; line-height: 40px; color: #555; font-size: 1.2rem; transition: 0.2s; cursor: pointer; 
}
.picker-item.selected { color: #fff; font-size: 1.4rem; font-weight: bold; }

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }