:root {
    color-scheme: dark;
    --bg: #0b1018;
    --surface: #121b28;
    --surface2: #172333;
    --border: #263446;
    --text: #f2f5f8;
    --muted: #9caabd;
    --accent: #b7f34b;
    --accent-dark: #263d12;
    --danger: #ff7676;
    --radius: 18px;
    --shadow: 0 18px 45px rgba(0, 0, 0, .18);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: radial-gradient(ellipse at 50% -20%, #203047 0, transparent 42%), var(--bg);
    color: var(--text);
    min-height: 100vh
}

button,
input,
textarea,
select {
    font: inherit
}

button,
a {
    -webkit-tap-highlight-color: transparent
}

a {
    color: inherit;
    text-decoration: none
}

.topbar {
    height: 76px;
    padding: 0 clamp(18px, 4vw, 60px);
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(9, 14, 21, .78);
    backdrop-filter: blur(18px)
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 13px;
    background: var(--accent);
    color: #10170b;
    display: grid;
    place-items: center;
    font-weight: 950;
    font-size: 23px
}

.brand strong,
.brand small {
    display: block;
    letter-spacing: .08em
}

.brand strong {
    font-size: 13px
}

.brand small {
    color: var(--muted);
    font-size: 10px;
    margin-top: 3px;
    letter-spacing: .04em
}

.admin-link {
    font-size: 13px;
    color: #d4dfeb;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 999px
}

.admin-link:hover {
    border-color: #53677f
}

.page-shell {
    max-width: 1500px;
    margin: auto;
    padding: clamp(22px, 4vw, 56px)
}

.hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 42px
}

.eyebrow {
    font-size: 10px;
    letter-spacing: .19em;
    font-weight: 800;
    color: var(--accent);
    margin: 0 0 10px
}

.hero h1,
.admin-heading h1,
.login-card h1 {
    font-size: clamp(30px, 4vw, 48px);
    letter-spacing: -.045em;
    line-height: 1.06;
    margin: 0 0 12px
}

.muted {
    color: var(--muted);
    line-height: 1.6;
    margin: 0
}

.small {
    font-size: 12px
}

.tiny {
    font-size: 11px
}

.offline-pill {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 14px;
    background: rgba(183, 243, 75, .08);
    border: 1px solid rgba(183, 243, 75, .19);
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px #b7f34b
}

.section-block {
    margin-bottom: 36px
}

.section-heading,
.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px
}

.section-heading h2,
.panel-heading h2,
.results-toolbar h2 {
    margin: 0;
    font-size: 21px;
    letter-spacing: -.025em
}

.section-heading .eyebrow,
.panel-heading .eyebrow,
.results-toolbar .eyebrow {
    margin-bottom: 5px
}

.type-grid {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 12px
}

.type-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 13px;
    text-align: left;
    min-height: 90px;
    padding: 18px;
    border: 1px solid var(--border);
    background: linear-gradient(140deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .01));
    border-radius: 16px;
    color: var(--text);
    cursor: pointer;
    transition: .18s ease
}

.type-card:hover {
    transform: translateY(-2px);
    border-color: #53667a
}

.type-card.active {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(183, 243, 75, .13), rgba(183, 243, 75, .025));
    box-shadow: inset 0 0 0 1px rgba(183, 243, 75, .15)
}

.type-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    background: var(--surface2);
    border-radius: 13px;
    font-size: 21px;
    flex-shrink: 0
}

.type-card.active .type-icon {
    background: var(--accent);
    color: #17210c
}

.type-card strong,
.type-card small {
    display: block
}

.type-card strong {
    font-size: 14px
}

.type-card small {
    color: var(--muted);
    font-size: 11px;
    margin-top: 5px;
    line-height: 1.4
}

.explorer-layout {
    display: grid;
    grid-template-columns: minmax(310px, .83fr) minmax(0, 1.55fr);
    gap: 20px;
    align-items: start
}

.panel {
    background: linear-gradient(150deg, rgba(22, 33, 48, .94), rgba(15, 23, 34, .96));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow)
}

.map-panel {
    padding: 22px
}

.segmented {
    display: flex;
    padding: 4px;
    border-radius: 999px;
    background: #0b1119;
    border: 1px solid var(--border)
}

.segment {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 8px 13px;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer
}

.segment.active {
    background: var(--accent);
    color: #15200c;
    font-weight: 800
}

.body-map {
    max-width: 360px;
    margin: 18px auto 8px;
    min-height: 340px;
    display: flex;
    justify-content: center;
    align-items: center
}

.body-map svg {
    width: 100%;
    height: auto;
    max-height: 680px;
    overflow: visible
}

.muscle-group {
    color: #354457;
    cursor: pointer;
    outline: none;
    transition: color .14s
}

.muscle-group path {
    stroke: transparent;
    stroke-width: 3;
    stroke-linejoin: round;
    paint-order: stroke
}

@media(hover:hover) {
    .muscle-group:hover {
        color: #839a64
    }
}

.muscle-group:focus-visible {
    color: #839a64
}

.muscle-group:focus-visible path {
    stroke: #d5f8a3
}

.muscle-group.selected,
.muscle-group.selected:hover {
    color: var(--accent)
}

.muscle-group.is-disabled {
    cursor: default;
    opacity: .4;
    pointer-events: none
}

.muscle-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding-top: 14px;
    border-top: 1px solid var(--border)
}

.muscle-chip {
    border: 1px solid var(--border);
    background: #101824;
    color: #c8d3df;
    border-radius: 999px;
    padding: 8px 11px;
    font-size: 11px;
    cursor: pointer
}

.muscle-chip.active {
    background: var(--accent-dark);
    border-color: #719b34;
    color: #e4ffc3
}

.results-panel {
    min-width: 0
}

.results-toolbar {
    padding: 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px
}

.count-pill,
.tag {
    white-space: nowrap;
    font-size: 11px;
    border: 1px solid var(--border);
    padding: 7px 10px;
    border-radius: 999px;
    color: #d2dce7;
    background: #0e1722
}

.filters {
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr 1.3fr;
    gap: 12px;
    margin-bottom: 14px
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0
}

.field>span {
    font-size: 11px;
    color: #b8c5d3;
    font-weight: 650
}

.field input,
.field textarea,
.field select {
    width: 100%;
    min-width: 0;
    border: 1px solid #304156;
    background: #0c141e;
    color: var(--text);
    border-radius: 10px;
    padding: 11px 12px;
    outline: none
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    border-color: #8bbd3d;
    box-shadow: 0 0 0 3px rgba(183, 243, 75, .08)
}

.field textarea {
    resize: vertical;
    line-height: 1.5
}

.field input::placeholder,
.field textarea::placeholder {
    color: #647386
}

.exercise-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px
}

.exercise-card {
    overflow: hidden;
    border: 1px solid var(--border);
    background: linear-gradient(150deg, #162233, #111a26);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    min-width: 0
}

.video-preview {
    aspect-ratio: 16/9;
    background: radial-gradient(ellipse at 50% 35%, #293a4f, #0b121b 75%);
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden
}

.video-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover
}

.play-button {
    width: 49px;
    height: 49px;
    border-radius: 50%;
    background: var(--accent);
    color: #14200b;
    display: grid;
    place-items: center;
    border: 0;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .3)
}

.video-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    color: #a9bacb;
    font-size: 11px
}

.video-placeholder .play-button {
    font-size: 17px
}

.card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1
}

.card-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px
}

.card-title-row h3 {
    font-size: 16px;
    line-height: 1.35;
    margin: 0;
    letter-spacing: -.02em
}

.difficulty {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .09em;
    border-radius: 5px;
    padding: 5px 6px;
    background: #243347;
    color: #c8d9eb;
    white-space: nowrap
}

.difficulty.beginner {
    background: #203522;
    color: #c4f1a6
}

.difficulty.advanced {
    background: #42252a;
    color: #ffb6bd
}

.card-description {
    color: #aab7c6;
    font-size: 12px;
    line-height: 1.55;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden
}

.card-meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: auto
}

.meta-chip {
    font-size: 10px;
    padding: 6px 8px;
    border-radius: 7px;
    background: #0c1520;
    border: 1px solid #243449;
    color: #bac7d5
}

.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 2px
}

.button {
    border: 0;
    border-radius: 10px;
    padding: 11px 15px;
    font-weight: 800;
    font-size: 12px;
    cursor: pointer;
    transition: transform .15s, opacity .15s
}

.button:hover {
    transform: translateY(-1px)
}

.button:disabled {
    opacity: .55;
    cursor: wait
}

.button.primary {
    background: var(--accent);
    color: #17220c
}

.button.secondary {
    background: #202d3d;
    border: 1px solid #35475d;
    color: #e3eaf1
}

.button.danger {
    background: #402329;
    border: 1px solid #68353d;
    color: #ffb9bf
}

.button.full {
    width: 100%
}

.empty-state {
    grid-column: 1/-1;
    text-align: center;
    padding: 52px 24px;
    border: 1px dashed #34465a;
    border-radius: 16px;
    color: var(--muted)
}

.empty-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 15px;
    background: #1b293a;
    color: var(--accent);
    font-size: 25px;
    margin: 0 auto 14px
}

.empty-state h3 {
    color: var(--text);
    font-size: 16px;
    margin: 0 0 8px
}

.empty-state p {
    font-size: 12px;
    margin: 0;
    line-height: 1.6
}

.footer {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-top: 42px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: #728196;
    font-size: 10px
}

.exercise-dialog {
    width: min(780px, calc(100% - 28px));
    max-height: 90vh;
    overflow: auto;
    background: #111b28;
    color: var(--text);
    border: 1px solid #3a4b60;
    border-radius: 20px;
    padding: 26px;
    box-shadow: 0 30px 100px #000a
}

.exercise-dialog::backdrop {
    background: #03070dc9;
    backdrop-filter: blur(6px)
}

.dialog-close {
    float: right;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    background: #1d2b3c;
    color: white;
    font-size: 22px;
    cursor: pointer
}

.dialog-content {
    clear: both
}

.dialog-video {
    width: 100%;
    max-height: 420px;
    background: #05090f;
    border-radius: 13px;
    margin: 12px 0 18px
}

.dialog-content h2 {
    font-size: 26px;
    margin: 6px 42px 10px 0
}

.dialog-content p {
    color: #b4c0ce;
    line-height: 1.7;
    font-size: 13px;
    white-space: pre-line
}

.dialog-section {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border)
}

.dialog-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--accent)
}

.admin-body {
    background: radial-gradient(ellipse at 50% -20%, #1d2b40 0, transparent 45%), var(--bg)
}

.admin-shell {
    max-width: 1400px;
    padding: 36px clamp(18px, 4vw, 52px) 60px;
    margin: auto
}

.login-card {
    max-width: 450px;
    margin: 7vh auto;
    padding: 30px
}

.login-card h1 {
    font-size: 34px
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 22px
}

.form-stack .button {
    margin-top: 3px
}

.form-message {
    min-height: 18px;
    font-size: 12px;
    color: #c6ef91;
    margin: 0
}

.form-message.error {
    color: #ff9ea5
}

.admin-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 26px
}

.admin-heading h1 {
    font-size: 36px
}

.admin-columns {
    display: grid;
    grid-template-columns: minmax(320px, .9fr) minmax(0, 1.1fr);
    gap: 20px;
    align-items: start
}

.editor-panel,
.library-panel {
    padding: 22px;
    min-width: 0
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px
}

.form-actions {
    display: flex;
    gap: 9px;
    flex-wrap: wrap
}

.admin-exercise-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px
}

.admin-exercise {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--border);
    background: #0e1722;
    border-radius: 13px
}

.admin-exercise-main {
    min-width: 0;
    flex: 1
}

.admin-exercise h3 {
    font-size: 13px;
    margin: 0 0 6px;
    overflow-wrap: anywhere
}

.admin-exercise p {
    font-size: 11px;
    color: var(--muted);
    margin: 0;
    line-height: 1.5
}

.admin-exercise-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px
}

.admin-exercise-actions .button {
    padding: 7px 9px;
    font-size: 10px
}

.status-label {
    display: inline-block;
    font-size: 9px;
    border-radius: 5px;
    padding: 4px 6px;
    margin-left: 6px;
    background: #1f3521;
    color: #c4f1a6
}

.status-label.inactive {
    background: #39272a;
    color: #ffc0c5
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translate(-50%, 20px);
    background: #d5ff9b;
    color: #15200c;
    border-radius: 999px;
    padding: 12px 18px;
    font-weight: 800;
    font-size: 12px;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: .2s;
    z-index: 20
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0)
}

[hidden] {
    display: none !important
}

@media(max-width:1050px) {
    .explorer-layout {
        grid-template-columns: minmax(280px, .8fr) minmax(0, 1.2fr)
    }

    .filters {
        grid-template-columns: 1fr 1fr
    }

    .search-field {
        grid-column: 1/-1
    }

    .admin-columns {
        grid-template-columns: 1fr
    }

    .editor-panel {
        order: 2
    }

    .library-panel {
        order: 1
    }

    .type-grid {
        /* grid-template-columns: repeat(2, minmax(0, 1fr)) */
        grid-auto-flow:row

    }
     .type-grid:last-child {
        .type-grid{grid-template-columns:repeat(2,minmax(0,1fr));grid-auto-flow:row}.type-card:last-child:nth-child(odd){grid-column:1/-1}
     }
}

@media(max-width:720px) {
    .topbar {
        height: 66px;
        padding: 0 16px
    }

    .page-shell {
        padding: 25px 14px
    }

    .hero {
        align-items: flex-start;
        flex-direction: column;
        margin-bottom: 30px
    }

    .hero h1 {
        font-size: 35px
    }

    .offline-pill {
        font-size: 11px
    }

    .type-grid {
        gap: 8px
    }

    .type-card {
        padding: 12px;
        min-height: 80px;
        gap: 10px
    }

    .type-icon {
        width: 36px;
        height: 36px;
        border-radius: 10px;
        font-size: 17px
    }

    .type-card strong {
        font-size: 12px
    }

    .type-card small {
        font-size: 10px
    }

    .explorer-layout {
        grid-template-columns: 1fr
    }

    .map-panel {
        padding: 16px
    }

    .body-map {
        max-width: 300px;
        min-height: 280px
    }

    .results-toolbar {
        padding: 17px
    }

    .filters {
        padding: 12px;
        gap: 9px
    }

    .exercise-grid {
        grid-template-columns: 1fr
    }

    .exercise-card {
        display: grid;
        grid-template-columns: 38% 1fr
    }

    .video-preview {
        height: 100%;
        min-height: 175px;
        aspect-ratio: auto
    }

    .card-body {
        padding: 13px
    }

    .card-title-row {
        flex-direction: column;
        gap: 7px
    }

    .card-title-row h3 {
        font-size: 14px
    }

    .card-description {
        font-size: 11px
    }

    .card-meta {
        gap: 5px
    }

    .meta-chip {
        font-size: 9px;
        padding: 5px 6px
    }

    .card-actions .button {
        padding: 9px 10px
    }

    .footer {
        flex-direction: column
    }

    .admin-shell {
        padding: 24px 13px
    }

    .admin-heading {
        align-items: flex-start
    }

    .admin-heading h1 {
        font-size: 29px
    }

    .editor-panel,
    .library-panel {
        padding: 16px
    }

    .login-card {
        margin: 5vh auto;
        padding: 23px
    }

    .form-row {
        grid-template-columns: 1fr
    }

    .admin-exercise {
        padding: 10px
    }

    .admin-link {
        font-size: 11px;
        padding: 9px 11px
    }
}

@media(max-width:420px) {
    .exercise-card {
        grid-template-columns: 1fr
    }

    .video-preview {
        aspect-ratio: 16/9;
        min-height: 0
    }

    .filters {
        grid-template-columns: 1fr 1fr
    }

    .search-field {
        grid-column: 1/-1
    }

    .panel-heading {
        align-items: flex-start
    }

    .segmented {
        flex-shrink: 0
    }

    .segment {
        padding: 8px 10px
    }
}

/* In-page muscle picker (replaces the native <select> popup on the admin form) */
.picker-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    overflow: hidden
}

.picker {
    position: relative
}

.picker-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    text-align: left;
    cursor: pointer;
    border: 1px solid #304156;
    background: #0c141e;
    color: var(--text);
    border-radius: 10px;
    padding: 11px 12px;
    outline: none
}

.picker-button:focus-visible,
.picker-button[aria-expanded=true] {
    border-color: #8bbd3d;
    box-shadow: 0 0 0 3px rgba(183, 243, 75, .08)
}

.picker-caret {
    color: var(--muted);
    font-size: 12px;
    transition: transform .15s
}

.picker-button[aria-expanded=true] .picker-caret {
    transform: rotate(180deg)
}

.picker-panel {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 40;
    background: #0f1824;
    border: 1px solid #3a4b60;
    border-radius: 12px;
    box-shadow: 0 18px 50px #000a;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: var(--picker-max, 320px)
}

.picker-panel[hidden] {
    display: none
}

.picker-up .picker-panel {
    top: auto;
    bottom: calc(100% + 6px)
}

.picker-search {
    width: 100%;
    border: 1px solid #304156;
    background: #0c141e;
    color: var(--text);
    border-radius: 8px;
    padding: 9px 10px;
    outline: none;
    flex: none
}

.picker-search:focus {
    border-color: #8bbd3d
}

.picker-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    min-height: 0;
    position: relative
}

.picker-group {
    position: sticky;
    top: 0;
    background: #0f1824;
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--accent);
    padding: 8px 8px 4px;
    font-weight: 800
}

.picker-option {
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    color: #dbe5ef
}

.picker-option.active {
    background: #1d2b3c
}

.picker-option[aria-selected=true] {
    color: #e4ffc3;
    font-weight: 700
}

.picker-option[aria-selected=true]::after {
    content: "✓";
    float: right;
    color: var(--accent)
}

.picker-empty {
    padding: 12px 10px;
    font-size: 12px;
    color: var(--muted)
}