*,
.icon-button {
    position: relative
}

.overlay,
.tooltip {
    opacity: 0;
    visibility: hidden
}

#info-panel h3,
#info-panel li,
#info-panel ul ul {
    margin-bottom: 8px
}

:root {
    --md-sys-color-primary-light: #006496;
    --md-sys-color-on-primary-light: #ffffff;
    --md-sys-color-primary-container-light: #cce5ff;
    --md-sys-color-on-primary-container-light: #001e31;
    --md-sys-color-secondary-light: #51606f;
    --md-sys-color-on-secondary-light: #ffffff;
    --md-sys-color-secondary-container-light: #d4e4f6;
    --md-sys-color-on-secondary-container-light: #0d1d2a;
    --md-sys-color-tertiary-light: #67587a;
    --md-sys-color-on-tertiary-light: #ffffff;
    --md-sys-color-tertiary-container-light: #ecdcff;
    --md-sys-color-on-tertiary-container-light: #221534;
    --md-sys-color-error-light: #ba1a1a;
    --md-sys-color-on-error-light: #ffffff;
    --md-sys-color-error-container-light: #ffdad6;
    --md-sys-color-on-error-container-light: #410002;
    --md-sys-color-background-light: #f8faff;
    --md-sys-color-on-background-light: #1a1c1e;
    --md-sys-color-surface-light: #f8faff;
    --md-sys-color-on-surface-light: #1a1c1e;
    --md-sys-color-surface-container-low-light: #f2f4f7;
    --md-sys-color-surface-variant-light: #dee3eb;
    --md-sys-color-on-surface-variant-light: #42474e;
    --md-sys-color-outline-light: #72777f;
    --md-sys-color-outline-variant-light: #c2c7cf;
    --md-sys-color-shadow-light: #000000;
    --md-sys-color-inverse-surface-light: #2f3133;
    --md-sys-color-inverse-on-surface-light: #f0f0f3;
    --md-sys-color-inverse-primary-light: #92ccff;
    --md-ref-typeface-plain: 'Roboto Flex', sans-serif;
    --md-ref-typeface-mono: 'Roboto Mono', monospace;
    --bg-color: var(--md-sys-color-background-light);
    --surface-color: var(--md-sys-color-surface-light);
    --primary-color: var(--md-sys-color-primary-light);
    --primary-variant: #00507a;
    --on-primary: var(--md-sys-color-on-primary-light);
    --text-color: var(--md-sys-color-on-surface-light);
    --text-color-secondary: var(--md-sys-color-on-surface-variant-light);
    --divider-color: var(--md-sys-color-outline-variant-light);
    --border-color: var(--md-sys-color-outline-variant-light);
    --input-border-color: var(--md-sys-color-outline-light);
    --error-color: var(--md-sys-color-error-light);
    --on-error-color: var(--md-sys-color-on-error-light);
    --shadow-color: var(--md-sys-color-shadow-light);
    --progress-bar-bg: var(--md-sys-color-surface-variant-light);
    --panel-shadow: 0 8px 10px -5px rgba(0, 0, 0, 0.2), 0 16px 24px 2px rgba(0, 0, 0, 0.14), 0 6px 30px 5px rgba(0, 0, 0, 0.12);
    --font-sans: var(--md-ref-typeface-plain);
    --font-mono: var(--md-ref-typeface-mono);
    --hover-opacity: 0.08;
    --focus-opacity: 0.12;
    --pressed-opacity: 0.12;
    --disabled-opacity: 0.38;
    --disabled-container-opacity: 0.12
}

[data-theme=dark] {
    --md-sys-color-primary-dark: #92ccff;
    --md-sys-color-on-primary-dark: #003450;
    --md-sys-color-primary-container-dark: #004b71;
    --md-sys-color-on-primary-container-dark: #cce5ff;
    --md-sys-color-secondary-dark: #b8c8da;
    --md-sys-color-on-secondary-dark: #23323f;
    --md-sys-color-secondary-container-dark: #394857;
    --md-sys-color-on-secondary-container-dark: #d4e4f6;
    --md-sys-color-tertiary-dark: #d0bfe7;
    --md-sys-color-on-tertiary-dark: #382a4a;
    --md-sys-color-tertiary-container-dark: #4f4161;
    --md-sys-color-on-tertiary-container-dark: #ecdcff;
    --md-sys-color-error-dark: #ffb4ab;
    --md-sys-color-on-error-dark: #690005;
    --md-sys-color-error-container-dark: #93000a;
    --md-sys-color-on-error-container-dark: #ffdad6;
    --md-sys-color-background-dark: #1a1c1e;
    --md-sys-color-on-background-dark: #e2e2e5;
    --md-sys-color-surface-dark: #1a1c1e;
    --md-sys-color-on-surface-dark: #e2e2e5;
    --md-sys-color-surface-container-low-dark: #1f2428;
    --md-sys-color-surface-variant-dark: #42474e;
    --md-sys-color-on-surface-variant-dark: #c2c7cf;
    --md-sys-color-outline-dark: #8c9199;
    --md-sys-color-outline-variant-dark: #42474e;
    --md-sys-color-shadow-dark: #000000;
    --md-sys-color-inverse-surface-dark: #e2e2e5;
    --md-sys-color-inverse-on-surface-dark: #1a1c1e;
    --md-sys-color-inverse-primary-dark: #006496;
    --bg-color: var(--md-sys-color-background-dark);
    --surface-color: var(--md-sys-color-surface-dark);
    --primary-color: var(--md-sys-color-primary-dark);
    --primary-variant: #b3d9ff;
    --on-primary: var(--md-sys-color-on-primary-dark);
    --text-color: var(--md-sys-color-on-surface-dark);
    --text-color-secondary: var(--md-sys-color-on-surface-variant-dark);
    --divider-color: var(--md-sys-color-outline-variant-dark);
    --border-color: var(--md-sys-color-outline-variant-dark);
    --input-border-color: var(--md-sys-color-outline-dark);
    --error-color: var(--md-sys-color-error-dark);
    --on-error-color: var(--md-sys-color-on-error-dark);
    --shadow-color: var(--md-sys-color-shadow-dark);
    --progress-bar-bg: var(--md-sys-color-surface-variant-dark);
    --panel-shadow: 0 8px 10px -5px rgba(0, 0, 0, 0.4), 0 16px 24px 2px rgba(0, 0, 0, 0.28), 0 6px 30px 5px rgba(0, 0, 0, 0.24)
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-sans);
    transition: background-color .3s, color .3s, border-color .3s, box-shadow .3s, fill .3s, opacity .3s;
    -webkit-tap-highlight-color: transparent
}

body,
html {
    height: 100%;
    width: 100%;
    background-color: var(--bg-color);
    color: var(--text-color)
}

body {
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 100%
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 4px 8px 16px;
    height: 64px;
    border-bottom: 1px solid var(--divider-color);
    flex-shrink: 0;
    background-color: var(--surface-color);
    z-index: 10
}

.header-title {
    font-weight: 400;
    font-size: 1.375rem;
    line-height: 1.75rem;
    text-align: center;
    flex-grow: 1;
    margin: 0 8px;
    letter-spacing: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis
}

.icon-button {
    width: 48px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    background-color: transparent;
    color: var(--text-color-secondary);
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    overflow: hidden
}

.icon-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: currentColor;
    opacity: 0;
    border-radius: 50%;
    transform: scale(1) translate(-50%, -50%);
    transform-origin: 50% 50%
}

.icon-button:active::after {
    transform: scale(15) translate(-50%, -50%);
    opacity: var(--pressed-opacity);
    transition: transform, opacity
}

.icon-button:hover,
.language-dropdown-content a:hover {
    background-color: rgba(var(--text-color), var(--hover-opacity))
}

.icon-button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    background-color: rgba(var(--text-color), var(--focus-opacity))
}

.language-dropdown {
    position: relative;
    display: inline-block
}

.language-dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 160px;
    z-index: 1000;
    background-color: var(--surface-color);
    box-shadow: 0 8px 16px 0 rgba(0, 0, 0, .2);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    max-height: 50vh;
    overflow-y: scroll
}

.language-dropdown-content a {
    color: var(--text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: .9rem;
    transition: background-color .2s
}

.language-dropdown:hover .language-dropdown-content {
    display: block
}

.material-symbols-outlined {
    display: inline-block;
    width: 24px;
    height: 24px;
    fill: currentColor;
    vertical-align: middle;
    color: inherit;
    user-select: none
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px;
    overflow-y: scroll
}

.current-reading-wrapper {
    text-align: center;
    margin-bottom: 16px;
    width: 100%;
    position: static
}

.current-db-display {
    font-size: clamp(4.5rem, 20vw, 8rem);
    font-weight: 200;
    line-height: 1.1;
    color: var(--text-color);
    letter-spacing: -.025em;
    margin-bottom: 4px;
    font-feature-settings: "tnum"
}

.control-button,
.current-db-unit {
    font-weight: 500;
    letter-spacing: .01em
}

.current-db-unit {
    font-size: clamp(1.1rem, 5vw, 1.75rem);
    color: var(--text-color-secondary);
    line-height: 1
}

#clippingIndicator {
    position: absolute;
    top: 8px;
    right: 10%;
    background-color: var(--error-color);
    color: var(--on-error-color);
    font-size: .65rem;
    font-weight: 500;
    padding: 3px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: .5px;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
    z-index: 5
}

#clippingIndicator.visible {
    opacity: 1
}

.stats-and-progress {
    width: 100%;
    max-width: 600px;
    margin: 20px auto;
    display: flex;
    flex-direction: column;
    gap: 12px
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background-color: var(--progress-bar-bg);
    border-radius: 4px;
    overflow: hidden;
    margin: 0
}

.progress-bar {
    height: 100%;
    width: 0%;
    background-color: var(--primary-color);
    border-radius: 4px;
    transition: width .2s linear, background-color .3s
}

.chart-container,
.reading-box {
    border-radius: 12px;
    box-shadow: 0 1px 2px 0 rgba(var(--shadow-color), .1), 0 1px 3px 1px rgba(var(--shadow-color), .08);
    background-color: var(--surface-color)
}

#levelDescription {
    font-size: .875rem;
    line-height: 1.25rem;
    color: var(--text-color-secondary);
    text-align: center;
    margin-top: 8px;
    height: 1.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.stats-readings {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
    width: 100%;
    margin: 0;
    text-align: center
}

.reading-box {
    padding: 12px 16px
}

.reading-box .label {
    display: block;
    font-size: .75rem;
    line-height: 1rem;
    font-weight: 500;
    color: var(--text-color-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: .04em
}

.reading-box .value {
    display: block;
    font-size: 1.375rem;
    line-height: 1.75rem;
    font-weight: 500;
    color: var(--text-color);
    font-family: var(--font-mono);
    font-feature-settings: "tnum";
    white-space: nowrap
}

.chart-container {
    width: 100%;
    max-width: 700px;
    height: 200px;
    min-height: 160px;
    position: relative;
    margin: 20px auto 0;
    overflow: hidden
}

#dbChart {
    display: block;
    width: 100%;
    height: 100%
}

.ad-container {
    min-height: 280px;
    margin: 20px auto;
    width: 100%;
    max-width: 728px;
    display: block
}

.footer-link {
    color: var(--primary-color);
    text-decoration: none;
    transition: opacity .2s;
    font-size: .8rem
}

.footer-link:hover {
    opacity: .8;
    text-decoration: underline
}

.footer-divider {
    margin: 0 6px;
    color: var(--text-color-secondary);
    font-size: .8rem
}

.footer {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 16px;
    height: 80px;
    border-top: 1px solid var(--divider-color);
    flex-shrink: 0;
    background-color: var(--surface-color);
    z-index: 999
}

.control-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    font-size: .875rem;
    cursor: pointer;
    border: none;
    border-radius: 20px;
    min-height: 40px;
    text-align: center;
    transition: background-color .2s, box-shadow .2s, opacity .2s, color .2s, border-color .2s;
    appearance: none;
    overflow: hidden;
    white-space: nowrap
}

#info-panel h3,
.reference-chart-container h2,
.settings-label {
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em
}

.control-button .material-symbols-outlined {
    width: 18px;
    height: 18px;
    vertical-align: bottom
}

.control-button:disabled {
    opacity: var(--disabled-opacity);
    cursor: not-allowed;
    box-shadow: none;
    background-color: rgba(var(--text-color), var(--disabled-container-opacity));
    color: rgba(var(--text-color), var(--disabled-opacity))
}

.control-button.secondary:disabled {
    border-color: rgba(var(--text-color), var(--disabled-container-opacity));
    background-color: transparent;
    color: rgba(var(--text-color), var(--disabled-opacity));
    opacity: 1
}

.control-button:disabled:hover {
    background-color: rgba(var(--text-color), var(--disabled-container-opacity))
}

.control-button.start,
.control-button.stop {
    background-color: var(--primary-color);
    color: var(--on-primary);
    box-shadow: 0 1px 2px 0 rgba(var(--shadow-color), .15), 0 1px 3px 1px rgba(var(--shadow-color), .1)
}

.control-button.start:hover:not(:disabled),
.control-button.stop:hover:not(:disabled) {
    box-shadow: 0 1px 3px 0 rgba(var(--shadow-color), .15), 0 4px 8px 3px rgba(var(--shadow-color), .1);
    filter: brightness(95%)
}

[data-theme=dark] .control-button.start:hover:not(:disabled),
[data-theme=dark] .control-button.stop:hover:not(:disabled) {
    filter: brightness(110%)
}

.control-button.stop {
    background-color: var(--error-color);
    color: var(--on-error-color)
}

.control-button.secondary {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--input-border-color)
}

.close-panel,
.settings-label,
.settings-label .info-icon {
    color: var(--text-color-secondary)
}

.control-button.secondary:hover:not(:disabled) {
    background-color: rgba(var(--primary-color), var(--hover-opacity));
    border-color: var(--primary-color)
}

.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    max-width: 90%;
    height: 100vh;
    background-color: var(--surface-color);
    z-index: 3000;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1), box-shadow .3s cubic-bezier(.4, 0, .2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: none;
    border-left: 1px solid var(--divider-color)
}

.side-panel.active {
    transform: translateX(0);
    box-shadow: var(--panel-shadow)
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 4px 16px 24px;
    height: 64px;
    border-bottom: 1px solid var(--divider-color);
    flex-shrink: 0
}

.panel-title {
    font-size: 1.125rem;
    line-height: 1.5rem;
    font-weight: 500
}

.panel-content {
    padding: 16px 24px;
    overflow-y: auto;
    flex-grow: 1;
    -webkit-overflow-scrolling: touch
}

.panel-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--divider-color);
    flex-shrink: 0;
    text-align: right
}

.settings-group {
    margin-bottom: 28px
}

#info-panel p,
.settings-label {
    margin-bottom: 12px
}

.settings-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .75rem
}

.settings-label .info-icon {
    width: 16px;
    height: 16px;
    cursor: help
}

.calibration-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 4px
}

.calibration-controls input[type=number] {
    width: 80px;
    flex-shrink: 0;
    text-align: right
}

.calibration-controls input[type=range] {
    flex-grow: 1;
    height: 20px
}

.settings-input,
.settings-select {
    width: 100%;
    padding: 16px;
    border-radius: 4px;
    border: 1px solid var(--input-border-color);
    background-color: transparent;
    color: var(--text-color);
    font-size: 1rem;
    line-height: 1.5rem;
    margin-bottom: 4px;
    transition: border-color .2s, background-color .2s, color .2s;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    height: 56px;
    box-sizing: border-box
}

.disclaimer,
.explanation {
    color: var(--text-color-secondary)
}

.settings-select {
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 24px;
    padding-right: 40px
}

.settings-input:focus,
.settings-select:focus {
    outline: 0;
    border: 2px solid var(--primary-color);
    padding: 15px
}

.settings-input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield
}

.settings-input[type=number]::-webkit-inner-spin-button,
.settings-input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0
}

input[type=range] {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--md-sys-color-surface-variant-light);
    border-radius: 2px;
    cursor: pointer;
    margin: 8px 0;
    display: block
}

[data-theme=dark] input[type=range] {
    background: var(--md-sys-color-surface-variant-dark)
}

input[type=range]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(var(--shadow-color), .4);
    margin-top: 0
}

input[type=range]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(var(--shadow-color), .4)
}

input[type=range]:focus {
    outline: 0
}

input[type=range]:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px rgba(var(--primary-color), .3)
}

input[type=range]:focus::-moz-range-thumb {
    box-shadow: 0 0 0 4px rgba(var(--primary-color), .3)
}

.explanation {
    font-size: .75rem;
    line-height: 1.4;
    padding: 4px 0 0
}

.disclaimer {
    font-size: .8rem;
    line-height: 1.5;
    padding: 12px;
    margin-top: 16px;
    border: 1px dashed var(--divider-color);
    border-radius: 8px;
    background-color: rgba(var(--text-color-secondary), .05)
}

#info-panel p strong,
.disclaimer strong {
    color: var(--text-color);
    font-weight: 500
}

.tooltip-container {
    position: relative;
    display: inline-block;
    vertical-align: middle
}

.tooltip,
.tooltip::after {
    position: absolute;
    left: 50%
}

.tooltip-trigger {
    cursor: help
}

.tooltip {
    bottom: 130%;
    transform: translateX(-50%);
    background-color: var(--md-sys-color-inverse-surface-light);
    color: var(--md-sys-color-inverse-on-surface-light);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: .75rem;
    line-height: 1.3;
    white-space: pre-wrap;
    max-width: 250px;
    z-index: 1010;
    transition: opacity .2s, visibility .2s;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2)
}

[data-theme=dark] .tooltip {
    background-color: var(--md-sys-color-inverse-surface-dark);
    color: var(--md-sys-color-inverse-on-surface-dark)
}

.tooltip-trigger:focus+.tooltip,
.tooltip-trigger:hover+.tooltip {
    opacity: .95;
    visibility: visible
}

.tooltip::after {
    content: '';
    top: 100%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: var(--md-sys-color-inverse-surface-light) transparent transparent transparent
}

[data-theme=dark] .tooltip::after {
    border-top-color: var(--md-sys-color-inverse-surface-dark)
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, .5);
    backdrop-filter: blur(3px);
    z-index: 2999;
    transition: opacity .3s ease-in-out, visibility .3s ease-in-out
}

#info-panel,
.reference-chart-container {
    background-color: var(--surface-color)
}

.overlay.active {
    opacity: 1;
    visibility: visible
}

.reference-chart-container {
    width: 100%;
    max-width: 600px;
    margin: 20px auto 0;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 1px 2px 0 rgba(var(--shadow-color), .1), 0 1px 3px 1px rgba(var(--shadow-color), .08);
    min-height: 400px
}

.reference-chart-container h2 {
    font-size: .875rem;
    color: var(--text-color-secondary);
    margin-bottom: 12px;
    text-align: center
}

.reference-chart-list {
    list-style: none;
    padding: 0;
    margin: 0
}

.reference-chart-item {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: .875rem;
    line-height: 1.25rem
}

.reference-chart-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    margin-right: 10px;
    flex-shrink: 0;
    border: 1px solid rgba(var(--shadow-color), .1)
}

.reference-chart-level {
    font-weight: 500;
    color: var(--text-color);
    min-width: 50px;
    text-align: right;
    margin-right: 8px;
    font-family: var(--font-mono)
}

#info-panel h3,
#info-panel p,
.reference-chart-desc {
    color: var(--text-color-secondary)
}

.reference-chart-desc {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis
}

#info-panel .panel-content {
    font-size: .9rem;
    line-height: 1.6
}

#info-panel h3 {
    font-size: .875rem;
    margin-top: 20px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--divider-color)
}

#info-panel ul {
    list-style: disc;
    margin-left: 20px;
    margin-bottom: 16px;
    padding-left: 5px
}

#info-panel ul ul {
    margin-top: 6px
}

#info-panel code {
    background-color: rgba(var(--text-color-secondary), .1);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: .85em;
    font-family: var(--font-mono)
}

@media (max-width:600px) {
    .ad-container {
        min-height: 250px;
        margin: 16px auto
    }

    .header {
        height: 56px;
        padding: 4px 8px 4px 16px
    }

    .header-title {
        font-size: 1.25rem;
        margin: 0 8px
    }

    .icon-button {
        width: 40px;
        height: 40px
    }

    .language-dropdown-content {
        right: -40px
    }

    .material-symbols-outlined {
        width: 20px;
        height: 20px
    }

    .main-content {
        padding: 16px
    }

    .current-db-display {
        font-size: clamp(3.5rem, 18vw, 6.5rem)
    }

    .current-db-unit {
        font-size: clamp(1rem, 4.5vw, 1.5rem)
    }

    .footer-divider,
    .footer-link,
    .footer-links {
        font-size: .7rem
    }

    #clippingIndicator {
        font-size: .6rem;
        padding: 2px 4px;
        top: 4px;
        right: 5%
    }

    .stats-and-progress {
        gap: 10px
    }

    .stats-readings {
        gap: 8px;
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr))
    }

    .reading-box {
        padding: 8px 10px;
        border-radius: 8px
    }

    .reading-box .value {
        font-size: 1.1rem
    }

    .chart-container {
        height: 160px;
        min-height: 120px
    }

    .footer-divider {
        margin: 0 4px
    }

    .footer {
        height: 72px;
        padding: 4px 8px
    }

    .control-button {
        padding: 8px 16px;
        font-size: .8125rem;
        min-height: 36px;
        border-radius: 18px
    }

    .control-button .material-symbols-outlined {
        width: 16px;
        height: 16px
    }

    .side-panel {
        width: 280px
    }

    .panel-content {
        padding: 12px 16px
    }

    .settings-group {
        margin-bottom: 20px
    }

    .settings-input,
    .settings-select {
        padding: 14px;
        font-size: .95rem;
        height: 50px
    }

    .settings-input:focus,
    .settings-select:focus {
        padding: 13px
    }

    .explanation {
        font-size: .7rem;
        padding: 4px 0 0
    }

    .calibration-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 8px
    }

    .calibration-controls input[type=number] {
        width: 100%
    }

    .reference-chart-container {
        padding: 12px;
        margin-top: 16px
    }

    .reference-chart-item {
        font-size: .8rem
    }

    .reference-chart-level {
        min-width: 40px
    }
}

@media (max-height:550px) and (max-width:900px) and (orientation:landscape) {
    .ad-container {
        min-height: 200px;
        margin: 12px auto
    }

    .app-container {
        height: 100%
    }

    .main-content {
        flex-direction: row;
        justify-content: space-evenly;
        align-items: center;
        padding: 12px;
        overflow: hidden;
        gap: 16px
    }

    .current-reading-wrapper {
        margin-bottom: 0;
        flex: 0 0 30%;
        text-align: center;
        align-self: center
    }

    .current-db-display {
        font-size: clamp(2.5rem, 10vh, 3.5rem)
    }

    .current-db-unit {
        font-size: clamp(.8rem, 3vh, 1rem)
    }

    #clippingIndicator {
        top: 0;
        right: 0;
        font-size: .55rem
    }

    .chart-container {
        height: auto;
        margin: 0;
        flex: 1 1 40%;
        min-height: 100px;
        align-self: stretch
    }

    .stats-and-progress {
        flex-direction: column;
        flex: 0 0 25%;
        padding: 0;
        justify-content: center;
        align-self: stretch;
        gap: 8px;
        margin: 0;
        max-width: 180px
    }

    .progress-bar-container {
        width: 100%;
        margin: 0;
        height: 5px;
        order: -1
    }

    #levelDescription,
    .control-button span:not(.material-symbols-outlined),
    .reference-chart-container {
        display: none
    }

    .stats-readings {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        margin: 0;
        width: 100%;
        max-width: none
    }

    .reading-box {
        padding: 6px 8px;
        border-radius: 6px
    }

    .reading-box .label {
        font-size: .6rem;
        margin-bottom: 1px
    }

    .reading-box .value {
        font-size: .8rem
    }

    .footer {
        height: 56px;
        padding: 4px 8px
    }

    .control-button {
        min-width: 50px;
        padding: 6px 12px;
        font-size: .75rem;
        min-height: 32px;
        border-radius: 16px;
        gap: 4px
    }

    .control-button .material-symbols-outlined {
        margin: 0;
        width: 18px;
        height: 18px
    }
}

.seo-content-section {
    width: 100%;
    max-width: 600px;
    margin: 24px auto 0;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 2px 0 rgba(var(--shadow-color), .1), 0 1px 3px 1px rgba(var(--shadow-color), .08);
    background-color: var(--surface-color);
    font-size: .9rem;
    line-height: 1.7;
    color: var(--text-color-secondary)
}

.seo-content-section h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-color);
    margin-top: 24px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--divider-color)
}

.seo-content-section h3 {
    font-size: .95rem;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 6px
}

.seo-content-section p {
    margin-bottom: 12px;
    color: var(--text-color-secondary)
}

.seo-content-section p strong {
    color: var(--text-color);
    font-weight: 500
}

.seo-content-section ul,
.seo-content-section ol {
    list-style-position: inside;
    margin-bottom: 16px;
    padding-left: 8px
}

.seo-content-section ul {
    list-style: disc
}

.seo-content-section ol {
    list-style: decimal
}

.seo-content-section li {
    margin-bottom: 6px;
    color: var(--text-color-secondary)
}

.seo-content-section li strong {
    color: var(--text-color);
    font-weight: 500
}

.reference-levels-list {
    columns: 2;
    column-gap: 20px
}

.faq-section {
    margin-bottom: 16px
}

.faq-item {
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--divider-color);
    border-radius: 8px;
    background-color: rgba(var(--shadow-color), .02)
}

.faq-item h3 {
    margin-bottom: 8px
}

.faq-item p {
    margin-bottom: 0
}

@media (max-width:600px) {
    .seo-content-section {
        padding: 14px;
        font-size: .85rem;
        margin-top: 16px
    }

    .seo-content-section h2 {
        font-size: 1rem;
        margin-top: 18px
    }

    .reference-levels-list {
        columns: 1
    }
}

.site-footer {
    width: 100%;
    max-width: 600px;
    margin: 32px auto 16px;
    padding: 24px 20px 16px;
    text-align: center;
    border-top: 2px solid transparent;
    border-image: linear-gradient(90deg, transparent, var(--primary-color), transparent) 1;
    position: relative
}

.site-footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px
}

.site-footer-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: .85rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background-color .2s, color .2s, transform .2s
}

.site-footer-link:hover {
    background-color: rgba(0, 100, 150, .08);
    color: var(--primary-variant);
    transform: translateY(-1px)
}

[data-theme=dark] .site-footer-link:hover {
    background-color: rgba(146, 204, 255, .1)
}

.site-footer-divider {
    color: var(--divider-color);
    font-size: .7rem;
    user-select: none
}

.site-footer-copyright {
    font-size: .78rem;
    color: var(--text-color-secondary);
    margin: 0;
    letter-spacing: .3px
}

@media (max-width:600px) {
    .site-footer {
        margin-top: 20px;
        padding: 16px 14px 12px
    }

    .site-footer-link {
        font-size: .8rem
    }

    .site-footer-copyright {
        font-size: .72rem
    }
}

/* Footer Language Selector */
.footer-language-selector {
    margin: 14px 0;
    text-align: center;
}

.lang-btn-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
    padding: 8px 14px;
    border-radius: 24px;
    border: 1.5px solid var(--border-color);
    background-color: var(--surface-color);
    color: var(--text-color-secondary);
    cursor: pointer;
    transition: border-color .2s, color .2s, background-color .2s, box-shadow .2s;
}

.lang-btn-wrapper:hover {
    border-color: var(--text-color-secondary);
    color: var(--text-color);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.lang-globe-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.lang-btn-text {
    font-size: .88rem;
    font-family: var(--font-sans);
    font-weight: 500;
    white-space: nowrap;
}

.lang-chevron-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: .6;
}

.lang-hidden-select {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

[data-theme=dark] .lang-btn-wrapper:hover {
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
}

/* Floating Theme Toggle Button */
.floating-theme-btn {
    position: fixed;
    bottom: 96px;
    right: 16px;
    z-index: 998;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--surface-color);
    color: var(--text-color-secondary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(.4, 0, .2, 1),
        box-shadow 0.3s cubic-bezier(.4, 0, .2, 1),
        background-color 0.3s,
        color 0.3s;
    padding: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.floating-theme-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(0, 0, 0, 0.12);
    background-color: var(--primary-color);
    color: var(--on-primary);
}

.floating-theme-btn:active {
    transform: scale(0.95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.floating-theme-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

.floating-theme-btn .material-symbols-outlined {
    width: 22px;
    height: 22px;
}

[data-theme=dark] .floating-theme-btn {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.3);
}

[data-theme=dark] .floating-theme-btn:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.35);
}

@media (max-width: 600px) {
    .floating-theme-btn {
        bottom: 88px;
        right: 12px;
        width: 42px;
        height: 42px;
    }

    .floating-theme-btn .material-symbols-outlined {
        width: 20px;
        height: 20px;
    }
}

@media (max-height: 550px) and (max-width: 900px) and (orientation: landscape) {
    .floating-theme-btn {
        bottom: 68px;
        right: 10px;
        width: 38px;
        height: 38px;
    }

    .floating-theme-btn .material-symbols-outlined {
        width: 18px;
        height: 18px;
    }
}

/* Premium Header Improvements */
.header {
    background-color: var(--surface-color) !important;
    /* Restored original color */
    /* backdrop-filter removed as per user request */
    border-bottom: 1px solid var(--divider-color) !important;
    box-shadow: none !important;
    /* Restored original flat look or default shadow if any */
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 0 !important;
    /* Remove any padding pushing content */
    height: 64px;
    position: relative !important;
    /* Ensure absolute children reference this */
}

/* Ensure no elements take up extra space */
.header>* {
    margin: 0 !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
}

.header-title {
    font-size: 1.25rem !important;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-color);
    text-align: center;
    width: auto !important;
}

/* Settings button positioned absolutely to match user's mark */
#settings-button {
    position: absolute !important;
    right: 25% !important;
    /* Positioned at the user's red marked area */
    top: 50% !important;
    transform: translateY(-50%) !important;
    margin: 0 !important;
}

/* Responsive adjustment for smaller screens */
@media (max-width: 768px) {
    #settings-button {
        right: 16px !important;
        /* standard positioning on mobile */
    }
}

[data-theme=dark] .header {
    background-color: var(--surface-color) !important;
    /* Restored original color for dark mode too */
    border-bottom: 1px solid var(--divider-color) !important;
    box-shadow: none !important;
}

/* =========================================
   Floating Control Bar (Desktop-like Layout on Mobile)
   ========================================= */

/* Ensure content isn't hidden behind floating footer */
.main-content {
    padding-bottom: 80px !important;
}

/* Floating Footer Container */
.footer {
    position: fixed !important;
    bottom: 24px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    background-color: var(--surface-color, #fff) !important;
    border: 1px solid var(--divider-color, #ddd) !important;
    border-radius: 100px !important;
    /* Pill shaped bar */
    padding: 8px 16px !important;
    gap: 8px !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15) !important;
    z-index: 1000 !important;
    width: auto !important;
    max-width: 95vw !important;
    flex-wrap: nowrap !important;
    /* Force 1 row like desktop */
}

/* Dark Mode Adjustment */
[data-theme="dark"] .footer {
    background-color: #2d2d2d !important;
    border-color: #444 !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4) !important;
}

/* Button Styles - Clean & Compact inside bar */
.control-button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 40px !important;
    padding: 0 16px !important;
    border-radius: 50px !important;
    font-family: inherit !important;
    font-weight: 500 !important;
    font-size: 0.9rem !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    border: none !important;
    /* Cleaner look */
    outline: none !important;
    gap: 6px !important;
    background-color: transparent !important;
    color: var(--text-color, #333) !important;
    flex: 0 0 auto !important;
    white-space: nowrap !important;
    min-width: 0 !important;
}

[data-theme="dark"] .control-button {
    color: #e0e0e0 !important;
}

/* Start/Stop Button with Dynamic State Color */
.control-button.start {
    background-color: var(--primary-color, #007bff) !important;
    color: white !important;
    padding: 0 20px !important;
    transition: background-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* Active State (Recording/Stop) - RED */
.control-button.stop,
.control-button.recording,
.control-button.active,
.control-button[aria-label*="Stop"],
.control-button[data-state="recording"] {
    background-color: #f44336 !important;
    /* Red */
    box-shadow: 0 0 12px rgba(244, 67, 54, 0.4) !important;
    border-color: #f44336 !important;
}

.control-button.start:hover:not(:disabled) {
    opacity: 0.9 !important;
    transform: translateY(-1px) !important;
}

/* Hover effect for Red State */
.control-button.stop:hover:not(:disabled),
.control-button[aria-label*="Stop"]:hover:not(:disabled) {
    background-color: #d32f2f !important;
    /* Darker Red */
    box-shadow: 0 0 16px rgba(244, 67, 54, 0.5) !important;
}

/* Secondary Buttons - Hover */
.control-button.secondary:hover:not(:disabled) {
    background-color: rgba(0, 0, 0, 0.05) !important;
}

[data-theme="dark"] .control-button.secondary:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.1) !important;
}

/* Icon Sizing */
.control-button .material-symbols-outlined,
.control-button svg {
    width: 20px !important;
    height: 20px !important;
}

/* Header Layout Fix - Prevent Merging */
.header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 8px 16px !important;
    position: relative !important;
}

.header-title {
    position: absolute !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    text-align: center !important;
    margin: 0 !important;
    white-space: nowrap !important;
    width: auto !important;
    pointer-events: none !important;
    font-weight: 600 !important;
    letter-spacing: 0.5px !important;
}

/* Controls grouped on the right - User Position Request */
.header-controls {
    display: flex !important;
    align-items: center !important;
    gap: 16px !important;
    /* Reduced gap to bring buttons closer */
    position: absolute !important;
    right: 25% !important;
    /* Specific user request */
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 20 !important;
    margin: 0 !important;
}

/* Force buttons to be static ensuring flex layout works */
.header-controls>button,
#settings-button,
#theme-toggle {
    position: static !important;
    transform: none !important;
    margin: 0 !important;
}

/* Ensure Header Icons are sized correctly */
.header-controls .icon-button svg {
    width: 24px !important;
    height: 24px !important;
    fill: currentColor !important;
}

/* Mobile Header Adjustment */
@media (max-width: 600px) {
    .header {
        justify-content: space-between !important;
    }

    .header-title {
        position: static !important;
        transform: none !important;
        text-align: left !important;
        flex-grow: 1 !important;
        font-size: 1.25rem !important;
    }

    .header-controls {
        position: static !important;
        right: auto !important;
        transform: none !important;
        margin-left: 0 !important;
        gap: 4px !important;
    }

    .header-controls .icon-button {
        width: 40px !important;
        height: 40px !important;
    }
}

/* Mobile Footer Adjustments */
@media (max-width: 600px) {
    /* .footer style removed to avoid conflict with new fixed positioning */

    .control-button {
        height: 38px !important;
        padding: 0 10px !important;
        /* Tighter padding */
        font-size: 0.75rem !important;
        gap: 4px !important;
    }

    .control-button svg {
        width: 18px !important;
        height: 18px !important;
    }

    /* Start button prominence */
    .control-button.start {
        padding: 0 14px !important;
    }
}

/* Custom Language Dropdown Styles */
.footer-language-selector {
    position: relative;
    display: inline-block;
    z-index: 1001;
    /* Ensure above other footer elements */
}

.lang-btn-wrapper {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 1002;
    /* Button stays on top */
}

.lang-dropdown-menu {
    position: absolute;
    bottom: 100%;
    /* Opens upwards */
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    width: max-content;
    /* Adjust to content width */
    min-width: 180px;
    max-height: 300px;
    /* Scrollable if too long */
    overflow-y: auto;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    padding: 8px;
    margin-bottom: 12px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.2s;
    z-index: 1000;
}

.lang-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.95rem;
    /* Larger touch target */
    font-weight: 500;
    border-radius: 8px;
    transition: background-color 0.1s;
    white-space: nowrap;
}

.lang-option:hover,
.lang-option:focus {
    background-color: var(--divider-color);
}

.lang-option.selected {
    color: var(--primary-color);
    background-color: rgba(0, 100, 255, 0.08);
}

/* Mobile Optimizations */
@media (max-width: 600px) {
    .lang-dropdown-menu {
        position: fixed;
        /* Center on screen for mobile? Or stick to button? similar to bottom sheet */
        bottom: 80px;
        /* Above footer */
        left: 50%;
        transform: translateX(-50%) scale(0.9);
        width: 80vw;
        max-width: 320px;
        min-width: 200px;
        max-height: 50vh;
        border-radius: 20px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    }

    .lang-dropdown-menu.active {
        transform: translateX(-50%) scale(1);
    }

    .lang-option {
        padding: 12px 20px;
        font-size: 1rem;
        justify-content: center;
        /* Center text on mobile */
    }
}

/* Scrollbar */
.lang-dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.lang-dropdown-menu::-webkit-scrollbar-thumb {
    background-color: var(--divider-color);
    border-radius: 3px;
}

.lang-dropdown-menu::-webkit-scrollbar-track {
    background: transparent;
}


/* Fix Floating Footer Overlap */
.main-content {
    padding-bottom: 0 !important;
    /* Removed to avoid double padding with footer */
}

/* Ensure footer links clear the floating buttons */
.site-footer {
    padding-bottom: 90px !important;
}

/* Fix Header Layout and Visual Separation */
.header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 0 16px !important;
    position: sticky !important;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    /* Subtle shadow to separate form content */
}

/* Reset Header Children */
.header>* {
    margin: 0 !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
}

/* Title Styling */
.header-title {
    text-align: left !important;
    flex-grow: 1 !important;
    font-weight: 500 !important;
}

/* Header Controls Container */
.header-controls {
    display: flex !important;
    align-items: center !important;
    gap: 0px !important;
    margin-right: -8px !important;
}

/* Fix Buttons */
#theme-toggle,
#settings-button {
    position: static !important;
    transform: none !important;
    margin: 0 !important;
}

/* Ensure Language Dropdown is Above Footer */
.lang-dropdown-menu {
    z-index: 2001 !important;
    /* Above fixed footer */
    bottom: 90px !important;
}

/* Stabilize Floating Footer - Global Centered Pill Style */
.footer {
    position: fixed !important;
    bottom: 24px !important;
    /* Visual floating gap */
    left: 50% !important;
    /* Center globally */
    transform: translateX(-50%) !important;
    /* Perfect center alignment */
    width: 90% !important;
    max-width: 500px !important;
    /* Maintain capsule width on desktop */
    z-index: 2000 !important;
    background-color: var(--surface-color) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2) !important;
    display: flex !important;
    justify-content: center !important;
    padding: 10px !important;
    border-radius: 30px !important;
    /* Rounded capsule globally */
}

/* Mobile Adjustments - Fine tune spacing if needed */
@media (max-width: 600px) {
    .header {
        padding: 0 12px !important;
    }

    .footer {
        bottom: 16px !important;
        width: 96% !important;
        max-width: 400px !important;
        padding: 6px !important;
        justify-content: space-evenly !important;
    }

    /* Ensure floating footer doesn't cover copyright */
    .site-footer {
        padding-bottom: 100px !important;
    }
}