:root {
    --bg: #f5f7fb;
    --bg-accent: #e6efff;
    --surface: #ffffff;
    --surface-muted: #f1f5f9;
    --ink: #101828;
    --ink-muted: #475467;
    --brand: #2563eb;
    --brand-strong: #1d4ed8;
    --accent: #06b6d4;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow-soft: 0 24px 60px rgba(15, 23, 42, 0.12);
    --shadow-card: 0 14px 36px rgba(15, 23, 42, 0.12);
    --radius-xl: 24px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 10px;
    --border: 1px solid rgba(148, 163, 184, 0.35);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
    margin: 0;
    color: var(--ink);
    background: radial-gradient(circle at top left, #e7f0ff 0%, transparent 50%),
        radial-gradient(circle at 85% 35%, rgba(251, 207, 232, 0.5) 0%, transparent 50%),
        radial-gradient(circle at 20% 80%, #d9f5ff 0%, transparent 45%),
        linear-gradient(180deg, #f8fafc 0%, #eef2f8 100%);
    background-size: 120% 120%, 120% 120%, 120% 120%, 100% 100%;
    background-position: 0% 0%, 85% 35%, 20% 80%, 50% 0%;
    animation: background-drift 28s ease-in-out infinite;
    min-height: 100vh;
    padding-top: 44px;
}

body::before,
body::after {
    content: '';
    position: fixed;
    width: 360px;
    height: 360px;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.35;
    z-index: -1;
}

html::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(rgba(15, 23, 42, 0.08) 1px, transparent 1px);
    background-size: 3px 3px;
    opacity: 0.12;
    mix-blend-mode: soft-light;
    pointer-events: none;
    z-index: -1;
    animation: noise-shift 6s steps(6) infinite;
}

body::before {
    background: #93c5fd;
    top: -120px;
    right: -120px;
    animation: blob-drift-1 6s ease-in-out infinite;
}

body::after {
    background: #67e8f9;
    bottom: -140px;
    left: -120px;
    animation: blob-drift-2 7s ease-in-out infinite;
}

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

a:hover {
    color: var(--brand-strong);
}

button,
button[type="submit"] {
    font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
    border: none;
    border-radius: 999px;
    padding: 14px 18px;
    cursor: pointer;
    background: linear-gradient(120deg, var(--brand), var(--accent));
    color: white;
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.2);
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(37, 99, 235, 0.24);
}

button:active {
    transform: translateY(0);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: var(--border);
    background: rgba(255, 255, 255, 0.85);
    font-size: 16px;
    color: var(--ink);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.65);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%),
        linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(1em + 2px),
        calc(100% - 13px) calc(1em + 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.menu-container {
    position: fixed;
    top: 0;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    z-index: 1000;
    justify-content: space-between;
}

.menu-button {
    background: var(--surface);
    color: var(--ink);
    border-radius: 8px;
    padding: 0;
    width: 36px;
    height: 30px;
    font-size: 12px;
    box-shadow: none;
    border: var(--border);
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.menu-icon {
    display: inline-block;
    width: 16px;
    height: 2px;
    background: var(--ink);
    border-radius: 999px;
    position: relative;
}

.menu-icon::before,
.menu-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 16px;
    height: 2px;
    background: var(--ink);
    border-radius: 999px;
}

.menu-icon::before {
    top: -5px;
}

.menu-icon::after {
    top: 5px;
}

.menu-links {
    display: flex;
    gap: 8px;
    margin-left: 0;
    flex-wrap: nowrap;
}

.menu-links a {
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.08);
    color: var(--ink);
    font-weight: 600;
    font-size: 12px;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.menu-links a:hover {
    background: rgba(37, 99, 235, 0.16);
    color: var(--brand-strong);
}

.menu-links.hidden {
    display: none;
}

.page-content {
    width: 92%;
    max-width: 1200px;
    margin: 0 auto 60px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}


.form-container,
.misc-container,
.analytics-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(148, 163, 184, 0.2);
    overflow: hidden;
    width: 100%;
}

.card-shell {
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    border: 1px solid rgba(148, 163, 184, 0.2);
    overflow: hidden;
    width: 100%;
    background: transparent;
}

.card-shell .form-container,
.card-shell .misc-container,
.card-shell .analytics-card {
    background: transparent;
    box-shadow: none;
    border: none;
}

.card-shell .container-padding {
    background: var(--surface);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.analytics-table-card {
    margin-top: 16px;
}

.history-entries {
    margin-top: 16px;
}

.container-padding {
    padding: 20px 22px 24px;
}

.entry-card .container-padding {
    padding-left: 5px;
    padding-right: 5px;
}

body > .form-container,
body > .card-shell {
    max-width: 420px;
    margin: 72px auto 32px;
    width: calc(100% - 32px);
}

body > .card-shell {
    padding: 0;
}

.div-header {
    background: transparent;
    color: var(--ink);
    padding: 10px 22px;
    backdrop-filter: blur(8px) saturate(140%);
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    position: relative;
    overflow: hidden;
}

.div-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    mix-blend-mode: difference;
    pointer-events: none;
    z-index: 0;
}

.div-header h2,
.div-header h3,
.div-header p {
    position: relative;
    z-index: 1;
}

.div-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--ink);
}

h2 {
    margin: 0;
    font-size: 22px;
}

form {
    display: grid;
    gap: 12px;
}

.container-padding > form button {
    width: 100%;
}

.form-link {
    text-align: center;
    color: var(--ink-muted);
    font-size: 14px;
}

.flash-messages {
    width: 92%;
    max-width: 1200px;
    margin: 16px auto 0;
}

.flash {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 10px;
    background-color: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: var(--ink);
}

.flash.warning {
    background-color: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
}

.flash.success {
    background-color: #ecfdf3;
    border-color: #bbf7d0;
    color: #166534;
}

.flash.danger {
    background-color: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

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

.recent-entries-table {
    margin-top: 16px;
}

th,
td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    font-size: 14px;
}

@media (max-width: 700px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

th {
    color: var(--ink-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 12px;
}

tr:hover {
    background: rgba(37, 99, 235, 0.04);
}

table button {
    width: auto;
    padding: 6px 12px;
    font-size: 12px;
    box-shadow: none;
}

.carousel-frame {
    position: relative;
}

.carousel-frame::before,
.carousel-frame::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 10px;
    width: 22px;
    pointer-events: none;
    z-index: 2;
}

.carousel-frame::before {
    left: 0;
    background: linear-gradient(90deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
}

.carousel-frame::after {
    right: 0;
    background: linear-gradient(-90deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0));
}

.carousel {
    display: flex;
    gap: 28px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-snap-stop: always;
    scroll-padding: 0 18px;
    padding: 0 18px 10px;
    -webkit-overflow-scrolling: touch;
}

.field-card,
.time-card {
    flex: 0 0 98%;
    background: var(--surface-muted);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: var(--radius-lg);
    padding: 30px;
    scroll-snap-align: center;
    text-align: center;
}

.field-card-header {
    font-size: 18px;
    color: var(--ink);
    margin-bottom: 10px;
}

.field-card-value-input {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 52px;
    color: var(--brand);
    margin: 12px 0 18px;
    text-align: center;
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
}

.field-card-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
}

.field-card-buttons button {
    width: auto;
    padding: 16px 22px;
    font-size: 16px;
    background: rgba(37, 99, 235, 0.12);
    color: var(--brand-strong);
    box-shadow: none;
}

.entry-card {
    background: transparent;
}

.field-card-buttons button:hover {
    background: rgba(37, 99, 235, 0.2);
}

.field-card-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.field-card-actions button {
    flex: 1;
    padding: 12px 18px;
}

.reset-button {
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
    box-shadow: none;
}

.reset-button:hover {
    background: rgba(220, 38, 38, 0.2);
}

.undo-button {
    background: rgba(37, 99, 235, 0.12);
    color: var(--brand-strong);
    box-shadow: none;
}

.undo-button:hover {
    background: rgba(37, 99, 235, 0.2);
}

.primary-submit {
    background: linear-gradient(120deg, var(--success), #4ade80);
    box-shadow: 0 10px 20px rgba(22, 163, 74, 0.2);
    justify-self: center;
    align-self: center;
    width: 100%;
    max-width: none;
    margin: 0;
    display: block;
}

.submit-row {
    padding: 10px 18px 0;
}

.primary-submit:hover {
    opacity: 0.92;
}

.session-toggle {
    width: 100%;
    background: rgba(37, 99, 235, 0.08);
    color: var(--brand-strong);
    box-shadow: none;
    border: 1px solid rgba(37, 99, 235, 0.2);
    margin-bottom: 10px;
}

.backfill-block {
    margin-top: 14px;
    display: grid;
    gap: 8px;
}

.backfill-toggle {
    margin-bottom: 0;
}

.backfill-panel.is-collapsed {
    display: none;
}

.session-details {
    display: grid;
    gap: 6px;
    color: var(--ink-muted);
    margin-bottom: 12px;
}

.session-details.is-collapsed {
    display: none;
}

.session-form {
    display: grid;
    gap: 10px;
}

.backfill-divider {
    margin: 16px 0;
    text-align: center;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.log-time-row {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
}

.log-time-row label {
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.suggestion-row,
.time-suggestion-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.suggestion-button {
    width: auto;
    padding: 6px 12px;
    background: rgba(15, 23, 42, 0.05);
    color: var(--ink);
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 999px;
    cursor: pointer;
    box-shadow: none;
}

.suggestion-button:hover {
    background: rgba(15, 23, 42, 0.1);
}

.goal-row {
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--ink-muted);
}

.workout-nav {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.workout-group {
    margin-bottom: 20px;
}

.workout-group h3 {
    margin: 10px 0;
    color: var(--ink);
}

.field-card-bool .toggle-button {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    background: rgba(37, 99, 235, 0.14);
    color: var(--brand-strong);
    box-shadow: none;
}

.field-card-bool .toggle-button.is-on {
    background: rgba(22, 163, 74, 0.18);
    color: #166534;
}

.time-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 12px 0 16px;
}

.time-grid-compact {
    grid-template-columns: repeat(2, 1fr);
}

.time-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.time-input {
    font-size: 32px;
    font-weight: bold;
    color: var(--brand);
    width: 90px;
    text-align: center;
}

.time-stepper {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    width: 100%;
}

.time-step {
    width: auto;
    padding: 10px 12px;
    font-size: 15px;
    background: rgba(37, 99, 235, 0.12);
    color: var(--brand-strong);
    box-shadow: none;
}

.time-step:hover {
    background: rgba(37, 99, 235, 0.2);
}

.time-label {
    font-size: 12px;
    color: var(--ink-muted);
}

.time-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

.time-actions-right {
    display: flex;
    gap: 10px;
    flex: 1;
}

.time-actions .reset-button {
    width: 100%;
}

.time-actions-right button {
    flex: 1;
}

.duration-toggle {
    background: rgba(37, 99, 235, 0.2);
    color: var(--brand-strong);
    box-shadow: none;
}

.duration-toggle.is-on {
    background: rgba(37, 99, 235, 0.35);
}

.analytics-page {
    width: 100%;
    margin: 0 auto;
}

.analytics-header {
    text-align: center;
    margin-bottom: 16px;
}

.analytics-subtitle {
    margin: 6px 0 0;
    color: var(--ink-muted);
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.analytics-filters label {
    display: block;
    margin-top: 8px;
    margin-bottom: 6px;
    color: var(--ink);
    font-weight: 600;
}

.analytics-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.analytics-stat {
    background: var(--surface-muted);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: var(--radius-md);
    padding: 10px;
    text-align: center;
}

.analytics-stat-label {
    font-size: 12px;
    color: var(--ink-muted);
}

.analytics-stat-value {
    font-size: 20px;
    color: var(--brand-strong);
    margin-top: 4px;
}

.analytics-chart {
    position: relative;
    width: 100%;
    height: 260px;
}

.analytics-chart svg {
    width: 100%;
    height: 100%;
    display: block;
}

.analytics-empty {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 20px;
    color: var(--ink-muted);
    background: #f8fafc;
    border-radius: var(--radius-md);
}

.analytics-empty.show {
    display: flex;
}

@media (min-width: 900px) {
    .menu-button {
        display: none;
    }

    .menu-links {
        display: flex;
        margin-left: 0;
    }

    .menu-links.hidden {
        display: flex;
    }
}

@media (max-width: 900px) {
    .menu-container {
        flex-wrap: nowrap;
        gap: 10px;
    }

    .menu-links {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: rgba(255, 255, 255, 0.98);
        padding: 12px 18px 16px;
        border-radius: 0 0 18px 18px;
        box-shadow: var(--shadow-soft);
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .menu-links a {
        width: 100%;
        padding: 12px 16px;
        font-size: 14px;
        border-radius: 12px;
    }

    .menu-links.hidden {
        display: none;
    }

    .menu-container.is-open .menu-links {
        display: flex;
    }
}

@media (max-width: 640px) {
    .page-content {
        width: 92%;
    }

    .analytics-chart {
        height: 220px;
    }
}

@keyframes background-drift {
    0% {
        background-position: 0% 0%, 85% 35%, 20% 80%, 50% 0%;
    }
    50% {
        background-position: 6% 4%, 80% 40%, 26% 74%, 50% 0%;
    }
    100% {
        background-position: 0% 0%, 85% 35%, 20% 80%, 50% 0%;
    }
}

@keyframes noise-shift {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 12px 18px;
    }
}

@keyframes blob-drift-1 {
    0% {
        transform: translate(0, 0);
        opacity: 0.25;
    }
    50% {
        transform: translate(-120px, 90px);
        opacity: 0.65;
    }
    100% {
        transform: translate(0, 0);
        opacity: 0.25;
    }
}

@keyframes blob-drift-2 {
    0% {
        transform: translate(0, 0);
        opacity: 0.22;
    }
    50% {
        transform: translate(130px, -110px);
        opacity: 0.6;
    }
    100% {
        transform: translate(0, 0);
        opacity: 0.22;
    }
}

@media (prefers-reduced-motion: reduce) {
    body {
        animation: none;
    }

    html::before {
        animation: none;
    }

    body::before,
    body::after {
        animation: none;
    }
}
