:root {
    --bg-color: #ffffff;
    --surface-color: #f2f2f5;
    --text-primary: #1c1c1e;
    --text-secondary: #8e8e93;
    --accent-color: #000000;
    --danger-color: #ff3b30;
    --pill-bg: #EAEAEA;
    --done-btn-bg: #000000;
    --done-btn-text: #ffffff;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 480px;
    /* Mobile Default */
    display: flex;
    flex-direction: column;
    padding: 0;
    position: relative;
    height: 100vh;
    margin: 0 auto;
    transition: max-width 0.3s;
}

/* Header */
.app-header {
    padding: 44px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--bg-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

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

.header-top h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

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

.header-actions .icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #F5F5F5;
    border: 1px solid #E5E5E5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    cursor: pointer;
}

.header-actions .icon-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2px;
}

.search-bar {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-icon {
    color: var(--text-secondary);
}

.search-bar input {
    border: none;
    background: transparent;
    font-size: 16px;
    color: var(--text-primary);
    flex-grow: 1;
    outline: none;
}

.search-badge {
    background: #ffffff;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 4px;
}

.search-badge::before {
    content: "✨";
}

/* Filter Chips */
.filter-chips {
    display: flex;
    gap: 8px;
    padding: 0 20px 16px;
}

.chip {
    background: var(--surface-color);
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
}

.chip.active {
    background: #e0e0e0;
    color: var(--text-primary);
}

/* List */
.recordings-list-section {
    flex-grow: 1;
    overflow-y: auto;
    padding-bottom: 120px;
}

.recordings-list {
    display: flex;
    flex-direction: column;
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
}

/* Recording Card */
.recording-card {
    padding: 16px 20px;
    border-bottom: 1px solid #F0F0F0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card-date {
    font-size: 13px;
    color: #8e8e93;
    font-weight: 500;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: #000;
    margin: 0;
}

.player-interface {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Important for Mobile */
    gap: 12px;
}

/* --- Player Pill Responsive Logic --- */

/* Mobile Base (Bubble Style) */
.player-pill {
    flex-grow: 0;
    width: fit-content;
    height: 48px;
    background: #F2F2F2;
    border-radius: 24px;
    display: flex;
    align-items: center;
    padding: 0 16px 0 8px;
    /* Compact padding */
    gap: 8px;
    transition: all 0.3s ease;
}

.progress-container {
    display: none;
    /* Hidden on Mobile */
}

.duration-display {
    font-size: 14px;
    font-weight: 600;
    color: #000;
    margin: 0;
    min-width: auto;
    font-variant-numeric: tabular-nums;
}

.play-toggle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    flex-shrink: 0;
}

.play-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Action Buttons */
.card-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #F2F2F2;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.action-btn:hover {
    background: #E5E5EA;
}

/* --- DESKTOP VIEW --- */
@media (min-width: 768px) {
    .app-container {
        max-width: 800px;
    }

    /* RESTRUCTURE HEADER FOR DESKTOP */
    .app-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 20px;
        padding-bottom: 24px;
    }

    .header-top {
        display: contents;
        /* Unwraps H1 and Actions so they participate in app-header flex */
    }

    .header-top h1 {
        display: none;
        /* Hide App Name */
    }

    .header-actions {
        order: 2;
        /* Move to the right */
        gap: 12px;
    }

    .header-actions .icon-btn {
        background: transparent;
        border: none;
        width: 40px;
        height: 40px;
        color: #555;
        border-radius: 50%;
        /* Optional: circular hover effect? */
    }

    .header-actions .icon-btn:hover {
        background: rgba(0, 0, 0, 0.05);
        /* Subtle hover */
        color: #000;
    }

    .search-bar {
        order: 1;
        /* Move to the left */
        flex-grow: 1;
        max-width: 600px;
    }

    /* Player transformations */
    .player-pill {
        flex-grow: 1;
        width: 100%;
        height: 56px;
        border-radius: 999px;
        padding: 0 12px 0 6px;
        gap: 12px;
    }

    .progress-container {
        display: flex;
        flex-grow: 1;
        align-items: center;
        height: 100%;
    }

    .duration-display {
        margin-right: 20px;
        min-width: 45px;
        text-align: right;
    }

    .play-toggle {
        width: 44px;
        height: 44px;
    }
}


/* Custom Range Slider (Common) */
.progress-bar {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: #D1D1D6;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    background-image: linear-gradient(#000, #000);
    background-size: 0% 100%;
    background-repeat: no-repeat;
}

.progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: black;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

.progress-bar::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Bottom Bar */
.bottom-bar {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 80px;
    z-index: 100;
}

.main-record-btn {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: black;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.main-record-btn:active {
    transform: scale(0.95);
}

/* Recording Bottom Sheet */
.recording-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg-color);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
    border-top-left-radius: 32px;
    border-top-right-radius: 32px;
    padding: 12px 24px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    z-index: 200;
    transform: translateY(110%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.sheet-handle {
    width: 36px;
    height: 4px;
    background: #E0E0E0;
    border-radius: 2px;
    margin-bottom: 8px;
}

.recording-sheet.active {
    transform: translateY(0);
}

.recording-pill {
    width: 100%;
    max-width: 340px;
    height: 72px;
    background: var(--pill-bg);
    border-radius: 36px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.recording-pill canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    bottom: 0;
    left: 0;
    opacity: 0.9;
}

.pill-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 20px;
    color: #000;
}

.pill-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0;
    color: #000;
}

.done-btn {
    width: 100%;
    max-width: 340px;
    padding: 18px;
    border-radius: 36px;
    border: none;
    background: var(--done-btn-bg);
    color: var(--done-btn-text);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s;
}

.done-btn:active {
    transform: scale(0.98);
}


.progress-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    height: 100%;
}

.progress-bar {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: #D1D1D6;
    /* Gray background track */
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    background-image: linear-gradient(#000, #000);
    background-size: 0% 100%;
    background-repeat: no-repeat;
}

/* Slider Thumb */
.progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: black;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s;
}

.progress-bar::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Action Buttons */
.card-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #F2F2F2;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.action-btn:hover {
    background: #E5E5EA;
}

/* Hidden Audio */
.hidden-audio {
    display: none;
}

/* Floating Action Button */
.bottom-bar {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 80px;
    z-index: 100;
}

.main-record-btn {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: black;
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.main-record-btn:active {
    transform: scale(0.95);
}

/* Recording Bottom Sheet */
.recording-sheet {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(150%);
    width: auto;
    min-width: 320px;
    max-width: 90%;
    background: var(--bg-color);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
    border-top-left-radius: 32px;
    border-top-right-radius: 32px;
    padding: 12px 24px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    z-index: 200;
    transform: translateY(110%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.sheet-handle {
    display: none;
}

.recording-sheet.active {
    transform: translateX(-50%) translateY(0);
}

/* Recording Pill (The visualization container) */
.recording-pill {
    position: relative;
    width: 280px;
    /* Fixed compact width */
    height: 80px;
    background: #EAEAEA;
    /* Light gray background */
    border-radius: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* Crop the wave */
    margin: 0 auto 24px;
    /* Center horizontally */
}

#visualizer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.pill-content {
    position: relative;
    z-index: 2;
    /* Sit on top of wave */
    display: flex;
    align-items: center;
    gap: 12px;
}

.pill-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    cursor: pointer;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.timer {
    font-size: 18px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #000;
}

.done-btn {
    width: 280px;
    /* Match pill width */
    padding: 18px;
    border-radius: 36px;
    border: none;
    background: var(--done-btn-bg);
    color: var(--done-btn-text);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s;
}

.done-btn:active {
    transform: scale(0.98);
}

/* More Options Dropdown */
.action-wrapper {
    position: relative;
    display: inline-block;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Space between buttons */
}

.circle-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #F2F2F2;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.circle-btn:hover {
    background: #E5E5EA;
}

.circle-btn svg {
    pointer-events: none;
}

/* Rename .more-btn to be just an instance/alias or remove if replaced */
.more-btn {
    /* Keeping for backward compat if needed, but styling is same as circle-btn */
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #F2F2F2;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.more-btn svg {
    pointer-events: none;
    /* Prevent clicking icon */
}

.dropdown-menu {
    position: absolute;
    right: 0;
    bottom: 110%;
    /* Show above button */
    background: #ffffff;
    min-width: 160px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    padding: 8px;
    display: none;
    flex-direction: column;
    z-index: 1000;
    transform-origin: bottom right;
    animation: scaleIn 0.1s ease-out;
}

.dropdown-menu.show {
    display: flex;
}

.dropdown-item {
    background: none;
    border: none;
    padding: 12px 16px;
    text-align: left;
    width: 100%;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #1c1c1e;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
}

.dropdown-item:hover {
    background: #F2F2F5;
}

.dropdown-item.delete {
    color: var(--danger-color);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    stroke-width: 2px;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}