/* --- Configuration --- */
:root {
    /* Core Colors */
    --background-color: #030616;
    --surface-color: #0a0d1d;
    --primary-text-color: #f1ffff;
    --secondary-text-color: #8191bd;
    --accent-color:  #aac5ff;
    --accent-contrast-color: #030616;
    --surface-hover-color: #1c2033;
    --shadow-color: transparent; /* Shadow for buttons and nav */

    /* Layout & Font */
    --font-family: 'Work Sans', sans-serif;
    --base-padding: 16px;
    --border-radius: 16px;
    --card-swipe-duration: 0.4s; /* Animation speed */
}

/* --- Resets & Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

/* Hide scrollbars for WebKit browsers */
::-webkit-scrollbar {
    display: none; /* for Chrome, Safari, and Opera */
}

/* --- Material Icons Base Styling --- */
.material-symbols-rounded { /* Corrected selector */
    font-family: 'Material Symbols Rounded'; /* Corrected font family */
    font-weight: 600;
    font-style: normal;
    font-size: 24px;  /* Default icon size */
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
    /* Support for all WebKit browsers. */
    -webkit-font-smoothing: antialiased;
    /* Support for Safari and Chrome. */
    text-rendering: optimizeLegibility;
    /* Support for Firefox. */
    -moz-osx-font-smoothing: grayscale;
    /* Support for IE. */
    font-feature-settings: 'liga';
    color: transparent; /* Hide text until font loads */
    transition: color 0s 0.1s; /* Add slight delay to color transition on load */
}

/* Restore icon color once fonts are loaded */
.fonts-loaded .material-symbols-rounded {
    color: inherit; /* Inherit color from parent */
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--primary-text-color);
    font-weight: 500;
    line-height: 1; /* Changed from 1.6 */
    overscroll-behavior-y: contain; /* Prevent pull-to-refresh */
    overflow: hidden; /* Prevent body scroll when dragging cards */
    height: 100%; /* Ensure body takes full height */
    user-select: none; /* Disable text selection */
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE/Edge */
    /* Hide scrollbars for IE, Edge, Firefox */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.app-container {
    position: relative; /* Needed for absolute positioning of FAB */
    display: flex;
    flex-direction: column;
    height: 100vh; /* Full viewport height */
    max-width: 800px; /* Max width for desktop */
    margin: 0 auto; /* Center on desktop */
    background-color: var(--background-color); /* Ensure container bg */
}

.main-content {
    flex-grow: 1; /* Takes remaining space */
    overflow-y: auto; /* Allow content scrolling */
    overflow-x: hidden; /* Prevent horizontal overflow */
    /* Standardized padding: T=0, R/L=base, B=72px + safe area */
    padding: 0 var(--base-padding) calc(72px + env(safe-area-inset-bottom, 0px)) var(--base-padding);
    position: relative; /* Needed for absolute positioning context if required */
}

/* REMOVED view-specific padding overrides for .main-content */
/* REMOVED view-specific horizontal padding additions for headers */
/* REMOVED view-specific horizontal padding additions for content areas */

/* --- Views --- */
.view {
    display: none; /* Hidden by default */
    flex-direction: column;
    /* height: 100%; */ /* REMOVED: Allow height to be determined by content for scrolling */
    width: 100%; /* Take full width */
}

.view.active-view {
    display: flex; /* Show active view */
}

.view-header {
    display: flex;
    align-items: center;
    height: 80px; /* Set fixed height (increased by 16px) */
    /* Standardized internal padding */
    padding: calc(var(--base-padding) / 2) var(--base-padding);
    /* border-bottom: 1px solid var(--surface-color); */ /* REMOVED divider line */
    flex-shrink: 0; /* Prevent header from shrinking */
    box-sizing: border-box; /* Include padding/border in height calculation */
    /* Make ALL view headers sticky */
    position: sticky;
    top: 0;
    background-color: var(--background-color); /* Ensure content scrolls under */
    z-index: 11; /* Above flashcards (10) and below bottom nav (1000) */
}

/* REMOVED specific sticky rules for vocab/settings headers */

.view-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    flex-grow: 1;
    /* margin-left: var(--base-padding); /* Space after back button */ /* Removed to reduce gap */
    line-height: 1.4;
    white-space: nowrap; /* Prevent wrapping */
    overflow: hidden; /* Hide overflow */
    text-overflow: ellipsis; /* Add ellipsis */
    /* Consider adding max-width if needed, e.g., max-width: calc(100% - 60px); */
}
.view-header h1:first-child {
     margin-left: 0; /* No margin if no back button */
 }


/* --- Category List --- */
.category-list {
    display: grid;
    gap: var(--base-padding);
    grid-template-columns: repeat(2, 1fr); /* Max 2 columns */
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 32px);
}

/* Single column on smaller screens */
@media (max-width: 640px) {
    .category-list {
        grid-template-columns: 1fr; /* Single column */
    }
}


/* --- Low Height Adjustments (<= 600px) --- */
@media (max-height: 600px) {
    /* Increased specificity by adding 'body' */
    body #flashcard-action-buttons {
        /* Re-center the container using fixed positioning */
        left: 50%;
        transform: translateX(-50%);

        /* Set max-width to match app container */
        max-width: 800px;
        /* Ensure width doesn't exceed viewport if viewport < max-width */
        width: 100%; /* This will be constrained by max-width */

        box-sizing: border-box;

        /* Use default base padding *within* the max-width */
        padding-left: var(--base-padding); /* e.g., 16px */
        padding-right: var(--base-padding); /* e.g., 16px */

        /* Distribute buttons to ends */
        justify-content: space-between;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);

        /* Remove fixed gap */
        /* gap: calc(var(--base-padding) * 4.5); */

        /* Keep original bottom positioning */
        /* bottom: calc(env(safe-area-inset-bottom, 0px) + 16px + 56px + 96px); */
        /* pointer-events are handled globally now */
    }

    /* Increased specificity by adding 'body' */
    body .flashcard {
        /* Calculate padding based on button container padding, button width, and extra gap */
        /* Button width = 56px */
        /* Container padding = var(--base-padding) */
        /* Extra gap = var(--base-padding) */
        padding-left: calc(var(--base-padding) + 56px + var(--base-padding));
        padding-right: calc(var(--base-padding) + 56px + var(--base-padding));

        /* Keep original top/bottom padding */
        padding-top: 8px;
        padding-bottom: 88px;

        /* Ensure width calculation includes padding */
        box-sizing: border-box;
    }

    /* Optional: Reduce font size slightly if needed */
    /*
    .learning-word {
        font-size: 2.5rem; /* Reduced from 3rem */
    /* }
    .known-word {
        font-size: 1.3rem; /* Reduced from 1.5rem */
    /* }
    */

    body:has(#flashcard-view.active-view) #new-bottom-nav {
        display: none;
    }
}

/* Add extra bottom padding only when running in a browser tab on iOS */
body.is-ios-browser .main-content {
    /* Add ~80px extra padding to account for browser UI */
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px) + 80px);
}

/* --- Text Selection --- */
::selection {
  background-color: transparent;
}

.category-item {
    background-color: var(--surface-color);
    border: solid 1px var(--surface-hover-color);
    color: var(--primary-text-color);
    padding: var(--base-padding);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left; /* Align text to the left */
    display: flex; /* Enable flexbox */
    justify-content: space-between; /* Push name left, count right */
    align-items: center; /* Vertically align items */
    min-height: 56px; /* Ensure consistent height */
    transition: background-color 0.2s ease;
    overflow: hidden; /* Ensure children are clipped if they overflow */
 }

.category-name-wrapper {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0; /* Allows the flex item to shrink for ellipsis */
    margin-right: 2px; /* Add space between name and count */
}

/* Style for status messages within the category list */
#category-list p {
    padding: var(--base-padding); /* Match category item padding */
    color: var(--secondary-text-color); /* Use secondary color */
    text-align: center; /* Center the message */
    /* Make sure it spans columns if the grid has more than one */
    grid-column: 1 / -1;
    margin-top: 200px; /* Push message down */
}

.category-count {
    font-size: 1rem; /* Changed from 0.8em */
    font-weight: 500;
    color: var(--secondary-text-color); /* Less prominent color */
    min-width: 5ch;
    text-align: right;
    /* margin-left removed as flexbox handles spacing */
 }

.card-counter {
    font-size: 1rem; /* Changed from 0.9rem */
    font-weight: 500;
    color: var(--secondary-text-color); /* Less prominent */
    margin-left: 8px; /* Space between title and counter */
    flex-shrink: 0; /* Prevent shrinking */
    min-width: 7ch; /* Add minimum width */
    text-align: right; /* Align text to the right */
}

#flashcard-view.word-list-active .card-counter {
    display: none; /* Changed from visibility: hidden */
}

/* --- Settings --- */
.settings-form {
    display: flex;
    flex-direction: column;
    /* gap: 24px; Replaced with margin-top for animation */
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 32px);
}

.settings-form > .form-group,
.settings-form > .settings-divider {
    margin-top: 24px;
}

.settings-form > :first-child {
    margin-top: 0;
}

/* Removed rule adding margin-top to subsequent children */


/* --- Info View Content --- */
.info-content {
    /* Styles specific to info content can go here */
    display: flex;
    flex-direction: column;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 32px);
    /* Removed invalid gap rule */
}

.info-cards-container {
    display: flex;
    flex-direction: column;
    gap: var(--base-padding); /* Add gap between cards */
}

.info-card {
    background-color: var(--surface-color);
    border: solid 1px var(--surface-hover-color);
    border-radius: var(--border-radius);
    overflow: hidden; /* Needed to clip content during animation */
}

.info-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: var(--base-padding);
    background: none; /* Remove default button background */
    border: none;
    color: var(--primary-text-color);
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    min-height: 56px; /* Ensure consistent height */
    transition: background-color 0.2s ease; /* Added background-color transition */
}

.info-card-header:focus,
#new-bottom-nav button:focus,
#global-tts-fab:focus,
#star-button:focus,
.back-button:focus,
#toggle-flashcard-view-mode-button:focus,
.word-list-item-buttons .icon-button:focus,
.category-item:focus {
    outline: none;
}

.info-card-title {
    /* Title takes up available space */
    flex-grow: 1;
    margin-right: var(--base-padding); /* Space before arrow */
}

.info-card-arrow {
    font-size: 24px; /* Match other icons */
    transition: transform 0.3s ease-out;
    flex-shrink: 0; /* Prevent arrow from shrinking */
}

.info-card-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.info-card-content p {
    padding: 0 var(--base-padding) var(--base-padding) var(--base-padding); /* T R B L */
    margin: 0; /* Reset paragraph margin */
    color: var(--secondary-text-color);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.4; /* Improve readability */
}

.info-card.active .info-card-arrow {
    transform: rotate(180deg);
}

.info-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--base-padding);
    padding-top: calc(var(--base-padding) * 2);
}

.info-logo {
    width: 128px;
    height: 128px;
    border-radius: var(--border-radius);
}

.info-version {
    color: var(--secondary-text-color);
    font-size: 1rem;
    font-weight: 500;
}

/* Removed #settings-error styles */

.form-group {
    display: flex;
    flex-direction: column;
    /* gap: var(--base-padding); */ /* Removed gap, using explicit margin on label */
}

/* Style for the separate text label (e.g., "My language") */
.form-label-text {
    color: var(--secondary-text-color);
    font-size: 1rem;
    font-weight: 500;
    padding-left: var(--base-padding); /* Add indent to align with select text */
    display: block; /* Ensure it takes its own line */
    color: var(--secondary-text-color); /* Keep secondary color */
    font-size: 1rem; /* Keep font size */
    pointer-events: none; /* Prevent label from reacting to hover/tap */
    margin-bottom: var(--base-padding); /* Space between label and input */
}

/* --- New Styles for Standard Select --- */
.settings-form select {
    width: 100%; /* Take full width */
    padding: var(--base-padding); /* Use base padding */
    background-color: var(--surface-color); /* Use surface color */
    color: var(--primary-text-color); /* Use primary text color */
    border: solid 1px var(--surface-hover-color);
    border-radius: var(--border-radius); /* Use standard border radius */
    font-family: var(--font-family); /* Match font */
    font-size: 1rem; /* Match font size */
    font-weight: 500;
    cursor: pointer;
    /* Allow browser default appearance for dropdown arrow */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    /* Arrow is now handled by the .select-arrow span */
    /* Removed background-color from transition */
    transition: border-color 0.2s ease, background-color 0.2s ease; /* Added background-color transition */
    min-height: 56px; /* Ensure consistent height */
}

/* Wrapper for select and icon */
.select-wrapper {
    position: relative; /* Needed to position the icon absolutely */
    display: block; /* Take full width */
}

/* Style the select within the wrapper */
.select-wrapper select {
    /* Ensure select still takes full width */
    width: 100%;
    /* Add padding on the right to make space for the icon */
    padding-right: calc(var(--base-padding) * 2 + 24px); /* Base padding + icon width + extra space */
}

/* Style the icon */
.select-arrow {
    position: absolute;
    right: var(--base-padding); /* Position from the right edge of the wrapper */
    top: 50%; /* Center vertically */
    transform: translateY(-50%);
    color: var(--primary-text-color); /* Use primary text color */
    font-size: 24px; /* Match previous size */
    pointer-events: none; /* Allow clicks to pass through to the select */
}

/* Hover state moved into @media (hover: hover) */

/* Focus and Active states */
.settings-form select:focus {
    outline: none; /* Remove default outline */
    /* Explicitly set background */
    background-color: var(--surface-color);
}
.settings-form select:active {
    outline: none; /* Remove default outline */
    /* Explicitly set background */
    background-color: var(--surface-color);
}

/* Ensure hover takes precedence when combined with focus/active */
/* Removed .settings-form select:active:hover rule */
/* Removed .settings-form select:focus:hover rule */

/* --- Input Field Styling (Matching Selects) --- */
#secret-code-input {
    width: 100%; /* Take full width */
    padding: var(--base-padding); /* Use base padding */
    background-color: var(--surface-color); /* Use surface color */
    color: var(--primary-text-color); /* Use primary text color */
    border: solid 1px var(--surface-hover-color);
    border-radius: var(--border-radius); /* Use standard border radius */
    font-family: var(--font-family); /* Match font */
    font-size: 1rem; /* Match font size */
    font-weight: 500;
    /* No cursor: pointer or appearance: none needed */
    /* No extra padding-right needed */
    transition: background-color 0.2s ease; /* Match select transition */
    box-sizing: border-box; /* Ensure padding is included in width */
    min-height: 56px; /* Ensure consistent height */
}

#secret-code-input:focus {
    outline: none; /* Remove default browser focus outline */
}

#secret-code-input:disabled {
  background-color: var(--surface-hover-color);
  color: var(--secondary-text-color);
  cursor: not-allowed; /* Optional: better visual cue */
}

/* Placeholder text color */
#secret-code-input::placeholder {
    color: var(--secondary-text-color);
}
/* --- End Input Field Styling --- */

/* --- Shake Animation --- */
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

.shake-error {
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
  transform: translateX(0);
}
/* --- End Shake Animation --- */

/* --- Flashcard View --- */
#flashcard-view {
     position: relative; /* Make this the positioning context for FABs */
     justify-content: space-between;
     height: 100%; /* Restore full height specifically for flashcard view layout */
 }

/* Styles for when word list is active within flashcard view */
#flashcard-view.word-list-active {
    height: auto; /* Allow height to be determined by its content */
    justify-content: flex-start; /* Align content to the top */
}

#flashcard-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    /* padding: 0; */ /* Padding removed as main-content handles horizontal */
    position: relative; /* Needed for absolute positioning of cards */
    /* overflow: hidden; */ /* REMOVED: Allow card to animate fully off-screen */
    min-height: 300px; /* Ensure space for card */
    touch-action: pan-x; /* Allow vertical swipe, prevent browser horizontal actions */
    -webkit-touch-callout: none; /* Disable callout menu on touch hold */
}

.flashcard-placeholder {
    padding: var(--base-padding); /* Add padding */
    color: var(--secondary-text-color);
    font-size: 1rem; /* Changed from 1.1rem */
    text-align: center;
}

.flashcard {
    /* background-color: var(--surface-color); */ /* Removed card background */
    /* border-radius: var(--border-radius); */ /* Removed for full screen */
    /* padding: calc(var(--base-padding) * 2) var(--base-padding); */ /* Original padding */
    padding: 8px var(--base-padding) 88px; /* Asymmetric padding: T=8px, R/L=16px, B=88px to shift center up */
    /* min-height: 250px; */ /* Removed for full screen */
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    /* max-width: 350px; */ /* Removed for full screen */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: var(--base-padding); /* Space between word containers */
    text-align: center;
    position: absolute; /* Stack cards for swiping */
    /* Make flashcard a positioning context for the button */
    /* position: relative; */ /* Already absolute */
    /* --- Initial state for animation IN --- */
    opacity: 0;
    transform: scale(0.8); /* Start slightly smaller */
    /* --- Transition for IN and OUT --- */
    /* Apply transition to transform and opacity (default timing for IN) */
    transition: opacity var(--card-swipe-duration) ease-out, transform var(--card-swipe-duration) ease-out; /* Default 0.4s for both */
    cursor: grab; /* Indicate draggable */
    user-select: none; /* Prevent text selection during drag */
    -webkit-user-drag: none; /* Prevent default image drag */
    will-change: transform, opacity; /* Hint browser about animations */
    z-index: 10; /* Ensure cards are above the global button */
}

#word-list-container {
    /* flex-grow: 1; Removed */
    /* overflow-y: auto; Removed */
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px)); /* Consistent internal spacing */
    display: none; /* Hidden by default */
    flex-direction: column;
    gap: var(--base-padding);
}

.word-list-item {
    background-color: var(--surface-color);
    border: solid 1px var(--surface-hover-color);
    padding: 8px 8px 8px 16px;
    border-radius: var(--border-radius);
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--base-padding); /* Gap between text and button groups */
    transition: max-height 0.3s ease-out, opacity 0.1s ease-out, margin-bottom 0.3s ease-out, padding-top 0.3s ease-out, padding-bottom 0.3s ease-out;
    overflow: hidden;
}

.word-list-item.is-removing {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: calc(-1 * (72px + var(--base-padding)));
    border-width: 0;
}

.word-list-item-text {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allow text to take available space */
    min-width: 0; /* Prevent overflow issues with long text */
}

.word-list-item-learning-word {
    color: var(--primary-text-color);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.4;
    word-break: break-word; /* Allow words to break and wrap */
    /* white-space: nowrap; */ /* Removed */
    /* overflow: hidden; */ /* Removed */
    /* text-overflow: ellipsis; */ /* Removed */
}

.word-list-item-known-word {
    color: var(--secondary-text-color);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.4;
    word-break: break-word; /* Allow words to break and wrap */
    /* white-space: nowrap; */ /* Removed */
    /* overflow: hidden; */ /* Removed */
    /* text-overflow: ellipsis; */ /* Removed */
}

.word-list-item-buttons {
    display: flex;
    align-items: center;
    gap: 0; /* Smaller gap between buttons */
    flex-shrink: 0; /* Prevent buttons from shrinking */
}

/* Style word list buttons like FABs */
.word-list-item-buttons .icon-button {
    width: 56px;
    height: 56px;
    color: var(--accent-color);
    border-radius: 16px;
    padding: 0; /* Override default icon-button padding for centering in fixed size */
    /* Flex properties for icon centering are inherited from .icon-button */
    touch-action: manipulation; /* Consistent with other FABs */
}

.word-list-item-buttons .icon-button .material-symbols-rounded {
    transition: transform 0.2s ease-out; /* Add transition for icon scaling */
}

/* Active state for word list button icons */
.word-list-item-buttons .icon-button:active .material-symbols-rounded {
    transform: scale(0.9); /* Scale icon down */
}


/* --- Swipe Up Guide --- */
.swipe-guide {
    position: absolute;
    top: 20%; /* Position above the words */
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none; /* Don't interfere with dragging */
}

.swipe-guide .material-symbols-rounded {
    font-size: 48px; /* Make icon larger */
    color: var(--secondary-text-color);
    opacity: 1; /* Slightly transparent */
    animation: swipeUpAnimation 2s infinite ease-in-out;
}

@keyframes swipeUpAnimation {
    0%, 100% {
        transform: translateY(0);
        opacity: 0;
    }
    50% {
        transform: translateY(-50px); /* Move up */
        opacity: 1; /* Fade out */
    }
}

/* --- Visible state for animation IN --- */
.flashcard.is-visible {
    opacity: 1;
    transform: scale(1); /* End at normal size */
}

/* Override transition duration specifically for swipe OUT animation */
.flashcard.is-swiping-out {
    transition-duration: 0.1s, var(--card-swipe-duration); /* opacity 0.1s, transform 0.4s */
}

.flashcard.is-dragging {
    cursor: grabbing;
    transition: none; /* No transition while actively dragging */
}

.learning-word-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: calc(var(--base-padding) / 2);
    flex-wrap: wrap; /* Allow wrap if needed */
    width: 100%; /* Take full width for centering */
}

.word {
    /* word-break: break-word; */ /* Allow long words to break */
    overflow-wrap: break-word;
}

.learning-word {
    font-size: 3rem; /* Increased size */
    font-weight: 700;
    color: var(--accent-color); /* Orange color */
    text-align: center;
    /* Animate opacity and transform */
    transition: opacity var(--card-swipe-duration) ease-out, transform var(--card-swipe-duration) ease-out;
}

.known-word {
    font-size: 1.5rem; /* Increased size */
    font-weight: 600;
    color: var(--secondary-text-color);
    text-align: center;
    /* Animate opacity and transform */
    transition: opacity var(--card-swipe-duration) ease-out, transform var(--card-swipe-duration) ease-out;
}

.flashcard .word.is-hidden {
    opacity: 0;
    transform: scale(0.8); /* Start slightly smaller when hidden */
    /* max-height: 0; */ /* REMOVED */
    /* overflow: hidden; */ /* REMOVED */
    padding-top: 0; /* Remove padding when hidden */
    padding-bottom: 0;
    margin-top: 0; /* Remove margin when hidden */
    margin-bottom: 0;
    /* Ensure transition applies when class is removed */
}
/* --- End Single Word Mode Styles --- */

.flashcard-controls {
    display: flex;
    justify-content: center;
    gap: var(--base-padding);
    padding: 0 var(--base-padding) var(--base-padding); /* Remove top padding again */
    width: 100%;
    /* min-height: 10px; */ /* Controls hidden */
    flex-shrink: 0; /* Prevent controls from shrinking */
    /* Align button centrally if needed */
    align-items: center;
    display: none; /* Hide controls for full-screen view */
}

/* --- General Icon Button Styling (includes back and speak button) --- */
.icon-button {
    background: none;
    border: none;
    color: var(--primary-text-color); /* Changed to primary */
    cursor: pointer;
    padding: 8px;
    border-radius: 16px; /* Circular background on hover */
    display: inline-flex; /* Align icon nicely */
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease; /* Added transform */
    flex-shrink: 0; /* Prevent buttons shrinking */
}
/* :hover rule moved into @media (hover: hover) below */
.icon-button:active {
    background-color: var(--surface-hover-color); /* Use surface hover */
}
.icon-button .material-symbols-rounded { /* Corrected selector */
    font-family: 'Material Symbols Rounded'; /* Corrected font family */
    /* Base styles applied by .material-symbols-rounded */
    font-size: 24px; /* Changed from 28px */
    /* Display is handled by parent flexbox (.icon-button) */
}
/* Changed ID selector to class selector */
.back-button {
    margin-left: -24px; /* Pull button left to align icon */
    margin-right: calc(var(--base-padding) / 2); /* Space before title */
    width: 56px; /* Match FAB size */
    height: 56px; /* Match FAB size */
    touch-action: manipulation;
}

.back-button .material-symbols-rounded {
    transition: transform 0.2s ease-out; /* Add transition for icon scaling */
}

.back-button:active .material-symbols-rounded {
    transform: scale(0.9); /* Scale back icon down on click */
}

#toggle-flashcard-view-mode-button {
    width: 56px;
    height: 56px;
    margin-right: -24px;
    margin-left: var(--base-padding);
    touch-action: manipulation;
}

#toggle-flashcard-view-mode-button .material-symbols-rounded {
    transition: transform 0.2s ease-out;
}

/* --- Floating Action Button (FAB) --- */
#global-tts-fab {
    display: none; /* Hidden by default */
    /* Removed positioning from individual FAB */
    /* position: fixed; */
    /* bottom: 168px; */
    /* left: 50%; */
    /* transform: translateX(-50%); */
    /* right: 24px; */ /* Removed right positioning */
    width: 56px;
    height: 56px;
    background-color: var(--surface-color); /* Dark surface color */
    color: var(--accent-color); /* Orange icon for contrast */
    border-radius: 16px;
    border: solid 1px var(--surface-hover-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 11; /* Above bottom nav */
    transition: transform 0.2s ease-out, background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation; /* Prevent double-tap zoom on iOS */
    /* Removed positioning from individual FAB */
    /* position: fixed; */
    /* bottom: 168px; */
    /* left: 50%; */
    /* transform: translateX(-50%); */
}
#global-tts-fab .material-symbols-rounded { /* Corrected selector */
    /* Base styles applied by .material-symbols-rounded */
    font-size: 24px; /* Changed from 28px */
    /* Display is handled by parent flexbox (#global-tts-fab) */
    transition: transform 0.2s ease-out; /* Add transition for icon scaling */
}
/* :hover rule moved into @media (hover: hover) below */
#global-tts-fab:active {
    background-color: var(--surface-hover-color); /* Keep background change */
    transform: none; /* REMOVE button scaling */
}
#global-tts-fab:active .material-symbols-rounded {
    transform: scale(0.9); /* Scale icon down */
}

/* --- Flashcard Action Buttons Container --- */
#flashcard-action-buttons {
    /* display: none; /* Removed - visibility controlled by parent view */
    position: fixed; /* Position relative to viewport */
    /* Use safe area inset for consistent bottom positioning */
    /* Calculate bottom: safe area + nav bottom space + nav height + desired gap */
    bottom: calc(env(safe-area-inset-bottom, 0px) + 16px + 56px + 96px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: calc(var(--base-padding) * 4.5); /* Increased space between buttons */
    align-items: center;
    justify-content: center;
    z-index: 11; /* Ensure it's above bottom nav */
    /* Visibility rules based on body class removed */
    pointer-events: none; /* Allow swipes to pass through container */
}

/* Re-enable pointer events for the buttons themselves globally */
#flashcard-action-buttons > .icon-button {
    pointer-events: auto;
}

/* --- Star Button Specific Styles --- */
#star-button {
    /* Inherits .icon-button styles */
    width: 56px; /* Match TTS FAB size */
    height: 56px; /* Match TTS FAB size */
    background-color: var(--surface-color); /* Match TTS FAB */
    border: solid 1px var(--surface-hover-color);
    color: var(--accent-color); /* Match TTS FAB icon color (unstarred) */
    touch-action: manipulation;
}

#star-button.starred {
    color: var(--accent-color); /* Accent color when starred */
}

#star-button.starred .material-symbols-rounded {
    font-variation-settings: 'FILL' 1; /* Fill the icon */
    /* Alternatively, change the icon name via JS if FILL doesn't work reliably */
    /* Combine transitions */
    transition: transform 0.2s ease-out, font-variation-settings 0.1s step-end;
}

/* Add base transition for the star icon */
#star-button .material-symbols-rounded {
    transition: transform 0.2s ease-out;
}

/* Hover/Active states for star button (using existing .icon-button rules) */
@media (hover: hover) {
    #star-button:hover {
        background-color: var(--surface-hover-color);
    }
    #star-button:hover .material-symbols-rounded {
        transform: scale(1.2); /* Scale Star icon on hover */
    }
}
#star-button:active {
    background-color: var(--surface-hover-color); /* Keep background change */
    transform: none; /* REMOVE button scaling */
}
/* Removed icon scaling on active state for consistency with JS animation */
/* #star-button:active .material-symbols-rounded {
    transform: scale(0.9); /* Scale icon down */
/* } */


/* Adjust main content padding specifically for flashcard view */

/* --- Light Mode Theme --- */
body.light-mode {
    /* Core Colors */
    --background-color: #f1f2fb;        /* Very light gray */
    --surface-color: #ffffff;           /* White */
    --primary-text-color: #0d1130;      /* Near black */
    --secondary-text-color: #5b5e8a;   /* Gray */
    --accent-color: #2f3bab;           /* Keep accent orange */

    /* Derived/Contrast Colors */
    --accent-contrast-color: #ffffff;   /* White text on accent */
    --surface-hover-color: #e2e4f7;     /* Slightly darker gray hover */
    --shadow-color: rgba(0, 0, 0, 0);

    /* NO specific component overrides here - relying on core variables */
}

/* --- Hover effects only for devices that support hover --- */
@media (hover: hover) {
    .category-item:hover {
        background-color: var(--surface-hover-color); /* Use surface hover */
    }
    .icon-button:hover {
        background-color: var(--surface-hover-color); /* Use surface hover */
        /* color: var(--primary-text-color); Already set */
    }
    #global-tts-fab:hover {
        background-color: var(--surface-hover-color); /* Use surface hover */
    }
    #global-tts-fab:hover .material-symbols-rounded {
        transform: scale(1.2); /* Scale TTS icon on hover */
    }
    .back-button:hover .material-symbols-rounded {
        transform: scale(1.2); /* Scale back icon on hover */
    }
    #toggle-flashcard-view-mode-button:hover .material-symbols-rounded {
        transform: scale(1.2); /* Scale icon on hover */
    }
    /* Restore select hover rule for devices that support hover */
    .settings-form select:hover {
        background-color: var(--surface-hover-color); /* Apply hover color only on hover */
    }
    /* Hover effect for collapsed info card headers */
    .info-card:not(.active) .info-card-header:hover {
        background-color: var(--surface-hover-color);
        /* transition: background-color 0.2s ease; */ /* Optional: Add transition if desired */
    }
    #new-bottom-nav button:hover:not(.active) .material-symbols-rounded {
         transform: scale(1.2); /* Scale icon up on hover */
    }
    /* Hover effect for text input */
    #secret-code-input:hover:not(:disabled) {
        background-color: var(--surface-hover-color);
    }

    /* Hover effect for word list button icons */
    .word-list-item-buttons .icon-button:hover .material-symbols-rounded {
        transform: scale(1.2); /* Scale icon up on hover */
    }
}

/* --- Keypress Animation --- */
/* Apply the same scale effect as :active to the icon when key is pressed */
#global-tts-fab.key-pressed .material-symbols-rounded,
#star-button.key-pressed .material-symbols-rounded,
.word-list-item-buttons .icon-button.key-pressed .material-symbols-rounded {
    transform: scale(0.9);
    /* Transition is already defined on the icon elements */
}


/* --- Utilities --- */
.hidden {
    display: none;
}

/* --- Toggle Switch Styles --- */
.form-group-switch {
    display: flex;
    flex-direction: row; /* Override default column direction */
    align-items: center;
    justify-content: space-between; /* Push label and switch apart */
    gap: var(--base-padding);
    padding-right: var(--base-padding); /* Add padding to the right of the container */
}

#single-word-initial-lang-group {
    max-height: 0;
    overflow: hidden;
    margin-top: 0;
    transition: max-height 0.3s ease-out, margin-top 0.3s ease-out;
}

#single-word-initial-lang-group.active {
    max-height: 50px; /* Approximate height of the content */
    margin-top: 24px;
}

.switch-content-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    opacity: 0;
    transition: opacity 0.2s ease-out;
}

#single-word-initial-lang-group.active .switch-content-wrapper {
    opacity: 1;
    transition-delay: 0.1s; /* Delay fade-in until container has expanded a bit */
}

.switch-label {
    color: var(--secondary-text-color); /* Use secondary text color for the label */
    font-size: 1rem; /* Match select font size */
    font-weight: 500;
    padding-left: var(--base-padding); /* Add indent to align with select text */
    /* flex-grow: 1; Removed */
    /* padding-right: calc(var(--base-padding) * 2.5); Removed */
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px; /* Width of the switch - Updated */
    height: 28px; /* Height of the switch - Updated */
    flex-shrink: 0; /* Prevent switch from shrinking */
    /* margin-right: var(--base-padding); Removed, alignment handled by label padding */
    /* padding-right: var(--base-padding); <-- REMOVED */
}

/* Hide default HTML checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The slider */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--surface-color); /* Passive track background */
    border: 1px solid var(--secondary-text-color); /* Passive track border */
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px; /* Size of the knob - Updated */
    width: 20px; /* Size of the knob - Updated */
    left: 3px; /* Position from left - Updated */
    bottom: 3px; /* Position from bottom - Updated */
    background-color: var(--secondary-text-color); /* Passive thumb color */
    transition: .4s;
    transform: rotate(0deg);
}

input:checked + .slider {
    background-color: var(--accent-color); /* Active track background */
    border-color: var(--accent-color); /* Active track border */
}

input:checked + .slider:before {
    transform: translateX(22px) rotate(90deg); /* Move knob to the right and rotate - Updated */
    background-color: var(--accent-contrast-color); /* Active thumb color */
}

/* Rounded sliders */
.slider.round {
    border-radius: 6px; /* Updated for rectangular shape */
}

.slider.round:before {
    border-radius: 4px; /* Updated for square knob */
}

/* --- Settings Divider --- */
.settings-divider {
    height: 1px;
    background-color: var(--surface-hover-color); /* Use surface hover color */
    margin: 0; /* Let parent gap handle spacing */
}

/* Removed extra space rule for the second form group */

/* --- New Bottom Navigation --- */
#new-bottom-nav {
    position: fixed;
    /* bottom: 24px; /* Space from bottom */ /* Replaced below */
    bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); /* Respect safe area */
    left: 50%; /* Center horizontally */
    transform: translateX(-50%); /* Fine-tune centering */
    display: flex;
    align-items: center; /* Vertically center icons */
    justify-content: center; /* Center buttons within the bar */
    gap: 16px; /* Gap between buttons */
    width: fit-content; /* Hug content */
    max-width: 224px; /* Added max-width */
    height: 56px; /* Set height */
    padding: 0 24px; /* Left/right padding for the bar */
    background-color: var(--accent-color); /* Bar background color */
    border-radius: 16px; /* Pill shape */
    box-shadow: 0 2px 24px var(--shadow-color); /* Add shadow */
    z-index: 1000; /* Keep it above content */
}

#new-bottom-nav button {
    background: none;
    border: none;
    color: var(--accent-contrast-color); /* Icon color */
    cursor: pointer;
    padding: 12px; /* Padding around icon */
    border-radius: 16px; /* Circular interaction area */
    display: flex; /* Needed for centering icon */
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    transition: background-color 0.2s ease, transform 0.1s ease; /* Added transform transition */
    /* Remove text-specific styles */
    /* font-family: var(--font-family); */
    /* font-size: 0.8rem; */
}

#new-bottom-nav button .material-symbols-rounded {
    font-size: 24px; /* Icon size */
    display: block; /* Ensure icon takes space */
    font-variation-settings: 'FILL' 0; /* Explicitly set default fill state */
    transition: transform 0.2s ease-out; /* Only transition transform */
}

#new-bottom-nav button:active {
    transform: scale(0.9); /* Scale down on click */
}

#new-bottom-nav button.active .material-symbols-rounded {
    font-variation-settings: 'FILL' 1; /* Fill the active icon */
    transform: scale(1.25); /* Make active icon larger */
}

/* Hover for devices that support it */
@media (hover: hover) {
    #new-bottom-nav button:hover:not(.active) .material-symbols-rounded {
         transform: scale(1.2); /* Scale icon up on hover */
    }
}
