/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; background: #f5f5f7; color: #1d1d1f; line-height: 1.5; }
a { color: #0066cc; text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: "SF Mono", Menlo, monospace; font-size: 0.85em; background: #e8e8ed; padding: 0.1em 0.3em; border-radius: 3px; }

/* ===== Nav ===== */
.nav { display: flex; align-items: center; gap: 0.75rem; padding: 0 1.25rem; height: 52px; background: linear-gradient(#fff, #f2f2f2); border-bottom: 1px solid #d4d4d4; box-shadow: 0 1px 10px rgba(0,0,0,0.08); }
.nav-brand { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: #1d1d1f; }
.nav-brand:hover { text-decoration: none; }
.nav-brand svg { flex-shrink: 0; }
.nav-brand-text { display: flex; align-items: baseline; gap: 0.18em; font-family: "Open Sans", "Helvetica Neue", Helvetica, sans-serif; font-size: 1.05rem; letter-spacing: -0.02em; line-height: 1; }
.nav-allset { font-weight: 700; color: #1d1d1f; }
.nav-learning { font-weight: 700; color: #0090C0; }
.nav-app { font-weight: 400; color: #3a3a3c; margin-left: 0.45em; padding-left: 0.45em; border-left: 1px solid #d2d2d7; }
.nav-user { margin-left: auto; color: #6e6e73; font-size: 0.9rem; }
.nav-logout { font-size: 0.9rem; color: #6e6e73; }

/* ===== Container ===== */
.container { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 0.3em; padding: 0.45rem 0.9rem; border-radius: 6px; border: 1px solid #d2d2d7; background: #fff; color: #1d1d1f; font-size: 0.9rem; cursor: pointer; transition: background 0.15s; font-family: inherit; }
.btn:hover { background: #f0f0f5; text-decoration: none; }
.btn-primary { background: #0066cc; color: #fff; border-color: #0066cc; }
.btn-primary:hover { background: #0055b3; }
.btn-primary:disabled { background: #a0a0a8; border-color: #a0a0a8; cursor: not-allowed; }
.btn-danger { color: #c0392b; border-color: #e0b0ae; }
.btn-danger:hover { background: #fdf0f0; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.82rem; }
.btn-full { width: 100%; justify-content: center; }

/* ===== Page Header ===== */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.header-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.subtitle { color: #6e6e73; font-size: 0.9rem; margin-top: 0.2rem; }
.en { font-weight: 400; color: #6e6e73; }

/* ===== Badges ===== */
.badge { display: inline-block; padding: 0.1em 0.5em; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.badge-a1 { background: #d1e8ff; color: #003d8f; }
.badge-a2 { background: #d4f1d4; color: #1a5c1a; }
.badge-b1 { background: #fff3cd; color: #7a5300; }
.badge-b2 { background: #fde2d8; color: #8a2500; }

/* ===== Search ===== */
.search-bar { margin-bottom: 1rem; }
.search-bar input { width: 100%; max-width: 500px; padding: 0.5rem 0.8rem; border: 1px solid #d2d2d7; border-radius: 6px; font-size: 0.95rem; font-family: inherit; }

/* ===== Table ===== */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.table th { background: #f5f5f7; text-align: left; padding: 0.6rem 0.9rem; font-size: 0.82rem; color: #6e6e73; border-bottom: 1px solid #e8e8ed; }
.table td { padding: 0.65rem 0.9rem; border-bottom: 1px solid #f0f0f5; font-size: 0.9rem; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f9f9fb; }
.actions { display: flex; gap: 0.4rem; white-space: nowrap; }

/* ===== Status dots ===== */
.status-dot { font-size: 0.82rem; }
.status-draft::before { content: '⚪ '; }
.status-generating::before { content: '🟡 '; }
.status-ready::before { content: '🟢 '; }
.status-finalized::before { content: '✅ '; }
.status-failed::before { content: '🔴 '; }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: 3rem; color: #6e6e73; }

/* ===== Login ===== */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f5f5f7; }
.login-box { background: #fff; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,0.10); padding: 2.5rem 2rem; width: 100%; max-width: 380px; }
.login-title { font-size: 1.8rem; font-weight: 800; margin-bottom: 0.15rem; }
.login-subtitle { font-weight: 400; color: #6e6e73; }
.login-tagline { color: #6e6e73; font-size: 0.85rem; margin-bottom: 1.5rem; }
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.error-msg { color: #c0392b; font-size: 0.88rem; }

/* ===== Forms ===== */
.form-card { background: #fff; border-radius: 10px; padding: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field label { font-size: 0.88rem; font-weight: 600; color: #3a3a3c; }
.field input, .field textarea, .field select { padding: 0.5rem 0.7rem; border: 1px solid #d2d2d7; border-radius: 6px; font-size: 0.95rem; font-family: inherit; }
.field textarea { resize: vertical; }
.field-row { display: flex; gap: 1rem; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.hint { font-size: 0.8rem; color: #8e8e93; }
.required { color: #c0392b; }
.form-actions { margin-top: 1.2rem; display: flex; align-items: center; gap: 1rem; }
.error-list { color: #c0392b; font-size: 0.88rem; list-style: disc; padding-left: 1.2rem; margin-top: 0.5rem; }

/* ===== Level picker ===== */
.level-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.level-option { cursor: pointer; }
.level-option input { position: absolute; opacity: 0; width: 0; height: 0; }
.level-option span { display: inline-block; padding: 0.35rem 0.9rem; border: 1px solid #d2d2d7; border-radius: 6px; font-weight: 600; font-size: 0.9rem; transition: all 0.15s; }
.level-option input:checked + span { background: #0066cc; color: #fff; border-color: #0066cc; }
.level-option:hover span { background: #f0f0f5; }

/* ===== Speaker cards (voices page) ===== */
.speaker-card { background: #fff; border-radius: 10px; padding: 1.25rem; margin-bottom: 1rem; box-shadow: 0 1px 4px rgba(0,0,0,0.07); }
.speaker-label { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.75rem; }
.selected-voice { margin-top: 0.5rem; font-size: 0.9rem; }
.voice-chip { background: #e3f0ff; color: #0055b3; padding: 0.2em 0.6em; border-radius: 4px; font-size: 0.85rem; }
.no-voice { color: #8e8e93; font-size: 0.85rem; }

/* ===== Chip filters ===== */
.chip-group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-bottom: 0.5rem; }
.chip-label { font-size: 0.75rem; font-weight: 600; color: #6e6e73; min-width: 3.5rem; }
.chip { padding: 0.2rem 0.6rem; border-radius: 12px; border: 1px solid #d2d2d7; background: #fff; font-size: 0.78rem; cursor: pointer; transition: all 0.12s; font-family: inherit; }
.chip:hover { background: #f0f0f5; }
.chip.active { background: #0066cc; color: #fff; border-color: #0066cc; }
.voice-select { width: 100%; padding: 0.45rem 0.7rem; border: 1px solid #d2d2d7; border-radius: 6px; font-size: 0.9rem; font-family: inherit; margin-top: 0.25rem; }
.dup-voice-warning { font-size: 0.85rem; color: #a16207; background: #fef9c3; border: 1px solid #fde68a; border-radius: 6px; padding: 0.3rem 0.7rem; }

/* ===== Lines list ===== */
.lines-list { display: flex; flex-direction: column; gap: 0.5rem; }
.line-row { display: flex; align-items: center; gap: 0.75rem; background: #fff; border-radius: 8px; padding: 0.65rem 1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.line-row[data-status="generating"] { border-left: 3px solid #f0a500; }
.line-row[data-status="ready"] { border-left: 3px solid #30c060; }
.line-row[data-status="failed"] { border-left: 3px solid #c0392b; }
.line-meta { display: flex; gap: 0.5rem; align-items: center; flex-shrink: 0; min-width: 5rem; }
.line-num { font-size: 0.75rem; color: #a0a0a8; min-width: 1.4rem; }
.line-speaker { font-weight: 800; font-size: 1rem; color: #3a3a3c; }
.voice-pill { font-size: 0.72rem; font-family: "SF Mono", Menlo, monospace; padding: 0.15em 0.55em; border-radius: 999px; border: 1px solid #d2d2d7; background: #f0f0f5; color: #6e6e73; white-space: nowrap; flex-shrink: 0; }
.line-text { flex: 1; font-size: 0.95rem; }
.line-controls { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.status-icon { font-size: 1rem; min-width: 1.4rem; text-align: center; color: #8e8e93; }
.btn-play-ready { background: #30c060; color: #fff; border-color: #28a050; font-size: 0.85rem; }
.btn-play-ready:hover { background: #28a050; }
.btn-regen { color: #6e6e73; font-size: 1rem; padding: 0.3rem 0.6rem; }
.spinning { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Audio player ===== */
.audio-player-card { background: #fff; border-radius: 10px; padding: 1.25rem; margin-bottom: 1.25rem; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.player-label { font-size: 0.85rem; color: #6e6e73; margin-bottom: 0.5rem; }
.full-player { width: 100%; margin-bottom: 0.75rem; }
.download-links { display: flex; gap: 0.6rem; }

/* ===== Nav settings link ===== */
.nav-settings { font-size: 1.1rem; color: #6e6e73; text-decoration: none; line-height: 1; }
.nav-settings:hover { color: #1d1d1f; text-decoration: none; }

/* ===== Settings page ===== */
.settings-section h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.75rem; }
.settings-table .setting-label { display: block; font-weight: 600; font-size: 0.9rem; }
.settings-table .setting-key { display: block; font-size: 0.75rem; color: #8e8e93; font-family: "SF Mono", Menlo, monospace; margin-top: 0.1rem; }
.setting-input { width: 14rem; padding: 0.35rem 0.6rem; border: 1px solid #d2d2d7; border-radius: 6px; font-size: 0.9rem; font-family: inherit; }
.settings-msg { padding: 0.4rem 0.8rem; border-radius: 6px; font-size: 0.88rem; margin-bottom: 0.75rem; }
.settings-msg-ok { background: #d4f1d4; color: #1a5c1a; }
.settings-msg-error { background: #fde2d8; color: #8a2500; }

/* ===== TTS Log ===== */
.log-scroll { overflow-x: auto; }
.log-table { font-size: 0.78rem; }
.log-table th, .log-table td { padding: 0.4rem 0.6rem; white-space: nowrap; }
.log-text { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-error { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #c0392b; }
.log-model { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.log-voice { }
.log-status { display: inline-block; padding: 0.1em 0.4em; border-radius: 4px; font-size: 0.72rem; font-weight: 600; }
.log-status-ok { background: #d4f1d4; color: #1a5c1a; }
.log-status-error { background: #fde2d8; color: #8a2500; }
.log-status-empty { background: #fff3cd; color: #7a5300; }
.log-row-ok td { }
.log-row-error td { background: #fff9f9; }
.log-row-empty td { background: #fffdf0; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .field-row { flex-direction: column; }
  .page-header { flex-direction: column; }
  .table { font-size: 0.82rem; }
}
