* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Playfair Display", Georgia, serif;
    background: rgb(168, 150, 255);
    color: #1d2433;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

#app {
    overflow-x: hidden;
    max-width: 100vw;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
    background: rgb(125, 99, 255);
    color: #fff;
    flex-wrap: wrap;
}

.topbar h1 {
    flex: 1;
    font-size: 1.25rem;
    margin: 0;
}

.topbar #userBar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar::after {
    content: "";
    flex: 1;
}

/* TTS progress bar (waiting for speech) */
.tts-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 1002;
    background: rgba(168, 150, 255, 0.2);
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.tts-progress-bar.is-active {
    opacity: 1;
}

.tts-progress-bar-inner {
    height: 100%;
    width: 40%;
    background: rgb(125, 99, 255);
    border-radius: 0 2px 2px 0;
    animation: tts-progress-slide 1.2s ease-in-out infinite;
}

@keyframes tts-progress-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* TTS loading: sentence-item becomes a progress bar (left-to-right fill, success green) */
.sentence-item.tts-loading,
.sentence-item.tts-done,
.review-sentence-item.tts-loading,
.review-sentence-item.tts-done {
    position: relative;
    overflow: hidden;
}

.sentence-item.tts-loading::before,
.sentence-item.tts-done::before,
.review-sentence-item.tts-loading::before,
.review-sentence-item.tts-done::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 0;
    background: rgb(86, 214, 122);
    border-radius: 8px;
    pointer-events: none;
}

.sentence-item.tts-loading::before,
.review-sentence-item.tts-loading::before {
    width: 0;
    animation: tts-sentence-fill 2.8s ease-out forwards;
}

.sentence-item.tts-done::before,
.review-sentence-item.tts-done::before {
    width: 100%;
    transition: opacity 0.25s ease-out;
}

.sentence-item.tts-loading .sentence-item-content,
.sentence-item.tts-loading .sentence-item-meta,
.sentence-item.tts-loading .sentence-actions,
.sentence-item.tts-done .sentence-item-content,
.sentence-item.tts-done .sentence-item-meta,
.sentence-item.tts-done .sentence-actions,
.review-sentence-item.tts-loading .review-sentence-main,
.review-sentence-item.tts-done .review-sentence-main {
    position: relative;
    z-index: 1;
}

@keyframes tts-sentence-fill {
    from { width: 0; }
    to { width: 100%; }
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

.grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
}

/* Dashboard: tabs + content panels */
.dashboard {
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 80px);
}

.dashboard-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.dashboard-tab {
    padding: 8px 16px;
    border: 2px solid rgb(125, 99, 255);
    background: #fff;
    color: rgb(125, 99, 255);
    font: inherit;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.dashboard-tab:hover {
    background: rgb(200, 188, 255);
}

.dashboard-tab.active {
    background: rgb(125, 99, 255);
    color: #fff;
}

.dashboard-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* List detail open animation (maximize + fade) */
.dashboard-list-detail {
    opacity: 0;
    transform: scale(0.94);
    transition: opacity 0.35s ease-out, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dashboard-list-detail.list-detail-open {
    opacity: 1;
    transform: scale(1);
}

.dashboard-list-detail .list-search-row {
    margin-top: 8px;
    margin-bottom: 4px;
}

.dashboard-list-detail .list-search-row input {
    flex: 1;
    min-width: 0;
}

/* Borderless soft inputs (new list, search, add sentence) */
.input-soft {
    min-height: 52px;
    padding: 14px 18px;
    font-size: 1.05rem;
    line-height: 1.45;
    border: none;
    border-radius: 12px;
    background: rgb(168, 150, 255);
    color: #1d2433;
    transition: background 0.2s, box-shadow 0.2s;
}

.input-soft::placeholder {
    color: rgba(29, 36, 51, 0.6);
}

.input-soft:hover {
    background: rgb(178, 162, 255);
}

.input-soft:focus {
    outline: none;
    background: #fff;
    box-shadow: 0 0 0 2px rgb(125, 99, 255);
}

/* Modern number input spinner (Settings merge window, etc.) */
input.input-soft[type="number"] {
    appearance: none;
    -moz-appearance: textfield;
}

input.input-soft[type="number"]::-webkit-outer-spin-button,
input.input-soft[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
    background-color: rgb(200, 188, 255);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='16' viewBox='0 0 10 16'%3E%3Cpath fill='%237d63ff' d='M5 2L1 6h8L5 2zm0 12l4-4H1l4 4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 10px 16px;
    width: 32px;
    min-height: 100%;
    border-radius: 0 12px 12px 0;
    cursor: pointer;
    opacity: 1;
    transition: background-color 0.2s ease;
}

input.input-soft[type="number"]::-webkit-inner-spin-button:hover {
    background-color: rgb(178, 162, 255);
}

/* Rounded select (day selection and other .input-soft selects) */
select.input-soft {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237d63ff' d='M2 4l4 4 4-4H2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

.sentence-list {
    transition: none;
}

/* During morph: existing items slide down from above */
.sentence-list.sentence-list-morphing .sentence-item:not(.sentence-item-morph-target) {
    transform: translateY(calc(-1 * var(--morph-item-height, 0)));
    transition: transform 0.45s ease-out;
}

.sentence-list-sentinel {
    min-height: 1px;
    pointer-events: none;
}

.dashboard-list-detail .list-item,
.dashboard-panel .list-item,
.dashboard-list-detail .sentence-item {
    overflow-wrap: break-word;
    word-break: break-word;
}

.mind-map-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    overflow: hidden;
}

.mind-map-section > h3 {
    flex: 0 0 auto;
}

.mind-map-zoom-wrap {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    touch-action: none;
}

.mind-map-zoom-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.mind-map-tabs-controls {
    margin-bottom: 0;
    margin-left: auto;
}

.mind-map-zoom-controls .btn-icon {
    min-width: 36px;
    background: #fff;
    color: #1d2433;
    transition: background 0.2s ease, color 0.2s ease;
}

.mind-map-zoom-controls .btn-icon:active {
    background: #eee;
    color: #1d2433;
}

.mind-map-zoom-label {
    font-size: 0.9rem;
    color: #374151;
    min-width: 3em;
}

.mind-map-section #mindMap {
    flex: 1;
    min-height: 0;
    max-width: 100%;
    width: 100%;
}

/* Fullscreen Mind Map overlay */
#mindMapFullscreenOverlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgb(168, 150, 255);
    display: flex;
    flex-direction: column;
    padding: 12px;
    padding-top: max(12px, env(safe-area-inset-top));
    box-sizing: border-box;
}

#mindMapFullscreenOverlay .mind-map-zoom-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#mindMapFullscreenOverlay #mindMap {
    flex: 1;
    min-height: 0;
    width: 100%;
    height: 100%;
}

#mindMapFullscreenOverlay .mind-map-fullscreen-close {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    right: 12px;
    z-index: 10;
    background: #fff;
    color: #1d2433;
    transition: background 0.2s ease, color 0.2s ease;
}

#mindMapFullscreenOverlay .mind-map-fullscreen-close:active {
    background: #eee;
    color: #1d2433;
}

@media (max-width: 768px) {
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .container {
        padding: 12px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .show-lists-btn {
        display: inline-block;
        margin-bottom: 10px;
    }

    .list-item-main {
        min-height: 44px;
        padding: 4px 0;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .topbar {
        padding: 12px 16px;
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .topbar h1 {
        font-size: 1.1rem;
    }

    input, select {
        min-height: 44px;
        font-size: 16px;
    }

    #useNaturalTtsInput {
        width: 1.25rem;
        height: 1.25rem;
        min-width: 1.25rem;
        min-height: 1.25rem;
        max-width: 1.25rem;
        max-height: 1.25rem;
    }
}

.card {
    background: #fff;
    border-radius: 10px;
    padding: 14px;
    box-shadow: 0 2px 8px rgba(15, 20, 30, 0.08);
}

.pending-review-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    max-height: 300px;
    overflow: hidden;
    transition: transform 0.35s ease-out, opacity 0.35s ease-out, max-height 0.35s ease-out, margin 0.35s ease-out, padding 0.35s ease-out;
}

.pending-review-item.is-completing {
    transform: translateX(100%);
    opacity: 0;
    max-height: 0;
    margin-top: 0;
    margin-bottom: 0;
    padding: 0;
}

.pending-review-info {
    flex: 1;
    min-width: 0;
}

.pending-review-title {
    font-size: 1.25rem;
    line-height: 1.35;
}

.pending-review-meta {
    font-size: 1.05rem;
    color: #586173;
    margin-top: 4px;
}

.pending-review-actions {
    flex: 0 0 30%;
    min-width: 0;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.pending-review-actions button {
    flex: 0 1 auto;
}

@media (max-width: 480px) {
    .pending-review-item {
        flex-direction: column;
        align-items: stretch;
    }
    .pending-review-actions {
        flex: 0 0 auto;
        width: 100%;
        justify-content: center;
    }
}

input, button, select {
    font: inherit;
}

input, select {
    width: 100%;
    padding: 8px;
    margin: 6px 0;
}

button {
    border: none;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    background: rgb(125, 99, 255);
    color: #fff;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
    button {
        min-height: 44px;
        min-width: 44px;
        padding: 10px 14px;
    }
}

button.secondary {
    background: #4d596f;
}

#logoutBtn {
    background: rgb(168, 150, 255);
    transition: background 0.2s ease;
}

#logoutBtn:active {
    background: rgb(125, 99, 255);
}

#saveSettingsBtn {
    transition: background 0.2s ease, transform 0.15s ease;
}

#saveSettingsBtn:active {
    background: rgb(168, 150, 255);
    transform: scale(0.98);
}

/* Settings panel: consistent spacing and centered buttons */
.settings-panel .settings-button-row {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 1rem;
}

.settings-panel .settings-button-row.review-reminders-row {
    margin-top: 0.5rem;
}

.settings-panel .settings-actions {
    margin-top: 1.25rem;
}

.review-reminders-row {
    justify-content: center;
}

#enableReviewRemindersBtn {
    background: rgb(125, 99, 255);
    padding-top: 16px;
    padding-bottom: 16px;
}

#enableReviewRemindersBtn:active {
    background: rgb(168, 150, 255);
}

button.danger {
    background: #bf2f43;
}

.btn-icon {
    padding: 6px 10px;
    font-size: 1rem;
    min-width: 2.5em;
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.sentence-actions .btn-icon,
.list-actions .btn-icon {
    flex: 0 0 auto;
}

.sentence-actions button,
.list-actions button {
    background: rgb(125, 99, 255);
    transition: background 0.2s ease;
}

.sentence-actions button:active,
.list-actions button:active {
    background: rgb(168, 150, 255);
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

li {
    margin: 6px 0;
    padding: 8px;
    border: 1px solid #e2e7f0;
    border-radius: 8px;
}

.sentence-item {
    max-height: 400px;
    overflow: hidden;
    transition: transform 0.35s ease-out, opacity 0.35s ease-out, max-height 0.35s ease-out, margin 0.35s ease-out, padding 0.35s ease-out;
}

.sentence-item.is-completing {
    transform: translateX(100%);
    opacity: 0;
    max-height: 0;
    margin-top: 0;
    margin-bottom: 0;
    padding: 0;
}

.sentence-item.is-adding {
    transform: translateX(-24px);
    opacity: 0;
}

/* Hidden while morph clone is animating from input to list */
.sentence-item.sentence-item-morph-target {
    opacity: 0;
    pointer-events: none;
}

/* Morph clone: flies from add-sentence input to the new list item (no overshoot to avoid overflow) */
.sentence-morph-clone {
    position: fixed;
    z-index: 1001;
    margin: 0;
    padding: 14px 18px;
    font-family: "Playfair Display", Georgia, serif;
    font-size: 1.05rem;
    line-height: 1.45;
    border: none;
    border-radius: 12px;
    background: #fff;
    color: #1d2433;
    box-shadow: 0 0 0 2px rgb(125, 99, 255);
    overflow: hidden;
    pointer-events: none;
    box-sizing: border-box;
    transition: top 0.45s ease-out,
                left 0.45s ease-out,
                width 0.45s ease-out,
                height 0.45s ease-out,
                border-radius 0.45s ease,
                box-shadow 0.45s ease;
}

.sentence-item .sentence-item-content {
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1.45;
}

.sentence-item.selected {
    border-color: rgb(125, 99, 255);
    background: rgb(200, 188, 255);
    box-shadow: 0 0 0 2px rgb(125, 99, 255);
}

.sentence-action-popup-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.3);
    display: none;
}

.sentence-action-popup-backdrop.is-open {
    display: block;
}

/* List action popup: visible first (no is-open), then animate in with is-open */
.list-action-popup-backdrop.is-visible {
    display: block;
}

/* List action popup (Rename / Delete): maximize animation */
.list-action-popup-backdrop .sentence-action-popup.list-action-popup {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease-out;
}

.list-action-popup-backdrop.is-open .sentence-action-popup.list-action-popup {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.sentence-action-popup {
    position: fixed;
    z-index: 1000;
    min-width: 280px;
    max-width: 90vw;
    padding: 16px;
    background: #fff;
    border: 1px solid #dbe1eb;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(31, 59, 102, 0.2);
}

.sentence-action-popup h4 {
    margin: 0 0 12px 0;
    font-size: 1rem;
}

.sentence-action-popup .popup-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}

.sentence-action-popup input[type="text"],
.sentence-action-popup input[type="url"],
.sentence-action-popup input[type="number"],
.sentence-action-popup select,
.sentence-action-popup textarea {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 8px;
    border: 1px solid #dbe1eb;
    border-radius: 6px;
    font-size: 0.95rem;
}

.sentence-action-popup textarea {
    min-height: 60px;
    resize: vertical;
}

.sentence-action-popup label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.sentence-action-popup .move-list-options {
    max-height: 200px;
    overflow-y: auto;
}

.sentence-action-popup .move-list-option {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.95rem;
}

.sentence-action-popup .move-list-option:hover {
    background: rgb(200, 188, 255);
}

.sentence-action-popup .video-links-list {
    list-style: none;
    padding: 0;
    margin: 0 0 12px 0;
    max-height: 200px;
    overflow-y: auto;
}

.sentence-action-popup .video-link-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #e2e7f0;
}

.sentence-action-popup .video-link-item:last-child {
    border-bottom: none;
}

.sentence-action-popup .video-link-open {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: rgb(99, 102, 241);
    text-decoration: none;
}

.sentence-action-popup .video-link-open:hover {
    text-decoration: underline;
}

.sentence-action-popup .video-link-add {
    margin-bottom: 12px;
}

.sentence-action-popup .video-link-add label {
    display: block;
    margin-top: 8px;
    margin-bottom: 2px;
}

.sentence-action-popup .video-link-add input[type="url"],
.sentence-action-popup .video-link-add input[type="number"],
.sentence-action-popup .video-link-add input[type="text"] {
    margin-bottom: 4px;
}

.sentence-action-popup .popup-add-video-link {
    margin-top: 8px;
}

.list-action-popup-backdrop .list-delete-message {
    margin: 0 0 16px 0;
    color: #374151;
    line-height: 1.5;
}

/* Mark reviewed confirm: maximize animation */
.mark-reviewed-confirm-backdrop.is-visible {
    display: block;
}

.mark-reviewed-confirm-backdrop .mark-reviewed-confirm-popup {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease-out;
}

.mark-reviewed-confirm-backdrop.is-open .mark-reviewed-confirm-popup {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.mark-reviewed-confirm-message {
    margin: 0 0 16px 0;
    color: #374151;
    line-height: 1.5;
}

/* Back to dashboard (leave review session): same backdrop, dimmer, and scale/opacity transition as mark-reviewed confirm */
.mark-reviewed-confirm-backdrop .sentence-action-popup.back-to-dashboard-confirm-popup {
    /* Inherits .sentence-action-popup (card, shadow, padding) + .mark-reviewed-confirm-popup animation rules above */
    max-width: min(400px, 92vw);
}

.mark-reviewed-confirm-backdrop .sentence-action-popup.back-to-dashboard-confirm-popup .popup-actions {
    flex-wrap: wrap;
    gap: 10px;
}

.mark-reviewed-confirm-backdrop .sentence-action-popup.back-to-dashboard-confirm-popup .back-to-dashboard-confirm-btn {
    flex: 1 1 auto;
    min-width: min(160px, 100%);
}

.grammar-result-popup .grammar-result-title {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
}


.grammar-result-popup .grammar-result-title.grammar-correct {
    color: #0d9488;
}

.grammar-result-popup .grammar-result-title.grammar-incorrect {
    color: #b91c1c;
}

.grammar-result-popup .grammar-result-feedback {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    line-height: 1.4;
    color: #374151;
}

button.show-lists-btn,
.show-lists-btn {
    display: inline-block;
    margin-bottom: 10px;
    background: rgb(125, 99, 255);
    transition: background 0.2s ease;
}

button.show-lists-btn:active,
.show-lists-btn:active {
    background: rgb(168, 150, 255);
}

.add-sentence-row {
    align-items: stretch;
}

.add-sentence-input {
    flex: 1;
    min-width: 0;
}

.add-sentence-btn {
    flex: 0 0 auto;
    min-height: 52px;
    padding: 14px 20px;
    font-weight: 600;
    border-radius: 12px;
}

.global-search-row {
    margin-bottom: 0.75rem;
}

.global-search-results {
    margin-bottom: 1rem;
}

.global-search-result-list {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0;
}

.global-search-result-item {
    padding: 8px 10px;
    margin: 4px 0;
    border: 1px solid #e2e7f0;
    border-radius: 8px;
    cursor: pointer;
}

.global-search-result-item:hover,
.global-search-result-item:focus {
    border-color: rgb(125, 99, 255);
    background: rgb(248, 246, 255);
    outline: none;
}

.global-search-result-content {
    font-size: 1rem;
    line-height: 1.4;
}

.list-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
    transition: box-shadow 0.25s ease, transform 0.35s ease-out, opacity 0.35s ease-out, max-height 0.35s ease-out, margin 0.35s ease-out, padding 0.35s ease-out;
    box-shadow: inset 0 0 0 0 transparent;
    max-height: 300px;
    overflow: hidden;
}

.list-item.is-completing {
    transform: translateX(100%);
    opacity: 0;
    max-height: 0;
    margin-top: 0;
    margin-bottom: 0;
    padding: 0;
}

.list-item.is-adding {
    transform: translateX(-24px);
    opacity: 0;
}

.list-item:focus-within {
    box-shadow: inset 0 0 0 2px rgb(125, 99, 255);
}

.list-item-main {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.list-item-main:hover {
    color: rgb(125, 99, 255);
}

.list-item-main:focus {
    outline: none;
    box-shadow: none;
}

.list-item-main::-moz-focus-inner {
    border: 0;
}

.list-item-sentence-count {
    font-weight: normal;
    color: var(--muted, #666);
    font-size: 0.9em;
}

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

.row > * {
    flex: 1;
}

.checkbox-label {
    flex: 0 0 auto;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
}

#useNaturalTtsInput {
    appearance: none;
    -webkit-appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    min-width: 1.25rem;
    min-height: 1.25rem;
    max-width: 1.25rem;
    max-height: 1.25rem;
    border-radius: 6px;
    border: 2px solid rgb(168, 150, 255);
    background: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease, border-color 0.2s ease;
}

#useNaturalTtsInput:hover {
    border-color: rgb(125, 99, 255);
}

#useNaturalTtsInput:checked {
    background: rgb(168, 150, 255);
    border-color: rgb(168, 150, 255);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2 6l3 3 5-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
}

#useNaturalTtsInput:focus {
    outline: 2px solid rgb(168, 150, 255);
    outline-offset: 2px;
}

.hint {
    font-size: 12px;
    color: #586173;
}

.auth-message {
    font-size: 13px;
    color: #2d3748;
    margin: 0.5rem 0;
}

.auth-footer {
    margin-top: 1rem;
    font-size: 13px;
}

.auth-footer a {
    color: #5b21b6;
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.mind-map-section {
    margin-top: 1rem;
}

#mindMap {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    min-height: 200px;
    background: #fdfefe;
    border: 1px solid #dbe1eb;
    border-radius: 10px;
    cursor: pointer;
    display: block;
    touch-action: none;
}

@media (max-width: 768px) {
    .dashboard {
        min-height: calc(100dvh - 80px);
        height: calc(100dvh - 80px);
    }

    .dashboard-content {
        flex: 1 1 0;
        min-height: 0;
    }

    .mind-map-section {
        margin-top: 12px;
        flex: 1 1 0;
        min-height: 0;
        flex-direction: column;
    }

    .mind-map-zoom-wrap {
        flex: 1 1 0;
        min-height: 0;
    }

    #mindMap {
        flex: 1 1 0;
        min-height: 0;
        max-width: 100%;
    }
}

.review-session-page {
    max-width: 720px;
    opacity: 0;
    transform: scale(0.94);
}

.review-session-page.review-session-open {
    opacity: 1;
    transform: scale(1);
}

.review-session-page.review-session-completing {
    opacity: 0;
    transform: scale(0.94);
    box-shadow: 0 0 0 4px rgba(86, 214, 122, 0.5);
    pointer-events: none;
}

.review-session-page {
    transition: opacity 0.35s ease-out, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.35s ease-out;
}

.review-session-page h2 {
    margin-top: 0;
}

.review-sentences-list {
    list-style: decimal;
    padding-left: 1.5em;
    margin: 1em 0;
}

.review-sentence-item {
    margin: 12px 0;
    padding: 14px 16px;
    border: 1px solid #e2e7f0;
    border-radius: 8px;
    background: #fafbfc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.review-sentence-item.review-sentence-item-completed {
    background: rgb(86, 214, 122);
    border-color: rgb(66, 194, 102);
}

.review-sentence-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.review-sentence-content {
    font-size: 1.05rem;
    line-height: 1.5;
    flex: 1;
}

.review-sentence-buttons {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.review-sentence-item .review-speak,
.review-sentence-item .review-speak-check {
    flex-shrink: 0;
}

.review-speak-check.stage-1 {
    background: rgb(220, 212, 255);
    border-color: rgb(125, 99, 255);
    color: rgb(125, 99, 255);
}

.review-speak-check.stage-2 {
    background: rgb(254, 215, 170);
    border-color: rgb(234, 88, 12);
    color: rgb(194, 65, 12);
}

.review-speak-check.stage-3 {
    background: rgb(254, 178, 178);
    border-color: rgb(185, 28, 28);
    color: rgb(153, 27, 27);
}

.test-review-speak-check.stage-1 {
    background: rgb(220, 212, 255);
    border-color: rgb(125, 99, 255);
    color: rgb(125, 99, 255);
}

.test-review-speak-check.stage-2 {
    background: rgb(254, 215, 170);
    border-color: rgb(234, 88, 12);
    color: rgb(194, 65, 12);
}

.test-review-speak-check.stage-3 {
    background: rgb(254, 178, 178);
    border-color: rgb(185, 28, 28);
    color: rgb(153, 27, 27);
}

.review-hidden-word {
    display: inline-block;
    min-width: 0.6em;
    height: 1em;
    margin: 0 1px;
    background: rgb(125, 99, 255);
    border-radius: 2px;
    vertical-align: middle;
    animation: review-hidden-word-fade 2s ease-in-out infinite;
}

@keyframes review-hidden-word-fade {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.review-skip-stage {
    display: block;
    margin-top: 8px;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #fff;
    background: rgb(125, 99, 255);
    border: 1px solid rgb(105, 79, 235);
    border-radius: 6px;
    cursor: pointer;
    animation: review-skip-stage-fade 1.5s ease-in-out infinite;
}

.review-skip-stage:hover {
    background: rgb(105, 79, 235);
    border-color: rgb(85, 59, 215);
}

@keyframes review-skip-stage-fade {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.review-voice-result {
    display: none;
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 4px;
}

.review-voice-result.review-voice-listening {
    background: #e0f2fe;
    color: #0c4a6e;
    border: 1px solid #7dd3fc;
}

.review-voice-result.review-voice-match {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.review-voice-result.review-voice-mismatch {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.test-review-popup .test-review-sentence {
    font-size: 1.05rem;
    line-height: 1.5;
    margin: 0 0 12px 0;
    padding: 10px 12px;
    background: rgb(220, 212, 255);
    border-radius: 8px;
    border: 1px solid #e2e7f0;
}

.test-review-popup .test-review-buttons {
    margin-bottom: 10px;
    gap: 8px;
}

.test-review-popup .test-review-voice-result {
    margin-bottom: 12px;
}

.review-session-actions {
    margin-top: 1.5em;
    gap: 12px;
    justify-content: center;
}

.review-session-actions button {
    flex: 0 1 auto;
}

.dict-word {
    cursor: pointer;
}

.dict-word:hover {
    color: rgb(125, 99, 255);
}

.definition-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.definition-modal.is-open {
    display: flex;
}

.definition-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}

.definition-modal-box {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 420px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.definition-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #e2e7f0;
}

.definition-modal-word {
    margin: 0;
    font-size: 1.25rem;
}

.definition-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #586173;
    padding: 0 4px;
}

.definition-modal-close:hover {
    color: #1d2433;
}

.definition-modal-body {
    padding: 14px 18px;
    overflow-y: auto;
}

.definition-loading,
.definition-error {
    color: #586173;
    margin: 0;
}

.definition-item {
    margin-bottom: 12px;
}

.definition-item:last-child {
    margin-bottom: 0;
}

.definition-pos {
    display: inline-block;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: rgb(125, 99, 255);
    font-weight: 600;
    margin-bottom: 4px;
}

.definition-text {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.45;
}

@media (max-width: 768px) {
    .btn-icon {
        min-width: 48px;
        min-height: 48px;
        padding: 12px 14px;
        font-size: 1.1rem;
    }

    button:not(.btn-icon) {
        min-height: 48px;
        padding: 12px 18px;
    }

    .add-sentence-input,
    .add-sentence-btn,
    .input-soft {
        min-height: 56px;
    }

    .add-sentence-input,
    .input-soft {
        padding: 16px 20px;
        font-size: 16px;
    }

    .add-sentence-btn {
        padding: 16px 22px;
    }

    .sentence-actions .btn-icon,
    .list-actions .btn-icon {
        min-width: 48px;
        min-height: 48px;
    }

    .sentence-item .sentence-item-content {
        font-size: 1.05rem;
    }

    .review-session-page {
        max-width: 100%;
    }

    .definition-modal-box {
        width: 95%;
        max-height: 85vh;
    }

    .definition-modal-close {
        min-width: 44px;
        min-height: 44px;
    }

    .row {
        gap: 6px;
    }
}
