body {
    margin: 0;
    padding: 0;
    background: #FFFFFF;
    font-family: medium-content-sans-serif-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    color: #333;
}

/* Global audio toggle */
.audio-toggle {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    color: #E0E0E0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    backdrop-filter: blur(4px);
}

/* Page preload animation for all pages (except audio UI) */
.page-preload body.secret-page > *:not(.audio-bar):not(.audio-toggle):not(link):not(script) {
    opacity: 0 !important;
    transform: translateY(16px) scale(1.02);
    filter: blur(2.5px);
}

body.secret-page > *:not(.audio-bar):not(.audio-toggle):not(link):not(script) {
    transition: opacity 600ms cubic-bezier(0.22, 1, 0.36, 1),
                transform 650ms cubic-bezier(0.22, 1, 0.36, 1),
                filter 650ms cubic-bezier(0.22, 1, 0.36, 1);
}
/* Light mode: make icon black for stronger contrast */
html:not(.dark-mode) .audio-toggle { color: #000000; }

/* Reserve space under fixed audio bar */
.with-audio body {
    padding-top: 24px;
}
@media (max-width: 600px) {
  .with-audio body { padding-top: 24px; }
}

/* Top audio bar with progress */
.audio-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    z-index: 10000;
    pointer-events: none;
}
.audio-bar-inner {
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 15px;
    pointer-events: auto;
}
.audio-bar .audio-toggle { pointer-events: auto; }
.audio-progress {
    flex: 1;
    height: 4px;
    border-radius: 999px;
    background: rgba(0,0,0,0.12);
    overflow: visible;
    pointer-events: auto;
    position: relative;
    cursor: pointer;
}
.audio-progress-fill {
    width: 0%;
    height: 100%;
    background: #FFFFFF;
    border-radius: inherit;
    transition: width 120ms linear, background-color 200ms ease;
}
.audio-progress:hover .audio-progress-fill {
    background: #1DB954;
}
/* draggable handle */
.audio-progress-handle {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #FFFFFF;
    box-shadow: 0 0 6px rgba(0,0,0,0.25);
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: background-color 200ms ease, opacity 150ms ease;
}
.audio-progress:hover .audio-progress-handle { opacity: 1; }
html.dark-mode .audio-progress { background: rgba(255,255,255,0.18); }
/* Light/Dark mode elapsed color */
html:not(.dark-mode) .audio-progress-fill { background: #000000; }
html.dark-mode .audio-progress-fill { background: #FFFFFF; }

/* Align to questions page container width */
.form-body .audio-bar-inner {
    max-width: 680px;
    padding: 0 15px;
}

.article {
    -webkit-text-size-adjust: 100%;
    --reach-tabs: 1;
    --reach-menu-button: 1;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    word-wrap: break-word;
    word-break: break-word;
    box-sizing: inherit;
    font-family: source-serif-pro, Georgia, Cambria, "Times New Roman", Times, serif;
    font-weight: 400;
    font-style: normal;
    color: #242424;
    max-width: 680px;
    margin: 40px auto;
    padding: 0 15px 60px;
    background: #FFFFFF;
    transition: opacity 500ms ease, transform 600ms ease, filter 600ms ease;
}

/* Secret page enter animation */
.page-preload body > *:not(.audio-bar):not(.audio-toggle):not(link):not(script):not(.article) {
    opacity: 0;
    transform: translateY(8px) scale(1.01);
    filter: blur(1.5px);
}

body > *:not(.audio-bar):not(.audio-toggle):not(link):not(script) {
    transition: opacity 450ms ease, transform 500ms ease, filter 500ms ease;
}

/* Secret page: animate each element inside the article individually */
.page-preload .article > * {
    opacity: 0;
    transform: translateY(14px) scale(1.01);
    filter: blur(1.5px);
}

.article > * {
    transition: opacity 600ms cubic-bezier(0.22, 1, 0.36, 1),
                transform 650ms cubic-bezier(0.22, 1, 0.36, 1),
                filter 650ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Subtle stagger for a more obvious, but tasteful, entrance */
.article > *:nth-child(1) { transition-delay: 40ms; }
.article > *:nth-child(2) { transition-delay: 80ms; }
.article > *:nth-child(3) { transition-delay: 120ms; }
.article > *:nth-child(4) { transition-delay: 160ms; }
.article > *:nth-child(5) { transition-delay: 200ms; }
.article > *:nth-child(6) { transition-delay: 240ms; }
.article > *:nth-child(7) { transition-delay: 280ms; }
.article > *:nth-child(8) { transition-delay: 320ms; }
.article > *:nth-child(9) { transition-delay: 360ms; }
.article > *:nth-child(10) { transition-delay: 400ms; }

.article h1 {
    -webkit-text-size-adjust: 100%;
    --reach-tabs: 1;
    --reach-menu-button: 1;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    word-break: break-word;
    word-wrap: break-word;
    box-sizing: inherit;
    margin: 0;
    font-family: sohne, "Helvetica Neue", Helvetica, Arial, sans-serif;
    color: #242424;
    font-style: normal;
    font-weight: 900;
    font-size: 42px;
    margin-top: 1.19em;
    margin-bottom: 32px;
    line-height: 52px;
    letter-spacing: -0.011em;
}
.author {
    -webkit-text-size-adjust: 90%;
    --reach-tabs: 1;
    --reach-menu-button: 1;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    color: rgba(0,0,0,0.8);
    font-family: medium-content-sans-serif-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    font-weight: 400;
    word-break: break-word;
    word-wrap: break-word;
    box-sizing: inherit;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-direction: row;
    margin-bottom: 2rem;
}

.author-info { display: flex; flex-direction: row; align-items: center; gap: 12px; flex-wrap: wrap; }
.author-top { display: inline-flex; align-items: center; gap: 12px; }
.author-bottom { display: inline-flex; align-items: center; gap: 8px; }

.author-photo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    /* loading animation */
    opacity: 0;
    transform: translateY(6px) scale(1.02);
    filter: blur(1px);
    transition: opacity 500ms ease, transform 600ms ease, filter 600ms ease;
    will-change: opacity, transform, filter;
}

html.author-img-loaded .author-photo {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: none;
}

.author-name {
    font-weight: 500;
}

.author-meta {
    color: #666;
    font-size: 0.9rem;
}

.follow-button {
    border: 1px solid #242424;
    background: transparent;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-family: medium-content-sans-serif-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    cursor: pointer;
}

.follow-button:hover {
    background: #f2f2f2;
}

.action-bar {
    -webkit-text-size-adjust: 100%;
    --reach-tabs: 1;
    --reach-menu-button: 1;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    color: rgba(0,0,0,0.8);
    font-family: medium-content-sans-serif-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    font-weight: 400;
    word-break: break-word;
    word-wrap: break-word;
    box-sizing: inherit;
    display: flex;
    justify-content: space-between;
    border-top: solid 1px #F2F2F2;
    border-bottom: solid 1px #F2F2F2;
    margin: 32px 0 0;
    padding: 10px 8px;
    align-items: center;
}

.actions-left,
.actions-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.action-icon {
    display: flex;
    align-items: center;
    gap: 4px;
}

.action-icon svg,
.actions-right svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.action-count {
    font-size: 14px;
}

.article p {
    margin: 0;
    margin-top: 2.14em;
    margin-bottom: -0.46em;
    font-size: 20px;
    line-height: 32px;
    letter-spacing: -0.003em;
    box-sizing: inherit;
    font-weight: 400;
    color: #242424;
}

.form-body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
    position: relative;
}

.form-body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: linear-gradient(rgba(0,0,0,0.66), rgba(0,0,0,0.66)), url('bg-big.jpg');
    background-position: center center;
    background-size: cover;
    background-repeat: no-repeat;
    filter: blur(4px);
    z-index: 0;
    opacity: 0;
    transform: scale(1.03);
    transition: opacity 600ms ease, transform 1200ms ease;
    will-change: opacity, transform;
}

.form-body.bg-loaded::before {
    opacity: 1;
    transform: scale(1);
}

.form-container {
    width: min(92vw, 680px);
    margin: 0;
    background: #F9FDFE;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1;
}

/* Dark mode base */
html.dark-mode body {
    background: #0f0f0f;
    color: #A5A5A5;
}

/* Dark mode for article pages */
html.dark-mode .article {
    background: transparent;
    color: #A5A5A5;
}
html.dark-mode .article h1,
html.dark-mode .author-name,
html.dark-mode .follow-button,
html.dark-mode .article p {
    color: #A5A5A5;
}
html.dark-mode .article figcaption {
    color: #A5A5A5;
}
html.dark-mode .follow-button {
    border-color: #A5A5A5;
}
html.dark-mode .follow-button:hover {
    color: #0f0f0f;
}

/* Dark mode: questions page */
html.dark-mode .form-container {
    background: #1A1A1A;
    color: #A5A5A5;
}
html.dark-mode .form-container input {
    background: #121212;
    border-color: #333;
    color: #E0E0E0;
}
html.dark-mode .form-container input::placeholder {
    color: #888;
}
html.dark-mode .form-container button {
    background: #0040FF;
    color: #FFFFFF;
}
html.dark-mode .form-container button:hover {
    background: #0040FF;
}
html.dark-mode .error { color: #ffb3b3; }
html.dark-mode .locked-message { color: #bbb; }

/* Dark mode: secret page action bar and icons */
html.dark-mode .action-bar {
    color: #A5A5A5;
    border-top: solid 1px #2a2a2a;
    border-bottom: solid 1px #2a2a2a;
}
html.dark-mode .action-icon svg,
html.dark-mode .actions-right svg {
    color: #A5A5A5;
}

/* Theme toggle button */
.theme-toggle {
    position: fixed;
    bottom: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.05);
    color: #333;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1), background-color 200ms ease, box-shadow 200ms ease;
    z-index: 9999;
    opacity: 0.7;
}
.theme-toggle:hover { transform: scale(1.1) rotate(8deg); opacity: 1; }
.theme-toggle:active { transform: scale(0.95) rotate(-6deg); }
.theme-toggle.pulse { animation: pulse 400ms ease; }
.theme-toggle .theme-toggle-icon { font-size: 18px; line-height: 1; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.45); }
  100% { box-shadow: 0 0 0 16px rgba(255, 193, 7, 0); }
}

/* Heartbeat animation (applied via .heartbeat-animation) */
@keyframes heartbeat {
  0% { transform: scale(1); }
  6% { transform: scale(1.03); }
  11% { transform: scale(1); }
  17% { transform: scale(1.03); }
  29% { transform: scale(1); }
}

.heartbeat-animation {
  animation: heartbeat 2.8s ease-in-out infinite;
}

/* Status change animation (reserved for future use) */
@keyframes statusChange {
  0% { transform: scale(1); opacity: 1; }
  25% { transform: scale(1.15); opacity: 0.8; }
  50% { transform: scale(1.05); opacity: 0.9; }
  75% { transform: scale(1.1); opacity: 0.85; }
  100% { transform: scale(1); opacity: 1; }
}

html.dark-mode .theme-toggle {
  background: rgba(255,255,255,0.06);
  color: #E0E0E0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.32);
}

.form-container h1 {
    text-align: center;
    margin-bottom: 20px;
}

.form-container label {
    display: block;
    margin-top: 0;
    font-weight: 500;
}

.form-container input {
    width: 100%;
    padding: 8px;
    margin-top: 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    transition: border-color 280ms cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 320ms cubic-bezier(0.4, 0, 0.2, 1),
                background-color 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

.form-container label > input {
    margin-top: 12px;
}

/* Remove number input spinners */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

.form-container input:focus {
    outline: none;
    border-color: #FFC107;
    box-shadow: 0 2px 12px rgba(255, 193, 7, 0.35);
    background-color: #FFFFFF;
    transition: border-color 280ms cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 320ms cubic-bezier(0.4, 0, 0.2, 1),
                background-color 280ms cubic-bezier(0.4, 0, 0.2, 1);
}

html.dark-mode .form-container input:focus {
    border-color: #FFCA2C;
    box-shadow: 0 2px 12px rgba(255, 202, 44, 0.42);
    background-color: #121212;
}

.form-container button {
    margin-top: 12px; /* aligns with consistent gap */
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 6px;
    background: #0040FF;
    color: #FFFFFF;
    font-size: 1rem;
    cursor: pointer;
    transform: scale(1);
    transition: transform 180ms cubic-bezier(0.4, 0, 0.2, 1), background-color 180ms ease, box-shadow 180ms ease;
    will-change: transform, box-shadow;
}

.form-container button:hover { background: #0040FF; transform: scale(1.03); }

.form-container button:active { transform: scale(0.97); }

/* (Removed heartbeat animation from the Unlock button; simple hover/active scaling instead) */

.form-split {
    display: grid;
    grid-template-columns: 1fr 1.618fr;
    align-items: stretch;
    min-height: 100%;
}

.form-visual {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    overflow: hidden;
}

.form-visual img {
    display: block;
    width: 100%;
    height: calc(100% + 90px);
    object-fit: cover;
    object-position: top center;
    transform: translateY(-90px);
    opacity: 0;
    filter: blur(1px);
    transform: translateY(-90px) translateY(6px) scale(1.02);
    transition: opacity 600ms ease, transform 700ms ease, filter 700ms ease;
    will-change: opacity, transform, filter;
}

.form-body.box-img-loaded .form-visual img {
    opacity: 1;
    filter: blur(0);
    transform: translateY(-90px) translateY(0) scale(1);
}

.form-content {
    padding: 24px 40px;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    position: relative;
}

/* Success animation states */
.form-content.success-anim > *:not(.correct-overlay) {
    filter: blur(4px);
    opacity: 0;
    transition: filter 400ms ease, opacity 400ms ease;
}

.correct-overlay {
    position: absolute;
    inset: 0;
    /* Center within the form-content column only */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: #333;
    text-align: center;
    padding: 20px;
    pointer-events: none;
    z-index: 2;
}
html.dark-mode .correct-overlay { color: #FFFFFF; }

.form-container.container-fade-out {
    opacity: 0;
    transform: scale(0.98);
    transition: opacity 600ms ease, transform 600ms ease;
}

.form-content h1 {
    text-align: left;
    margin-top: 0;
    margin-bottom: 0;
}

.form-content form {
    width: 100%;
    margin-top: 12px;
    margin-bottom: 0;
    display: grid;
    row-gap: 12px;
}

.form-content input {
    width: 100%;
}

.form-content button {
    width: 100%;
    margin-top: 12px;
}

.form-content .error,
.form-content .locked-message {
    width: 100%;
}

.error {
    color: #c00;
    text-align: center;
}

.locked-message {
    text-align: center;
    margin-top: 15px;
    color: #555;
}

img {
    max-width: 100%;
    height: auto;
}

.article figure {
    margin: 2.14em 0;
}

.article figure img {
    display: block;
    width: 100%;
    height: auto;
}

.article figcaption {
    margin-top: 8px;
    color: rgba(0,0,0,0.6);
    font-family: medium-content-sans-serif-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 8px;
    text-align: left;
}

.table-container {
    overflow-x: auto;
    margin-top: 20px;
}

@media (max-width: 600px) {
    .form-body::before {
        background-image:
            linear-gradient(rgba(0,0,0,0.66), rgba(0,0,0,0.66)),
            url('bg-big.jpg');
    }
    .article {
        margin: 30px auto 60px;
        padding: 0 20px;
    }

    .article h1 {
        font-size: 32px;
        line-height: 40px;
    }

    .action-bar {
        flex-direction: row;
        align-items: center;
    }

    /* Allow wrap only when truly needed */
    .author { align-items: center; }
    .author-top { flex-wrap: nowrap; }
    .author-bottom { margin-top: 0; }

    .form-container {
        width: calc(100vw - 40px);
        margin: 30px 20px;
        padding: 0;
    }

    .form-split { display: block; }

    .form-visual { display: none; }

    .form-visual img {
        width: 100%;
        height: calc(100% + 90px);
        object-fit: cover;
        transform: translateY(-90px);
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

@media (min-width: 1200px) {
    .form-body::before {
        background-image:
            linear-gradient(rgba(0,0,0,0.66), rgba(0,0,0,0.66)),
            url('bg-big.jpg');
    }
}

/* Admin logs page styles */
.logs-container {
    max-width: 900px;
    margin: 40px auto;
    padding: 0 20px;
}

.logs-container h1 {
    text-align: left;
    margin-bottom: 20px;
}

.logs-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, 160px);
  grid-auto-rows: 120px;
  gap: 16px;
  justify-content: start; /* prevents last row from stretching */
}

.stat-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-sizing: border-box;
  border-radius: 8px;
  background: rgba(0,0,0,0.03);
  flex-direction: column;
  text-align: center;
  gap: 4px;
}

html.dark-mode .stat-card {
    background: rgba(255,255,255,0.1);
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 600;
}

.stat-label {
    display: block;
    font-size: 14px;
    color: rgba(0,0,0,0.6);
}

html.dark-mode .stat-label {
    color: rgba(255,255,255,0.7);
}

.logs-container table {
    border: 1px solid #ddd;
    border-collapse: collapse;
}

.logs-container th, .logs-container td {
    border-bottom: 1px solid #ddd;
    text-align: center;
    vertical-align: middle;
}

.logs-container tbody tr:nth-child(even) {
    background-color: rgba(0,0,0,0.03);
}

html.dark-mode .logs-container tbody tr:nth-child(even) {
    background-color: rgba(255,255,255,0.05);
}
