/* ============================================
   Thot Transcribe - Production Stylesheet
   ============================================ */

/* --- CSS Custom Properties (Light theme) --- */
:root {
    --primary: #1a365d;
    --primary-light: #2b6cb0;
    --primary-lighter: #4299e1;
    --accent: #ed8936;
    --accent-light: #fbd38d;
    --bg: #f7fafc;
    --bg-elevated: #edf2f7;
    --card: #ffffff;
    --card-hover: #f8fafc;
    --text: #2d3748;
    --text-light: #718096;
    --text-muted: #a0aec0;
    --border: #e2e8f0;
    --border-light: #edf2f7;
    --success: #38a169;
    --success-bg: #f0fff4;
    --error: #e53e3e;
    --error-bg: #fff5f5;
    --warning: #d69e2e;
    --warning-bg: #fffff0;
    --info: #3182ce;
    --info-bg: #ebf8ff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;
    --transition: 0.2s ease;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* --- Dark theme --- */
[data-theme="dark"] {
    --primary: #90cdf4;
    --primary-light: #63b3ed;
    --primary-lighter: #4299e1;
    --accent: #ed8936;
    --accent-light: #7b5b33;
    --bg: #1a202c;
    --bg-elevated: #2d3748;
    --card: #2d3748;
    --card-hover: #353f50;
    --text: #e2e8f0;
    --text-light: #a0aec0;
    --text-muted: #718096;
    --border: #4a5568;
    --border-light: #2d3748;
    --success: #68d391;
    --success-bg: #1c3a2a;
    --error: #fc8181;
    --error-bg: #3a1c1c;
    --warning: #f6e05e;
    --warning-bg: #3a351c;
    --info: #63b3ed;
    --info-bg: #1c2d3a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
}

/* --- Reset --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* --- Accessibility --- */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    z-index: 1000;
    font-size: 0.9rem;
    text-decoration: none;
    border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
    top: 0;
}

:focus-visible {
    outline: 2px solid var(--primary-lighter);
    outline-offset: 2px;
}

/* --- Base --- */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Header --- */
header {
    background: var(--primary);
    color: white;
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

[data-theme="dark"] header {
    background: #1a202c;
    border-bottom: 1px solid var(--border);
}

.header-content {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left h1 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    color: rgba(255,255,255,0.65);
    font-size: 0.78rem;
    margin-top: -0.1rem;
}

[data-theme="dark"] .subtitle {
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.header-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: rgba(255,255,255,0.85);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition);
}

.header-btn:hover {
    background: rgba(255,255,255,0.2);
}

[data-theme="dark"] .header-btn {
    background: rgba(255,255,255,0.05);
    color: var(--text-light);
}

[data-theme="dark"] .header-btn:hover {
    background: rgba(255,255,255,0.1);
}

/* --- Offline banner --- */
.offline-banner {
    background: var(--warning-bg);
    color: var(--warning);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 500;
    justify-content: center;
    border-bottom: 1px solid var(--warning);
}

/* --- Main layout --- */
main {
    max-width: 960px;
    margin: 1rem auto;
    padding: 0 0.75rem;
    padding-bottom: env(safe-area-inset-bottom, 1rem);
}

/* --- Card --- */
.card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: box-shadow var(--transition);
}

.card h2 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.section-header h2 {
    margin-bottom: 0;
}

/* --- Form elements --- */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.form-group {
    margin-bottom: 0.75rem;
}

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

select, input[type="text"], input[type="date"] {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
    -webkit-appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23718096' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

select:focus, input[type="text"]:focus, input[type="date"]:focus {
    border-color: var(--primary-lighter);
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
    outline: none;
}

/* --- Audio source tabs --- */
.audio-source-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg);
}

.tab-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all var(--transition);
}

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

[data-theme="dark"] .tab-btn.active {
    background: var(--primary-lighter);
    color: #1a202c;
}

.tab-btn:not(.active):hover {
    background: var(--bg-elevated);
}

/* --- File drop zone --- */
.file-drop {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

.file-drop:hover, .file-drop.dragover, .file-drop:focus-within {
    border-color: var(--primary-lighter);
    background: var(--info-bg);
}

.file-drop input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.file-drop p {
    color: var(--text-light);
    font-size: 0.85rem;
}

.file-drop .link {
    color: var(--primary-light);
    text-decoration: underline;
    font-weight: 600;
}

.file-info {
    font-size: 0.75rem !important;
    color: var(--text-muted) !important;
}

.file-name {
    color: var(--primary) !important;
    font-weight: 600;
    margin-top: 0.25rem;
}

/* --- Recording area --- */
.record-area {
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.record-visualizer {
    width: 100%;
    max-width: 300px;
    height: 60px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.record-visualizer canvas {
    width: 100%;
    height: 100%;
}

.record-time {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.05em;
}

.record-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.record-button {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    border: 3px solid var(--error);
    background: transparent;
    color: var(--error);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.record-button:hover {
    background: var(--error-bg);
}

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

.record-button.recording .mic-icon { display: none; }
.record-button.recording .stop-icon { display: block !important; }

@keyframes pulse-record {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.4); }
    50% { box-shadow: 0 0 0 12px rgba(229, 62, 62, 0); }
}

.record-secondary {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.record-secondary:hover {
    background: var(--error-bg);
    color: var(--error);
    border-color: var(--error);
}

.record-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- Upload progress --- */
.upload-progress {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.progress-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

.progress-percent {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary);
    font-family: var(--font-mono);
}

.progress-bar-track {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--primary-lighter));
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.progress-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* --- Buttons --- */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

[data-theme="dark"] .btn-primary {
    background: var(--primary-lighter);
    color: #1a202c;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-ghost:hover {
    background: var(--bg-elevated);
    color: var(--text);
}

.back-btn {
    background: none;
    border: none;
    color: var(--primary-light);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-sans);
    margin-bottom: 0.75rem;
    padding: 0.3rem 0;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: color var(--transition);
}

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

/* --- Filter panel --- */
.filter-toggle-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: all var(--transition);
}

.filter-toggle-btn:hover {
    background: var(--bg-elevated);
}

.filter-toggle-btn[aria-expanded="true"] {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.filter-count {
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    padding: 0.05rem 0.4rem;
    border-radius: var(--radius-full);
    font-weight: 700;
}

.filter-panel {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.5rem;
}

.filter-group {
    margin-bottom: 0.25rem;
}

.filter-group label {
    font-size: 0.7rem;
}

.filter-group select,
.filter-group input {
    padding: 0.4rem 0.6rem;
    font-size: 0.82rem;
}

.filter-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

/* --- Transcription list items --- */
.t-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: all 0.15s ease;
    border-radius: var(--radius-md);
    margin-bottom: 2px;
}

.t-item:hover {
    background: var(--card-hover);
    box-shadow: var(--shadow-sm);
}

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

.t-item[role="listitem"] {
    position: relative;
}

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

.t-info h3 {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.t-info p {
    font-size: 0.78rem;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.t-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.badge-pending { background: #fefcbf; color: #975a16; }
.badge-transcribing { background: #bee3f8; color: #2a4365; }
.badge-analyzing { background: #e9d8fd; color: #553c9a; }
.badge-ready { background: #c6f6d5; color: #276749; }
.badge-error { background: #fed7d7; color: #9b2c2c; }

[data-theme="dark"] .badge-pending { background: #3a351c; color: #f6e05e; }
[data-theme="dark"] .badge-transcribing { background: #1c2d3a; color: #63b3ed; }
[data-theme="dark"] .badge-analyzing { background: #2d1f4e; color: #b794f4; }
[data-theme="dark"] .badge-ready { background: #1c3a2a; color: #68d391; }
[data-theme="dark"] .badge-error { background: #3a1c1c; color: #fc8181; }

/* --- Empty state --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    gap: 0.5rem;
}

.empty-state p {
    font-size: 0.9rem;
}

/* --- Detail view --- */
.detail-header {
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.detail-header h2 {
    margin-bottom: 0.2rem;
    font-size: 1.05rem;
}

.detail-meta {
    font-size: 0.8rem;
    color: var(--text-light);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.detail-meta .t-badge {
    font-size: 0.68rem;
}

/* --- Audio player --- */
.audio-player-container {
    margin-bottom: 1.25rem;
    background: var(--bg);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    border: 1px solid var(--border-light);
}

.audio-player-container audio {
    width: 100%;
    height: 36px;
    border-radius: var(--radius-sm);
}

.audio-player-container audio::-webkit-media-controls-panel {
    background: var(--bg);
}

.audio-timestamp-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    background: var(--info-bg);
    color: var(--info);
    border: none;
    padding: 0.1rem 0.35rem;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-family: var(--font-mono);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    vertical-align: middle;
    margin-right: 0.2rem;
}

.audio-timestamp-btn:hover {
    background: var(--primary);
    color: white;
}

/* --- Detail sections --- */
.detail-section {
    margin-bottom: 1.25rem;
}

.detail-section h3 {
    font-size: 0.88rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

.detail-section ul {
    list-style: none;
}

.detail-section li {
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
    line-height: 1.5;
}

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

/* --- Action items --- */
.actions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.actions-header h3 {
    margin-bottom: 0;
}

.bulk-actions {
    display: flex;
    gap: 0.3rem;
}

.bulk-actions button {
    font-size: 0.72rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-light);
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition);
}

.bulk-actions .bulk-validate:hover {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success);
}

.bulk-actions .bulk-reject:hover {
    background: var(--error-bg);
    color: var(--error);
    border-color: var(--error);
}

.action-item {
    display: flex;
    align-items: center;
    padding: 0.55rem 0.65rem;
    margin-bottom: 0.35rem;
    background: var(--bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    transition: all var(--transition);
    gap: 0.5rem;
}

.action-item:hover {
    border-color: var(--border);
}

.action-item.status-validated {
    border-left: 3px solid var(--success);
}

.action-item.status-rejected {
    border-left: 3px solid var(--error);
    opacity: 0.6;
}

.action-item.status-executed {
    border-left: 3px solid var(--primary-lighter);
}

.action-checkbox {
    flex-shrink: 0;
}

.action-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

.action-status-icon {
    flex-shrink: 0;
    font-size: 1rem;
}

.action-text {
    flex: 1;
    font-size: 0.85rem;
    min-width: 0;
}

.action-target {
    font-size: 0.7rem;
    background: var(--primary);
    color: white;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    font-weight: 600;
}

[data-theme="dark"] .action-target {
    background: var(--primary-lighter);
    color: #1a202c;
}

.action-buttons {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.action-buttons button {
    padding: 0.25rem 0.55rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font-sans);
    transition: all var(--transition);
    white-space: nowrap;
}

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

.btn-validate:hover { filter: brightness(1.1); }

.btn-reject {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error) !important;
}

.btn-reject:hover {
    background: var(--error);
    color: white;
}

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

.btn-execute:hover { filter: brightness(1.1); }

/* --- Blockquote / verbatims --- */
blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.5rem 0.75rem;
    margin: 0.4rem 0;
    background: var(--warning-bg);
    font-style: italic;
    font-size: 0.85rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    line-height: 1.5;
}

/* --- Raw text --- */
.raw-text {
    background: var(--bg);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.8;
    border: 1px solid var(--border-light);
    font-family: var(--font-sans);
}

.raw-text .highlight-segment {
    transition: background-color 0.3s ease;
    cursor: pointer;
    border-radius: 2px;
    padding: 0 1px;
}

.raw-text .highlight-segment:hover {
    background: var(--accent-light);
}

.raw-text .highlight-segment.active {
    background: var(--accent-light);
    font-weight: 600;
}

/* --- Export bar --- */
.export-bar {
    display: flex;
    gap: 0.4rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.export-bar button {
    padding: 0.45rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text);
}

.export-bar button:hover {
    background: var(--bg-elevated);
    border-color: var(--primary-light);
    color: var(--primary);
}

/* --- Spinner --- */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    flex-shrink: 0;
}

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

/* --- Toast notifications --- */
.toast-container {
    position: fixed;
    top: 4.5rem;
    right: 0.75rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    pointer-events: none;
    max-width: 340px;
    width: calc(100% - 1.5rem);
}

.toast {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.65rem 0.75rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    pointer-events: auto;
    animation: toastIn 0.3s ease;
    font-size: 0.85rem;
    line-height: 1.4;
}

.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--error); }
.toast-info { border-left: 3px solid var(--info); }

.toast-icon {
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 700;
    font-size: 0.82rem;
    margin-bottom: 0.1rem;
}

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

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    line-height: 1;
}

.toast-close:hover {
    color: var(--text);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(20px); }
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    header { padding: 0.6rem 0.75rem; }

    .header-left h1 { font-size: 1.05rem; }
    .subtitle { font-size: 0.72rem; }

    main { padding: 0 0.5rem; margin-top: 0.5rem; }
    .card { padding: 0.9rem; margin-bottom: 0.6rem; border-radius: var(--radius-md); }

    .filter-row {
        grid-template-columns: 1fr 1fr;
    }

    .action-item {
        flex-wrap: wrap;
    }

    .action-buttons {
        width: 100%;
        justify-content: flex-end;
        margin-top: 0.25rem;
    }

    .export-bar {
        flex-direction: column;
    }

    .export-bar button {
        justify-content: center;
    }

    .detail-meta {
        flex-direction: column;
        align-items: flex-start;
    }

    .toast-container {
        top: auto;
        bottom: 0.75rem;
        right: 0.5rem;
        left: 0.5rem;
        max-width: none;
        width: auto;
    }
}

@media (max-width: 380px) {
    .filter-row {
        grid-template-columns: 1fr;
    }

    .bulk-actions {
        flex-direction: column;
    }
}

/* Touch optimization for mobile */
@media (hover: none) and (pointer: coarse) {
    .t-item {
        padding: 0.8rem 0.75rem;
        min-height: 52px;
    }

    .action-buttons button {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    .btn-primary {
        padding: 0.8rem 1.25rem;
    }

    select, input[type="text"], input[type="date"] {
        padding: 0.65rem 0.8rem;
        font-size: 1rem;
    }

    .tab-btn {
        padding: 0.6rem 0.75rem;
    }
}

/* PWA installed: hide install button */
@media (display-mode: standalone) {
    #install-btn { display: none !important; }
}

/* Print */
@media print {
    header, .back-btn, .export-bar, .action-buttons, .bulk-actions,
    .filter-panel, .filter-toggle-btn, .audio-player-container,
    .toast-container, #upload-section, #active-section { display: none !important; }

    .card { box-shadow: none; border: 1px solid #ccc; }
    body { background: white; color: black; }
}
