:root {
    --bg-color: #0d1117;
    --panel-bg: rgba(22, 27, 34, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --accent: #3b82f6;
    --safe: #2ea043;
    --warning: #d29922;
    --danger: #f85149;
    --safe-glow: rgba(46, 160, 67, 0.4);
    --warning-glow: rgba(210, 153, 34, 0.4);
    --danger-glow: rgba(248, 81, 73, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at top right, rgba(59, 130, 246, 0.1), transparent 400px),
                      radial-gradient(circle at bottom left, rgba(248, 81, 73, 0.05), transparent 400px);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

.app-container {
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 380px;
    padding: 2rem;
    border-radius: 28px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05) inset;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    transition: all 0.3s ease;
    position: relative;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.1);
    transform: scale(1.05);
}

.meter-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0;
}

/* The starting point is rotated back by 135deg so the missing 25% is at the bottom */
.progress-ring {
    transform: rotate(-225deg);
    filter: drop-shadow(0 0 12px var(--safe-glow));
    transition: filter 0.3s ease;
}

.progress-ring__circle {
    stroke-dasharray: 597;
    stroke-dashoffset: 597;
    transition: stroke-dashoffset 0.1s linear, stroke 0.3s ease;
    stroke-linecap: round;
}

.progress-ring__circle-bg {
    stroke-dasharray: 597;
    /* 597 * 0.25 = 149.25 */
    stroke-dashoffset: 149.25;
    stroke-linecap: round;
}

.db-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#current-db {
    font-size: 4.5rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -2px;
    background: linear-gradient(to bottom, #ffffff, #a3a3a3);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.db-unit {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: -4px;
}

.status-text {
    position: absolute;
    bottom: -10px;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--safe);
    text-transform: uppercase;
    letter-spacing: 3px;
    filter: drop-shadow(0 0 5px var(--safe-glow));
    transition: color 0.3s ease, filter 0.3s ease;
}

.stats-container {
    display: flex;
    justify-content: space-between;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    border-radius: 20px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    flex: 1;
}

.stat-box:nth-child(2) {
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

.stat-label {
    font-size: 0.70rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.stat-val-group {
    display: flex;
    align-items: baseline;
    gap: 2px;
}

.stat-val {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sensitivity-control {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding: 0 0.5rem;
}

.sens-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sens-label {
    font-size: 0.70rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.sens-val {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 700;
    background: rgba(255,255,255,0.1);
    padding: 3px 8px;
    border-radius: 6px;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    border: 1px solid var(--border-color);
}

input[type=range]::-webkit-slider-thumb {
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -7px;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.primary-btn {
    width: 100%;
    padding: 1.1rem;
    border: none;
    background: linear-gradient(135deg, var(--accent), #1d4ed8);
    color: white;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 1px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3), inset 0 1px 1px rgba(255,255,255,0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4), inset 0 1px 1px rgba(255,255,255,0.3);
}

.primary-btn:active {
    transform: translateY(1px);
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.primary-btn.recording {
    background: linear-gradient(135deg, var(--danger), #b91c1c);
    box-shadow: 0 8px 20px rgba(248, 81, 73, 0.3), inset 0 1px 1px rgba(255,255,255,0.2);
}

.primary-btn.recording:hover {
    box-shadow: 0 10px 25px rgba(248, 81, 73, 0.4), inset 0 1px 1px rgba(255,255,255,0.3);
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

.recording-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: #fff;
    border-radius: 50%;
    margin-right: 8px;
    animation: pulse 1.5s infinite;
}

/* Popup / Minimal Window Styles */
body.is-popup {
    background: var(--bg-color);
}
body.is-popup .app-container {
    padding: 1.5rem;
    border-radius: 0;
    border: none;
    box-shadow: none;
    height: 100vh;
    max-width: 100%;
    justify-content: space-evenly;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
body.is-popup header {
    display: none;
}
body.is-popup .controls {
    display: flex;
}
