:root {
    --primary: #1e40af;
    --primary-light: #3b82f6;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --red: #ef4444;
    --green: #22c55e;
    --yellow: #eab308;
    --radius: 12px;
}

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

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

#app { display: flex; flex-direction: column; height: 100dvh; }

header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; background: var(--primary); color: white; flex-shrink: 0;
}
header h1 { font-size: 1.1rem; }
.icon-btn { background: none; border: none; color: white; font-size: 0.9rem; cursor: pointer; padding: 4px 8px; }

.view { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.view.active { display: flex; }

/* Record */
.record-area {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; padding: 24px; gap: 16px;
}
.record-timer { font-size: 3rem; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.waveform { width: 80%; max-width: 300px; height: 60px; }
.record-btn {
    width: 80px; height: 80px; border-radius: 50%; border: 4px solid var(--primary);
    background: white; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.record-btn:active { transform: scale(0.95); }
.record-icon {
    width: 32px; height: 32px; background: var(--red); border-radius: 50%;
    transition: all 0.3s;
}
.record-btn.recording .record-icon {
    border-radius: 4px; width: 24px; height: 24px;
}
.record-status { font-size: 0.85rem; color: var(--muted); }
.title-input {
    width: 100%; max-width: 300px; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 0.9rem; text-align: center;
}

/* Template & Import */
.template-select {
    width: 100%; max-width: 300px; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 0.85rem; background: var(--card); color: var(--text);
}
.import-btn {
    width: 100%; max-width: 300px; padding: 10px; border: 1px dashed var(--border);
    border-radius: var(--radius); background: none; color: var(--primary); font-size: 0.85rem;
    cursor: pointer;
}
.import-btn:active { background: rgba(30,64,175,0.05); }

.url-import { width: 100%; max-width: 300px; display: flex; flex-direction: column; gap: 6px; }

/* Realtime text */
.realtime-text {
    width: 100%; max-width: 300px; min-height: 40px; max-height: 80px;
    overflow-y: auto; font-size: 0.85rem; color: var(--muted);
    background: var(--card); border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 12px; text-align: left; line-height: 1.4;
}

/* Search */
.search-bar { padding: 8px 12px; flex-shrink: 0; }
.search-bar input {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 0.9rem; background: var(--card); color: var(--text);
}

/* Chat */
.chat-panel { margin-top: 16px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-messages-list { max-height: 200px; overflow-y: auto; padding: 10px; }
.chat-msg { margin-bottom: 8px; font-size: 0.85rem; line-height: 1.5; }
.chat-msg.user { text-align: right; }
.chat-msg .bubble {
    display: inline-block; padding: 6px 12px; border-radius: 12px; max-width: 85%;
    text-align: left; word-break: break-word;
}
.chat-msg.user .bubble { background: var(--primary); color: white; }
.chat-msg.assistant .bubble { background: var(--bg); }
.chat-input-row { display: flex; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; border: none; padding: 10px; font-size: 0.85rem; background: var(--card); color: var(--text); }
.chat-input-row button { padding: 10px 14px; border: none; background: var(--primary); color: white; cursor: pointer; font-size: 0.85rem; }

/* Speaker edit */
.speaker-label { cursor: pointer; }
.speaker-label:hover { opacity: 0.7; }

/* Export */
.export-bar { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.export-btn {
    flex: 1; min-width: 80px; padding: 10px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--card); color: var(--text); font-size: 0.8rem; cursor: pointer; text-align: center;
}
.export-btn:active { background: var(--bg); }

/* Nav Tabs */
.nav-tabs {
    display: flex; border-top: 1px solid var(--border); flex-shrink: 0;
    background: var(--card);
}
.nav-tab {
    flex: 1; padding: 12px; border: none; background: none;
    font-size: 0.85rem; color: var(--muted); cursor: pointer; font-weight: 500;
}
.nav-tab.active { color: var(--primary); border-top: 2px solid var(--primary); }

/* Recordings List */
.recordings-list { flex: 1; overflow-y: auto; padding: 12px; }
.recording-item {
    background: var(--card); border-radius: var(--radius); padding: 14px;
    margin-bottom: 10px; border: 1px solid var(--border); cursor: pointer;
}
.recording-item:active { background: #f1f5f9; }
.ri-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.ri-title { font-weight: 600; font-size: 0.95rem; }
.ri-status {
    font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; font-weight: 500;
}
.ri-status.done { background: #dcfce7; color: #166534; }
.ri-status.processing { background: #fef3c7; color: #92400e; }
.ri-status.error { background: #fecaca; color: #991b1b; }
.ri-meta { font-size: 0.8rem; color: var(--muted); }
.ri-preview { font-size: 0.8rem; color: var(--muted); margin-top: 6px; line-height: 1.4; }
.empty-state { text-align: center; color: var(--muted); padding: 3rem 1rem; }

/* Detail */
.detail-content { flex: 1; overflow-y: auto; padding: 16px; }
.detail-tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.detail-tab {
    padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px;
    background: none; cursor: pointer; font-size: 0.8rem; color: var(--muted);
}
.detail-tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.detail-section { display: none; }
.detail-section.active { display: block; }

/* Transcript */
.segment { margin-bottom: 12px; line-height: 1.6; }
.speaker-label {
    display: inline-block; font-size: 0.7rem; font-weight: 600; padding: 2px 8px;
    border-radius: 4px; margin-right: 6px; color: white;
}
.speaker-0 { background: #3b82f6; }
.speaker-1 { background: #22c55e; }
.speaker-2 { background: #f59e0b; }
.speaker-3 { background: #ef4444; }
.speaker-4 { background: #8b5cf6; }
.segment-text { font-size: 0.9rem; }

/* Summary */
.summary-card { background: #f0f9ff; border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.summary-card h4 { font-size: 0.85rem; color: var(--primary); margin-bottom: 8px; }
.summary-text { font-size: 0.9rem; line-height: 1.6; }
.topic-item { margin-bottom: 12px; }
.topic-name { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.decision { font-size: 0.85rem; color: var(--text); padding-left: 16px; line-height: 1.5; }

/* Action Items */
.action-item {
    background: var(--card); border: 1px solid var(--border); border-radius: 8px;
    padding: 12px; margin-bottom: 8px;
}
.ai-task { font-size: 0.9rem; font-weight: 500; margin-bottom: 4px; }
.ai-meta { font-size: 0.8rem; color: var(--muted); }

/* Delete */
.delete-btn {
    width: 100%; margin-top: 24px; padding: 12px; background: none;
    border: 1px solid var(--red); color: var(--red); border-radius: var(--radius);
    font-size: 0.9rem; cursor: pointer;
}

/* Modal */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-content { background: white; border-radius: var(--radius); padding: 32px; text-align: center; max-width: 300px; }
.spinner {
    width: 40px; height: 40px; border: 3px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-hint { font-size: 0.8rem; color: var(--muted); margin-top: 8px; }

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a; --card: #1e293b; --text: #f1f5f9;
        --muted: #94a3b8; --border: #334155;
    }
    .title-input { background: var(--card); color: var(--text); border-color: var(--border); }
    .recording-item:active { background: #334155; }
    .summary-card { background: #1e3a5f; }
    .modal-content { background: var(--card); }
}
