/* --- Copy Button Styles --- */
.copy-btn {
    z-index: 10;
}
.copy-btn img {
    width: 22px;
    height: 22px;
}
.copy-btn svg {
    color: #6cb7ff;
    stroke: #6cb7ff;
}
.copy-btn[data-tooltip]:hover::after,
.copy-btn[data-tooltip].show-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    top: -36px;
    right: 0;
    background: #222;
    color: #fff;
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
    z-index: 9999;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s;
    pointer-events: none;
}
:root {
    --bg: #0f1117;
    --surface: #171b24;
    --surface-soft: #1f2633;
    --border: #2b3444;
    --text: #e8edf5;
    --text-soft: #a6b0c0;
    --brand: #6cb7ff;
    --brand-strong: #3fa3ff;
}

html,
body {
    min-height: 100%;
}

body {
    font-family: Inter, 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.65;
    background: radial-gradient(circle at top, #151a24 0%, var(--bg) 60%);
    color: var(--text);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: #ffffff;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
}

h1 {
    font-size: 2.2rem;
}

h2 {
    font-size: 1.5rem;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    color: #9ed2ff;
    text-decoration: underline;
}

.navbar {
    background-color: #0d1016 !important;
    border-bottom: 1px solid #20293a;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    position: relative;
    z-index: 2;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.01em;
    padding-top: 0;
    padding-bottom: 0;
    margin-right: 0.75rem;
    line-height: 1;
}

.navbar-brand img {
    height: 84px;
    width: auto;
    display: block;
}

.nav-link {
    color: var(--text-soft) !important;
    transition: color 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    color: var(--brand) !important;
}

.page-shell {
    max-width: 1080px;
    margin: 0 auto;
    padding: 2rem 1rem;
    position: relative;
    /* z-index intentionally removed — setting it created a stacking context that
       buried fixed overlays (verb modal, vocab card overlay) below the sticky
       tabs bar, hiding the close button on mobile. */
}

.hero {
    margin-bottom: 2rem;
    text-align: center;
}

.hero .lead {
    color: var(--text-soft);
    max-width: 680px;
    margin: 0.75rem auto 0;
}

.section-title {
    margin-bottom: 1rem;
}

.content-card {
    border: 1px solid var(--border);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    background-color: var(--surface);
    color: var(--text);
    border-radius: 12px;
    overflow: hidden;
}

.content-card .card-body {
    padding: 1.25rem;
}

.content-card .card-title {
    margin-top: 0;
    margin-bottom: 0.3rem;
    font-size: 1.35rem;
}

.meta-row {
    color: var(--text-soft);
    font-size: 0.92rem;
    margin-bottom: 0.75rem;
}

.chip {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    border: 1px solid #365377;
    background: rgba(108, 183, 255, 0.1);
    color: #b9ddff;
    font-size: 0.78rem;
    margin: 0 0.35rem 0.35rem 0;
}

.chip-tag,
.chip-category {
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.15s ease;
}

.chip-tag:hover,
.chip-category:hover {
    filter: brightness(1.3);
    text-decoration: none;
}

.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.75rem;
}

.category-pill {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-soft);
    font-size: 1rem;
    text-decoration: none;
    margin-bottom: -1px;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.category-pill:hover {
    color: var(--text);
    border-bottom-color: var(--border);
    text-decoration: none;
}

.category-pill.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
    font-weight: 600;
}

.tag-clear-link {
    font-size: 0.85rem;
    color: var(--text-soft);
    text-decoration: none;
}

.tag-clear-link:hover {
    color: var(--text);
    text-decoration: none;
}

.card-text {
    color: #d4dceb;
}

.article-content {
    max-width: 860px;
    margin: 0 auto;
    padding: 2rem 1rem;
    position: relative;
    z-index: 1;
}

.article-prose {
    margin-top: 1rem;
    font-size: 1.05rem;
    line-height: 1.8;
    color: #dbe3f1;
}

.article-prose p,
.article-prose ul,
.article-prose ol,
.article-prose blockquote,
.article-prose pre {
    margin-bottom: 1rem;
}

.article-prose blockquote {
    border-left: 3px solid var(--brand);
    padding-left: 1rem;
    color: #b9c6da;
}

.article-prose code {
    background: #111722;
    color: #9ed2ff;
    padding: 0.1rem 0.35rem;
    border-radius: 6px;
}

.article-prose pre {
    background: #111722;
    border: 1px solid #263146;
    border-radius: 10px;
    padding: 1rem;
    overflow-x: auto;
}

.panel {
    max-width: 860px;
    margin: 0 auto;
}

.panel .panel-body {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 12px;
    padding: 1.25rem;
}

.btn {
    border-radius: 8px;
    font-weight: 600;
}

.btn-primary {
    background-color: var(--brand);
    border-color: var(--brand);
    color: #092039;
}

.btn-primary:hover {
    background-color: var(--brand-strong);
    border-color: var(--brand-strong);
    color: #061526;
}

.btn-success {
    background-color: #66bb6a;
    border-color: #66bb6a;
}

.btn-success:hover {
    background-color: #4caf50;
    border-color: #4caf50;
}

.btn-info {
    color: #062034;
    font-weight: 600;
}

.form-control {
    background-color: var(--surface-soft);
    border: 1px solid var(--border);
    color: var(--text);
}

.form-control:focus {
    background-color: var(--surface-soft);
    border-color: var(--brand);
    color: var(--text);
    box-shadow: 0 0 0 0.2rem rgba(108, 183, 255, 0.2);
}

.form-label {
    color: #dce5f3;
    font-weight: 600;
}

.form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}

.text-muted {
    color: var(--text-soft) !important;
}

.about-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 1rem;
}

.about-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
}

.about-card {
    min-height: 220px;
    perspective: 1000px;
    cursor: pointer;
    overflow: hidden;
}

.about-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 220px;
    transition: transform 0.55s ease;
    transform-style: preserve-3d;
    will-change: transform;
    border-radius: 12px;
}

.about-card:hover .about-card-inner,
.about-card:focus .about-card-inner,
.about-card:focus-within .about-card-inner {
    transform: rotateY(180deg);
}

.about-card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.about-card-front {
    z-index: 2;
    transform: rotateY(0deg);
}

.about-card-back {
    transform: rotateY(180deg);
    background: linear-gradient(160deg, #1a2433, #15202d);
}

.about-card-face h2 {
    margin-top: 0;
    font-size: 1.2rem;
}

.about-card-face p {
    margin-bottom: 0;
}

.about-motto {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.about-motto-flip {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    min-height: 130px;
}

.about-motto-flip .about-card-inner {
    min-height: 130px;
}


.about-motto-flip:hover .about-card-inner,
.about-motto-flip:focus .about-card-inner,
.about-motto-flip:focus-within .about-card-inner {
    transform: rotateX(180deg);
}

.about-motto-flip .about-card-front {
    transform: rotateX(0deg);
}

.about-motto-flip .about-card-back {
    transform: rotateX(180deg);
}

.about-motto-flip .about-card-face {
    padding: 0.85rem 1rem;
}
footer {
    background-color: #0d1016 !important;
    border-top: 1px solid #20293a;
    margin-top: 2rem;
    position: relative;
    z-index: 0;
}

/* ================================
Article tables (explicit styling)
================================ */
.article-prose table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin: 1.25rem 0;
}

.article-prose th,
.article-prose td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    vertical-align: top;
    line-height: 1.4; /* override prose line-height */
}

.article-prose th {
    font-weight: 600;
    color: #ffffff;
}

.article-prose td code {
    padding: 0.05rem 0.25rem;
    line-height: 1.2;
    white-space: nowrap;
}

/* Optional Polish */
.article-prose thead th {
    border-bottom: 2px solid var(--border);
}

.article-prose tbody tr {
    border-bottom: 1px solid #263146;
}

.article-prose tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

.alert-danger {
    background-color: #3a1a1a;
    border: 1px solid #661a1a;
    color: #ff8a80;
}

@media (max-width: 768px) {
    .page-shell,
    .article-content {
        padding: 1.25rem 0.85rem;
    }

    h1 {
        font-size: 1.9rem;
    }

    .content-card .card-body,
    .panel .panel-body {
        padding: 1rem;
    }

    .about-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1080px) and (min-width: 769px) {
    .about-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ================================
   Italian SPA
   ================================ */

/* Sub-nav tab bar */
.ita-tabs-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.ita-tabs {
    display: flex;
    gap: 0;
    overflow-x: auto;
}

.ita-tab {
    display: inline-block;
    padding: 0.75rem 1.25rem;
    color: var(--text-soft);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.ita-tab:hover {
    color: var(--text);
    text-decoration: none;
}

.ita-tab.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

/* Setup panels */
.ita-setup-panel h3 {
    margin-top: 0;
}

/* Quiz layout */
.ita-quiz-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.ita-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.ita-progress-fill {
    height: 100%;
    background: var(--brand);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.ita-quiz-prompt {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.ita-lang-label {
    display: inline-block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-soft);
    margin-bottom: 0.25rem;
}

.ita-pronoun {
    color: var(--brand);
    font-style: italic;
}

/* Answer buttons */
.ita-option-btn {
    font-size: 1.05rem;
    padding: 0.75rem 1rem;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
}

.ita-option-btn:disabled {
    opacity: 1;
}

.ita-correct {
    background: rgba(102, 187, 106, 0.2) !important;
    border-color: #66bb6a !important;
    color: #a5d6a7 !important;
}

.ita-wrong {
    background: rgba(239, 83, 80, 0.2) !important;
    border-color: #ef5350 !important;
    color: #ef9a9a !important;
}

.ita-input-correct {
    border-color: #66bb6a !important;
    box-shadow: 0 0 0 0.2rem rgba(102, 187, 106, 0.25) !important;
}

.ita-input-wrong {
    border-color: #ef5350 !important;
    box-shadow: 0 0 0 0.2rem rgba(239, 83, 80, 0.25) !important;
}

/* Feedback */
.ita-feedback-correct {
    color: #a5d6a7;
    font-weight: 600;
    font-size: 1.1rem;
}

.ita-feedback-wrong {
    color: #ef9a9a;
    font-weight: 600;
    font-size: 1.05rem;
}

/* Results score ring */
.ita-results {
    padding: 2rem 0;
}

.ita-score-ring {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 1rem auto;
}

.ita-score-ring svg {
    width: 100%;
    height: 100%;
}

.ita-score-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--brand);
}

/* Grammar */
.ita-grammar-toggle {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ita-grammar-toggle:hover {
    color: var(--brand);
}

.ita-chevron {
    font-size: 0.85rem;
    transition: transform 0.2s;
}

.ita-chevron-open {
    transform: rotate(180deg);
}

.grammar-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
}

.grammar-table th,
.grammar-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.95rem;
}

.grammar-table th {
    color: var(--brand);
    font-weight: 600;
}

/* Verb reference grid */
.ita-verb-ref-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    margin-top: 1rem;
}

/* Flip card structure */
.ita-verb-ref-card {
    perspective: 800px;
    cursor: pointer;
    border-radius: 10px;
    min-height: 220px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ita-verb-ref-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.ita-verb-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.5s ease;
    transform-style: preserve-3d;
}

.ita-verb-flipped .ita-verb-flip-inner {
    transform: rotateY(180deg);
}

.ita-verb-front,
.ita-verb-back {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 10px;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    line-height: 1.5;
}

.ita-verb-front {
    position: relative;
}

.ita-verb-back {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    transform: rotateY(180deg);
}

/* Example pairs on back */
.ita-example-pair {
    margin-bottom: 0.65rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.ita-example-pair:last-child {
    border-bottom: none;
}

.ita-example-it {
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text);
}

.ita-example-en {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #9eaab8;
    margin-top: 0.1rem;
}

/* Overlay */
.ita-card-overlay {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ita-card-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.ita-card-enlarged {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
}

.ita-card-enlarged .ita-verb-ref-card {
    min-height: 320px;
}

.ita-card-enlarged .ita-verb-front,
.ita-card-enlarged .ita-verb-back {
    padding: 1.75rem;
}

.ita-card-enlarged .card-title {
    font-size: 1.5rem;
}

.ita-card-enlarged .ita-conj-table {
    font-size: 1.15rem;
}

.ita-card-enlarged .ita-conj-table td {
    padding: 0.35rem 0.6rem;
}

.ita-card-enlarged .ita-conj-table td:first-child {
    font-size: 1rem;
}

.ita-card-enlarged .ita-example-it {
    font-size: 1.15rem;
}

.ita-card-enlarged .ita-example-en {
    font-size: 1.05rem;
}

.ita-enlarged-active {
    animation: ita-zoom-in 0.25s ease forwards;
}

@keyframes ita-zoom-in {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.ita-conj-table {
    width: 100%;
    font-size: 0.95rem;
    line-height: 1.45;
}

.ita-conj-table td {
    padding: 0.25rem 0.4rem;
}

.ita-conj-table td:first-child {
    color: #9eaab8;
    width: 60px;
    font-size: 0.88rem;
}

.ita-conj-table td:last-child {
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Sentence builder */
.ita-sentence-answer {
    min-height: 52px;
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    line-height: 1.6;
    transition: border-color 0.2s;
}

.ita-sentence-answer:not(:empty) {
    border-style: solid;
}

.ita-sentence-correct {
    border-color: #66bb6a !important;
    background: rgba(102, 187, 106, 0.08) !important;
}

.ita-sentence-wrong {
    border-color: #ef5350 !important;
    background: rgba(239, 83, 80, 0.08) !important;
}

.ita-answer-word {
    display: inline;
}

.ita-sentence-words {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ita-word-btn {
    font-size: 1.05rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: opacity 0.2s, transform 0.15s;
}

.ita-word-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.ita-word-used {
    opacity: 0.3;
}

/* Mobile tweaks */
@media (max-width: 768px) {
    .ita-tabs {
        gap: 0;
    }
    .ita-tab {
        padding: 0.65rem 0.85rem;
        font-size: 0.88rem;
    }
    .ita-verb-ref-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
    .ita-card-enlarged {
        max-width: 95%;
    }
    .ita-card-enlarged .ita-verb-front,
    .ita-card-enlarged .ita-verb-back {
        padding: 1rem;
    }
}

/* ================================
   Gufo – Italian Voice Tutor FAB
   ================================ */

#gufo-container {
    position: fixed;
    bottom: 4.5rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

#gufo-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.3s;
    padding: 0;
}

#gufo-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0,0,0,0.5);
}

#gufo-btn svg {
    width: 52px;
    height: 52px;
}
#gufo-container[data-state="idle"] #gufo-btn::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(108,183,255,0.3);
    animation: gufo-pulse 2.5s ease-in-out infinite;
}

@keyframes gufo-pulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.12); opacity: 0; }
}

/* Connecting spinner */
#gufo-container[data-state="connecting"] #gufo-btn {
    border-color: var(--brand);
    pointer-events: none;
}
#gufo-container[data-state="connecting"] #gufo-btn::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--brand);
    animation: gufo-spin 0.8s linear infinite;
}

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

/* Connected – green ring */
#gufo-container[data-state="connected"] #gufo-btn {
    border-color: #66bb6a;
    box-shadow: 0 0 16px rgba(102,187,106,0.3);
}

#gufo-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

#gufo-status {
    font-size: 0.7rem;
    color: #66bb6a;
    font-weight: 600;
}

/* Audio wave bars */
#gufo-waves {
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 3px;
    height: 12px;
    align-items: flex-end;
}

#gufo-waves span {
    display: block;
    width: 3px;
    border-radius: 2px;
    background: #66bb6a;
}

.gufo-waves-hidden span {
    height: 0;
    opacity: 0;
}

.gufo-waves-listening span {
    height: 4px;
    opacity: 0.6;
    animation: gufo-wave-idle 1.2s ease-in-out infinite;
}
.gufo-waves-listening span:nth-child(2) { animation-delay: 0.15s; }
.gufo-waves-listening span:nth-child(3) { animation-delay: 0.3s; }

.gufo-waves-active span {
    opacity: 1;
    animation: gufo-wave 0.5s ease-in-out infinite alternate;
}
.gufo-waves-active span:nth-child(1) { animation-delay: 0s; }
.gufo-waves-active span:nth-child(2) { animation-delay: 0.12s; }
.gufo-waves-active span:nth-child(3) { animation-delay: 0.24s; }

@keyframes gufo-wave-idle {
    0%, 100% { height: 3px; }
    50% { height: 6px; }
}

@keyframes gufo-wave {
    from { height: 3px; }
    to { height: 12px; }
}

/* Mobile: smaller button */
@media (max-width: 768px) {
    #gufo-container {
        bottom: 4rem;
        right: 1rem;
    }
    #gufo-btn {
        width: 68px;
        height: 68px;
    }
    #gufo-btn svg {
        width: 44px;
        height: 44px;
    }
}

/* ================================
   Vocabulary Flash Cards
   ================================ */

.ita-flashcard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    padding: 0.5rem 0;
}

.ita-flip-card {
    height: 220px;
    cursor: pointer;
    perspective: 600px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ita-flip-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--brand);
    border-radius: 12px;
}

.ita-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.45s ease;
    transform-style: preserve-3d;
}

.ita-flip-card.is-flipped .ita-flip-inner {
    transform: rotateY(180deg);
}

.ita-flip-front,
.ita-flip-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    text-align: center;
}

.ita-flip-front {
    background: var(--surface);
}

.ita-flip-back {
    background: var(--surface-soft);
    border-color: var(--brand);
    transform: rotateY(180deg);
}

.ita-flip-media {
    position: relative;
    width: 100%;
    height: 140px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-soft);
}

.ita-flip-skeleton {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, var(--surface) 25%, var(--border) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: ita-shimmer 1.5s infinite;
    border-radius: 8px;
}

.ita-flip-skeleton-none {
    animation: none;
    background: var(--surface-soft);
}

@keyframes ita-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.ita-flip-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.35s ease;
}

.ita-flip-img.loaded {
    opacity: 1;
}

.ita-flip-word {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    word-break: break-word;
}

.ita-flip-back .ita-flip-en {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--brand);
    word-break: break-word;
}

/* ── Enlarged vocab flip card overlay ── */
.ita-flip-card-overlay-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 380px;
}

.ita-flip-card-overlay-wrap .ita-flip-card {
    height: 520px;
    cursor: pointer;
    transform: none !important;
    box-shadow: 0 20px 64px rgba(0, 0, 0, 0.7);
}

.ita-flip-card-overlay-wrap .ita-flip-media {
    height: 320px;
}

.ita-flip-card-overlay-wrap .ita-flip-word {
    font-size: 1.5rem;
}

.ita-flip-card-overlay-wrap .ita-flip-back .ita-flip-en {
    font-size: 1.6rem;
}

.ita-flip-card-hint {
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.82rem;
    color: var(--text-soft);
    position: relative;
    z-index: 1;
}

@media (max-width: 768px) {
    .ita-flashcard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .ita-flip-card {
        height: 180px;
    }
    .ita-flip-media {
        height: 80px;
    }
}

/* ── Level Selector Bar ───────────────────────────────────────────── */
.ita-level-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1.5rem;
    display: flex;
    align-items: center;
}

.ita-levels {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ita-level-label {
    color: var(--muted);
    font-size: 0.85rem;
    margin-right: 0.25rem;
}

.ita-level-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--fg);
    border-radius: 20px;
    padding: 0.2rem 0.85rem;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ita-level-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.ita-level-btn.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 600;
}

/* ── Reading Comprehension ───────────────────────────────────────── */
.ita-reading-body {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--fg);
}

.ita-reading-body mark,
.ita-gloss-mark {
    background: rgba(var(--brand-rgb, 99, 102, 241), 0.25);
    color: inherit;
    border-radius: 3px;
    padding: 0 2px;
    cursor: help;
    text-decoration: underline dotted;
}

.ita-reading-glossary {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.ita-gloss-item {
    font-size: 0.88rem;
    display: block;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    background: var(--surface);
}

/* ── Idiom Flip Cards ────────────────────────────────────────────── */
.ita-idiom-card {
    width: 100%;
    min-height: 260px;
    perspective: 1000px;
    cursor: pointer;
    user-select: none;
}

.ita-idiom-flip-inner {
    position: relative;
    width: 100%;
    min-height: 260px;
    transform-style: preserve-3d;
    transition: transform 0.45s cubic-bezier(.4,0,.2,1);
}

.ita-idiom-flip-inner.ita-idiom-flipped {
    transform: rotateY(180deg);
}

.ita-idiom-front,
.ita-idiom-back {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ita-idiom-back {
    transform: rotateY(180deg);
}

.ita-idiom-text {
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    color: var(--fg);
}

.ita-idiom-meaning {
    font-size: 1.25rem;
    color: var(--fg);
}

.ita-idiom-example-it {
    font-size: 1rem;
    color: var(--fg);
}

.ita-idiom-example-en {
    font-size: 0.88rem;
}

/* ── Empty state ─────────────────────────────────────────────────── */
.ita-empty-state {
    max-width: 480px;
    margin: 0 auto;
}

/* ── Verb Reference ──────────────────────────────────────────────── */
.ita-verb-ref-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.ita-verb-ref-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ita-verb-ref-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.ita-verb-ref-search {
    width: 200px;
}

.ita-verb-ref-filter {
    width: 140px;
}

.ita-verb-ref-pginfo {
    font-size: 0.9rem;
    white-space: nowrap;
}

.ita-verb-ref-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.ita-verb-ref-card {
    background: var(--card-bg, #1e1e2e);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    user-select: none;
}

.ita-verb-ref-card:hover,
.ita-verb-ref-card:focus {
    transform: translateY(-3px);
    border-color: var(--brand, #c084fc);
    box-shadow: 0 4px 16px rgba(192, 132, 252, 0.25);
    outline: none;
}

.ita-vrc-infinitive {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 0.2rem;
    color: var(--fg, #e2e8f0);
}

.ita-vrc-translation {
    font-size: 0.82rem;
    color: var(--muted, #94a3b8);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.ita-vrc-badges {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

/* ── Verb Modal Overlay ──────────────────────────────────────────── */
.ita-verb-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.ita-verb-modal {
    background: var(--card-bg, #1e1e2e);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    animation: verb-modal-in 0.2s ease;
}

@keyframes verb-modal-in {
    from { opacity: 0; transform: scale(0.93); }
    to   { opacity: 1; transform: scale(1); }
}

.ita-verb-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.2rem 1.3rem 0.8rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    gap: 0.75rem;
}

.ita-verb-modal-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--fg, #e2e8f0);
    margin-right: 0.4rem;
}

.ita-verb-modal-trans {
    font-size: 0.9rem;
    color: var(--muted, #94a3b8);
    margin-top: 0.3rem;
}

.ita-verb-modal-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.ita-verb-modal-tab {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--muted, #94a3b8);
    padding: 0.7rem 0.5rem;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.ita-verb-modal-tab:hover {
    color: var(--fg, #e2e8f0);
}

.ita-verb-modal-tab.active {
    color: var(--brand, #c084fc);
    border-bottom-color: var(--brand, #c084fc);
}

.ita-verb-modal-body {
    padding: 1.2rem 1.3rem;
}

.ita-tense-heading {
    color: var(--brand, #c084fc);
    font-weight: 700;
    margin-bottom: 0.6rem;
}

.ita-aux-note {
    font-size: 0.85rem;
    color: var(--muted, #94a3b8);
    margin-bottom: 0.75rem;
    background: rgba(255,255,255,0.04);
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
}

.ita-tense-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.2rem;
}

.ita-tense-table td {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.ita-pron {
    color: var(--muted, #94a3b8);
    font-size: 0.88rem;
    width: 40%;
}

.ita-form {
    font-weight: 700;
    color: var(--fg, #e2e8f0);
    font-size: 0.95rem;
}

.ita-verb-modal-examples {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 1rem;
}

.ita-examples-heading {
    color: var(--brand, #c084fc);
    font-weight: 700;
    margin-bottom: 0.6rem;
}

.ita-ex-pair {
    margin-bottom: 0.75rem;
}

.ita-ex-it {
    font-size: 0.92rem;
    color: var(--fg, #e2e8f0);
}

.ita-ex-en {
    font-size: 0.85rem;
    color: var(--muted, #94a3b8);
    margin-top: 0.1rem;
}

@media (max-width: 768px) {
    .ita-level-bar {
        padding: 0.4rem 1rem;
    }

    .ita-idiom-text {
        font-size: 1.3rem;
    }

    .ita-verb-ref-search { width: 140px; }
    .ita-verb-ref-filter { width: 120px; }

    .ita-verb-ref-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}