/* oj.uz popup tab buttons */
.tab-switcher {
  display: flex;
  justify-content: center;
  margin-bottom: 1em;
  border-bottom: 1px solid #ccc;
}

.tab-switcher .tab {
  flex: 1;
  padding: 0.6em 1em;
  cursor: pointer;
  border: none;
  outline: none;
  background: #f5f5f5; /* default for light mode */
  font-size: 0.95em;
  transition: background-color 0.2s, color 0.2s;
  border-radius: 0; /* no rounded corners */
  color: #333;
}

.tab-switcher .tab:hover {
  background-color: #e0e0e0;
}

.tab-switcher .tab.active {
  background-color: #0177CC; /* light mode primary */
  color: #fff;
  font-weight: 600;
  border-bottom: 2px solid #0177CC;
}

/* Dark mode overrides */
body.dark-mode .tab-switcher {
  border-bottom: 1px solid #555;
}

body.dark-mode .tab-switcher .tab {
  background: #222;
  color: #eee;
}

body.dark-mode .tab-switcher .tab:hover {
  background-color: #333;
}

body.dark-mode .tab-switcher .tab.active {
  background-color: #3399ff; /* dark mode primary */
  border-bottom: 2px solid #3399ff;
  color: #fff;
}

/* --- oj.uz username-only section styles --- */
.ojuz-section {
  background-color: #e8f5e8;
  border: 1px solid #28a745;
  padding: 1rem;
  margin: 1.5rem 0;
}

.dark-mode .ojuz-section {
  background-color: #1e3e1e;
  border-color: #28a745;
}

/* Better spacing between label and input */
.ojuz-section .form-row label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
}

/* Harmonize with your vc-input sizing */
.ojuz-section .vc-input {
  width: 100%;
  max-width: 520px;
  padding: 0.6rem 0.7rem;
  border: 1px solid #ccc;
  font-size: 1rem;
  box-sizing: border-box;
}

.dark-mode .ojuz-section .vc-input {
  background: #222;
  color: #eee;
  border-color: #555;
}

.form-note {
  font-size: 0.9rem;
  color: var(--text-secondary, #666);
  margin-top: 0.5rem;
  font-style: italic;
}

.dark-mode .form-note {
  color: #aaa;
}

/* --- Note editor layout fixes --- */
.popup {
    max-height: 85vh;
    overflow: hidden;
}

.popup-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
}

.md-toolbar {
    display: flex;
    align-items: center;
    gap: .25rem;
    flex-wrap: wrap;
}

.md-toolbar-sep {
    width: 1px;
    height: 16px;
    background: #ddd;
    margin: 0 .25rem;
}

body.dark-mode .md-toolbar-sep {
    background: #444;
}

.md-textarea,
.md-preview {
    width: 100%;
    box-sizing: border-box;
    max-height: 50vh;
    /* keep inside popup */
    overflow: auto;
    /* scroll instead of leaking */
}

.md-textarea {
    min-height: 180px;
}

.md-preview {
    padding: 0.75rem 0.85rem;
    border: 1px solid #d0d7de;
    background: #fafbfc;
    color: #222;
}

.md-preview pre {
    overflow: auto;
}

.dark-mode .md-preview {
    border-color: #3a3a3a;
    background: #1f1f1f;
    color: #e6e6e6;
}

body {
    font-family: sans-serif;
    padding: 20px;
}

h2 {
    margin-bottom: 10px;
}

.problem-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 20px;
}

.problem {
    padding: 8px;
    border-radius: 4px;
    text-align: center;
    color: white;
    font-weight: bold;
}

.white {
    background-color: #ffffff;
}

.green {
    background-color: #7dbf7d;
}

.yellow {
    background-color: #ffd966;
}

.red {
    background-color: #f47174;
}

.problem-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    border: 1px solid #ccc;
}

.problem-table td {
    border: 1px solid #ccc;
    padding: 12px;
    text-align: center;
}

.year-cell {
    font-weight: bold;
    color: #007bff;
    background-color: #eee;
    white-space: nowrap;
    text-align: center;
    vertical-align: middle;
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    padding: 8px 4px;
}

.day-cell {
    background-color: #f5f5f5;
    color: #1184ff;
    padding: 8px 4px;
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    white-space: nowrap;
    text-align: center;
}

.problem-cell {
    transition: background-color 0.3s ease;
    width: auto;
    min-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 12px;
}

.problem-cell a {
    text-decoration: none;
    color: #007bff;
    font-weight: 500;
}

.day-cell {
    background-color: #f5f5f5;
    color: #1184ff;
    padding: 8px 4px;
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    white-space: nowrap;
    text-align: center;
}

#status-popup {
    position: absolute;
    z-index: 1000;
    background: white;
    border: 1px solid #ccc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 8px 12px;
    width: 120px;
    /* Fixed width */
    font-size: 14px;
    border-radius: 0px;
    /* No rounding */
}

/* Subtle note icon inside the status popup */
#status-popup {
    position: absolute;
}

#status-popup {
    position: absolute;
}

/* Inline score row */
.popup-score {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    white-space: nowrap;
    font-family: monospace;
    margin: 0;
}

/* keep the score parts together on the left */
.score-left {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}

.popup-score .score-left {
    display: flex;
    align-items: baseline;
    gap: 4px;
    white-space: nowrap;
}

/* compact note icon */
.note-icon {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    line-height: 1;
    color: #888;
    opacity: 0.75;
    cursor: pointer;
    margin-left: auto;
    /* NEW: moves icon to far right without adding gaps */
}

.note-icon:hover {
    opacity: 1;
    color: #555;
}

.dark-mode .note-icon {
    color: #bbb;
}

.dark-mode .note-icon:hover {
    color: #fff;
}

/* Filled state when a note exists */
.note-icon.has-note {
    opacity: 0.95;
    color: #3f51b5;
}

.dark-mode .note-icon.has-note {
    color: #82c6ff;
}

#popup-status {
    padding: 4px 8px;
    font-weight: bold;
    cursor: pointer;
    color: #333;
    margin-bottom: 6px;
    text-align: center;
    border-radius: 0;
}

#popup-status.yellow {
    color: #000000;
}

#popup-status.green {
    color: #ffffff;
}

#popup-status.red {
    color: #ffffff;
}

#popup-score {
    display: inline-block;
    min-width: 20px;
    background: none;
    outline: none;
    border: none;
    padding: 0;
    color: #3f51b5;
    font-weight: bold;
    border-radius: 0;
}

.popup-score {
    white-space: nowrap;
    font-family: monospace;
}

.visually-hidden {
    position: absolute !important;
    left: -9999px !important;
    top: auto !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

.note-icon {
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
    cursor: pointer;
    color: #888;
}

.note-icon svg {
    display: block;
}

/* Ensure editable score doesn't reserve extra width globally */
#popup-score[contenteditable] {
    display: inline;
    min-width: 0;
    width: auto;
    margin: 0;
    padding: 0;
    white-space: normal;
}

/* Fallback when .score-left isn't present (e.g., profile pages) */
.popup-score>#popup-score+.popup-out-of {
    margin-left: 4px;
}

.popup-score span:focus {
    background-color: #f0f0f0;
    outline: none;
}

.popup-out-of {
    color: #3f51b5;
    font-weight: bold;
}

#status-popup {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#status-popup.show {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

@keyframes bump {
    0% {
        transform: scale(1, 1);
    }

    30% {
        transform: scale(1.15, 0.96);
    }

    60% {
        transform: scale(0.95, 1.04);
    }

    100% {
        transform: scale(1, 1);
    }
}

#popup-score.bump {
    animation: bump 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.table-container {
    max-width: 85%;
    margin: 0 auto;
    /* centers it */
    padding: 0 1rem;
    /* optional inner spacing */
}

.table-container table {
    table-layout: fixed;
    width: 100%;
    border-collapse: collapse;
}

.table-container th,
.table-container td {
    white-space: normal;
    overflow-wrap: break-word;
    /* tries to break between words */
    word-break: break-word;
    /* but allows breaking long single words only if needed */
    hyphens: auto;
    /* gives cleaner breaks if browser supports hyphenation */
    text-align: center;
}

.navbar {
    padding: 1rem 2rem;
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
    position: relative;
}

.navbar::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    /* Center the border to 80% width */
    width: 80%;
    border-bottom: 1px solid #ddd;
}

.navbar-content {
    width: 100%;
    max-width: 1000px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-title {
    font-size: 2rem;
    font-weight: bold;
    color: #333;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.welcome-message {
    font-size: 1rem;
    color: #666;
}

.logout-button {
    font-size: 1rem;
    text-decoration: none;
    color: #555;
    padding: 0.4rem 0.8rem;
    border: 1px solid #ccc;
    transition: background-color 0.2s;
}

.logout-button:hover {
    background-color: #e0e0e0;
}

.login-container {
    background-color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 320px;
    padding: 40px;
    box-sizing: border-box;
    margin: 20px auto;
    font-family: sans-serif;
}

.login-container h2 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-weight: 600;
}

.form-field {
    margin-bottom: 20px;
}

.input-field {
    width: 100%;
    padding: 0.4rem 0.8rem;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.input-field:focus {
    border-color: #bbb;
    outline: none;
}

.error-message {
    display: none;
    color: red;
    font-size: 12px;
    text-align: left;
    margin-top: 5px;
    margin-bottom: 10px;
    padding-left: 5px;
}

.btn-login {
    width: 100%;
    padding: 0.4rem 0.8rem;
    background-color: #e0e0e0;
    border: 1px solid #ccc;
    color: #555;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-weight: normal;
    text-decoration: none;
}

.btn-login:hover {
    background-color: #8e8e8e;
    color: white;
    font-weight: bold;
}

.footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: #555;
}

.footer a {
    text-decoration: none;
    color: #777;
}

.footer a:hover {
    text-decoration: underline;
    color: #555;
}

@media (max-width: 600px) {
    .login-container {
        width: 100%;
        padding: 20px;
    }
}

/* Dark mode styles for login page: */
.dark-mode .login-container {
    background-color: #1e1e1e;
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.05);
}

.dark-mode .login-container h2 {
    color: #ffffff;
}

.dark-mode .input-field {
    background-color: #2a2a2a;
    border: 1px solid #444;
    color: #f0f0f0;
}

.dark-mode .input-field:focus {
    border-color: #888;
}

.dark-mode .error-message {
    color: #ff6b6b;
}

.dark-mode .btn-login {
    background-color: #333;
    border: 1px solid #555;
    color: #f0f0f0;
}

.dark-mode .btn-login:hover {
    background-color: #555;
    color: #ffffff;
    font-weight: bold;
}

.dark-mode .footer {
    color: #aaa;
}

.dark-mode .footer a {
    color: #bbb;
}

.dark-mode .footer a:hover {
    color: #fff;
}

/* Skeleton loading animation for problem cells */
.problem-cell.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 37%, #f0f0f0 63%);
    background-size: 400% 100%;
    animation: shimmer 1.2s ease-in-out infinite;
    color: transparent;
    height: 20px;
    padding: 12px;
}

/* Shimmer animation for skeleton rows */
@keyframes shimmer {
    0% {
        background-position: -100% 0;
    }

    100% {
        background-position: 100% 0;
    }
}

/* Dark mode toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 40px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    transition: 0.2s;
}

input:checked+.slider {
    background-image: url('../images/moon.png');
    background-size: 25px 25px;
}

input:not(:checked)+.slider {
    background-image: url('../images/sun.png');
    background-size: 35px 35px;
}

/* Dark mode styles */
.dark-mode {
    background-color: #1e1e1e;
    color: #ffffff
}

.dark-mode .navbar-title,
.dark-mode .welcome-message,
.dark-mode .logout-button {
    color: #ffffff;
}

.dark-mode .year-cell,
.dark-mode .day-cell {
    background-color: #202938;
}

.dark-mode table,
.dark-mode td,
.dark-mode th {
    border: 1px solid #2a2a2a;
    /* softer gray border */
}

.dark-mode .white {
    background-color: #1b1b1b;
}

.dark-mode .green {
    background-color: #64cd69;
}

.dark-mode .yellow {
    background-color: #e6b800;
}

.dark-mode .red {
    background-color: #f44336;
}

.dark-mode .problem-cell.skeleton {
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 37%, #2a2a2a 63%);
    background-size: 400% 100%;
    animation: shimmer 1.2s ease-in-out infinite;
    color: transparent;
    height: 20px;
    padding: 12px;
}

.dark-mode #status-popup {
    background: #2a2a2a;
    border-color: #444;
    color: #f0f0f0;
}

.dark-mode #popup-status {
    color: #f0f0f0;
}

.dark-mode #popup-status.yellow {
    color: #000000;
}

.dark-mode #popup-status.green {
    color: #ffffff;
}

.dark-mode #popup-status.red {
    color: #ffffff;
}

.dark-mode #popup-score {
    color: #4ea1f3;
}

.dark-mode .popup-out-of {
    color: #4ea1f3;
}

.dark-mode .popup-score span:focus {
    background-color: #3a3a3a;
}

/* Solve Count */
#solve-count-container {
    border-bottom: 1px solid #ddd;
    width: 80%;
    margin: 0 auto;
}

#solve-count {
    display: flex;
    justify-content: center;
    align-items: center;
}

.square {
    width: 20px;
    height: 20px;
    display: inline-block;
    margin-right: 5px;
}

.solve-count-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
}

#progress-bar {
    display: flex;
    height: 20px;
    margin-top: 20px;
    margin-bottom: 20px;
    overflow: hidden;
}

#progress-bar .progress-segment {
    width: 0%;
    transition: width 0.3s ease;
}

#progress-bar .progress-segment.white {
    width: 100%;
}

.progress-segment.white {
    background-color: #e5e5e5;
}

.dark-mode .progress-segment.white {
    background-color: #353535;
}

/* Basic styling for settings button and icon - Removed border-radius, faster transitions, fixed color */
.settings-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    /* Removed border-radius */
}

.settings-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Assuming dark mode needs separate hover */
body.dark-mode .settings-button:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.settings-icon {
    /* Using specific colors as vars are not desired */
    color: #333;
    /* Light mode icon color */
    transition: color 0.15s ease;
}

/* Assuming dark mode needs a different icon color */
body.dark-mode .settings-icon {
    color: #fff;
    /* Dark mode icon color */
}

/* Dropdown styling - Removed border-radius, faster transitions, fixed colors */
.settings-container {
    position: relative;
    display: inline-block;
}

.settings-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;

    /* Using specific colors as vars are not desired */
    background-color: rgba(255, 255, 255, 0.95);
    /* Light mode background (with transparency for blur) */
    border: 1px solid #ccc;
    /* Light mode border */
    /* Removed border-radius */
    padding: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);

    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;

    z-index: 1000;

    /* Backdrop filter needs transparency in background-color */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Assuming dark mode needs different dropdown colors */
body.dark-mode .settings-dropdown {
    background-color: rgba(51, 51, 51, 0.95);
    /* Dark mode background (with transparency for blur) */
    border-color: #555;
    /* Dark mode border */
}


.settings-container.active .settings-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}


/* Styling for individual items in the dropdown - Removed border-radius, faster transitions, entire item clickable */
.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 0;
    /* Removed border-radius */
    cursor: pointer;
    /* Entire item is clickable */
    /* Base transition for hover and state changes */
    transition: background-color 0.15s ease, color 0.2s ease;
    /* Faster background, slightly slower text color */
}

/* Styling for the label text within the item */
.settings-label {
    font-size: 1.2rem;
    font-weight: bold;
    padding: 0.3rem 0.6rem;
    display: inline-block;
    text-align: center;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Assuming dark mode needs different label text color */
body.dark-mode .settings-label {
    color: #fff;
    /* Dark mode text color */
}

.settings-item.red .settings-label,
.settings-item.green .settings-label {
    color: #fff;
}

/* Hide old toggle switch styles */
.toggle-switch,
.toggle-input,
.toggle-slider {
    display: none !important;
}

#connections-item {
    width: 100%;
    /* Ensure the parent container takes up full width */
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

.general-button {
    display: flex;
    align-items: center;
    gap: 0;
    width: 100%;
    /* Ensures the button takes up 100% of the div's width */
    height: auto;
    /* Automatically adjust height based on content */
    min-height: 40px;
    /* Ensure the button has a minimum height for legibility */
    padding: 0 12px;
    /* Adds padding on the left and right for better spacing */
    margin: 0;
    font-size: 14px;
    /* Increase font size for legibility */
    font-weight: bold;
    color: #333;
    text-decoration: none;
    background-color: transparent;
    border: none;
    cursor: pointer;
    box-sizing: border-box;
    transition: background-color 0.15s ease, color 0.2s ease;
    text-align: left;
    /* Ensure the text is aligned to the left */
}

.general-button:hover {
    background-color: #e0e0e0;
}

body.dark-mode .general-button {
    color: #fff;
}

body.dark-mode .general-button:hover {
    background-color: #444;
}

/* general page container */
.general-page {
    width: 80%;
    margin: 2rem auto;
    padding: 0;
}

/* responsive grid: adjusts number of columns */
.connections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

/* each judge “tile” */
.connection-card {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: var(--card-bg, #f9f9f9);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.connection-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* judge logo */
.connection-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    margin-right: 0.75rem;
}

/* judge name */
.connection-name {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #333);
    margin: 0;
}

/* connect button re-using your general-button base */
.connect-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    font-size: 0.875rem;
    font-weight: bold;
    color: #fff;
    background-color: #0077cc;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.connect-button svg {
    display: block;
    /* remove inline gaps */
    fill: currentColor;
    /* inherit text color */
}

.connect-button:hover {
    background-color: #005fa3;
}

/* dark-mode overrides (if you want) */
body.dark-mode .connection-card {
    background-color: #2b2b2b;
}

body.dark-mode .connection-name {
    color: #eee;
}

body.dark-mode .connect-button {
    background-color: #3399ff;
}

body.dark-mode .connect-button:hover {
    background-color: #287acc;
}

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);

    /* Start completely transparent */
    opacity: 0;
    /* Initially hidden from layout */
    display: none;

    align-items: center;
    justify-content: center;
    z-index: 1200;

    /* Add transition for opacity */
    transition: opacity 0.3s ease-in-out;
    /* Adjust duration and timing function */
}

/* State when the popup is active (visible) */
.popup-overlay.active {
    /* Make it visible for layout */
    display: flex;
    /* Fade in */
    opacity: 1;
}

.popup {
    background: #fff;
    color: #333;
    padding: 1.5rem;
    border-radius: 8px;
    width: 90%;
    max-width: 720px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    position: relative;

    /* Initial state for animation (e.g., slightly scaled down and transparent) */
    transform: scale(0.9);
    opacity: 0;

    /* Add transition for transform and opacity */
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
    /* Match duration of overlay transition */
}

/* State when the popup overlay is active, animate the popup itself */
.popup-overlay.active .popup {
    transform: scale(1);
    /* Scale back to normal size */
    opacity: 1;
    /* Fade in */
}


.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.popup-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.popup-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
}

.popup-close:hover {
    color: #000;
}

.popup-body p {
    margin: 0.75rem 0;
    line-height: 1.4;
}

.cookie-instruction {
    background-color: #f4f4f4;
    padding: 0.5rem;
    border-radius: 4px;
    margin: 1rem 0 0.5rem;
    font-family: monospace;
    font-size: 0.9rem;
}

.cookie-input {
    width: 96%;
    padding: 0.6rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.primary-button {
    background-color: #0077cc;
    color: #fff;
    border: none;
    padding: 0.6rem 1rem;
    font-size: 1rem;
    cursor: pointer;
}

.primary-button:hover {
    background-color: #005fa3;
}

body.dark-mode .popup {
    background-color: #1e1e1e;
    color: #eee;
}

body.dark-mode .cookie-instruction {
    background-color: #2d2d2d;
    color: #ccc;
}

body.dark-mode .cookie-input {
    background-color: #333;
    color: #eee;
    border: 1px solid #555;
}

body.dark-mode .submit-cookie-button {
    background-color: #3399ff;
}

body.dark-mode .submit-cookie-button:hover {
    background-color: #287acc;
}

#popup-message {
    display: none;
    margin-bottom: 10px;
}

#popup-message-oly-save {
    display: none;
    margin-top: 12px;
}

.save-button-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 40px;
    margin-bottom: 60px;
}

.save-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    background-color: #28a745;
    color: white;
    font-size: 1rem;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.2s ease;
    min-width: 240px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: bold;
}

.save-button:hover {
    background-color: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.olympiad-hidden {
    display: none;
}

#olympiad-list h2 {
    visibility: hidden;
}

#olympiad-reorder-list h3 {
    visibility: hidden;
}

.usaco-tab-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.usaco-tab {
    padding: 6px 12px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    border-radius: 0;
    color: white;
}

.usaco-tab-content.hidden {
    display: none;
}

/* Light Mode Colors */
.platinum {
    background-color: #b0b0b0;
}

.gold {
    background-color: #e6b800;
}

.silver {
    background-color: #c0c0c0;
}

.bronze {
    background-color: #cd7f32;
}

/* Dark Mode Overrides */
.dark-mode .usaco-tab.platinum {
    background-color: #d0d0d0;
    color: #1a1a1a;
}

.dark-mode .usaco-tab.gold {
    background-color: #ffd700;
    color: #333300;
}

.dark-mode .usaco-tab.silver {
    background-color: #e0e0e0;
    color: #222222;
}

.dark-mode .usaco-tab.bronze {
    background-color: #de985c;
    color: #3a1f0f;
}

.usaco-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: flex-start;
}

/* Prevent tab buttons from shrinking awkwardly on wrap */
.usaco-tab-buttons {
    display: none;
    /* this will be changed in the js to 'flex' */
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1.3rem;
}

body.home .navbar .navbar-content {
    justify-content: center;
}

body.home .navbar-user {
    position: absolute;
    right: 12rem;
}

@media (max-width: 700px) {
    body.home .navbar-user {
        right: 1rem;
    }
}

body.home .navbar-title {
    display: none;
}

.center-header {
    text-align: center;
    margin: 2rem 1rem;
}

.auth-buttons {
    display: inline-flex;
    gap: 1rem;
    margin-bottom: 3rem;
}

.auth-buttons a {
    padding: 0.75rem 1.5rem;
    background-color: #28a745;
    color: white;
    text-decoration: none;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-buttons a:hover {
    background-color: #218838;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.features {
    max-width: 1000px;
    margin: 0 auto 4rem;
    padding: 0 1rem;
}

.features h2 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2rem;
}

.feature-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.feature-card {
    background-color: var(--card-bg);
    border-radius: 6px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.2s ease,
        box-shadow 0.2s ease,
        background-color 0.3s ease,
        color 0.3s ease;
}

.feature-card:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.feature-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
}

.feature-card p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

body,
.navbar,
.features,
.auth-buttons a {
    transition: background-color 0.3s ease, color 0.3s ease;
}

.btn-github {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    background-color: #24292e;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
    margin-bottom: 20px;
}

.btn-github:hover {
    background-color: #333;
}

.github-logo {
    width: 20px;
    height: 20px;
}

.btn-discord {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    background-color: #5865F2;
    /* Discord blurple */
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
    margin-bottom: 20px;
}

.btn-discord:hover {
    background-color: #4752C4;
    /* Slightly darker blurple */
}

.discord-logo {
    width: 20px;
    height: 20px;
}

/* Google OAuth button */
.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    width: 100%;
    padding: 10px;
    margin-bottom: 20px;

    background-color: #ffffff;
    color: #3c4043;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;

    transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

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

.btn-google:active {
    background-color: #eeeeee;
    border-color: #bdbdbd;
    box-shadow: none;
}

.google-logo {
    width: 18px;
    height: 18px;
}

.separator {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
}

.separator::before,
.separator::after {
    content: "";
    flex: 1;
    border-top: 1px solid #ccc;
}

.separator span {
    margin: 0 12px;
    padding: 2px 10px;
    font-size: 14px;
    color: #666;
    background-color: white;
    border-radius: 50px;
}

.dark-mode .separator::before,
.dark-mode .separator::after {
    border-top-color: #444;
}

.dark-mode .separator span {
    background-color: #1e1e1e;
    color: #aaa;
}

.popup-body a {
    color: #4ea1f3;
    /* soft blue that fits dark backgrounds */
    text-decoration: none;
    font-weight: 500;
}

.popup-body a:hover {
    text-decoration: underline;
    color: #82c6ff;
    /* lighter blue on hover */
}

.spinner {
    display: inline-block;
    width: 0.8em;
    height: 0.8em;
    border: 2px solid #ccc;
    border-top: 2px solid #333;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 4px;
    vertical-align: middle;
}

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

/* Mobile Responsive Improvements */
@media (max-width: 768px) {
    .navbar {
        padding: 0.5rem 1rem;
    }

    .navbar-content {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .navbar-title {
        font-size: 1.5rem;
        order: 1;
        flex: 1;
    }

    .navbar-user {
        order: 2;
        width: 100%;
        justify-content: space-between;
        margin-top: 0.5rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .welcome-message {
        font-size: 0.9rem;
        order: 1;
        flex: 1;
    }

    .logout-button {
        order: 3;
        font-size: 0.9rem;
        padding: 0.3rem 0.6rem;
    }

    .dark-mode-toggle {
        order: 2;
        transform: scale(0.9);
    }

    .settings-container {
        order: 4;
        transform: scale(0.9);
    }

    .settings-dropdown {
        right: -1rem;
        left: auto;
        width: 200px;
    }

    /* Stats container mobile */
    #solve-count-container {
        margin: 1rem;
        padding: 1rem;
    }

    #solve-count {
        flex-wrap: wrap;
        gap: 0.75rem;
        justify-content: center;
    }

    .solve-count-item {
        min-width: 80px;
        text-align: center;
    }

    .solve-count-item span:last-child {
        font-size: 16px !important;
    }

    #yellow-count,
    #red-count,
    #green-count,
    #white-count {
        font-size: 16px;
    }

    /* Tables mobile */
    .table-container {
        margin: 1rem;
        padding: 0.75rem;
        overflow-x: auto;
    }

    .table-container h2 {
        font-size: 1.4rem;
        margin-bottom: 1rem;
        text-align: center;
        line-height: 1.3;
        padding: 0 0.5rem;
    }

    .problem-table {
        min-width: 100%;
        font-size: 0.9rem;
    }

    .year-cell,
    .day-cell {
        min-width: 70px;
        max-width: 70px;
        width: 70px;
        padding: 0.5rem 0.2rem;
        font-size: 0.8rem;
        text-align: center;
        word-break: break-word;
    }

    .problem-cell {
        min-width: 80px;
        padding: 0.4rem 0.2rem;
        font-size: 0.85rem;
        min-height: 40px;
        cursor: pointer;
    }

    .problem-cell a {
        font-size: 0.85rem;
        line-height: 1.2;
        word-break: break-word;
        hyphens: auto;
    }

    .problem-cell:hover {
        transform: none;
        /* Disable hover transform on mobile */
    }

    /* USACO tabs mobile */
    .usaco-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
    }

    .usaco-tab-buttons {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .usaco-tab {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
        min-width: 70px;
        flex: 1;
        max-width: 90px;
    }

    /* Status popup mobile */
    #status-popup {
        width: 140px;
        font-size: 14px;
        padding: 8px 12px;
    }

    #popup-status {
        padding: 4px 8px;
        margin-bottom: 6px;
        font-size: 13px;
    }

    #popup-score {
        min-width: 20px;
        padding: 2px 4px;
        font-size: 14px;
    }

    .popup-out-of {
        font-size: 14px;
    }

    /* Improve skeleton loading on mobile */
    .skeleton-row .skeleton {
        height: 35px;
    }

    /* Better spacing for mobile */
    #olympiad-list {
        padding: 0 0.5rem;
    }
}

/* Extra small mobile screens */
@media (max-width: 480px) {
    .navbar {
        padding: 0.5rem 0.75rem;
    }

    .navbar-title {
        font-size: 1.3rem;
    }

    .welcome-message {
        font-size: 0.85rem;
    }

    #solve-count-container {
        margin: 0.75rem;
        padding: 0.75rem;
    }

    .solve-count-item {
        min-width: 70px;
    }

    .solve-count-item span:last-child {
        font-size: 0.85rem;
    }

    .table-container {
        margin: 0.75rem 0.5rem;
        padding: 0.5rem;
    }

    .table-container h2 {
        font-size: 1.2rem;
    }

    .problem-table {
        font-size: 0.85rem;
    }

    .year-cell,
    .day-cell {
        min-width: 60px;
        max-width: 60px;
        width: 60px;
        font-size: 0.75rem;
        padding: 0.3rem 0.1rem;
    }

    .problem-cell {
        min-width: 70px;
        padding: 0.3rem 0.15rem;
        font-size: 0.8rem;
    }

    .problem-cell a {
        font-size: 0.8rem;
    }

    .usaco-tab {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
        min-width: 60px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {

    /* This targets touch devices */
    .problem-cell {
        min-height: 44px;
        /* Apple's recommended minimum touch target */
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
    }

    .problem-cell a {
        padding: 0.5rem;
        display: inline-block;
        text-align: center;
        position: relative;
        z-index: 2;
    }

    /* Remove hover effects on touch devices */
    .problem-cell:hover {
        transform: none;
        box-shadow: none;
    }

    .usaco-tab:hover {
        transform: none;
    }

    .settings-button:hover {
        background-color: var(--button-bg, #f0f0f0);
    }
}

/* Horizontal scroll indicator for tables */
@media (max-width: 768px) {
    .table-container::after {
        content: '';
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 20px;
        height: 20px;
        background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.1));
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .table-container:hover::after {
        opacity: 1;
    }

    /* Better scrollbar for horizontal scroll */
    .table-container {
        scrollbar-width: thin;
        scrollbar-color: var(--accent-color, #007bff) transparent;
    }

    .table-container::-webkit-scrollbar {
        height: 6px;
    }

    .table-container::-webkit-scrollbar-track {
        background: transparent;
    }

    .table-container::-webkit-scrollbar-thumb {
        background-color: var(--accent-color, #007bff);
        border-radius: 3px;
    }
}

/* Section Progress Bars */
.section-progress-bar {
    width: 100%;
    height: 10px;
    /* Smaller than main progress bar */
    background-color: #f0f0f0;
    overflow: hidden;
    margin-bottom: 1rem;
    display: flex;
}

.section-progress-bar .progress-segment {
    height: 100%;
    width: 0%;
    /* Start with 0 width */
    transition: width 0.3s ease;
}

/* Initially show white segment at 100% until data loads */
.section-progress-bar .progress-segment.white {
    width: 100%;
}

.section-progress-bar .progress-segment.white {
    background-color: #e5e5e5;
}

.dark-mode .section-progress-bar .progress-segment.white {
    background-color: #2a2a2a;
}

/* Ensure section progress bars are visible but smaller */
.table-container .section-progress-bar {
    margin: 0.5rem 0 1rem 0;
}

/* Left section with home icon and title */
.navbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.home-icon {
    text-decoration: none;
    padding: 0.25rem;
    display: flex;
    align-items: center;
}

.home-icon svg {
    width: 30px;
    height: 30px;
}

/* Icon fill colors */
.home-icon-svg path {
    fill: black;
}

.dark-mode .home-icon-svg path {
    fill: white;
}

/* Empty state styling */
.empty-state {
    text-align: center;
    margin: 2rem auto;
    padding: 3rem 2rem;
    background-color: #ffffff;
    transition: background-color 0.3s ease;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: #333;
    font-weight: 600;
}

.empty-state p {
    margin: 0.75rem 0;
    font-size: 1rem;
    color: #666;
    line-height: 1.5;
}

/* Dark mode support */
.dark-mode .empty-state {
    background-color: #1e1e1e;
    border-color: #1e1e1e;
}

.dark-mode .empty-state h3 {
    color: #ffffff;
}

.dark-mode .empty-state p {
    color: #cccccc;
}

/* --- Markdown editor (Obsidian-like live preview) --- */
.md-toolbar {
    display: flex;
    gap: .25rem;
    margin-bottom: .5rem;
}

.md-btn {
    background: transparent;
    border: 1px solid #d0d0d0;
    padding: .25rem .5rem;
    cursor: pointer;
    font-size: .9rem;
    line-height: 1;
}

.md-btn:hover {
    background: #f2f2f2;
}

body.dark-mode .md-btn {
    border-color: #555;
    color: #eee;
}

body.dark-mode .md-btn:hover {
    background: #2a2f36;
}

/* Markdown editor refinements */
.md-editor {
    min-height: 220px;
    padding: .5rem .75rem;
    border: 1px solid #d0d0d0;
    background: #fff;
    overflow: auto;
    cursor: text;
}

.md-editor:focus-within {
    outline: 2px solid #a7c7ff;
    outline-offset: -2px;
}

.md-line {
    padding: 2px 0;
}

.md-line.editing {
    background: #f8f9fb;
    border-radius: 2px;
}

.md-line code {
    padding: 0 .2em;
    background: rgba(0, 0, 0, .05);
    border-radius: 2px;
}

.md-line pre {
    margin: .25rem 0;
    padding: .5rem;
    background: #f6f8fa;
    border: 1px solid #e1e4e8;
    overflow: auto;
}

body.dark-mode .md-editor {
    background: #1b1b1b;
    border-color: #333;
}

body.dark-mode .md-line.editing {
    background: #262b31;
}

body.dark-mode .md-line code {
    background: #2a2f36;
}

body.dark-mode .md-line pre {
    background: #1f242a;
    border-color: #2b3138;
    color: #e6e6e6;
}

/* --- Markdown textarea (true textbox) --- */
.md-textarea {
    width: 100%;
    min-height: 240px;
    padding: 0.75rem 0.85rem;
    font: 14px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    color: #222;
    background: #fff;
    border: 1px solid #d0d7de;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .03);
    resize: vertical;
    outline: none;
}

.md-textarea:focus {
    border-color: #4ea1f3;
    box-shadow: 0 0 0 3px rgba(78, 161, 243, .25);
}

.dark-mode .md-textarea {
    color: #e6e6e6;
    background: #222;
    border-color: #3a3a3a;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2);
}

.dark-mode .md-textarea:focus {
    border-color: #82c6ff;
    box-shadow: 0 0 0 3px rgba(130, 198, 255, .25);
}