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

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --accent: #e94560;
    --accent-glow: rgba(233, 69, 96, 0.4);
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --success: #4ade80;
    --warning: #fbbf24;
    --error: #f87171;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.screen {
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

.hidden {
    display: none !important;
}

/* Login Screen */
#login-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.login-container {
    width: 90%;
    max-width: 320px;
    padding: 2rem;
}

.logo {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-circle {
    width: 80px;
    height: 80px;
    background: var(--accent);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
    box-shadow: 0 0 30px var(--accent-glow);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 300;
}

.input-group {
    margin-bottom: 1rem;
}

.input-group input {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
    font-size: 1rem;
}

.input-group input::placeholder {
    color: var(--text-secondary);
}

.input-group input:focus {
    outline: 2px solid var(--accent);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.btn-login {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
}

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

.error-message {
    color: var(--error);
    text-align: center;
    margin-top: 1rem;
    min-height: 1.5rem;
}

/* Recording Screen */
#record-screen {
    background: var(--bg-primary);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
}

header h2 {
    font-weight: 400;
    font-size: 1.1rem;
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--text-secondary);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    overflow-y: auto;
}

/* Status Area */
#status-area {
    text-align: center;
    margin: 1rem 0;
}

#status-text {
    font-size: 1.3rem;
    color: var(--text-secondary);
    transition: color 0.3s;
}

#status-text.recording {
    color: var(--accent);
}

#status-text.processing {
    color: var(--warning);
}

#status-text.success {
    color: var(--success);
}

#timer {
    font-size: 2rem;
    font-weight: 300;
    color: var(--accent);
    margin-top: 0.5rem;
    font-variant-numeric: tabular-nums;
}

/* Waveform */
#waveform-container {
    width: 100%;
    height: 80px;
    margin: 1rem 0;
}

#waveform {
    width: 100%;
    height: 100%;
}

/* Record Button */
.record-button {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--accent), #c73e54);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1.5rem 0;
    box-shadow: 0 8px 30px var(--accent-glow);
    transition: transform 0.1s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent;
}

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

.record-button.recording {
    animation: pulse 1.5s infinite;
}

.record-button.processing {
    background: linear-gradient(145deg, var(--warning), #d4a521);
    box-shadow: 0 8px 30px rgba(251, 191, 36, 0.4);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 8px 30px var(--accent-glow); }
    50% { box-shadow: 0 8px 50px var(--accent-glow), 0 0 60px var(--accent-glow); }
}

.record-icon {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    transition: border-radius 0.2s, width 0.2s, height 0.2s;
}

.record-button.recording .record-icon {
    border-radius: 4px;
    width: 30px;
    height: 30px;
}

/* Result Area */
#result-area {
    width: 100%;
    max-width: 400px;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1rem;
    margin: 1rem 0;
}

#transcription {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
    min-height: 2rem;
}

.btn-copy {
    background: transparent;
    border: 1px solid var(--text-secondary);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}

.btn-copy.copied {
    border-color: var(--success);
    color: var(--success);
}

/* History Area */
#history-area {
    width: 100%;
    max-width: 400px;
    margin-top: 1rem;
}

#history-area h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 0.5rem;
}

#history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.history-text {
    flex: 1;
    word-break: break-word;
}

.history-time {
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0.7;
}

/* Offline Indicator */
#offline-indicator {
    position: fixed;
    bottom: calc(1rem + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: var(--warning);
    color: #000;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.offline-dot {
    width: 8px;
    height: 8px;
    background: #000;
    border-radius: 50%;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Install Prompt */
#install-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    padding: 1rem;
    padding-bottom: calc(1rem + var(--safe-bottom));
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    z-index: 100;
}

.install-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.install-content p {
    width: 100%;
    text-align: center;
    margin-bottom: 0.5rem;
}

#install-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
}

#install-dismiss {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Loading Spinner */
.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (min-width: 768px) {
    .record-button {
        width: 160px;
        height: 160px;
    }

    .record-icon {
        width: 50px;
        height: 50px;
    }
}
