:root {
    --bg: #0b0b0d;
    --panel: #17171b;
    --panel-2: #1f1f24;
    --line: #2b2b31;
    --text: #f5f5f0;
    --muted: #9a9aa2;
    --accent: #ff3b30;

    --tough: #ffb703;
    --tougher: #fb5607;
    --extreme: #ff1b3d;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, "Segoe UI", system-ui, Roboto, Arial, sans-serif;
    min-height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header.top {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    padding-top: calc(14px + env(safe-area-inset-top));
    background: #000;
    border-bottom: 2px solid var(--accent);
}

header.top h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #fff;
}

header.top h1 span {
    color: var(--accent);
}

header.top .navlink {
    position: relative;
    display: inline-flex;
    align-items: center;
    color: var(--muted);
    text-decoration: none;
    font-family: inherit;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .5px;
    text-transform: uppercase;
    background: transparent;
    border: 1px solid var(--line);
    padding: 8px 14px;
    border-radius: 999px;
    white-space: nowrap;
    cursor: pointer;
}

.update-star {
    position: absolute;
    top: -6px;
    right: -6px;
    color: var(--extreme);
    font-size: 14px;
    line-height: 1;
    animation: update-star-flash 1s steps(1, end) infinite;
}

@keyframes update-star-flash {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

header.top .navlink:active {
    background: var(--panel-2);
}

header.top .navlink.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

main {
    flex: 1;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

footer.foot {
    text-align: center;
    color: var(--muted);
    font-size: 11px;
    padding: 16px;
    letter-spacing: .5px;
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-weight: 800;
    letter-spacing: .5px;
    text-transform: uppercase;
    font-size: 14px;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 18px;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
}

.btn:active { transform: translateY(1px); }

.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 9px 14px; font-size: 12px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn.danger { background: #2a1416; border-color: #5c2026; color: #ff8a8a; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* Rank pills / colors, shared by picker buttons and admin badges */

.rank-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #1a1200;
}

.rank-Tough { background: var(--tough); }
.rank-Hardcore { background: var(--tougher); color: #fff; }
.rank-Extreme { background: var(--extreme); color: #fff; }
.rank-Unrated { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }

.rank-btn-Tough { background: var(--tough); border-color: var(--tough); color: #1a1200; }
.rank-btn-Hardcore { background: var(--tougher); border-color: var(--tougher); color: #fff; }
.rank-btn-Extreme { background: var(--extreme); border-color: var(--extreme); color: #fff; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
}

.modal-overlay[hidden] {
    display: none;
}

.modal-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 22px;
    width: 100%;
    max-width: 360px;
}

.modal-title {
    margin: 0 0 16px;
    text-align: center;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-size: 15px;
}

.modal-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empty-hint {
    margin-top: 18px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

.empty-hint a, .empty-hint .link-btn {
    color: var(--accent);
    font-weight: 700;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.settings-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 28px;
}

.settings-cog {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--muted);
    text-decoration: none;
    font-size: 18px;
}

.settings-cog:active { background: var(--panel); }

/* --- Workout picker (choose a specific workout within a rank) --- */

.workout-picker {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.workout-pick {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 18px;
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
}

.workout-pick:active { background: var(--panel-2); }

.workout-pick .name {
    font-weight: 800;
    font-size: 16px;
}

.workout-pick .arrow {
    color: var(--muted);
    flex: none;
}

/* --- The board (workout display, styled like a real gym whiteboard) --- */

.board-nav-wrap {
    position: relative;
    touch-action: pan-y;
    overflow: hidden;
}

.board-swipe-hint {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    margin-top: 10px;
}

.board-wrap {
    padding: 10px;
    border-radius: 18px;
    background: linear-gradient(160deg, #2a2a2e, #050505);
    box-shadow: 0 12px 30px rgba(0,0,0,.5);
}

.board {
    display: flex;
    flex-direction: column;
    background: linear-gradient(170deg, #ffffff, #f0f0f2 85%);
    border-radius: 8px;
    padding: 18px 18px 14px;
    text-align: left;
    color: #17171a;
    font-family: 'Kalam', cursive;
    font-weight: 700;
    transition: transform 200ms ease, opacity 200ms ease;
}

.board.slide-exit-left  { transform: translateX(-40px); opacity: 0; }
.board.slide-exit-right { transform: translateX(40px);  opacity: 0; }
.board.slide-enter-right { transition: none; transform: translateX(40px);  opacity: 0; }
.board.slide-enter-left  { transition: none; transform: translateX(-40px); opacity: 0; }

.board .rank-pill { font-size: 12px; padding: 4px 14px; }

.board h2 {
    margin: 10px 0 10px;
    font-size: 23px;
    font-family: 'Permanent Marker', cursive;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: .5px;
    line-height: 1.2;
    color: #141414;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 3px solid #d81e26;
}

.board .body .section {
    display: inline-block;
    font-family: 'Permanent Marker', cursive;
    font-weight: 400;
    text-transform: uppercase;
    color: #d81e26;
    border: 2px solid #d81e26;
    border-radius: 6px;
    padding: 3px 12px;
    margin: 9px 0 5px;
    font-size: 15px;
}

.board .body .section:first-child { margin-top: 0; }

.board .body .line {
    display: flex;
    gap: 7px;
    padding: 1px 0;
    font-size: 15px;
    line-height: 1.28;
}

.board .body .line .num { color: #1d5fd6; }
.board .body .line .txt { color: #17171a; }
.board .body .line .note { color: #d81e26; }

.rate-row:empty { display: none; }

.rate-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    margin-bottom: 10px;
}

.rate-btns {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.rate-btn {
    flex: 1;
    max-width: 140px;
    font-family: inherit;
    font-weight: 800;
    font-size: 13px;
    padding: 12px 6px;
    border-radius: 10px;
    border: 2px solid var(--accent);
    background: transparent;
    color: var(--accent);
    cursor: pointer;
}

.rate-btn:active { background: var(--accent); color: #fff; }

.rated-note {
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    color: #4ade80;
}

.board .credit {
    margin-top: auto;
    padding-top: 14px;
    text-align: center;
    font-family: -apple-system, "Segoe UI", system-ui, Roboto, Arial, sans-serif;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent);
}

.board-actions {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* --- Admin --- */

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tab {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--muted);
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    cursor: pointer;
}

.tab.active { color: #fff; border-color: var(--accent); background: #2a1512; }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 14px;
}

.field { margin-bottom: 14px; }

.field label {
    display: block;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    margin-bottom: 6px;
}

.field input[type=text],
.field select,
.field textarea {
    width: 100%;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    padding: 12px;
    font-family: inherit;
    font-size: 15px;
}

.field textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 6px; }

.workout-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.workout-row:last-child { border-bottom: none; }

.workout-row .info { flex: 1; min-width: 0; }
.workout-row .title { font-weight: 800; font-size: 15px; margin: 0 0 6px; }
.workout-row .snippet {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workout-row .row-actions { display: flex; gap: 8px; flex: none; }

.empty-list { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 14px; }

.stat-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.stat-tag {
    display: inline-block;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
}
