:root {
    --bg-dark: #0f0f11;
    --card-bg: #1c1c1e;
    --text-main: #ffffff;
    --text-muted: #8e8e93;
    --accent-green: #30d158;
    --accent-red: #ff453a;
    --accent-blue: #0a84ff;
    --border: #2c2c2e;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    height: 100vh;
    overflow: hidden; /* App feels native */
}

.app-container {
    width: 100%;
    max-width: 450px;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

/* Header & Inputs */
.app-header { padding: 20px; background: var(--bg-dark); z-index: 10; border-bottom: 1px solid var(--border); }
.exercise-picker { display: flex; gap: 10px; }
select { flex: 1; background: var(--card-bg); color: var(--text-main); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 1.1rem; font-weight: 600; outline: none; }
.icon-btn { background: var(--card-bg); color: var(--accent-blue); border: 1px solid var(--border); border-radius: 10px; width: 48px; font-size: 1.5rem; font-weight: bold; cursor: pointer; }

/* Views & Tabs */
.view { flex: 1; overflow-y: auto; padding: 20px; display: none; padding-bottom: 90px; }
.view.active-view { display: flex; flex-direction: column; gap: 20px; animation: fadeIn 0.2s ease-out; }

/* Timer Elements */
#view-timer { position: relative; }
.timer-card { text-align: center; padding: 40px 0; }
.floating-sound-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    width: 52px;
    height: 36px;
    border-radius: 999px;
    font-size: 0.72rem;
    letter-spacing: 0.5px;
    color: var(--text-main);
    background: rgba(28, 28, 30, 0.95);
}
.floating-sound-btn:disabled {
    opacity: 0.85;
    cursor: default;
    color: var(--accent-green);
}
#status { font-size: 1.2rem; font-weight: 700; letter-spacing: 2px; margin-bottom: 10px; color: var(--text-muted); }
#display {
    font-size: 5rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    text-align: left;
    padding-left: 0.25ch;
}

.settings-grid { display: flex; gap: 15px; }
.setting-box { flex: 1; background: var(--card-bg); padding: 12px; border-radius: 12px; text-align: center; }
.setting-box label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 5px; }
.setting-box input { width: 100%; background: transparent; border: none; color: var(--text-main); font-size: 1.5rem; text-align: center; font-weight: bold; outline: none; }

.controls { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; }
.btn { border: none; border-radius: 14px; padding: 18px; font-size: 1.1rem; font-weight: 700; cursor: pointer; color: white; transition: opacity 0.2s, transform 0.1s; }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }
.primary-btn { background: var(--accent-green); flex: 1; }
.danger-btn { background: var(--accent-red); flex: 1; }
.secondary-btn { background: var(--card-bg); flex: 1; color: var(--text-main); border: 1px solid var(--border); }

/* History Elements */
.view-title { font-size: 1.5rem; margin-bottom: 10px; }
.history-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.history-card { background: var(--card-bg); padding: 15px; border-radius: 12px; }
.history-card h3 { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }

.data-list { list-style: none; }
.data-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.data-list li:last-child { border: none; }
.dur { font-weight: bold; font-size: 1.1rem; }
.datetime { display: flex; flex-direction: column; align-items: flex-end; font-size: 0.75rem; color: var(--text-muted); }

/* Accordion */
.all-history-accordion { background: var(--card-bg); border-radius: 12px; overflow: hidden; margin-top: 10px; }
.all-history-accordion summary { padding: 15px; font-weight: 600; cursor: pointer; list-style: none; outline: none; display: flex; justify-content: space-between; align-items: center; }
.all-history-accordion summary::-webkit-details-marker { display: none; }
.all-history-accordion summary::after { content: '▼'; font-size: 0.8rem; color: var(--text-muted); transition: transform 0.2s; }
.all-history-accordion[open] summary::after { transform: rotate(180deg); }
.full-list { padding: 0 15px 15px 15px; }

/* Bottom Nav */
.bottom-nav { position: absolute; bottom: 0; width: 100%; background: rgba(15, 15, 17, 0.9); backdrop-filter: blur(10px); border-top: 1px solid var(--border); display: flex; padding-bottom: env(safe-area-inset-bottom, 15px); z-index: 20; }
.nav-btn { flex: 1; background: none; border: none; padding: 15px 0; color: var(--text-muted); font-size: 0.8rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.nav-icon { font-size: 1.4rem; filter: grayscale(100%); opacity: 0.5; }
.nav-btn.active { color: var(--accent-blue); font-weight: 600; }
.nav-btn.active .nav-icon { filter: grayscale(0%); opacity: 1; }

/* Modal */
.modal-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px); z-index: 50; display: flex; justify-content: center; align-items: center; padding: 20px; opacity: 1; transition: opacity 0.2s; }
.modal-overlay.hidden { display: none; opacity: 0; }
.modal-content { background: var(--card-bg); width: 100%; max-width: 350px; padding: 25px; border-radius: 20px; text-align: center; border: 1px solid var(--border); }
.highlight-text { color: var(--accent-blue); font-size: 1.2rem; font-weight: bold; margin: 5px 0 15px; }
.sub-text { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 15px; }

.edit-timer { display: flex; justify-content: center; align-items: baseline; gap: 5px; margin-bottom: 25px; }
.edit-timer input { width: 70px; font-size: 2rem; background: var(--bg-dark); color: var(--text-main); border: 1px solid var(--border); text-align: center; border-radius: 10px; padding: 10px; font-weight: bold; outline: none; }
.edit-timer span { font-size: 1.2rem; color: var(--text-muted); }
.modal-actions { display: flex; gap: 10px; }

.modal-actions .btn { 
    padding: 14px; 
    font-size: 1rem; 
}

/* Settings Pill (timer view summary) */
.settings-pill { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.settings-pill .pill-item { background: var(--card-bg); border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px; font-size: 0.78rem; color: var(--text-muted); display: flex; gap: 5px; align-items: center; }
.settings-pill .pill-item strong { color: var(--text-main); font-weight: 600; }

/* Settings View */
.setting-section { display: flex; flex-direction: column; gap: 10px; }
.setting-section-title { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.settings-note { font-size: 0.85rem; color: var(--text-muted); line-height: 1.4; }
.save-settings-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Chart */
.chart-container { background: var(--card-bg); padding: 15px; border-radius: 12px; }
.chart-container h3 { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 15px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }
.chart-container canvas { max-height: 250px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }