html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

html {
  position: relative;
  min-height: 100%;
}

header {
    background-color: #ffe000b0 !important;
}

body {
  margin-bottom: 60px;
}

.categories {
/*    height: 90%;*/
    font-size: 13px;
}

#translation, #foreignWord {
    font-weight: bold;
    font-size: 25px;
}

#foreignWord, #context {
    width: 100%;
}

.font-weight-bold {
    font-weight: bold;
}

.study {
    width: 100%;
}

.study-panel {
    max-width: none;
    background: #fbfcfd;
    padding: 10px 1px;
    box-shadow: 0 10px 24px rgba(22, 35, 60, 0.06);
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.study-panel-body {
    margin-top: 8px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.study-panel-title {
    font-weight: 600;
    color: #2f3437;
    margin-bottom: 8px;
    text-align: center;
}

.study-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.study-buttons .btn-row-main {
    width: 100%;
    justify-content: center;
    text-align: center;
}

.study-buttons > button {
    margin-top: 5px;
    text-align: center;
}

/* Horizontal rows for study buttons */
.btn-row {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch; /* make all buttons same height as tallest in the row */
    gap: 8px; /* space between buttons */
    margin-bottom: 10px;
}

.study-buttons .btn-row-main {
    justify-content: center;
}

/* Make button content centered while allowing equal height stretching */
.btn-row > .btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* .btn-row-main and .btn-row-pronounce intentionally inherit from .btn-row */

.btn-row-secondary {
    border-top: 1px dashed #cfcfcf;
    padding-top: 8px;
}

@media (max-width: 600px) {
    .study-buttons {
        width: 100%;
        align-items: stretch; /* let child rows fill width */
    }

    .btn-row {
        gap: 6px;
        margin-bottom: 8px;
    }

    /* Make main and secondary rows take full width and distribute buttons equally */
    .btn-row-main,
    .btn-row-secondary {
        width: 100%;
    }

    .btn-row-main > .btn,
    .btn-row-secondary > .btn {
        flex: 1 1 0; /* each button takes equal share of the row */
        min-width: 0; /* allow shrinking to fit */
        text-align: center;
    }
}

.description-tooltiptext {
    text-align: left;
    font-weight: 400;
}

.description-tooltip {
    position: relative;
    display: inline-block;
    border-bottom: 1px dotted black;
    opacity: 1;
}

    .description-tooltip .description-tooltiptext {
        visibility: hidden;
        width: 400px;
        background-color: #555;
        color: #fff;
        border-radius: 6px;
        padding: 5px 0;
        position: absolute;
        z-index: 1;
        top: 100%;
        left: 80%;
        /*transform: translateX(-50%);*/ /* Adjust horizontally */
        margin-left: 0px;
        opacity: 0;
        transition: opacity 0.3s;
    }

        .description-tooltip .description-tooltiptext::after {
            content: "";
            position: absolute;
            left: 50%; /* Adjust the arrow to be in the middle */
            transform: translateX(-50%);
            margin-left: 0px; /* Reset if necessary */
            border-width: 5px;
            border-style: solid;
            border-color: #555 transparent transparent transparent;
        }

    .description-tooltip:hover .description-tooltiptext {
        visibility: visible;
        opacity: 1;
        z-index: 1000;
    }

/* Adjustments for small screens */
@media (max-width: 600px) {
    .description-tooltip .description-tooltiptext {
        width: 250px;
        left: 0%;
       /* transform: translateX(-50%);*/
    }
}


.study-description {
    margin-bottom: 40px;
}

.app-name {
    font: bold;
}

#bottomPrescriptBlock {
    margin-top: 15px;
}

input[type="checkbox"] {
    width: auto;
    appearance: auto;
}

#newCategory {
    width: 200px;
}

.add-word-inputs-container {
    display: flex;
    flex-wrap: wrap;
}

.add-word-text-fields, .add-word-existing-categories, .add-word-new-category {
    padding: 10px;
    box-sizing: border-box;
}

/* These styles are currently disabled but kept for reference
.add-word-text-fields {
    width: 33.33%;
}

.add-word-existing-categories {
    width: 33.33%;
}
*/

.add-word-new-category > button {
    margin-top: 5px;
}

.btn-add-word {
    margin: 10px;
}

.existing-categories-container {
    height: 100%;
}

.categories {
    height: 100%;
}

@media (max-width: 1000px) {
    .add-word-text-fields, .add-word-existing-categories, .add-word-new-category {
        width: 100%;
    }
}

.div-table {
    display: table;
    width: 100%;
    border-collapse: collapse;
}

.div-table-row {
    display: table-row;
}

.div-table-header, .div-table-cell {
    display: table-cell;
    padding: 8px; /* Adjust based on your preference */
    border: 1px solid #ddd; /* Mimic the table border */
    text-align: left; /* Adjust text alignment as needed */
}

.div-table-header {
    background-color: #f2f2f2; /* Header background */
    font-weight: bold; /* Make header text bold */
}

.div-cell-no-wrap {
    white-space: nowrap;
}

/* When the screen width is 1000px or less */
@media screen and (max-width: 1000px) {
    .hide-when-screen-width-less-1000 {
        display: none;
    }
}

/* When the screen width is 900px or less */
@media screen and (max-width: 900px) {
    .hide-when-screen-width-less-900 {
        display: none;
    }
}

/* When the screen width is 800px or less */
@media screen and (max-width: 800px) {
    .hide-when-screen-width-less-800 {
        display: none;
    }
}

/* When the screen width is 600px or less */
@media screen and (max-width: 600px) {
    .hide-when-screen-width-less-600 {
        display: none;
    }
}

.audio-text {
    background: none;
    border: none;
    padding: 4px; /* give tappable area */
    margin: 0;
    cursor: pointer;
    border-radius: 50%; /* circular hover */
    transition: background-color .15s ease, box-shadow .15s ease, transform .05s ease;
}

.audio-text:hover {
    background-color: rgba(27, 110, 194, 0.08); /* subtle primary-tinted hover */
}

.audio-text:focus {
    outline: 0;
    background-color: rgba(27, 110, 194, 0.10);
    box-shadow: 0 0 0 .25rem rgba(27, 110, 194, 0.25); /* consistent with primary focus */
}

.audio-text:active {
    background-color: rgba(27, 110, 194, 0.16);
    transform: scale(0.96); /* press feedback */
}

/* Brief pulse effect when big pronounce button minimizes into the small one */
.tray-pulse {
    animation: tray-pulse 300ms ease-out;
}

@keyframes tray-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 .0rem rgba(27,110,194,0.00); }
    50% { transform: scale(1.08); box-shadow: 0 0 0 .25rem rgba(27,110,194,0.20); }
    100% { transform: scale(1); box-shadow: 0 0 0 .0rem rgba(27,110,194,0.00); }
}

@media (prefers-reduced-motion: reduce) {
    .tray-pulse { animation: none; }
}

.audio-button-cell {
    padding: 4px;
    margin: 0;
    width: 10px;
}

  /* Themed secondary button to replace Bootstrap's gray */
  .btn-secondary {
    color: #fff;
    background-color: #629ef7; /* light blue complementing primary #1b6ec2 */
    border-color: #5b90dd;
  }

  .btn-secondary:hover {
    color: #fff;
    background-color: #4f86d8;
    border-color: #3f78ce;
  }

  .btn-secondary:focus,
  .btn-secondary.focus {
    color: #fff;
    background-color: #4f86d8;
    border-color: #3f78ce;
    box-shadow: 0 0 0 .25rem rgba(27, 110, 194, 0.25); /* echo primary hue */
  }

  .btn-secondary:active,
  .btn-secondary.active,
  .show > .btn-secondary.dropdown-toggle {
    color: #fff;
    background-color: #477dcc;
    border-color: #3a6fbe;
  }

  .btn-secondary:disabled,
  .btn-secondary.disabled {
    color: #fff;
    background-color: #9dbcf0;
    border-color: #88abeb;
  }

  /* Tertiary button background */
  .btn-tertiary {
    background-color: #e0e0e0;
    /* Slightly smaller sizing for tertiary buttons (UX-consistent) */
    font-size: .875rem; /* similar to .btn-sm */
    padding: .25rem .5rem; /* reduce height and width padding */
    line-height: 1.5;
  }

  .btn-tertiary:hover {
    background-color: #cfcfcf;
  }

.rating-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 400px;
}

.rating-buttons > .btn {
    width: 100%;
    display: flex;
    align-items: center;
}

.rating-emoji {
    flex-shrink: 0;
    width: 1.5em;
    text-align: left;
    margin-right: 6px;
}

.rating-text {
    flex: 1;
    text-align: center;
}

.rating-text-full {
    display: inline;
}

.rating-text-short {
    display: none;
}

.rating-buttons > .btn.rating-5 {
    background-color: #4caf7c;
    border-color: #43a06f;
    color: #fff;
}
.rating-buttons > .btn.rating-5:hover { background-color: #43a06f; }

.rating-buttons > .btn.rating-4 {
    background-color: #c8b835;
    border-color: #b5a62e;
    color: #fff;
}
.rating-buttons > .btn.rating-4:hover { background-color: #b5a62e; }

.rating-buttons > .btn.rating-3 {
    background-color: #e8943a;
    border-color: #d48432;
    color: #fff;
}
.rating-buttons > .btn.rating-3:hover { background-color: #d48432; }

.rating-buttons > .btn.rating-2 {
    background-color: #dc7030;
    border-color: #c8632a;
    color: #fff;
}
.rating-buttons > .btn.rating-2:hover { background-color: #c8632a; }

.rating-buttons > .btn.rating-1 {
    background-color: #d04848;
    border-color: #bc3f3f;
    color: #fff;
}
.rating-buttons > .btn.rating-1:hover { background-color: #bc3f3f; }

.rating-buttons > .btn.rating-0 {
    background-color: #5a5a6a;
    border-color: #4e4e5c;
    color: #fff;
}
.rating-buttons > .btn.rating-0:hover { background-color: #4e4e5c; }

@media (max-width: 600px) {
    .rating-buttons {
        max-width: none;
    }
}

@media (min-width: 1000px) {
    .study-panel {
        width: max-content;
        max-width: 100%;
    }

    .study-panel-body {
        width: auto;
    }

    .rating-text-full {
        display: none;
    }

    .rating-text-short {
        display: inline;
    }

    .study-panel .rating-buttons {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 8px;
        max-width: none;
        width: fit-content !important;
        margin: 0 auto;
    }

    .study-panel .rating-buttons > .btn {
        flex: 0 0 auto !important;
        width: max-content !important;
        padding: 0.4rem 0.55rem;
        font-size: 0.85rem;
        min-width: max-content;
        white-space: nowrap;
    }

    .study-panel .rating-text {
        white-space: nowrap;
    }

    .rating-emoji {
        width: 1.1em;
    }
}

#foreignWordSection {
    display: flex;
    align-items: center;
}

#foreignWord {
    max-width: 500px;
}

.word-card {
    max-width: 560px;
    background: linear-gradient(145deg, #ffffff, #f6f7f9);
    border: 1px solid #e0e4e8;
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: 0 12px 30px rgba(22, 35, 60, 0.08);
    display: grid;
    gap: 16px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 600px) {
    .word-card {
        padding: 3px 3px;
    }
}

@media (min-width: 900px) {
    .word-card {
        width: 560px;
    }
}

@media (min-width: 900px) and (max-height: 800px) {
    .word-card {
        padding: 14px 16px;
        gap: 12px;
    }

    .word-card-side {
        padding: 10px 12px;
    }

    .word-card-label {
        margin-bottom: 3px;
    }

    .word-card-text {
        font-size: 22px;
    }
}

.word-card-side {
    background: #fff;
    border: 1px solid #eef1f4;
    border-radius: 12px;
    padding: 1px 7px;
}

.word-card-side-foreign {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 10px;
}

.word-card-side-foreign .word-card-label {
    grid-column: 1 / -1;
}

.word-card-side-foreign #foreignWord {
    grid-column: 1 / 2;
    grid-row: 2;
}

.word-card-side-foreign .word-card-audio {
    grid-column: 2 / 3;
    grid-row: 2;
}

.word-card-label {
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #7a8795;
}

.word-card-text {
    font-size: 26px;
    font-weight: 600;
    color: #1f2a37;
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 380px) {
    .word-card .word-card-text {
        font-size: clamp(18px, 5vw, 22px) !important;
    }

    .word-card .word-card-label {
        font-size: 10px !important;
    }
}

.word-card-audio {
    position: static;
    border: none;
    background: #f2f6ff;
    color: #2b4db3;
    border-radius: 10px;
    padding: 6px 10px;
    cursor: pointer;
}

.progress-info {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    pointer-events: none;
}

.progress-info-bar {
    height: 3px;
    background: rgba(22, 35, 60, 0.12);
}

.progress-info-bar-fill {
    display: block;
    height: 100%;
    background: #2b4db3;
    transition: width 200ms ease;
}

.progress-info-meta {
    position: absolute;
    right: 12px;
    bottom: 6px;
    font-size: 12px;
    color: rgba(22, 35, 60, 0.65);
    display: flex;
    gap: 8px;
    align-items: center;
}

.progress-info-revision {
    font-size: 11px;
    opacity: 0.8;
}

.word-info-links {
    display: block;
    text-align: center;
    margin-top: 6px;
}

.word-info-links summary {
    cursor: pointer;
    font-weight: 600;
    color: #1f2a37;
    padding: 4px 10px;
    border-radius: 999px;
    background: #eef2f7;
    border: 1px solid #d7dee7;
    list-style: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.word-info-links summary::-webkit-details-marker {
    display: none;
}

.word-info-summary-open {
    display: none;
}

.word-info-links[open] .word-info-summary-closed {
    display: none;
}

.word-info-links[open] .word-info-summary-open {
    display: inline;
}

.word-info-links[open] summary {
    background: #e2e8f2;
}

.word-info-links-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.word-info-links-body a {
    display: inline-flex;
    width: fit-content;
    align-self: center;
}

#revise-words-react-root #wordInfo {
    text-align: center;
}

/* PWA install button in header */
.pwa-install-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border: 2px solid #1b6ec2;
    border-radius: 8px;
    background: #fff;
    color: #1b6ec2;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
    margin-right: 8px;
}

.pwa-install-btn:hover {
    background: #1b6ec2;
    color: #fff;
}

.pwa-install-btn:active {
    transform: scale(0.96);
}

@media (max-width: 575.98px) {
    .pwa-install-btn {
        padding: 5px 7px;
        margin-right: 6px;
    }
}

/* iOS PWA install instruction banner */
.pwa-ios-banner {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.4);
    animation: pwa-ios-fade-in 0.2s ease-out;
}

@keyframes pwa-ios-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.pwa-ios-banner-content {
    position: relative;
    background: #fff;
    border-radius: 16px;
    padding: 20px 20px 24px;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    animation: pwa-ios-slide-up 0.25s ease-out;
}

@keyframes pwa-ios-slide-up {
    from { transform: translateY(30px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.pwa-ios-banner-content::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 10px solid #fff;
}

.pwa-ios-banner-close {
    position: absolute;
    top: 8px;
    right: 12px;
    border: none;
    background: none;
    font-size: 22px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.pwa-ios-banner-close:hover {
    color: #333;
}

.pwa-ios-banner-title {
    font-weight: 700;
    font-size: 16px;
    color: #1f2a37;
    margin: 0 0 12px 0;
}

.pwa-ios-banner-step {
    font-size: 14px;
    color: #444;
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.pwa-ios-banner-step:last-child {
    margin-bottom: 0;
}

.pwa-ios-icon-share {
    display: inline-flex;
    vertical-align: middle;
    color: #007aff;
}

/* Study category filter */
.study-category-filter {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    padding: 0;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
}

.filter-header:hover {
    background: #f0f0f0;
    border-radius: 8px;
}

.filter-toggle-icon {
    font-size: 0.8em;
    color: #666;
}

.filter-body {
    padding: 0 14px 14px 14px;
    border-top: 1px solid #e0e0e0;
}

.filter-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding-top: 10px;
}

.filter-checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Sortable table headers */
.sortable-table th[data-sortable="true"],
.sortable-table .div-table-header[data-sortable="true"] {
    cursor: pointer;
    user-select: none;
}

.sortable-table th[data-sortable="true"]:hover,
.sortable-table .div-table-header[data-sortable="true"]:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.sort-badge {
    font-size: 0.75em;
    font-weight: bold;
    opacity: 0.8;
    color: #0d6efd;
}