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

html {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a2e;
    color: #fff;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
}

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

/* ===== Top-right toolbar ===== */
#toolbar {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 100;
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

#toolbar select {
    background: rgba(15, 52, 96, 0.85);
    color: #fff;
    border: 1px solid #533483;
    border-radius: 6px;
    padding: 0.15rem 0.3rem;
    font-size: 0.75rem;
    min-height: 28px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    -webkit-appearance: none;
    appearance: none;
}

.toolbar-arrow {
    color: #555;
    font-size: 0.7rem;
}

#toolbar button {
    background: rgba(15, 52, 96, 0.85);
    color: #00d4ff;
    border: 1px solid #533483;
    border-radius: 6px;
    font-size: 0.85rem;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#btn-mic {
    font-size: 0.85rem !important;
    color: #ff6b6b !important;
}

#btn-mic.paused {
    color: #a8e06c !important;
}

#btn-new {
    font-size: 1rem !important;
    font-weight: bold;
    color: #a8e06c !important;
}

#toolbar button:active {
    background: #533483;
}

/* ===== Engine selector (top-left) ===== */
#engine-select {
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 100;
    background: rgba(15, 52, 96, 0.7);
    color: #888;
    border: 1px solid rgba(83, 52, 131, 0.5);
    border-radius: 6px;
    padding: 0.15rem 0.3rem;
    font-size: 0.7rem;
    min-height: 28px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ===== SEO content (visible to crawlers, hidden when app starts) ===== */
#seo-content {
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
    color: #ccc;
    line-height: 1.8;
}

#seo-content h1 { font-size: 1.5rem; color: #00d4ff; margin-bottom: 1rem; }
#seo-content h2 { font-size: 1.2rem; color: #00d4ff; margin: 1.5rem 0 0.5rem; }
#seo-content h3 { font-size: 1rem; color: #a8e06c; margin: 1rem 0 0.3rem; }
#seo-content p { margin-bottom: 0.8rem; }
#seo-content ul, #seo-content ol { padding-left: 1.5rem; margin-bottom: 1rem; }
#seo-content li { margin-bottom: 0.4rem; }

#seo-content.hidden { display: none; }

/* ===== Loading bar ===== */
#loading-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    text-align: center;
    font-size: 0.75rem;
    color: #aaa;
    background: rgba(22, 33, 62, 0.9);
    padding: 0.3rem;
    display: none;
}

#loading-bar.show {
    display: block;
}

/* ===== Subtitle area ===== */
#subtitle-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Push content to bottom when few items */
#subtitle-container::before {
    content: "";
    flex: 1;
}

.sentence {
    margin-bottom: 1rem;
    opacity: 1;
    transition: opacity 0.8s ease;
}

.sentence.fading {
    opacity: 0;
}

.sentence .original {
    font-size: 1.3rem;
    color: #fff;
    line-height: 1.5;
    word-break: break-word;
}

.sentence .translated {
    font-size: 1.25rem;
    color: #00d4ff;
    line-height: 1.5;
    margin-top: 0.15rem;
    opacity: 0;
    transition: opacity 0.5s ease;
    word-break: break-word;
}

.sentence .translated.show {
    opacity: 1;
}

.sentence .translated.ai-source {
    color: #a8e06c;
}

.sentence .translated.loading::after {
    content: "⋯";
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}

.interim {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    margin-bottom: 0.8rem;
    word-break: break-word;
}

/* ===== Guide overlay ===== */
#guide {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(26, 26, 46, 0.95);
    transition: opacity 0.6s ease;
}

#guide.hidden {
    opacity: 0;
    pointer-events: none;
}

.guide-content {
    text-align: center;
    padding: 2rem;
    max-width: 500px;
}

.guide-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: guidePulse 2s infinite;
}

@keyframes guidePulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

#guide-title {
    font-size: 1.6rem;
    font-weight: 600;
    color: #00d4ff;
    margin-bottom: 1.5rem;
}

#guide-steps {
    text-align: left;
    margin: 0 auto 1.5rem;
    display: inline-block;
}

#guide-steps .step {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    margin-bottom: 1rem;
    font-size: 1.05rem;
    line-height: 1.5;
    color: #ccc;
}

#guide-steps .step-num {
    background: #00d4ff;
    color: #1a1a2e;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

#guide-hint {
    color: #666;
    font-size: 0.85rem;
    margin-top: 1rem;
    animation: blink 2s infinite;
}

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

@media (max-width: 768px) {
    .guide-icon { font-size: 3rem; }
    #guide-title { font-size: 1.3rem; }
    #guide-steps .step { font-size: 0.95rem; }
    .guide-content { padding: 1.5rem; }
}

/* ===== Fullscreen ===== */
#app:fullscreen,
#app:-webkit-full-screen {
    background: #1a1a2e;
}

#app:fullscreen #subtitle-container,
#app:-webkit-full-screen #subtitle-container {
    padding: 2rem 3rem;
}

#app:fullscreen .sentence .original,
#app:-webkit-full-screen .sentence .original {
    font-size: 2.2rem;
}

#app:fullscreen .sentence .translated,
#app:-webkit-full-screen .sentence .translated {
    font-size: 2rem;
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .sentence .original { font-size: 1.1rem; }
    .sentence .translated { font-size: 1.05rem; }
    .sentence { margin-bottom: 0.8rem; }
    .interim { font-size: 1rem; }
    #subtitle-container { padding: 0.6rem; }
}

@media (max-width: 380px) {
    .sentence .original { font-size: 1rem; }
    .sentence .translated { font-size: 0.95rem; }
}

@media (max-height: 500px) and (orientation: landscape) {
    .sentence .original { font-size: 1rem; }
    .sentence .translated { font-size: 0.95rem; }
    .sentence { margin-bottom: 0.5rem; }
    #subtitle-container { padding: 0.5rem 0.8rem; }
}

@media (min-width: 1200px) {
    #subtitle-container { padding: 2rem 4rem; }
    .sentence .original { font-size: 1.6rem; }
    .sentence .translated { font-size: 1.5rem; }
}
