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

/* Hamburger Menu */
.hamburger-menu {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #333;
    border-radius: 8px;
    width: 50px;
    height: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 10px;
}

.hamburger-menu:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.hamburger-menu span {
    display: block;
    width: 25px;
    height: 3px;
    background: #333;
    margin: 3px 0;
    transition: all 0.3s ease;
    border-radius: 2px;
}

.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

.hamburger-menu.hidden {
    display: none !important;
}

/* Sidebar Menu */
.sidebar-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    transition: left 0.3s ease;
    z-index: 999;
    overflow-y: auto;
}

.sidebar-menu.active {
    left: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.sidebar-header h2 {
    color: #333;
    font-size: 1.5em;
    transition: color 0.3s ease;
}

.sidebar-header h2:hover {
    color: #1a237e;
}

.sidebar-close {
    background: none;
    border: none;
    font-size: 32px;
    color: #333;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    transition: all 0.2s ease;
}

.sidebar-close:hover {
    background: #f0f0f0;
    color: #000;
}

.sidebar-content {
    padding: 20px;
}

.menu-items {
    list-style: none;
    margin-bottom: 30px;
}

.menu-items li {
    margin-bottom: 15px;
}

.menu-items a {
    display: block;
    padding: 12px 15px;
    color: #333;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 1.1em;
}

.menu-items a:hover {
    background: #f0f0f0;
    color: #000;
}

.menu-item-with-sub {
    margin-bottom: 10px;
}

.menu-item-with-sub>a {
    font-weight: 600;
}

.sub-menu {
    list-style: none;
    margin-top: 8px;
    margin-left: 20px;
    padding-left: 0;
}

.sub-menu li {
    margin-bottom: 8px;
}

.sub-menu a {
    font-size: 0.9em;
    color: #666;
    padding: 8px 15px;
    font-weight: normal;
}

.sub-menu a:hover {
    background: #f0f0f0;
    color: #333;
}

/* Social Icons - Top Right */
.social-icons-top-right {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    gap: 12px;
    align-items: center;
}

.social-icons-top-right .social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: #1a237e;
    text-decoration: none;
    transition: all 0.3s ease;
    border: 2px solid #1a237e;
    backdrop-filter: blur(10px);
}

.social-icons-top-right .social-icon:hover {
    background: #1a237e;
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(26, 35, 126, 0.4);
}

.social-icons-top-right .social-icon svg {
    width: 22px;
    height: 22px;
}

/* Menu Overlay */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 998;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: white;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    color: #333;
}

/* Split view: when lyrics open, full viewport and each pane scrolls independently */
.split-view {
    display: flex;
    flex-direction: row;
    width: 100%;
    min-height: 100vh;
    overflow: hidden;
}

.split-view.lyrics-open {
    height: 100vh;
    max-height: 100vh;
}

/* Main pane: own scroll, does not affect lyrics pane */
.split-view-main-pane {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.split-view-divider {
    display: none;
    flex-shrink: 0;
    width: 6px;
    height: auto;
    background: #e0e0e0;
    cursor: col-resize;
    transition: background 0.2s;
}

.split-view-divider:hover {
    background: #333;
}

.split-view.lyrics-open .split-view-divider {
    display: block;
}

/* Lyrics pane: own scroll, does not affect main pane */
.split-view-lyrics-pane {
    flex-shrink: 0;
    width: 0;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-left: none;
    transition: width 0.25s ease, min-width 0.25s ease, height 0.25s ease;
}

.split-view.lyrics-open .split-view-lyrics-pane {
    width: var(--lyrics-pane-width, 420px);
    min-width: 280px;
    max-width: 90vw;
    overflow: hidden;
    border-left: 1px solid #e0e0e0;
}

/* Mobile: vertical split – top = main page, bottom = 我的歌詞 */
@media screen and (max-width: 768px) {
    .split-view {
        flex-direction: column;
    }

    .split-view-main-pane {
        min-height: 0;
    }

    .split-view-divider {
        width: 100%;
        height: 6px;
        cursor: row-resize;
    }

    .split-view-lyrics-pane {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        height: 0;
        min-height: 0;
        border-left: none;
        border-top: none;
    }

    .split-view.lyrics-open .split-view-lyrics-pane {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        height: var(--lyrics-pane-height, 50vh);
        min-height: 200px;
        max-height: 85vh;
        border-top: 1px solid #e0e0e0;
    }
}

/* Lyrics pane inner: header/footer fixed; only body scrolls (close stays visible) */
.split-view-lyrics-pane .lyrics-pane-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    overflow-x: hidden;
    background: #fff;
}

.split-view-lyrics-pane .lyrics-panel-body {
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.split-view-lyrics-pane .lyrics-panel-header {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #fff;
}

.split-view-lyrics-pane .lyrics-panel-resize-height {
    display: none !important;
}

.container {
    max-width: 100%;
    margin: 0;
    background: white;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
}

header {
    background: white;
    color: #333;
    padding-top: 100px;
    text-align: center;
    position: relative;
    width: 100%;
    height: 60vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    overflow: hidden;
}

.hero-image {
    width: 70vw;
    height: 60vh;
    display: block;
    margin: 0;
    border-radius: 0;
    z-index: 1;
    padding: 50px;
    pointer-events: none;
    object-fit: contain;
}

.hero-image-container {
    text-align: center;
    padding: 50px;
}

/* 0243 / 主題詞語 / home full-song: when results are visible, show hero icon next to the input bar */
body.results-visible-0243 header,
body.results-visible-topic header,
body.results-visible-fullsong header {
    height: auto;
    min-height: 0;
    padding: 0;
    padding-top: 0;
    position: static;
    /* allow hero to be positioned independently */
    background: transparent;
    border: none;
}

body.results-visible-0243 .hero-image-container,
body.results-visible-topic .hero-image-container,
body.results-visible-fullsong .hero-image-container {
    padding: 0;
    margin: 0;
    position: relative;
    /* now flows inline next to input */
    top: auto;
    left: auto;
    flex: 0 0 auto;
    cursor: pointer;
    user-select: none;
    max-height: 60px;
    overflow: hidden;
    transition:
        opacity 0.25s ease,
        transform 0.25s ease,
        max-height 0.25s ease;
}

body.results-visible-0243 .hero-image,
body.results-visible-topic .hero-image,
body.results-visible-fullsong .hero-image {
    width: 44px;
    height: 44px;
    max-width: none;
    max-height: none;
    padding: 0;
    border-radius: 10px;
    pointer-events: auto;
    object-fit: contain;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
    background: #fff;
    transition:
        opacity 0.25s ease,
        transform 0.25s ease;
}

/* Input bar pinned to the top row, to the right of the hero icon */
body.results-visible-0243 .input-section,
body.results-visible-topic .input-section,
body.results-visible-fullsong .input-section {
    padding: 0;
    position: sticky;
    top: 80px;
    /* align with hero icon under navbar */
    z-index: 300;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

body.results-visible-0243 .input-section .input-group,
body.results-visible-topic .input-section .input-group,
body.results-visible-fullsong .input-section .input-group {
    width: 100%;
    max-width: min(720px, 100vw - 40px);
    margin: 0 auto;
}

/* In 主題詞語 mode, show a label to the left of the input box */
body.results-visible-topic .input-section .input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}


body.results-visible-topic .input-section .input-wrapper {
    flex: 1 1 auto;
}

/* When scrolled down in 0243 / 主題詞語 mode, fade/collapse the hero icon */
body.hero-collapsed-0243 .hero-image-container {
    opacity: 0;
    transform: translateY(-8px);
    max-height: 0;
    pointer-events: none;
}

body.hero-collapsed-0243 .hero-image {
    opacity: 0;
    transform: scale(0.9);
}

/* Give results a little breathing room below the sticky input */
body.results-visible-0243 .results-section,
body.results-visible-topic .results-section,
body.results-visible-fullsong .results-section {
    padding-top: 22px;
}

/*
 * Home full song: scroll the main pane only — no max-height box inside results
 * (avoids double scroll and “trapped” lyrics).
 */
body.results-visible-fullsong .results-section {
    max-height: none;
    overflow: visible;
    -webkit-overflow-scrolling: auto;
}

/*
 * Lock the split view to the viewport when full-song results are showing (all breakpoints).
 * Otherwise .split-view grows with content, #mainPane never gets a bounded height, and
 * overflow-y:auto on .split-view-main-pane does nothing — the page feels “not scrollable”.
 */
body.results-visible-fullsong .split-view:not(.lyrics-open) {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

body.results-visible-fullsong .split-view:not(.lyrics-open) .split-view-main-pane {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

body.results-visible-fullsong .container {
    display: flex;
    flex-direction: column;
    min-height: min-content;
    overflow-x: hidden;
    overflow-y: visible;
}

/* Lyrics panel open: split is already viewport-tall — keep main pane as the scrollport */
body.results-visible-fullsong .split-view.lyrics-open .split-view-main-pane {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/*
 * 主題詞語 picker + results: lock split view to the viewport so #mainPane scrolls
 * (same issue as full-song — otherwise content grows and the pane never becomes a scrollport).
 */
body.topic-page .split-view:not(.lyrics-open),
body.results-visible-topic .split-view:not(.lyrics-open) {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

body.topic-page .split-view:not(.lyrics-open) .split-view-main-pane,
body.results-visible-topic .split-view:not(.lyrics-open) .split-view-main-pane {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

body.topic-page .container,
body.results-visible-topic .container {
    display: flex;
    flex-direction: column;
    min-height: min-content;
    overflow-x: hidden;
    overflow-y: visible;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
    position: relative;
    z-index: 10;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.3);
    padding: 20px 40px;
    border-radius: 10px;
}

.subtitle {
    font-size: 1.1em;
    color: white;
    position: relative;
    z-index: 10;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 5px;
}

.input-section {
    padding: 0;
    background: white;
    position: relative;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.input-group {
    margin-bottom: 25px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 1.1em;
}

.input-group {
    width: 100%;
}

.input-wrapper {
    position: relative;
    width: 100%;
}

.input-group input {
    width: 100%;
    padding: 15px 50px 15px 15px;
    font-size: 1.2em;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    transition: all 0.3s ease;
    font-family: 'Courier New', monospace;
    text-align: center;
}

.send-icon-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: color 0.3s ease, background 0.3s ease;
    width: auto;
    border-radius: 50%;
}

.send-icon-btn:hover {
    color: white;
    background: rgba(0, 0, 0, 0.05);
}

.send-icon-btn:active {
    opacity: 0.8;
}

.send-icon-btn svg {
    width: 20px;
    height: 20px;
}

.input-group input:focus {
    outline: none;
    border-color: #333;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.input-group input.chatbot-mode {
    text-align: left;
    padding-left: 15px;
}

.input-group input.topic-mode {
    text-align: center;
    padding-left: 15px;
}

.input-group input.home-phrase-mode {
    text-align: left;
    padding-left: 15px;
    font-family: inherit;
}

.send-icon-btn:disabled,
.send-icon-btn.is-loading {
    cursor: wait;
    opacity: 0.55;
    pointer-events: none;
}

.full-song-result .full-song-lyrics {
    margin: 0;
    padding: 18px 20px;
    background: #f8f8f8;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    font-size: 1.05em;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    color: #222;
}

.full-song-copy-row {
    margin-top: 14px;
}

.hint {
    display: block;
    margin-top: 8px;
    color: #666;
    font-size: 0.9em;
}

.inspiration-lines {
    text-align: center;
    margin: 20px 0;
}

.inspiration-lines p {
    margin: 10px 0;
    color: #333;
    font-size: 1em;
    line-height: 1.6;
}

/* Topic Buttons */
.topic-buttons-container {
    margin: 30px 0;
    width: 100%;
}

.topic-buttons-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 16px 12px;
    max-width: 1400px;
    margin: 0 auto;
}

/* 主題詞語結果：兩個詞與選題同風格，2×2／每行 2 個 */
.topic-buttons-grid.topic-buttons-grid--results {
    grid-template-columns: repeat(2, 1fr);
    max-width: 520px;
}

.topic-btn.topic-btn--result-word {
    cursor: pointer;
    pointer-events: auto;
    min-height: 100px;
    justify-content: center;
}

.topic-btn.topic-btn--result-word.result-word-copy-active {
    border-color: #1a7f37;
    box-shadow: 0 0 0 2px rgba(26, 127, 55, 0.35);
    background: #f3faf5;
}

.topic-btn.topic-btn--result-word .topic-label {
    font-size: 1.35em;
}

.topic-words-result .pattern-header h3 {
    font-size: 1.15em;
}

.topic-btn {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 14px;
    padding: 18px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
    min-height: 88px;
    justify-content: center;
}

.topic-btn:hover {
    border-color: #333;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.topic-btn:active {
    transform: translateY(0);
}

.topic-label {
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
}

button {
    background: #333;
    color: white;
    border: 2px solid #333;
    padding: 15px 40px;
    font-size: 1.1em;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

button:hover:not(:disabled) {
    background: #555;
    border-color: #555;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

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

.error-message {
    background: #fee;
    color: #c33;
    padding: 15px 40px;
    border-left: 4px solid #c33;
    margin: 0 40px 20px;
    border-radius: 5px;
}

/* Home page: DeepSeek full-song loading hint */
.home-lyrics-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0 40px 20px;
    padding: 14px 20px;
    background: #f0f4ff;
    color: #1a237e;
    border: 1px solid #c5cae9;
    border-radius: 10px;
    font-size: 1.05em;
    font-weight: 600;
    line-height: 1.4;
}

.home-lyrics-loading-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #c5cae9;
    border-top-color: #1a237e;
    border-radius: 50%;
    flex-shrink: 0;
    animation: home-lyrics-spin 0.75s linear infinite;
}

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

.home-lyrics-loading-text {
    text-align: center;
}

@media screen and (max-width: 768px) {

    .home-lyrics-loading {
        margin-left: 16px;
        margin-right: 16px;
        flex-wrap: wrap;
    }
}

/* Clipboard toast (0243 / 主題詞語 result boxes) */
.copy-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    max-width: min(92vw, 420px);
    padding: 14px 20px;
    border-radius: 12px;
    background: #1a1a1a;
    color: #fff;
    font-size: 0.95em;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
    z-index: 10050;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.copy-toast.copy-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.copy-toast.copy-toast--error {
    background: #5c1f1f;
}

.results-section {
    padding: 40px;
    /* Allow long 0243 results to scroll independently of the page/body */
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.result-header h2 {
    color: #333;
    font-size: 2em;
}

.header-buttons {
    display: flex;
    gap: 10px;
}

.copy-btn {
    width: auto;
    padding: 10px 20px;
    font-size: 0.9em;
    background: #333;
    border: 2px solid #333;
}

.copy-btn:hover:not(:disabled) {
    background: #555;
    border-color: #555;
}

.regenerate-btn {
    width: auto;
    padding: 10px 20px;
    font-size: 0.9em;
    background: #333;
    color: white;
    border: 2px solid #333;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.regenerate-btn:hover:not(:disabled) {
    background: #555;
    border-color: #555;
}

.regenerate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.input-info {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    border: 1px solid #e0e0e0;
}

.input-info h3 {
    margin-bottom: 10px;
    color: #333;
}

.input-info code {
    background: #f0f0f0;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 1.2em;
    color: #333;
}

.patterns-section {
    margin-bottom: 30px;
}

.patterns-section h3 {
    margin-bottom: 15px;
    color: #333;
}

.patterns-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.pattern-tag {
    background: #333;
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 500;
}

.lyrics-section h3 {
    margin-bottom: 20px;
    color: #333;
}

.count-badge {
    font-size: 0.6em;
    font-weight: normal;
    color: #333;
    background: #f0f0f0;
    padding: 4px 10px;
    border-radius: 12px;
    margin-left: 10px;
}

.results-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 20px;
}

.phrase-box {
    display: inline-flex;
    flex-direction: column;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px 20px;
    min-width: 180px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: relative;
}

.phrase-box.invalid-tone {
    border-color: #dc3545;
    background: #fff5f5;
}

.phrase-box:hover {
    border-color: #333;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.phrase-box.invalid-tone:hover {
    border-color: #dc3545;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.2);
}

.phrase-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    z-index: 10;
}

.delete-phrase-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: #dc3545;
    color: white;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 0;
}

.phrase-box:hover .delete-phrase-btn {
    opacity: 1;
}

.delete-phrase-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

.delete-phrase-btn:active {
    transform: scale(0.95);
}

.phrase-word {
    font-size: 1.4em;
    font-weight: 600;
    color: #333;
    text-align: center;
    margin-bottom: 10px;
    line-height: 1.3;
}

.phrase-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.tone-badge {
    background: #333;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 500;
}

.tone-badge.invalid-tone-badge {
    background: #dc3545;
}

.invalid-indicator {
    color: #dc3545;
    font-size: 0.75em;
    font-weight: 600;
    margin-top: 4px;
}


.validation-badge {
    font-size: 0.7em;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    margin-left: 10px;
}

.validation-badge.valid {
    background: #d4edda;
    color: #155724;
}

.validation-badge.invalid {
    background: #f8d7da;
    color: #721c24;
}

.delete-btn {
    width: auto;
    padding: 10px 20px;
    font-size: 0.9em;
    background: #333;
    color: white;
    border: 2px solid #333;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.delete-btn:hover:not(:disabled) {
    background: #555;
    border-color: #555;
}

.delete-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 15px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

.btn-secondary.btn-danger-outline {
    color: #b71c1c;
    border: 2px solid #e57373;
    background: #fff;
}

.btn-secondary.btn-danger-outline:hover {
    background: #ffebee;
    border-color: #c62828;
    color: #b71c1c;
}

/* My Lyrics Sliding Panel Styles */
.lyrics-slide-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1001;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    --my-lyrics-panel-width: 420px;
}

.lyrics-slide-panel.active {
    opacity: 1;
    /* Keep panel container non-blocking so overlay area passes clicks/scroll to page */
    pointer-events: none;
}

/* Only the panel content and resize handle receive clicks; overlay area stays click-through */
.lyrics-slide-panel.active .lyrics-panel-content,
.lyrics-slide-panel.active .lyrics-panel-resize-width {
    pointer-events: auto;
}

/* Overlay: very subtle tint, never blocks – user can scroll and click 0243 / main page */
.lyrics-slide-panel .lyrics-panel-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.08);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.lyrics-slide-panel.active .lyrics-panel-overlay {
    opacity: 1;
}

/* Desktop: resizable width, panel on right */
.lyrics-panel-content {
    position: absolute;
    background: white;
    box-shadow: -2px 0 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 500px;
    right: -100%;
    top: 0;
    bottom: auto;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --my-lyrics-panel-width: 420px;
}

@media screen and (min-width: 769px) {
    .lyrics-panel-content {
        width: var(--my-lyrics-panel-width);
        max-width: 90vw;
    }
}

.lyrics-slide-panel.active .lyrics-panel-content {
    right: 0;
}

/* Desktop: width resize handle (left edge of panel) */
.lyrics-panel-resize-width {
    display: none;
    position: absolute;
    right: var(--my-lyrics-panel-width);
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    z-index: 11;
    background: transparent;
}

@media screen and (min-width: 769px) {
    .lyrics-slide-panel.active .lyrics-panel-resize-width {
        display: block;
    }

    .lyrics-panel-resize-width:hover,
    .lyrics-panel-resize-width:active {
        background: rgba(0, 0, 0, 0.06);
    }

    .lyrics-panel-resize-width::after {
        content: '';
        position: absolute;
        left: 3px;
        top: 50%;
        transform: translateY(-50%);
        width: 2px;
        height: 40px;
        background: #ccc;
        border-radius: 1px;
    }
}

/* Mobile: height resize handle (top bar) */
.lyrics-panel-resize-height {
    display: none;
    flex-shrink: 0;
    height: 24px;
    cursor: row-resize;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    border-bottom: 1px solid #e0e0e0;
    touch-action: none;
}

.lyrics-panel-resize-height .lyrics-resize-height-bar {
    width: 40px;
    height: 4px;
    background: #bbb;
    border-radius: 2px;
}

@media screen and (max-width: 768px) {
    .lyrics-panel-resize-height {
        display: flex;
    }
}

.lyrics-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid #e0e0e0;
    flex-shrink: 0;
}

.lyrics-panel-header h2 {
    margin: 0;
    color: #333;
    font-size: 1.5em;
}

.lyrics-panel-close {
    background: none;
    border: none;
    font-size: 32px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    transition: all 0.2s ease;
}

.lyrics-panel-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* 我的歌詞：文字「關閉」按鈕（與登入／收件匣的 × 區分） */
.lyrics-panel-close--labeled {
    font-size: 1rem;
    font-weight: 600;
    width: auto;
    min-height: 40px;
    padding: 8px 14px;
    color: #333;
    border: 2px solid #e0e0e0;
    background: #fafafa;
}

.lyrics-panel-close--labeled:hover {
    background: #eee;
    border-color: #ccc;
}

.lyrics-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    display: flex;
    flex-direction: column;
}

.lyrics-panel-footer {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px 25px;
    border-top: 2px solid #e0e0e0;
    flex-shrink: 0;
}

/* 我的歌詞底部：2×2（刪除｜錄音 / 儲存｜關閉） */
.lyrics-panel-footer--actions-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    justify-content: stretch;
}

.lyrics-panel-footer--actions-grid .btn-primary,
.lyrics-panel-footer--actions-grid .btn-secondary,
.lyrics-panel-footer--actions-grid .lyrics-panel-close--labeled {
    width: 100%;
    box-sizing: border-box;
}

.my-lyrics-audio-section {
    padding: 0 25px 12px;
    flex-shrink: 0;
}

.my-lyrics-recording-status {
    font-size: 0.95em;
    color: #c62828;
    margin-bottom: 8px;
}

.my-lyrics-recording-status.is-idle-hint {
    color: #666;
}

.my-lyrics-audio-player-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.my-lyrics-audio-el {
    flex: 1;
    min-width: 200px;
    max-width: 100%;
    height: 40px;
}

.btn-small {
    padding: 8px 14px;
    font-size: 0.9em;
}

.lyrics-textarea {
    width: 100%;
    flex: 1;
    min-height: 300px;
    padding: 20px;
    font-size: 1.1em;
    line-height: 1.8;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    resize: none;
    transition: border-color 0.3s ease;
    background: #fafafa;
    color: #333;
}

.lyrics-textarea:focus {
    outline: none;
    border-color: #333;
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.lyrics-textarea::placeholder {
    color: #999;
    font-style: italic;
}

/* My Lyrics – dropdown at top, full-width editor */
.lyrics-panel-body-with-files {
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

/* Collapsed dropdown: header at top, menu opens below */
.lyrics-file-dropdown {
    flex-shrink: 0;
    position: relative;
    border-bottom: 2px solid #e0e0e0;
    background: #f8f8f8;
}

.lyrics-file-dropdown-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: none;
    background: #f8f8f8;
    font-size: 1em;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}

.lyrics-file-dropdown-header:hover {
    background: #eee;
}

.lyrics-file-dropdown-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lyrics-file-dropdown-chevron {
    flex-shrink: 0;
    margin-left: 8px;
    font-size: 0.75em;
    color: #666;
    transition: transform 0.2s ease;
}

.lyrics-file-dropdown.open .lyrics-file-dropdown-chevron {
    transform: rotate(180deg);
}

.lyrics-file-dropdown .lyrics-file-list {
    display: none;
    flex-direction: column;
    max-height: 220px;
    overflow-y: auto;
    border-top: 1px solid #e0e0e0;
    background: #fff;
}

.lyrics-file-dropdown.open .lyrics-file-list {
    display: flex;
}

.lyrics-file-list {
    width: 100%;
    min-width: 0;
}

.lyrics-file-list-ul {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    max-height: 180px;
}

.lyrics-file-list-ul li {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}

.lyrics-file-list-ul li:hover {
    background: #eee;
}

.lyrics-file-list-ul li.active {
    background: #333;
    color: #fff;
}

.btn-add-lyrics {
    margin: 10px;
    padding: 10px;
    border: 2px dashed #ccc;
    border-radius: 8px;
    background: #fff;
    color: #666;
    cursor: pointer;
    font-size: 0.95em;
    transition: border-color 0.2s, color 0.2s;
}

.btn-add-lyrics:hover {
    border-color: #333;
    color: #333;
}

.lyrics-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
    width: 100%;
    min-width: 0;
}

.lyrics-rename-row {
    margin-bottom: 12px;
    flex-shrink: 0;
}

.lyrics-rename-row label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #555;
}

.lyrics-filename-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 1em;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
}

.lyrics-filename-input:focus {
    outline: none;
    border-color: #333;
    background: #fff;
}

.lyrics-panel-body-with-files .lyrics-textarea {
    min-height: 0;
    flex: 1;
    width: 100%;
    box-sizing: border-box;
}

/* Login panel – auth forms */
.login-panel-content .lyrics-panel-body {
    padding: 25px;
}

.auth-state {
    margin-bottom: 1rem;
    display: none;
    /* shown via JS when user is logged in */
}

.auth-user-email {
    margin: 0 0 12px 0;
    font-size: 0.95em;
    color: #333;
    word-break: break-all;
}

.auth-forms {
    width: 100%;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.auth-tab {
    flex: 1;
    padding: 12px 16px;
    background: #f5f5f5;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1em;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.auth-tab:hover {
    background: #eee;
    color: #333;
}

.auth-tab.active {
    background: white;
    color: #333;
    border-bottom-color: #333;
}

.auth-form label {
    display: block;
    margin: 14px 0 6px 0;
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

.auth-form input {
    width: 100%;
    padding: 12px 14px;
    font-size: 1em;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    outline: none;
    border-color: #333;
}

.auth-form button[type="submit"] {
    width: 100%;
    margin-top: 20px;
    padding: 12px;
}

.auth-error {
    margin: 10px 0 0 0;
    font-size: 0.9em;
    color: #c33;
    min-height: 1.4em;
}

/* Forgot password link */
.auth-forgot-row {
    margin-top: 12px;
    margin-bottom: 0;
    text-align: center;
}

.auth-forgot-link {
    display: inline-block;
    font-size: 0.92em;
    font-weight: 500;
    color: #424242;
    text-decoration: none;
    padding: 4px 2px;
    border-bottom: 1px solid rgba(66, 66, 66, 0.35);
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.auth-forgot-link:hover {
    color: #111;
    border-bottom-color: #111;
}

.auth-forgot-link:focus-visible {
    outline: 2px solid #333;
    outline-offset: 3px;
    border-radius: 4px;
}

/* Google sign-in – centered logo + label */
.btn-google {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    border: 1px solid #dadce0;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 1em;
    font-family: inherit;
    line-height: 1.35;
    transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    color: black;
}

.btn-google:hover {
    background: #f8f9fa;
    border-color: #c6c6c6;
    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.15);
}

.btn-google:focus-visible {
    outline: 2px solid #333;
    outline-offset: 2px;
}

.btn-google-inner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
}

.btn-google-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 0;
}

.btn-google-logo svg {
    display: block;
}

.btn-google-text {
    text-align: center;
    flex: 0 1 auto;
}

/* Mobile: Bottom half, resizable height */
@media screen and (max-width: 768px) {
    .lyrics-panel-content {
        max-width: 100%;
        width: 100%;
        right: 0 !important;
        bottom: -100%;
        top: auto;
        height: 50vh;
        max-height: 95vh;
        min-height: 30vh;
        border-radius: 20px 20px 0 0;
        transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1), right 0s 0.4s;
        box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.3);
        --my-lyrics-panel-height: 50vh;
    }

    .lyrics-panel-content {
        height: var(--my-lyrics-panel-height);
    }

    .lyrics-slide-panel.active .lyrics-panel-content {
        bottom: 0;
        right: 0 !important;
        transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .lyrics-panel-header {
        padding: 15px 20px;
    }

    .lyrics-panel-body {
        padding: 20px;
    }

    .lyrics-panel-footer {
        padding: 15px 20px;
    }

    .lyrics-panel-footer:not(.lyrics-panel-footer--actions-grid) {
        flex-direction: column;
    }

    .my-lyrics-audio-section {
        padding: 0 20px 10px;
    }

    .my-lyrics-audio-player-wrap {
        flex-direction: column;
        align-items: stretch;
    }

    .my-lyrics-audio-el {
        min-width: 0;
        width: 100%;
    }
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 2px solid #e0e0e0;
}

.modal-header h2 {
    margin: 0;
    color: #333;
    font-size: 1.5em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.modal-body {
    padding: 30px;
}

.modal-section {
    margin-bottom: 25px;
}

.modal-section label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

.number-input {
    width: 100px;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 1em;
}

.number-input:focus {
    outline: none;
    border-color: #333;
}

.patterns-checkbox-container {
    max-height: 300px;
    overflow-y: auto;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 10px;
}

.pattern-checkbox-item {
    min-width: 80px;
}

.pattern-checkbox-item label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background 0.2s ease;
    margin-bottom: 0;
}

.pattern-checkbox-item label:hover {
    background: #f0f0f0;
}

.pattern-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.pattern-checkbox-label {
    font-weight: 500;
    color: #333;
    font-size: 0.9em;
}

.pattern-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.small-btn {
    padding: 6px 15px;
    font-size: 0.85em;
    background: #333;
    color: white;
    border: 2px solid #333;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.small-btn:hover {
    background: #555;
    border-color: #555;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 30px;
    border-top: 2px solid #e0e0e0;
}

.btn-secondary {
    padding: 10px 20px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s ease;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-primary {
    padding: 10px 20px;
    background: #333;
    color: white;
    border: 2px solid #333;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s ease;
}

.btn-primary:hover {
    background: #555;
    border-color: #555;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Load More Button */
.load-more-container {
    text-align: center;
    margin: 30px 0;
    padding: 20px;
}

.load-more-btn {
    padding: 12px 30px;
    background: #333;
    color: white;
    border: 2px solid #333;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.load-more-btn:hover {
    background: #555;
    border-color: #555;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

.load-more-btn:active {
    transform: translateY(0);
}

.jyutping-badge {
    background: #f0f0f0;
    color: #666;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.85em;
    font-family: 'Courier New', monospace;
}

/* Pattern Group and Results Display */
.pattern-group {
    margin-bottom: 40px;
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.pattern-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.pattern-header h3 {
    color: #333;
    font-size: 1.3em;
    font-weight: 600;
    margin: 0;
}

.pattern-mapping-hint {
    color: #666;
    font-size: 0.9em;
    margin: 8px 0 0;
}

.phrases-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

/* 0243 page: keep desktop auto-fill behavior; on mobile show fixed 5×# grid */
.phrases-list.phrases-list--0243 .phrase-box {
    min-width: 0;
    padding: 12px 10px;
    cursor: pointer;
}

.phrases-list.phrases-list--0243 .phrase-box.result-word-copy-active {
    border-color: #1a7f37;
    box-shadow: 0 0 0 2px rgba(26, 127, 55, 0.35);
    background: #f3faf5;
}

.phrases-list.phrases-list--0243 .phrase-word {
    margin-bottom: 0;
    font-size: 1.15em;
}

@media screen and (max-width: 768px) {
    .phrases-list.phrases-list--0243 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 8px;
    }
}

@media screen and (max-width: 480px) {
    .phrases-list.phrases-list--0243 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 6px;
    }
}

/* 0243 mobile: full-bleed pattern groups; phrase cells row layout (not column flex) */
@media screen and (max-width: 768px) {

    /*
     * Without a fixed-height split view, #mainPane grows with content and overflow-y:auto
     * never creates a scrollport — scroll falls through to the document, which often fails
     * on mobile Safari. Match the lyrics-open pattern: viewport-tall split view + main pane scrolls.
     */
    /* Full-song: viewport lock is global (all widths); 0243 still needs it here on small screens. */
    body.results-visible-0243 .split-view:not(.lyrics-open) {
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }

    body.results-visible-0243 .split-view:not(.lyrics-open) .split-view-main-pane {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    /* Fill viewport so there is no empty white band below the results (short lists). */
    body.results-visible-0243 .container,
    body.topic-page .container,
    body.results-visible-topic .container {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        min-height: 100dvh;
        /* Override global .container overflow:hidden — it clips tall results and breaks scroll. */
        overflow-x: hidden;
        overflow-y: visible;
    }

    body.results-visible-fullsong .container {
        min-height: 100vh;
        min-height: 100dvh;
        /* Space below lyrics + copy row; clear home indicator / safe area */
        padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    }

    body.results-visible-0243 .container>header,
    body.results-visible-0243 .container>.input-section,
    body.results-visible-0243 .container>#errorMessage,
    body.topic-page .container>header,
    body.topic-page .container>.input-section,
    body.topic-page .container>#errorMessage,
    body.results-visible-topic .container>header,
    body.results-visible-topic .container>.input-section,
    body.results-visible-topic .container>#errorMessage,
    body.results-visible-fullsong .container>header,
    body.results-visible-fullsong .container>.input-section,
    body.results-visible-fullsong .container>#errorMessage,
    body.results-visible-fullsong .container>#homeLyricsLoading {
        flex-shrink: 0;
    }

    body.results-visible-0243 .results-section,
    body.results-visible-topic .results-section,
    body.results-visible-fullsong .results-section {
        padding-left: 2px;
        padding-right: 2px;
        padding-bottom: 0;
        flex: 1 1 auto;
        /* min-height:0 let the flex item shrink below its content — clipped + no usable scroll on mobile. */
        min-height: min-content;
        max-height: none;
        overflow-x: hidden;
        overflow-y: visible;
    }

    body.results-visible-0243 .pattern-group:last-child,
    body.results-visible-fullsong .pattern-group:last-child {
        margin-bottom: 0;
    }

    body.results-visible-0243 .result-header,
    body.results-visible-fullsong .result-header {
        padding-left: 16px;
        padding-right: 16px;
    }

    body.results-visible-0243 .pattern-group,
    body.results-visible-fullsong .pattern-group {
        padding: 0;
        width: 100%;
        max-width: none;
        border-radius: 0;
    }

    body.results-visible-0243 .pattern-header,
    body.results-visible-fullsong .pattern-header {
        padding-left: 16px;
        padding-right: 16px;
    }

    .phrases-list.phrases-list--0243 .phrase-box {
        flex-direction: row;
        align-items: center;
        justify-content: center;
    }

    .phrases-list.phrases-list--0243 .phrase-word {
        margin-bottom: 0;
    }
}

.no-results {
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.json-output {
    padding: 40px;
    background: white;
    color: #333;
    border-top: 2px solid #e0e0e0;
    transition: all 0.3s ease;
}

.json-output.collapsed pre {
    display: none;
}

.json-output h3 {
    color: #333;
    margin-bottom: 15px;
}

.json-output pre {
    background: #f8f8f8;
    padding: 20px;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 0.9em;
    line-height: 1.5;
    border: 1px solid #e0e0e0;
    color: #333;
}

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    body.sidebar-open .social-icons-top-right {
        display: none;
    }

    header {
        height: auto;
        min-height: 40vh;
        max-height: 50vh;
        padding: 20px 15px;
    }

    /* Home / 0243 / topic results: hero moved out — no tall empty header band */
    body.results-visible-fullsong header,
    body.results-visible-0243 header,
    body.results-visible-topic header {
        min-height: 0;
        max-height: none;
        padding-top: 0;
        padding-bottom: 0;
    }

    .hero-image {
        padding: 20px 10px;
        max-height: 100%;
        object-fit: contain;
    }

    .input-section {
        padding: 0;
    }

    .input-group input {
        padding: 12px 45px 12px 12px;
        font-size: 1em;
    }

    .send-icon-btn {
        right: 8px;
        padding: 6px;
    }

    .send-icon-btn svg {
        width: 18px;
        height: 18px;
    }

    button {
        padding: 12px 30px;
        font-size: 1em;
    }

    .inspiration-lines {
        margin: 15px 0;
    }

    .inspiration-lines p {
        font-size: 0.9em;
        margin: 8px 0;
    }

    .inspiration-lines .text-en,
    .inspiration-lines .text-zh {
        display: block;
    }

    .inspiration-lines .text-zh {
        margin-top: 4px;
    }

    /* Topic picker: 8 per row on tablet / mobile; results grid stays 2 cols via .topic-buttons-grid--results */
    .topic-buttons-container .topic-buttons-grid:not(.topic-buttons-grid--results) {
        grid-template-columns: repeat(8, 1fr);
        gap: 10px 6px;
    }

    .topic-buttons-container .topic-buttons-grid:not(.topic-buttons-grid--results) .topic-btn {
        min-height: 56px;
        padding: 8px 4px;
    }

    .topic-buttons-container .topic-buttons-grid:not(.topic-buttons-grid--results) .topic-label {
        font-size: 0.8em;
    }
}

@media screen and (max-width: 480px) {
    header {
        min-height: 30vh;
        max-height: 40vh;
        padding: 15px 10px;
        padding-top: 100px;
    }

    body.results-visible-fullsong header,
    body.results-visible-0243 header,
    body.results-visible-topic header {
        min-height: 0;
        max-height: none;
        padding: 0;
    }

    .hero-image {
        padding: 15px 5px;
    }

    .input-section {
        padding: 0;
    }

    .input-group input {
        padding: 10px 40px 10px 10px;
        font-size: 0.95em;
    }

    .send-icon-btn {
        right: 6px;
        padding: 5px;
    }

    .send-icon-btn svg {
        width: 16px;
        height: 16px;
    }

    button {
        padding: 10px 25px;
        font-size: 0.95em;
    }

    /* Topic picker: 8 per row on small phones */
    .topic-buttons-container .topic-buttons-grid:not(.topic-buttons-grid--results) {
        grid-template-columns: repeat(8, 1fr);
        gap: 6px 3px;
    }

    .topic-buttons-container .topic-buttons-grid:not(.topic-buttons-grid--results) .topic-btn {
        min-height: 48px;
        padding: 6px 2px;
    }

    .topic-buttons-container .topic-buttons-grid:not(.topic-buttons-grid--results) .topic-label {
        font-size: 0.68em;
    }
}

/* My Lyrics - Admin Remark */
.my-lyrics-remark {
    flex-shrink: 0;
    margin: 18px 25px 10px 25px;
    padding: 12px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: #fafafa;
}

.my-lyrics-remark-title {
    font-weight: 700;
    color: #333;
    margin-bottom: 6px;
}

.my-lyrics-remark-sub {
    margin: 0 0 10px;
    font-size: 0.88em;
    color: #555;
    line-height: 1.45;
}

.my-lyrics-remark-text {
    white-space: pre-wrap;
    color: #333;
    line-height: 1.6;
    font-size: 1em;
    max-height: min(42vh, 320px);
    overflow-y: auto;
}

/* Inbox — all admin remarks for the signed-in user */
.inbox-intro {
    margin: 0 0 14px;
    font-size: 0.9em;
    color: #555;
    line-height: 1.5;
}

.inbox-remarks-content {
    white-space: pre-wrap;
    color: #333;
    line-height: 1.6;
    font-size: 0.95em;
    padding: 12px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: #fafafa;
    max-height: min(55vh, 420px);
    overflow-y: auto;
}

/* Admin page — dashboard */
.admin-body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(165deg, #eef2f7 0%, #e4e9f2 45%, #f5f7fb 100%);
    color: #1a1a1a;
}

.admin-page {
    max-width: 1680px;
    margin: 0 auto;
    padding: 24px 20px 64px;
    box-sizing: border-box;
}

.admin-top-nav {
    margin-bottom: 16px;
}

.admin-back-home {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #334155;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.admin-back-home:hover {
    color: #0f172a;
    background: #fff;
    border-color: rgba(15, 23, 42, 0.12);
}

.admin-card {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    padding: 28px 22px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
    margin-bottom: 5px;
}

.admin-auth-session {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.admin-auth-session .admin-user-email {
    max-width: min(100%, 260px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-btn-logout {
    border-radius: 10px;
}

.admin-auth-card {
    max-width: 480px;
    margin: 0 auto;
}

.admin-auth-card__title {
    margin: 0 0 8px;
    font-size: 1.25rem;
}

.admin-auth-card__lead {
    margin: 0 0 20px;
    color: #64748b;
    font-size: 0.95rem;
    line-height: 1.5;
}

.admin-auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-auth-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
}

.admin-auth-form__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.admin-dashboard {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.admin-dashboard__settings-summary,
.admin-dashboard__settings summary {
    cursor: pointer;
    font-weight: 600;
    color: #374151;
    list-style: none;
    padding: 2px 0;
}

.admin-dashboard__settings summary::-webkit-details-marker {
    display: none;
}

.admin-dashboard__settings summary::before {
    content: '▸ ';
    display: inline-block;
    transition: transform 0.15s ease;
    color: #94a3b8;
}

.admin-dashboard__settings[open] summary::before {
    transform: rotate(90deg);
}

.admin-dashboard__settings-body {
    padding-top: 16px;
}

.admin-settings-add {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.admin-settings-add .admin-input {
    flex: 1 1 220px;
    min-width: 0;
}

.admin-table-wrap {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}

.admin-dashboard__main-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px 20px;
    margin-bottom: 20px;
}

.admin-dashboard__main-intro {
    flex: 1 1 240px;
    min-width: 0;
}

.admin-dashboard__main-aside {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 12px 16px;
}

.admin-dashboard__session {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.admin-dashboard__session .admin-user-email {
    max-width: min(42vw, 220px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-dashboard__heading {
    margin: 0 0 6px;
    font-size: 1.65rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.admin-dashboard__lead {
    margin: 0;
    font-size: 0.92rem;
    color: #64748b;
    max-width: 52ch;
    line-height: 1.45;
}

.admin-dashboard__stat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 12px 18px;
    border-radius: 14px;
    background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    min-width: 120px;
}

.admin-dashboard__stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.admin-dashboard__stat-label {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 2px;
}

.admin-dashboard-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 18px;
}

.admin-dashboard-toolbar__search {
    flex: 1 1 240px;
    min-width: 0;
}

.admin-toolbar-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
}

.admin-toolbar-label span {
    white-space: nowrap;
}

.admin-select {
    min-width: 170px;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    color: #1e293b;
    font-size: 0.92rem;
    font-family: inherit;
    cursor: pointer;
}

.admin-lyrics-empty {
    padding: 28px 20px;
    text-align: center;
    color: #64748b;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 14px;
    margin-bottom: 16px;
}

.admin-dashboard-cards-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    padding: 4px 0 8px;
}

.admin-lyric-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin: 0;
    min-height: 148px;
    padding: 16px 16px 14px;
    text-align: left;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    background: #fff;
    cursor: pointer;
    font: inherit;
    color: inherit;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.admin-lyric-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}

.admin-lyric-card--selected {
    border-color: #334155;
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.1);
}

.admin-lyric-card__student {
    font-weight: 700;
    font-size: 0.98rem;
    color: #0f172a;
    line-height: 1.3;
}

.admin-lyric-card__lyric-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #334155;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.admin-lyric-card__meta {
    font-size: 0.78rem;
    color: #64748b;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.admin-lyric-card__time {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

.admin-lyric-preview__head {
    margin-bottom: 14px;
}

.admin-lyric-preview__heading {
    margin: 0 0 6px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #111827;
}

.admin-lyric-preview__meta {
    font-size: 0.88rem;
    color: #475569;
    line-height: 1.55;
    white-space: pre-wrap;
    margin-bottom: 10px;
    padding: 12px 14px;
    background: #f1f5f9;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.admin-lyric-preview__filename {
    font-size: 0.92rem;
    color: #64748b;
    word-break: break-word;
}

.admin-lyric-preview__audio-block {
    margin-bottom: 14px;
}

.admin-lyric-preview__audio-block .admin-detail__label {
    margin-bottom: 8px;
}

.admin-lyric-preview__audio {
    display: block;
    width: 100%;
    max-width: min(100%, 480px);
    margin-top: 4px;
    border-radius: 10px;
}

.admin-lyric-preview__body {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #334155;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    max-height: min(70vh, 560px);
    overflow: auto;
}

.admin-detail__title {
    margin: 0 0 16px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #111827;
}

.admin-detail__empty {
    color: #64748b;
    padding: 24px;
    text-align: center;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px dashed #cbd5e1;
}

.admin-detail__panel {
    margin-top: 4px;
}

.admin-detail__header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.admin-detail__name {
    font-weight: 700;
    font-size: 1.12rem;
    color: #0f172a;
}

.admin-detail__email {
    color: #64748b;
    font-size: 0.92rem;
    margin-top: 4px;
}

.admin-detail__delete {
    border: 1px solid #fca5a5;
    color: #b91c1c;
    border-radius: 10px;
}

.admin-detail__block {
    margin-bottom: 20px;
}

.admin-detail__label {
    font-weight: 700;
    margin-bottom: 8px;
    color: #374151;
}

.admin-detail__remarks {
    white-space: pre-wrap;
    color: #334155;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
    min-height: 72px;
    line-height: 1.55;
}

.admin-detail__remark-add {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-top: 12px;
}

.admin-textarea--remark {
    flex: 1 1 280px;
    min-height: 100px;
    min-width: 0;
}

.admin-detail__files {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}

.admin-detail__file-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.admin-detail__file-editor {
    flex: 1 1 320px;
    min-width: 0;
}

.admin-detail__file-editor-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 8px;
}

.admin-detail__file-editor-label {
    font-weight: 600;
    color: #374151;
}

.admin-detail__file-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 12px;
}

.admin-detail__delete-file {
    border: 1px solid #fca5a5;
    color: #b91c1c;
    border-radius: 10px;
}

.admin-hr {
    height: 1px;
    background: #e5e7eb;
    margin: 16px 0;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.admin-table th,
.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    text-align: left;
    vertical-align: top;
}

.admin-table tr:hover {
    background: #fafbfc;
}

.admin-chip {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #f8fafc;
    font-size: 0.88rem;
    color: #334155;
}

.admin-textarea,
.admin-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    color: #1e293b;
    font-size: 1em;
    box-sizing: border-box;
}

.admin-textarea {
    min-height: 260px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.7;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
}

.admin-badge-warn {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(220, 38, 38, 0.06);
    border: 1px solid rgba(220, 38, 38, 0.2);
    color: #991b1b;
    font-size: 0.88rem;
    margin-top: 10px;
}

@media screen and (max-width: 1400px) {
    .admin-dashboard-cards-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media screen and (max-width: 1100px) {
    .admin-dashboard-cards-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media screen and (max-width: 820px) {
    .admin-dashboard-cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media screen and (max-width: 520px) {
    .admin-dashboard-cards-grid {
        grid-template-columns: 1fr;
    }

    .admin-page {
        padding: 16px 14px 48px;
    }
}