/**
 * NullField Lab - v2 design layer
 * Loaded after styles.css; overrides only. Grey and gold instrument theme.
 * Identity: machined lab hardware. One signature element: the tuning dial.
 */

:root {
    --v2-ground-hi: #16120D;
    --v2-ground-lo: #0A0908;
    --v2-plate: #1C1915;
    --v2-plate-hi: #211D17;
    --v2-hairline: #37322B;
    --v2-hairline-hi: #4A4136;
    --v2-brass: #D4A574;
    --v2-brass-bright: #EBC98F;
    --v2-brass-deep: #8F7440;
    --v2-smoke: #ABA396;
    --v2-ash: #6E675C;
    --v2-ink: #14110D;
    --v2-readout: #F2E7D4;
    --v2-signal: #00D9B1;
}

/* ===== GROUND ===== */
body {
    background: linear-gradient(180deg, var(--v2-ground-hi) 0%, var(--v2-ground-lo) 100%);
    color: var(--v2-smoke);
}

.app-container {
    gap: 14px;
}

/* ===== HEADER: engraved nameplate ===== */
.app-header {
    padding: 18px 16px 14px;
    border: 1px solid var(--v2-hairline);
    border-bottom: 1px solid var(--v2-hairline);
    border-radius: 8px;
    background: linear-gradient(180deg, var(--v2-plate-hi) 0%, var(--v2-plate) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    margin-bottom: 4px;
}

.app-header::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid rgba(212, 165, 116, 0.16);
    border-radius: 5px;
    pointer-events: none;
}

.app-title {
    font-size: 21px;
    letter-spacing: 7px;
    color: var(--v2-brass);
    margin-bottom: 5px;
}

.version-chip {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--v2-ink);
    background: linear-gradient(180deg, var(--v2-brass-bright), var(--v2-brass));
    border-radius: 3px;
    padding: 2px 6px 1px;
    margin-left: 8px;
    vertical-align: middle;
    transform: translateY(-2px);
}

.app-subtitle {
    color: var(--v2-ash);
    letter-spacing: 4px;
}

.profile-menu-dashboard {
    position: absolute;
    top: 12px;
    right: 12px;
}

.profile-btn-dashboard {
    border-width: 1px;
    border-color: var(--v2-brass-deep);
}

.profile-btn-dashboard:hover {
    border-color: var(--v2-brass);
}

/* ===== PLATES (cards) ===== */
.card {
    background: var(--v2-plate);
    border: 1px solid var(--v2-hairline);
    border-radius: 8px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 1px 2px rgba(0, 0, 0, 0.35);
    transition: border-color 0.2s;
}

.card:hover {
    border-color: var(--v2-hairline-hi);
}

.card-header {
    font-size: 11px;
    letter-spacing: 1.5px;
    color: #B9AE9C;
}

.card-icon {
    color: var(--v2-brass-deep);
}

.grid-value {
    color: var(--v2-brass);
}

/* ===== FREQUENCY BEZEL: the instrument face ===== */
.frequency-card {
    background: linear-gradient(180deg, #211C15 0%, #171310 100%);
    border: 1px solid #3D3629;
    border-radius: 10px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        inset 0 -16px 32px rgba(0, 0, 0, 0.35),
        0 2px 10px rgba(0, 0, 0, 0.4);
}

.frequency-value {
    font-weight: 200;
    /* fluid: never wraps "52.00 Hz" on narrow phones (68px wraps at 390px) */
    font-size: clamp(44px, 15vw, 68px);
    letter-spacing: -1px;
    color: var(--v2-readout);
    /* tight radii so the glow follows the glyphs, not the block */
    text-shadow: 0 0 2px rgba(242, 231, 212, 0.35), 0 0 10px rgba(212, 165, 116, 0.3);
    font-variant-numeric: tabular-nums;
}

/* Base sheet pulses a 60-80px white text-shadow while playing, which reads
   as a square halo behind the readout. Replace with a steady tight glow;
   the dial needle carries the playing motion. */
.frequency-card.playing .frequency-value {
    animation: none;
    text-shadow: 0 0 2px rgba(242, 231, 212, 0.5), 0 0 12px rgba(212, 165, 116, 0.45);
}

/* Signature: the tuning dial */
.dial-scale {
    position: relative;
    width: 100%;
    height: 26px;
    max-width: 260px;
    margin: 10px auto 4px;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
}

.dial-scale::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 9px;
    background: repeating-linear-gradient(90deg, rgba(171, 163, 150, 0.38) 0 1px, transparent 1px 8px);
}

.dial-scale::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 15px;
    background: repeating-linear-gradient(90deg, rgba(212, 165, 116, 0.5) 0 1px, transparent 1px 40px);
}

.dial-needle {
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 2px;
    height: 24px;
    transform: translateX(-50%);
    background: var(--v2-brass);
    border-radius: 1px;
    box-shadow: 0 0 6px rgba(212, 165, 116, 0.55);
    z-index: 1;
    transition: background 0.3s, box-shadow 0.3s;
}

.frequency-card.playing .dial-needle {
    background: var(--v2-brass-bright);
    box-shadow: 0 0 12px rgba(235, 201, 143, 0.9);
    animation: dial-hum 2.4s ease-in-out infinite;
}

@keyframes dial-hum {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

.brainwave-label {
    font-size: 12px;
    letter-spacing: 3px;
    color: #B9AE9C;
}

.frequency-correction {
    color: var(--v2-ash);
}

/* ===== TRANSPORT: machined play control ===== */
.play-button {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 32%, #2B251D 0%, #17130E 72%);
    border: 1px solid var(--v2-hairline-hi);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        inset 0 -8px 14px rgba(0, 0, 0, 0.5),
        0 0 0 4px #12100C,
        0 0 0 5px var(--v2-hairline),
        0 4px 14px rgba(0, 0, 0, 0.5);
    margin: 24px auto 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.play-button:hover {
    transform: none;
    border-color: var(--v2-brass-deep);
}

.play-button:active {
    transform: scale(0.97);
}

.play-icon {
    border-left: 26px solid var(--v2-brass);
    border-top: 16px solid transparent;
    border-bottom: 16px solid transparent;
    margin-left: 7px;
}

.pause-icon {
    gap: 8px;
}

.pause-bar {
    width: 8px;
    height: 32px;
    background: var(--v2-brass);
    border-radius: 1px;
}

/* ===== CONTROLS ===== */
.action-button,
.preset-btn {
    background: rgba(212, 165, 116, 0.06);
    border: 1px solid #6B5A3E;
    border-radius: 6px;
    color: #D9B586;
    transition: background 0.2s, border-color 0.2s;
}

.action-button:hover,
.preset-btn:hover {
    background: rgba(212, 165, 116, 0.14);
    border-color: var(--v2-brass);
}

.setup-button,
.modal-btn.primary {
    background: linear-gradient(180deg, var(--v2-brass-bright) 0%, #C79A64 100%);
    color: var(--v2-ink);
    border-radius: 6px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 2px 6px rgba(0, 0, 0, 0.35);
}

.modal-btn.secondary {
    border-radius: 6px;
}

.microcontrol-btn {
    border-radius: 6px;
}

.btn-premium {
    border-radius: 6px;
}

.fab {
    background: linear-gradient(180deg, var(--v2-brass-bright) 0%, #C79A64 100%);
    border: 1px solid var(--v2-brass-deep);
    color: var(--v2-ink);
}

/* ===== WAVE VISUALIZATION ===== */
#waveCanvas {
    display: block;
    width: 100%;
    max-width: 400px;
    height: 120px;
    background: linear-gradient(180deg, #14110C 0%, #100D0A 100%);
    border: 1px solid var(--v2-hairline);
    border-radius: 6px;
}

/* ===== MODALS ===== */
.modal-content {
    background: linear-gradient(180deg, #1E1A14 0%, #171310 100%);
    border: 1px solid #3D3629;
    border-radius: 10px;
}

/* ===== QUIET FURNITURE ===== */
.diagnostics-toggle {
    color: var(--v2-ash);
    letter-spacing: 3px;
}

.diagnostics-toggle:hover {
    color: var(--v2-brass);
}

.tga-footer {
    color: #5C564B;
    border-top: 1px solid rgba(55, 50, 43, 0.5);
}

/* ===== GLOBAL SURFACES: selection, scrollbars ===== */
::selection {
    background: rgba(212, 165, 116, 0.35);
    color: #F2E7D4;
}

html {
    scrollbar-color: #4A4136 #12100C;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: #12100C;
}

*::-webkit-scrollbar-thumb {
    background: #3D362C;
    border-radius: 5px;
    border: 2px solid #12100C;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--v2-brass-deep);
}

/* ===== MODALS: every overlay and dialog ===== */
.modal,
.modal-overlay {
    background: rgba(12, 10, 8, 0.84);
}

.modal-header {
    border-bottom: 1px solid var(--v2-hairline);
}

.modal-header h3,
.modal-header h2 {
    color: var(--v2-brass);
}

.modal-close {
    color: var(--v2-ash);
    background: transparent;
}

.modal-close:hover {
    color: var(--v2-brass);
}

.modal-tabs {
    border-bottom: 1px solid var(--v2-hairline);
}

.tab-button {
    color: var(--v2-ash);
}

.tab-button:hover {
    color: var(--v2-smoke);
}

.tab-button.active {
    color: var(--v2-brass);
    border-color: var(--v2-brass);
}

.binaural-preview {
    background: rgba(16, 13, 10, 0.9);
    border: 1px solid var(--v2-hairline);
}

/* form fields, all dialogs */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="time"],
select,
textarea {
    background: #14110D;
    border: 1px solid var(--v2-hairline);
    color: #E8DFCE;
    border-radius: 6px;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="time"]:focus,
select:focus,
textarea:focus {
    border-color: var(--v2-brass-deep);
    outline: none;
}

input[type="range"] {
    accent-color: var(--v2-brass);
}

/* modals never scroll horizontally */
.modal-content,
.modal-body {
    overflow-x: hidden;
}

/* mood check-in: five equal columns that shrink, so the row can never overflow */
.mood-options {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.mood-btn {
    min-width: 0;
    padding: 10px 4px;
    background: var(--v2-plate);
    border: 1px solid var(--v2-hairline);
    border-radius: 6px;
}

.mood-btn:hover {
    border-color: var(--v2-brass-deep);
}

.mood-btn.selected,
.mood-btn.active {
    border-color: var(--v2-brass);
    background: rgba(212, 165, 116, 0.08);
}

/* Permission request modal: permissions.js builds it with inline styles
   (navy backdrop, cool plate), so !important is required to repaint it
   without forking the script. */
#permission-modal > div {
    background: rgba(12, 10, 8, 0.84) !important;
}

#permission-modal > div > div {
    background: linear-gradient(180deg, #1E1A14 0%, #171310 100%) !important;
    border: 1px solid #3D3629 !important;
    border-radius: 10px !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 20px 60px rgba(0, 0, 0, 0.5) !important;
}

#permission-modal p {
    color: var(--v2-smoke) !important;
}

#permission-modal #grant-permissions {
    background: linear-gradient(180deg, var(--v2-brass-bright) 0%, #C79A64 100%) !important;
    color: var(--v2-ink) !important;
    border-radius: 6px !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 2px 6px rgba(0, 0, 0, 0.35) !important;
}

#permission-modal #skip-permissions {
    background: transparent !important;
    color: var(--v2-ash) !important;
    border: 1px solid var(--v2-hairline-hi) !important;
    border-radius: 6px !important;
}

#permission-modal #skip-permissions:hover {
    color: var(--v2-brass) !important;
    border-color: var(--v2-brass-deep) !important;
}

/* ===== SETUP WIZARD ===== */
/* The wizard must never scroll on phones: compact scale + hidden overflow.
   Content is sized to fit a 568px-tall viewport at its largest. */
.setup-wizard {
    background: linear-gradient(180deg, var(--v2-ground-hi) 0%, var(--v2-ground-lo) 100%);
    padding: 16px;
    overflow: hidden;
}

.setup-container {
    max-height: 100%;
}

.setup-icon {
    font-size: 38px;
    margin-bottom: 10px;
    color: var(--v2-brass);
}

.setup-title {
    font-size: 19px;
    margin-bottom: 8px;
}

.setup-description {
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 14px;
}

.setup-feature-list {
    gap: 8px;
    margin-bottom: 16px;
}

.setup-feature {
    padding: 9px 12px;
}

.setup-button {
    padding: 13px;
}

.setup-button-secondary {
    padding: 10px;
    margin-top: 8px;
}

/* step 2: science sections tighter */
.science-section,
.compensation-formula {
    padding: 8px 12px;
}

.science-section {
    margin-bottom: 8px;
}

.science-label {
    font-size: 10px;
    margin-bottom: 4px;
}

.science-explanation {
    font-size: 11.5px;
    line-height: 1.45;
}

.compensation-formula {
    margin-top: 8px !important; /* inline style on the element */
}

.formula-line {
    padding: 2px 0;
    font-size: 11px;
}

/* step 3: reference list scrolls internally, sized to the viewport
   so the step itself never overflows (inline max-height needs !important) */
#setupStep3 .frequency-guide {
    max-height: min(320px, calc(100dvh - 330px)) !important;
    min-height: 120px;
}

/* step 5 + 6 */
.grid-option {
    padding: 12px;
}

.setup-tips {
    gap: 8px;
}

.setup-tip {
    padding: 8px 10px;
    font-size: 11.5px;
}

/* very short viewports: shrink the fixed furniture further */
@media (max-height: 700px) {
    .setup-icon {
        font-size: 28px;
        margin-bottom: 6px;
    }
    .setup-title {
        font-size: 16px;
    }
    .setup-description {
        margin-bottom: 8px;
    }
    #setupStep3 .frequency-guide {
        max-height: calc(100dvh - 290px) !important;
    }
}

/* desktop: sensor hardware does not exist there; patch-v2.js sets the class */
.v2-desktop .permission-item:has(#magnetometerStatus),
.v2-desktop .permission-item:has(#cameraStatus) {
    display: none;
}

/* ===== DESKTOP: nothing dangles below the TGA footer =====
   Base CSS force-expands the advanced section and the (data-empty) chart
   husks below the footer with !important, creating a scrollbar over dead
   space. Collapse both; the advanced section opens via the toggle like on
   mobile. app.js toggles inline style.display, so the open state is
   selected via the style attribute. */
@media (min-width: 1024px) {
    /* rows 5/6 (charts, advanced) must hug their content; the base auto
       tracks resolve ~400px tall even when their occupants are hidden */
    .app-container {
        grid-template-rows: auto auto auto auto min-content min-content;
    }

    .desktop-charts {
        display: none !important;
    }

    /* base draws a 400px dashed charts placeholder as an anonymous grid item;
       it is the phantom "empty space" below the footer */
    .app-container::after {
        content: none;
    }

    .advanced-section {
        display: none !important;
    }

    .advanced-section[style*="display: flex"],
    .advanced-section[style*="display:flex"],
    .advanced-section[style*="display: block"] {
        display: grid !important; /* keep the base desktop grid layout */
    }

    .diagnostics-toggle {
        /* occupy the vacated charts row; auto-placement would drop it into an
           implicit row ~440px below the footer (the "empty space" bug) */
        grid-area: charts;
        display: block !important;
    }
}

/* ===== MOBILE MOON BACKDROP (injected by patch-v2.js) ===== */
#bgMoon {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    opacity: 0.38;
    pointer-events: none;
}

@media (min-width: 769px), (prefers-reduced-motion: reduce) {
    #bgMoon {
        display: none;
    }
}

.setup-title {
    color: var(--v2-brass);
}

.setup-description,
.setup-note,
.setup-tip {
    color: var(--v2-smoke);
}

.setup-feature,
.setup-tips,
.permission-item {
    background: var(--v2-plate);
    border: 1px solid var(--v2-hairline);
    border-radius: 8px;
}

.setup-button-secondary {
    background: transparent;
    border: 1px solid var(--v2-hairline-hi);
    color: var(--v2-smoke);
    border-radius: 6px;
}

.setup-button-secondary:hover {
    border-color: var(--v2-brass-deep);
    color: var(--v2-brass);
}

.feature-text,
.permission-name {
    color: #E8DFCE;
}

.feature-icon {
    color: var(--v2-brass);
}

.compensation-formula,
.sine-visualization,
.problem-item,
.benefit-item {
    background: rgba(28, 25, 21, 0.6);
    border: 1px solid var(--v2-hairline);
}

.freq-hormones,
.freq-function,
.freq-band-details .freq-hormones,
.freq-band-details .freq-function {
    color: var(--v2-smoke);
}

.freq-label,
.schedule-title {
    color: #B9AE9C;
}

/* ===== ADVANCED PANEL ===== */
.advanced-section {
    background: linear-gradient(180deg, #1A1611 0%, #14110D 100%);
    border: 1px solid var(--v2-hairline);
}

.advanced-tabs {
    background: #14110D;
    border-bottom: 1px solid var(--v2-hairline);
}

.advanced-tab {
    color: var(--v2-ash);
}

.advanced-tab.active {
    color: var(--v2-brass);
    background: rgba(212, 165, 116, 0.08);
}

.card-title {
    color: #B9AE9C;
    letter-spacing: 1.5px;
}

.advanced-label {
    color: var(--v2-smoke);
}

.advanced-value {
    color: var(--v2-brass);
}

/* ===== DASHBOARD REMNANTS (navy / cool grey to warm) ===== */
.stat-chip {
    background: var(--v2-plate);
    border: 1px solid var(--v2-hairline);
}

.protocol-current,
.frequency-details {
    background: rgba(16, 13, 10, 0.75);
    border: 1px solid var(--v2-hairline);
}

.hormone-section {
    background: rgba(16, 13, 10, 0.6);
}

.hormone-detail {
    background: rgba(28, 25, 21, 0.5);
}

.hormone-name {
    color: #E8DFCE;
}

.hormone-mechanism {
    color: var(--v2-smoke);
}

.detection-status,
.alignment-text {
    color: var(--v2-smoke);
}

.vector-label {
    color: var(--v2-ash);
}

.vector-value {
    color: #B9AE9C;
}

.lunar-phase {
    color: #E8DFCE;
}

.profile-dropdown-dashboard {
    background: var(--v2-plate);
    border: 1px solid var(--v2-hairline);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.dropdown-item-dashboard {
    color: var(--v2-smoke);
}

.dropdown-item-dashboard:hover {
    background: rgba(212, 165, 116, 0.08);
    color: var(--v2-brass);
}

/* ===== MOOD HISTORY MODAL ===== */
.mood-history-content {
    max-height: 88vh;
    display: flex;
    flex-direction: column;
}

.mood-history-content .modal-body {
    overflow-y: auto;
    min-height: 0;
}

.mood-trend-wrap {
    position: relative;
    background: linear-gradient(180deg, #14110C 0%, #100D0A 100%);
    border: 1px solid var(--v2-hairline);
    border-radius: 6px;
    padding: 10px 12px 6px;
    margin-bottom: 12px;
}

.mood-trend-title {
    font-size: 10px;
    letter-spacing: 1.5px;
    color: #B9AE9C;
    margin-bottom: 6px;
}

#moodTrendCanvas {
    display: block;
    width: 100%;
    height: 170px;
    cursor: crosshair;
}

.mood-trend-tooltip {
    position: absolute;
    top: 26px;
    background: var(--v2-plate);
    border: 1px solid var(--v2-brass-deep);
    border-radius: 4px;
    color: #E8DFCE;
    font-size: 11px;
    padding: 4px 8px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 2;
}

.mood-history-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.mood-history-toolbar input {
    flex: 1;
    min-width: 0;
    padding: 9px 10px;
    font-size: 12px;
    font-family: inherit;
}

.mood-history-count {
    font-size: 10px;
    color: var(--v2-ash);
    white-space: nowrap;
}

.mood-export-btn {
    width: auto;
    padding: 9px 12px;
    font-size: 11px;
    white-space: nowrap;
}

.mood-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 340px;
    overflow-y: auto;
    padding-right: 2px;
}

.mood-history-empty {
    text-align: center;
    color: var(--v2-ash);
    font-size: 12px;
    padding: 28px 12px;
}

.mood-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--v2-plate);
    border: 1px solid var(--v2-hairline);
    border-radius: 6px;
    padding: 10px 12px;
}

.mood-row-emoji {
    font-size: 22px;
    line-height: 1.2;
}

.mood-row-main {
    flex: 1;
    min-width: 0;
}

.mood-row-top {
    font-size: 12px;
    color: #E8DFCE;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.mood-row-level {
    color: var(--v2-brass);
    font-size: 11px;
}

.mood-row-context {
    color: var(--v2-ash);
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.mood-row-note {
    color: var(--v2-smoke);
    font-size: 12px;
    margin-top: 4px;
    overflow-wrap: anywhere;
}

.mood-row-meta {
    color: var(--v2-ash);
    font-size: 10px;
    margin-top: 4px;
}

.mood-row-actions {
    display: flex;
    gap: 6px;
}

.mood-row-btn {
    background: transparent;
    border: 1px solid var(--v2-hairline);
    border-radius: 5px;
    color: var(--v2-smoke);
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 12px;
}

.mood-row-btn:hover {
    border-color: var(--v2-brass);
    color: var(--v2-brass);
}

.mood-row-btn.danger:hover {
    border-color: #FF4757;
    color: #FF4757;
}

.mood-row-editing {
    border-color: var(--v2-brass-deep);
}

.mood-level-pick {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.mood-level-pick button {
    background: #14110D;
    border: 1px solid var(--v2-hairline);
    border-radius: 5px;
    font-size: 18px;
    padding: 6px 0;
    cursor: pointer;
}

.mood-level-pick button.selected {
    border-color: var(--v2-brass);
    background: rgba(212, 165, 116, 0.10);
}

.mood-note-edit {
    width: 100%;
    padding: 8px 10px;
    font-size: 12px;
    font-family: inherit;
    margin-bottom: 8px;
}

.mood-edit-actions {
    display: flex;
    gap: 8px;
}

.mood-edit-btn {
    padding: 7px 14px;
    border-radius: 5px;
    border: 1px solid var(--v2-hairline-hi);
    background: transparent;
    color: var(--v2-smoke);
    font-size: 11px;
    cursor: pointer;
}

.mood-edit-btn.save {
    background: linear-gradient(180deg, var(--v2-brass-bright) 0%, #C79A64 100%);
    color: var(--v2-ink);
    border-color: var(--v2-brass-deep);
    font-weight: 600;
}

/* ===== UPDATE TOAST ===== */
#v2UpdateToast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: var(--v2-plate);
    border: 1px solid var(--v2-brass-deep);
    border-radius: 8px;
    color: #E8DFCE;
    font-size: 12px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10001;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

#v2UpdateToast button {
    background: linear-gradient(180deg, var(--v2-brass-bright) 0%, #C79A64 100%);
    color: var(--v2-ink);
    border: none;
    border-radius: 5px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

/* ===== ACCESSIBILITY FLOOR ===== */
button:focus-visible,
a:focus-visible,
.toggle-switch:focus-visible {
    outline: 2px solid rgba(212, 165, 116, 0.7);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .frequency-card.playing .dial-needle {
        animation: none;
    }
    .dial-needle {
        transition: none;
    }
}

/* ===== DESKTOP ===== */
@media (min-width: 769px) {
    .frequency-value {
        font-size: 84px;
    }
    .dial-scale {
        max-width: 320px;
    }
}

/* Base styles.css pins the play button to the card bottom at >=1024px;
   reserve room for it and keep it centered through hover/active. */
@media (min-width: 1024px) {
    .frequency-card {
        min-height: 340px;
        padding-bottom: 130px;
    }
    .play-button {
        bottom: 18px;
    }
    .play-button:hover {
        transform: translateX(-50%);
    }
    .play-button:active {
        transform: translateX(-50%) scale(0.97);
    }
}

/* Respect the compact breakpoints the base sheet defines */
@media (max-width: 400px) {
    .app-title {
        font-size: 16px;
        letter-spacing: 4px;
    }
    .app-header {
        padding: 16px 44px 12px;
    }
}

@media (max-width: 380px) {
    .frequency-value {
        font-size: 46px;
    }
    .dial-scale {
        max-width: 200px;
    }
}

@media (max-height: 600px) {
    .frequency-value {
        font-size: 36px;
    }
    .play-button {
        width: 64px;
        height: 64px;
        margin: 12px auto 8px;
    }
    .play-icon {
        border-left-width: 20px;
        border-top-width: 12px;
        border-bottom-width: 12px;
        margin-left: 5px;
    }
    .pause-bar {
        height: 24px;
    }
}

/* ===== AUTH LAYER (firebase-auth.js): modal, toast, dropdown account UI ===== */

.auth-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 9, 8, 0.82);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-modal {
    position: relative;
    width: 100%;
    max-width: 380px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 26px 24px 22px;
    border: 1px solid var(--v2-hairline);
    border-radius: 8px;
    background: linear-gradient(180deg, var(--v2-plate-hi) 0%, var(--v2-plate) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 18px 48px rgba(0, 0, 0, 0.55);
    color: var(--v2-smoke);
}

.auth-modal::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid rgba(212, 165, 116, 0.16);
    border-radius: 5px;
    pointer-events: none;
}

.auth-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    color: var(--v2-ash);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    z-index: 1;
}

.auth-modal-close:hover {
    color: var(--v2-brass);
}

.auth-modal-title {
    margin: 0 0 18px;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 5px;
    color: var(--v2-brass);
}

.auth-error {
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 99, 99, 0.35);
    border-radius: 6px;
    background: rgba(255, 99, 99, 0.08);
    color: #E8938F;
    font-size: 13px;
}

.auth-google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--v2-brass-deep);
    border-radius: 6px;
    background: linear-gradient(180deg, var(--v2-brass-bright) 0%, #C79A64 100%);
    color: var(--v2-ink);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 2px 6px rgba(0, 0, 0, 0.35);
    transition: filter 0.15s ease;
}

.auth-google-btn:hover:not(:disabled) {
    filter: brightness(1.06);
}

.auth-google-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 14px;
    color: var(--v2-ash);
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--v2-hairline);
}

.auth-label {
    display: block;
    margin: 12px 0 5px;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--v2-ash);
}

.auth-input {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 12px;
    border: 1px solid var(--v2-hairline);
    border-radius: 6px;
    background: var(--v2-ink);
    color: var(--v2-readout);
    font-size: 15px;
}

.auth-input:focus {
    outline: none;
    border-color: var(--v2-brass-deep);
    box-shadow: 0 0 0 2px rgba(212, 165, 116, 0.15);
}

.auth-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 16px;
    padding: 11px 14px;
    border: 1px solid var(--v2-hairline-hi);
    border-radius: 6px;
    background: linear-gradient(180deg, var(--v2-plate-hi) 0%, var(--v2-plate) 100%);
    color: var(--v2-brass);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.auth-submit:hover:not(:disabled) {
    border-color: var(--v2-brass-deep);
    color: var(--v2-brass-bright);
}

.auth-submit:disabled {
    opacity: 0.6;
    cursor: default;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
    font-size: 12px;
}

.auth-links a {
    color: var(--v2-ash);
    text-decoration: none;
}

.auth-links a:hover {
    color: var(--v2-brass);
    text-decoration: underline;
}

/* Toast (showAuthToast) */
.auth-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translate(-50%, 16px);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(92vw, 420px);
    padding: 11px 16px;
    border: 1px solid var(--v2-hairline-hi);
    border-radius: 6px;
    background: linear-gradient(180deg, var(--v2-plate-hi) 0%, var(--v2-plate) 100%);
    color: var(--v2-readout);
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 10001;
}

.auth-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.auth-toast-success i {
    color: var(--v2-signal);
}

.auth-toast-error {
    border-color: rgba(255, 99, 99, 0.4);
}

.auth-toast-error i {
    color: #E8938F;
}

.auth-toast-info i {
    color: var(--v2-brass);
}

/* Profile dropdown account content (rebuilt by updateAuthUI) */
.dropdown-divider {
    height: 1px;
    margin: 4px 0;
    background: var(--v2-hairline);
}

.dropdown-user-info {
    padding: 12px 16px 10px;
}

.dropdown-user-info .user-name {
    color: var(--v2-readout);
    font-size: 14px;
    font-weight: 600;
}

.dropdown-user-info .user-email {
    color: var(--v2-ash);
    font-size: 12px;
    margin-top: 2px;
    word-break: break-all;
}

.user-tier {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 8px 1px;
    border-radius: 3px;
    background: linear-gradient(180deg, var(--v2-brass-bright), var(--v2-brass));
    color: var(--v2-ink);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2px;
}

.user-tier.tier-pro {
    background: linear-gradient(180deg, #7BE0CB, var(--v2-signal));
}

.profile-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--v2-brass-deep);
    object-fit: cover;
    display: block;
}

.profile-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--v2-brass-bright), var(--v2-brass));
    color: var(--v2-ink);
    font-size: 13px;
    font-weight: 700;
}

/* ===== V2 DIALOGS (dialog-v2.js: v2Alert / v2Confirm) ===== */
.v2-dialog {
    z-index: 20002;
}

.v2-dialog .modal-content {
    max-width: 440px;
    padding: 24px 26px;
    background: linear-gradient(180deg, var(--v2-plate-hi) 0%, var(--v2-plate) 100%);
    border: 1px solid var(--v2-hairline-hi);
}

.v2-dialog-title {
    margin: 0 0 12px;
    color: var(--v2-brass);
    font-size: 16px;
    letter-spacing: 0.5px;
}

.v2-dialog-message {
    color: var(--v2-smoke);
    font-size: 14px;
    line-height: 1.55;
}

.v2-dialog .modal-actions {
    border-top: 1px solid var(--v2-hairline);
    padding-top: 16px;
}
