* {
    box-sizing: border-box;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: #f5f5f5;
}
h1 {
    color: #333;
    margin-bottom: 20px;
}
.controls {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}
.status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}
.status-indicator {
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
    background: #f0f0f0;
}
.status-indicator.connected {
    background: #d4edda;
    color: #155724;
}
.status-indicator.connecting {
    background: #fff3cd;
    color: #856404;
}
.status-indicator.error {
    background: #f8d7da;
    color: #721c24;
}
.source-selection {
    margin-bottom: 15px;
}
.source-selection label {
    margin-right: 20px;
    cursor: pointer;
}
.button-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}
button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-connect {
    background: #007bff;
    color: white;
}
.btn-connect:hover:not(:disabled) {
    background: #0056b3;
}
.btn-connect.connected {
    background: #dc3545;
}
.btn-connect.connected:hover:not(:disabled) {
    background: #c82333;
}
.btn-play {
    background: #28a745;
    color: white;
}
.btn-play:hover:not(:disabled) {
    background: #218838;
}
.btn-play.playing {
    background: #dc3545;
}
.btn-play.playing:hover:not(:disabled) {
    background: #c82333;
}
.file-input-container {
    display: none;
    margin-bottom: 15px;
}
.file-input-container.visible {
    display: block;
}
.progress-container {
    display: none;
    margin-bottom: 15px;
}
.progress-container.visible {
    display: block;
}
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
}
.progress-fill {
    height: 100%;
    background: #007bff;
    width: 0%;
    transition: width 0.1s;
}
.transcript-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    min-height: 200px;
}
.transcript-container h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    font-size: 18px;
}
.transcript-aligned {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.word-block {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.word-block .word-text {
    font-size: 16px;
    color: #333;
    font-weight: 500;
}
.word-block .word-phone {
    font-size: 13px;
    color: #888;
    font-style: italic;
}
.transcript-partial {
    color: #666;
    font-style: italic;
}
.display-mode {
    margin-bottom: 10px;
    font-size: 13px;
}
.display-mode label {
    margin-right: 12px;
    cursor: pointer;
}
.latency-display {
    font-size: 12px;
    color: #888;
    margin-top: 10px;
}
.settings-panel {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-top: 20px;
}
.settings-panel h3 {
    margin-top: 0;
}
.setting-row {
    margin-bottom: 10px;
}
.setting-row label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}
.setting-row input[type="text"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Message banner for errors and warnings */
.message-banner {
    display: none;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
    font-weight: 500;
}
.message-banner.visible {
    display: block;
}
.message-banner.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.message-banner.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* Audio level meter */
.level-meter-container {
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #888;
}
.level-meter-container.visible {
    display: flex;
}
.level-meter {
    width: 80px;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}
.level-meter-fill {
    height: 100%;
    background: #28a745;
    width: 0%;
    transition: width 0.05s;
}

/* Dialect comparison select */
.dialect-select {
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 13px;
    margin-left: 12px;
}
.dialect-select.hidden {
    display: none;
}

/* Phone comparison status colors */
.word-phone.phone-match { color: #2d8a4e; }
.word-phone.phone-close { color: #b88b00; }
.word-phone.phone-mismatch { color: #d32f2f; }
.word-phone.phone-oov { color: #888; font-style: italic; }

/* Per-character annotation spans */
.phone-char-match { /* inherits parent */ }
.phone-char-substitution { text-decoration: underline wavy #d32f2f; }
.phone-char-insertion { color: #888; font-size: 0.85em; vertical-align: super; }
.phone-char-deletion { opacity: 0.5; }

/* Elision group */
.word-block.elision-group { border-bottom: 2px dashed #b88b00; }

/* Reference pronunciation tooltip */
.word-block[data-ref-phones] { position: relative; cursor: help; }
.word-block[data-ref-phones]:hover::after {
    content: "ref: " attr(data-ref-phones);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
}
