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

:root {
    --primary: #4a90d9;
    --primary-dark: #357abd;
    --danger: #d9534f;
    --success: #5cb85c;
    --bg: #f5f5f5;
    --card-bg: #ffffff;
    --text: #333333;
    --text-light: #888888;
    --border: #e0e0e0;
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    padding: 16px;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header h1 {
    font-size: 1.2rem;
    font-weight: 600;
}

/* Main content */
main {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    padding-bottom: 80px;
}

/* Views */
.view {
    display: none;
}
.view.active {
    display: block;
}

/* Steps */
.step {
    display: none;
}
.step.active {
    display: block;
}

/* Navigation */
nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    display: flex;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding: 8px 0;
}

.nav-btn {
    flex: 1;
    border: none;
    background: none;
    padding: 10px;
    font-size: 0.85rem;
    color: var(--text-light);
    cursor: pointer;
}

.nav-btn.active {
    color: var(--primary);
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-dark);
}
.btn-primary:disabled {
    background: #aaa;
    cursor: not-allowed;
}

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

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

/* Record button */
.btn-record {
    width: 100%;
    padding: 20px;
    background: var(--primary);
    color: white;
    font-size: 1.1rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.btn-record.recording {
    background: var(--danger);
}

.record-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    display: inline-block;
}

.btn-record.recording .record-icon {
    background: white;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Forms */
form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.9rem;
    font-weight: 500;
}

input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}

/* Info boxes */
.info-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin: 12px 0;
}

/* Status messages */
.status {
    padding: 8px 0;
    font-size: 0.9rem;
}
.status.error {
    color: var(--danger);
}
.status.success {
    color: var(--success);
}

/* Group options */
.group-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.divider {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Message list */
#group-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--text-light);
}

#group-code-display {
    font-weight: 600;
    font-family: monospace;
    font-size: 1rem;
    color: var(--text);
}

#message-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.filter-btn {
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--card-bg);
    cursor: pointer;
    font-size: 0.85rem;
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.message-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.message-item:hover {
    background: #f0f0f0;
}

.message-item.unread {
    border-left: 4px solid var(--primary);
}

.message-meta {
    flex: 1;
}

.message-sender {
    font-weight: 600;
    font-size: 0.95rem;
}

.message-time {
    font-size: 0.8rem;
    color: var(--text-light);
}

.message-duration {
    font-size: 0.8rem;
    color: var(--text-light);
}

.message-play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-play-btn.playing {
    background: var(--danger);
}

/* Record area */
#record-area {
    margin-top: 20px;
}

#record-preview {
    margin-top: 16px;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

#record-preview audio {
    width: 100%;
    margin: 8px 0;
}

.preview-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Device status */
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
    border-bottom: none;
}

/* Utilities */
.hidden {
    display: none !important;
}

h2 {
    margin-bottom: 16px;
}

h3 {
    margin: 16px 0 8px;
}

/* Responsive */
@media (max-width: 480px) {
    #app {
        max-width: 100%;
    }
    nav {
        max-width: 100%;
    }
}
