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

:root {
    --primary-color: #007AFF;
    --record-color: #FF3B30;
    --success-color: #34C759;
    --warning-color: #FF9500;
    --background: #F2F2F7;
    --card-background: #FFFFFF;
    --text-primary: #000000;
    --text-secondary: #8E8E93;
    --border-color: #C6C6C8;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #000000;
        --card-background: #1C1C1E;
        --text-primary: #FFFFFF;
        --text-secondary: #8E8E93;
        --border-color: #38383A;
    }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 430px;
    margin: 0 auto;
    padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
    min-height: 100vh;
}

/* Header - iOS Style */
.header {
    text-align: center;
    padding: 20px 0;
    margin-bottom: 24px;
}

.header h1 {
    font-size: 34px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 6px 12px;
    background: var(--card-background);
    border-radius: 20px;
    box-shadow: var(--shadow-sm);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
}

.status-dot.recording {
    background: var(--record-color);
    animation: pulse 1.5s ease-in-out infinite;
}

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

.status-text {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Main Recording Area */
.main-content {
    background: var(--card-background);
    border-radius: 20px;
    padding: 32px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}

/* Timer Display */
.timer-display {
    text-align: center;
    margin-bottom: 40px;
}

.timer-text {
    font-size: 56px;
    font-weight: 200;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -2px;
    font-feature-settings: "tnum";
}

/* Audio Visualizer - Minimal Style */
.audio-visualizer {
    margin: 24px 0;
    height: 80px;
    background: var(--background);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
}

#visualizerCanvas {
    width: 100%;
    height: 100%;
    opacity: 0.8;
}

/* Control Buttons - iOS Style */
.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-bottom: 32px;
}

.btn {
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

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

.btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Record Button - Prominent */
.btn-record {
    width: 88px;
    height: 88px;
    background: var(--record-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
}

.btn-record:hover:not(:disabled) {
    background: #FF5449;
}

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

.btn-record .icon-record {
    width: 32px;
    height: 32px;
    color: white;
}

.btn-record span {
    display: none;
}

/* Secondary Buttons */
.btn-pause,
.btn-stop {
    width: 56px;
    height: 56px;
    background: var(--card-background);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--border-color);
}

.btn-pause:hover:not(:disabled),
.btn-stop:hover:not(:disabled) {
    background: var(--background);
    border-color: var(--primary-color);
}

.btn-pause svg,
.btn-stop svg {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
}

.btn-pause span,
.btn-stop span {
    display: none;
}

/* Settings - iOS Style Selector */
.settings {
    background: var(--background);
    border-radius: 12px;
    padding: 16px;
}

.settings label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.select-quality {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-background);
    font-size: 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

.select-quality:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

/* Recordings Section - iOS List Style */
.recordings-section {
    background: var(--card-background);
    border-radius: 20px;
    padding: 20px 0;
    box-shadow: var(--shadow-md);
}

.recordings-section h2 {
    font-size: 22px;
    font-weight: 700;
    padding: 0 20px;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.recordings-list {
    max-height: 400px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.recordings-list::-webkit-scrollbar {
    width: 0;
    display: none;
}

.empty-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 60px 20px;
    font-size: 16px;
}

/* Recording Item - iOS List Item Style */
.recording-item {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 0.5px solid var(--border-color);
    transition: background 0.2s ease;
    cursor: pointer;
}

.recording-item:hover {
    background: var(--background);
}

.recording-item:last-child {
    border-bottom: none;
}

.recording-item:active {
    background: var(--border-color);
}

.recording-info {
    flex: 1;
    min-width: 0;
}

.recording-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recording-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

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

.btn-action {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.btn-action:hover {
    background: var(--background);
}

.btn-action:active {
    transform: scale(0.9);
}

.btn-play {
    color: var(--primary-color);
}

.btn-download {
    color: var(--success-color);
}

.btn-delete {
    color: var(--record-color);
}

/* Install Prompt - iOS Style Alert */
.install-prompt {
    position: fixed;
    bottom: env(safe-area-inset-bottom, 20px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-background);
    padding: 20px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 360px;
    width: calc(100% - 32px);
    z-index: 1000;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(120%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.install-prompt p {
    margin-bottom: 16px;
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.4;
}

.install-prompt .btn-group {
    display: flex;
    gap: 12px;
}

.btn-install,
.btn-dismiss {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-install {
    background: var(--primary-color);
    color: white;
}

.btn-install:hover {
    background: #0051D5;
}

.btn-dismiss {
    background: var(--background);
    color: var(--text-secondary);
}

.btn-dismiss:hover {
    background: var(--border-color);
}

/* Responsive - Smaller Screens */
@media (max-width: 390px) {
    .container {
        padding: env(safe-area-inset-top) 12px env(safe-area-inset-bottom);
    }
    
    .timer-text {
        font-size: 48px;
    }
    
    .btn-record {
        width: 72px;
        height: 72px;
    }
    
    .btn-pause,
    .btn-stop {
        width: 48px;
        height: 48px;
    }
    
    .controls {
        gap: 20px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Focus Styles for Keyboard Navigation */
.btn:focus-visible,
.select-quality:focus-visible,
.btn-action:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Loading State */
.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Success Animation */
@keyframes success {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.success {
    animation: success 0.3s ease;
}