/* ═══════════════════════════════════════════════════════════
     DESIGN TOKENS
   ═══════════════════════════════════════════════════════════ */

:root {
    /* Colors - Warm Tropical Ocean Theme */
    --canvas: #f8faf9;
    --surface: #ffffff;
    --surface-subtle: #f2f5f4;
    --surface-hover: #e8edeb;

    --text-primary: #1f2826;
    --text-secondary: #4a5854;
    --text-muted: #7a8680;
    --text-inverse: #f8faf9;

    --border: #d4ddd9;
    --border-strong: #b8c5bf;
    --border-subtle: #e3e9e6;

    --primary: #3d9b8f;
    --primary-hover: #2f8478;

    --link: #3d9b8f;
    --link-hover: #2f8478;
    --link-visited: var(--link);

    --success: #5a9f70;
    --success-bg: rgba(90, 159, 112, 0.12);
    --success-border: rgba(90, 159, 112, 0.3);

    --warning: #c9a658;
    --warning-bg: rgba(201, 166, 88, 0.12);
    --warning-border: rgba(201, 166, 88, 0.3);

    --danger: #c76b5f;
    --danger-hover: #b55f54;
    --danger-bg: rgba(199, 107, 95, 0.12);
    --danger-border: rgba(199, 107, 95, 0.3);

    --info: #5b8ca8;
    --info-bg: rgba(91, 140, 168, 0.12);
    --info-border: rgba(91, 140, 168, 0.3);

    /* Typography */
    --font-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: Menlo, Consolas, Monaco, 'Liberation Mono', monospace;

    --text-xs: 0.6875rem;
    --text-sm: 0.8125rem;
    --text-md: 0.9375rem;
    --text-lg: 1.0625rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;

    --weight-medium: 500;
    --weight-semibold: 600;

    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.65;

    /* Spacing */
    --space-2xs: 0.25rem;
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Layout */
    --container-max: 900px;
    --container-wide: 1080px;

    /* Borders */
    --radius-sm: 3px;
    --radius-md: 4px;
    --radius-pill: 999px;

    /* Shadows */
    --shadow-md: 0 2px 4px rgba(31, 40, 38, 0.06), 0 2px 6px rgba(31, 40, 38, 0.03);
    --shadow-lg: 0 4px 8px rgba(31, 40, 38, 0.08), 0 4px 12px rgba(31, 40, 38, 0.04);

    /* Motion */
    --duration-fast: 150ms;
    --easing: cubic-bezier(0.4, 0.0, 0.2, 1);

    /* Z-index */
    --z-header: 300;
}

/* ═══════════════════════════════════════════════════════════
   BASE & RESET
   ═══════════════════════════════════════════════════════════ */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-base);
    font-size: var(--text-md);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: var(--canvas);
}

a {
    color: var(--link);
    text-decoration: none;
    transition: color var(--duration-fast) var(--easing);
}

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

a:visited {
    color: var(--link-visited);
}

ul, ol {
    padding-left: var(--space-xl);
    margin: var(--space-sm) 0;
}

li {
    margin: var(--space-xs) 0;
}

/* ═══════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════ */

.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: var(--z-header);
}

.header__container {
    max-width: var(--container-wide);
    margin: 0 auto;
    padding: var(--space-sm) var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
}

.header__brand,
.header__brand:visited {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    letter-spacing: 0;
    line-height: 1;
}

.header__brand-mark {
    width: 1.75rem;
    height: 1.75rem;
    display: block;
    flex: 0 0 auto;
}

.header__brand:hover {
    color: var(--text-primary);
    text-decoration: none;
}

.header__link,
.header__link:visited {
    color: var(--primary);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
    transition: background var(--duration-fast) var(--easing),
                color var(--duration-fast) var(--easing);
}

.header__link:hover {
    background: #eaf4f2;
    color: var(--primary);
    text-decoration: none;
}

.header__nav {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
}

.header-menu {
    display: none;
    position: relative;
}

.header-menu__toggle {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    list-style: none;
}

.header-menu__toggle::-webkit-details-marker {
    display: none;
}

.header-menu__icon {
    position: relative;
    width: 1.45rem;
    height: 1rem;
}

.header-menu__icon span {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    border-radius: var(--radius-pill);
    background: currentColor;
    transition: top var(--duration-fast) var(--easing),
                transform var(--duration-fast) var(--easing);
}

.header-menu__icon span:first-child {
    top: 0.18rem;
}

.header-menu__icon span:last-child {
    top: 0.68rem;
}

.header-menu[open] .header-menu__toggle {
    background: #eaf4f2;
    border-color: var(--primary);
    color: var(--primary);
}

.header-menu[open] .header-menu__icon span:first-child {
    top: 0.43rem;
    transform: rotate(45deg);
}

.header-menu[open] .header-menu__icon span:last-child {
    top: 0.43rem;
    transform: rotate(-45deg);
}

.section {
    padding: var(--space-xl) var(--space-lg);
}

.section__container {
    max-width: var(--container-max);
    margin: 0 auto;
}

.section__header {
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.section__title {
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    letter-spacing: -0.02em;
}

.section__description {
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

.profile-pane-nav {
    margin-bottom: var(--space-lg);
    display: flex;
    gap: var(--space-sm);
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
}

.profile-pane-nav__tabs {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.profile-pane-nav__actions {
    display: flex;
    gap: var(--space-xs);
    margin-left: auto;
}

.profile-pane-header {
    margin-bottom: var(--space-lg);
    display: block;
}

.profile-pane-header__content {
    width: 100%;
}

.profile-email-updates {
    margin-top: var(--space-lg);
}

.email-updates-form {
    display: grid;
    gap: var(--space-md);
}

.email-updates-form .btn {
    justify-self: start;
}

.email-updates-choice {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
}

.email-updates-choice input {
    flex: none;
    margin-top: 0.3em;
}

.profile-locations {
    display: grid;
    gap: var(--space-md);
}

.profile-locations__intro {
    margin: 0;
}

.profile-locations__search {
    width: min(100%, 32rem);
}

.profile-locations__host-cta {
    display: flex;
    justify-content: flex-start;
    margin-top: var(--space-md);
}

.profile-locations__list,
.profile-locations__search-results {
    display: grid;
    gap: var(--space-sm);
}

.profile-locations__heading,
.profile-locations__search-heading {
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.profile-locations__search-heading {
    margin-top: var(--space-sm);
}

.profile-location {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.profile-location--candidate {
    border-style: dashed;
}

.profile-location__content {
    min-width: 0;
    display: grid;
    gap: var(--space-2xs);
}

.profile-location__title {
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
}

.profile-location__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs) var(--space-xs);
    color: var(--text-muted);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
}

.profile-location__remove {
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-base);
    font-size: var(--text-lg);
    line-height: 1;
    cursor: pointer;
    transition: background var(--duration-fast) var(--easing),
                color var(--duration-fast) var(--easing),
                border-color var(--duration-fast) var(--easing);
}

.profile-location__remove:hover {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger);
}

.profile-location__remove:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.profile-locations__empty {
    padding: var(--space-md);
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.profile-locations__empty p {
    margin: 0;
}

.profile-locations__empty p + p {
    margin-top: var(--space-xs);
}

.profile-locations__empty--search {
    margin-top: var(--space-sm);
}

.hosting-hub-list {
    display: grid;
    gap: var(--space-md);
}

.hosting-hub-summary__header {
    display: flex;
    justify-content: space-between;
    gap: var(--space-md);
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: var(--space-sm);
}

.hosting-hub-create {
    margin-top: var(--space-md);
    display: flex;
}

.hosting-hub {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    overflow: hidden;
}

.hosting-hub__header {
    display: flex;
    justify-content: space-between;
    gap: var(--space-md);
    align-items: flex-start;
    flex-wrap: wrap;
    padding: var(--space-md);
    background: var(--surface-subtle);
    border-bottom: 1px solid var(--border-subtle);
}

.hosting-hub__identity {
    min-width: 0;
    display: grid;
    gap: var(--space-2xs);
}

.hosting-hub__label,
.hosting-events__heading,
.hosting-event__kind {
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.hosting-hub__name {
    color: var(--text-primary);
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    letter-spacing: 0;
    line-height: var(--leading-tight);
    margin: 0;
}

.hosting-hub__title-row {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.hosting-hub__page-link {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    line-height: var(--leading-tight);
}

.hosting-event__link {
    align-self: center;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    line-height: var(--leading-tight);
}

.hosting-event__link:focus-visible {
    border-radius: var(--radius-sm);
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.hosting-hub__meta,
.hosting-event__meta {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.hosting-hub__actions,
.hosting-event__actions {
    display: flex;
    flex-wrap: wrap;
}

.hosting-hub__actions {
    gap: var(--space-xs);
}

.hosting-event__actions {
    column-gap: var(--space-md);
    row-gap: var(--space-xs);
}

.hosting-events {
    padding: var(--space-md);
}

.hosting-events__heading {
    margin-bottom: var(--space-sm);
}

.hosting-events__list {
    display: grid;
    gap: var(--space-sm);
    border-left: 2px solid var(--border-subtle);
    padding-left: var(--space-md);
}

.hosting-event {
    position: relative;
    display: flex;
    justify-content: space-between;
    gap: var(--space-md);
    align-items: flex-start;
    flex-wrap: wrap;
    padding: var(--space-sm);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--canvas);
}

.hosting-event::before {
    content: "";
    position: absolute;
    left: calc(-1 * var(--space-md) - 5px);
    top: 1rem;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-pill);
    background: var(--primary);
    border: 2px solid var(--surface);
}

.hosting-event__content {
    min-width: min(100%, 260px);
    display: grid;
    gap: var(--space-2xs);
}

.hosting-event__topline {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
    flex-wrap: wrap;
    color: var(--text-primary);
}

.hosting-events__empty {
    margin: 0;
    color: var(--text-muted);
}

.hosting-checkin-page,
.hub-checkin-page {
    display: grid;
    gap: var(--space-md);
}

.hosting-checkin-card,
.hub-checkin-card {
    max-width: 720px;
}

.hosting-checkin-card__body,
.hub-checkin-card__body {
    display: grid;
    gap: var(--space-md);
}

.hosting-checkin-card__details,
.hub-checkin-card__meta {
    display: grid;
    gap: var(--space-2xs);
}

.hosting-checkin-card__hub {
    color: var(--text-primary);
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
}

.hosting-checkin-card__meta,
.hub-checkin-card__meta {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.hosting-checkin-card__qr {
    box-sizing: border-box;
    width: min(100%, 320px);
    height: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: white;
    padding: var(--space-sm);
}

.hosting-checkin-card__notice {
    max-width: 560px;
}

.hub-checkin-card__note {
    margin: 0;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.me-runs__run-column {
    width: 100%;
}

.me-runs__nowrap-column {
    white-space: nowrap;
}

.me-runs__time-column {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.me-runs__manage-column {
    white-space: nowrap;
    width: 1%;
}

.me-runs__manage-detail-row--hidden {
    display: none;
}

.me-runs__manage-detail-cell {
    padding-top: 0;
    background: var(--bg-surface);
}

.me-runs__run-name {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
}

.me-runs__submission-summary {
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.run-submission-preview {
    display: inline-block;
}

.run-submission-preview--detail {
    display: block;
    width: 100%;
    padding: var(--space-sm) 0;
}

.run-submission-preview__editor {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.run-submission-preview__controls {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.run-submission-preview__choices {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.run-submission-preview__choice {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: var(--text-sm);
}

.run-submit-preview__hint {
    color: var(--text-muted);
    font-size: var(--text-xs);
    line-height: var(--leading-tight);
}

.run-submit-preview__hint--warning {
    color: var(--warning);
}

.run-submission-preview--blocked .run-submit-preview__hint {
    opacity: 0.85;
}

.grid {
    display: grid;
    gap: var(--space-md);
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* ═══════════════════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════════════════ */

/* Card */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    transition: border-color var(--duration-fast) var(--easing);
}

.card:hover {
    border-color: var(--border-strong);
}

a.card--link {
    display: block;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: border-color var(--duration-fast) var(--easing),
                box-shadow var(--duration-fast) var(--easing);
}

a.card--link:visited {
    color: inherit;
}

a.card--link:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    text-decoration: none;
    color: inherit;
}

.card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.card__title {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    letter-spacing: -0.01em;
}

.card__body {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
}

.card__body p + p {
    margin-top: 0.5em;
}

/* Table */
.table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-xs);
}

.table th {
    background: var(--surface-subtle);
    padding: var(--space-2xs) var(--space-xs);
    text-align: left;
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.3;
}

.table td {
    padding: var(--space-2xs) var(--space-xs);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    line-height: 1.4;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover {
    background: var(--surface-hover);
}

.table--no-hover tr:hover {
    background: transparent;
}

.table tr.table__row--selected {
    background: var(--info-bg);
}

.table--dense th {
    padding: 4px 6px;
}

.table--dense td {
    padding: 2px 6px;
    font-size: 11px;
}

.leaderboard-rank {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
}

.leaderboard-table-container {
    margin: 1em 0;
}

/* Fill the header width so the status badge aligns with the table edge. */
.leaderboard-page__header > div {
    width: 100%;
}

/* Opaque run IDs may be unbreakable; fixed layout prevents them from widening the whole table. */
.leaderboard-table {
    width: 100%;
    table-layout: fixed;
}

.leaderboard-col--rank {
    width: 4ch;
    white-space: nowrap;
}

.leaderboard-col--account {
    width: 12ch;
    white-space: nowrap;
}

.leaderboard-col--points {
    /* Reserve room for both the score chip and its /ceiling suffix. */
    width: 12ch;
    white-space: nowrap;
}

.leaderboard-col--time {
    width: 10ch;
    white-space: nowrap;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.leaderboard-table th.leaderboard-col--time {
    text-align: right;
}

.leaderboard-col--created {
    width: 11ch;
    white-space: nowrap;
}

.leaderboard-run-line {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

.leaderboard-run-name {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-run-name--disqualified {
    color: var(--text-muted);
    text-decoration: line-through;
}

.code-inline.leaderboard-account-key {
    background: var(--leaderboard-account-key-color, var(--surface-subtle));
    border: none;
}

.code-inline.leaderboard-score {
    border: none;
}

.code-inline.leaderboard-score--perfect {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.leaderboard-score-ceiling {
    color: var(--text-muted);
    margin-left: 4px;
}

.leaderboard-score-disq {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.9em;
}

.leaderboard-muted {
    color: var(--text-muted);
    font-size: var(--text-xs);
}

body.embed-page {
    margin: 0;
    background: var(--bg);
}

.leaderboard-embed {
    padding: var(--space-sm);
}

/* Public/member hub detail */
.hub-page {
    max-width: 1040px;
}

.hub-page__layout {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
    gap: var(--space-lg);
    align-items: start;
}

.hub-page__main {
    display: grid;
    gap: var(--space-md);
}

.hub-page__side {
    display: grid;
    gap: var(--space-md);
}

.hub-page__eyebrow {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.hub-page__title {
    margin-bottom: 0;
}

.hub-page__description {
    max-width: 64ch;
    margin-bottom: 0;
}

.hub-profile {
    display: grid;
    gap: var(--space-lg);
}

.hub-profile__header,
.hub-profile__section,
.hub-profile__meetup {
    display: grid;
    gap: var(--space-md);
}

.hub-profile__location {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-secondary);
    font-size: var(--text-md);
}

.hub-profile__location-icon {
    width: 1rem;
    height: 1rem;
    color: var(--text-muted);
    flex: 0 0 auto;
}

.hub-profile__challenge-list {
    display: grid;
    gap: var(--space-md);
}

.hub-profile__challenge-row {
    display: grid;
    gap: var(--space-md);
    padding: var(--space-lg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.hub-profile__challenge-header {
    display: flex;
    justify-content: space-between;
    gap: var(--space-md);
    align-items: flex-start;
}

.hub-profile__challenge-title {
    color: var(--text-primary);
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
}

.hub-profile__challenge-title + .hub-profile__meta {
    margin-top: var(--space-2xs);
}

.hub-profile__meta,
.hub-profile__challenge-copy {
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.hub-profile__meta {
    line-height: var(--leading-normal);
}

.hub-profile__challenge-copy {
    display: grid;
    gap: var(--space-2xs);
}

.hub-profile__challenge-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-lg);
    align-items: start;
}

.hub-profile__actions,
.hub-profile__badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.hub-profile__actions {
    column-gap: var(--space-md);
    row-gap: var(--space-xs);
}

.hub-profile__badges {
    gap: var(--space-xs);
}

.hub-profile__action-link,
.hub-profile__action-link:visited {
    align-self: center;
    color: var(--link);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    line-height: var(--leading-tight);
}

.hub-profile__action-link:hover {
    color: var(--link-hover);
}

.hub-profile__action-link:focus-visible {
    border-radius: var(--radius-sm);
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.hub-profile__external-link,
.hub-profile__external-link:visited {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-md);
    color: var(--primary);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    padding: var(--space-xs) var(--space-sm);
    text-decoration: none;
}

.hub-profile__external-link:hover {
    background: #eaf4f2;
    color: var(--primary);
    text-decoration: none;
}

.hub-profile__badges {
    justify-content: flex-end;
}

.hub-profile__local-note {
    margin: 0;
    padding: var(--space-sm);
    border: 1px solid var(--info-border);
    border-radius: var(--radius-md);
    background: var(--info-bg);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.hub-page__back-link {
    display: inline-flex;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.hub-page__board-badge,
.leaderboard-page__board-badge {
    font-size: var(--text-sm);
    padding: calc(var(--space-2xs) + 1px) var(--space-sm);
}

.hub-page__board-badge--hall,
.leaderboard-page__board-badge--hall {
    background: rgba(214, 178, 76, 0.18);
    color: #8f6510;
    border-color: rgba(181, 142, 39, 0.38);
    font-weight: 700;
}

.hub-page__board-badge-dot,
.leaderboard-page__board-badge-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
    flex: 0 0 auto;
}

.hub-page__board-badge-star,
.leaderboard-page__board-badge-star {
    font-size: 0.9rem;
    line-height: 1;
    color: #b8840f;
    display: inline-block;
    flex: 0 0 auto;
}

.hub-page__action-stack {
    display: grid;
    gap: var(--space-md);
    justify-items: center;
    width: min(100%, 320px);
    justify-self: center;
}

.hub-page__notice {
    margin-bottom: 0;
}

.hub-page__qr {
    box-sizing: border-box;
    width: min(100%, 320px);
    height: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: white;
    padding: var(--space-sm);
}

.hub-public-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-md) var(--space-lg);
    font-size: var(--text-sm);
}

.hub-public-meta__label {
    display: block;
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: var(--space-2xs);
}

.hub-public-meta__value {
    color: var(--text-primary);
}

.hub-public-meta__value a {
    word-break: break-word;
}

.hub-public-description {
    font-size: var(--text-sm);
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: var(--leading-relaxed);
}

.hub-leaderboard {
    display: grid;
    gap: var(--space-sm);
}

.hub-leaderboard__table {
    margin: 0;
}

.hub-leaderboard-empty {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

@media (max-width: 900px) {
    .hub-page__layout {
        grid-template-columns: 1fr;
    }

    .hub-public-meta {
        grid-template-columns: 1fr;
    }

    .hub-profile__challenge-header,
    .hub-profile__challenge-body {
        display: grid;
        grid-template-columns: 1fr;
    }

    .hub-profile__badges {
        justify-content: flex-start;
    }
}

.profile-api-keys {
    margin-top: var(--space-lg);
}

.profile-api-keys__meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.profile-api-keys__hint {
    margin-bottom: var(--space-md);
}

.profile-api-keys__notice,
.profile-api-keys__fresh-token {
    margin-bottom: var(--space-md);
}

.profile-api-keys__token {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    word-break: break-all;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2xs);
    padding: var(--space-2xs) var(--space-xs);
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    line-height: 1;
    border: 1px solid;
}

.badge--success {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success-border);
}

.badge--warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: var(--warning-border);
}

.badge--danger {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger-border);
}

.badge--info {
    background: var(--info-bg);
    color: var(--info);
    border-color: var(--info-border);
}

/* Code */
.code-block {
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    overflow-x: auto;
}

.code-block__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xs);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border-subtle);
}

.code-block__label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.code-block pre {
    margin: 0;
    line-height: var(--leading-relaxed);
}

.code-inline {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 0.15em 0.35em;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* Alert */
.alert {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    display: flex;
    gap: var(--space-sm);
    align-items: flex-start;
}

.alert__content {
    flex: 1;
}

.alert__title {
    font-weight: var(--weight-medium);
    margin-bottom: var(--space-2xs);
}

.alert--info {
    background: #ebf2f6;
    border-color: var(--info);
}

.alert--warning {
    background: #f8f4eb;
    border-color: var(--warning);
}

.alert--success {
    background: #eef5f1;
    border-color: var(--success);
}

/* Empty State */
.empty-state {
    padding: var(--space-2xl) var(--space-lg);
    text-align: center;
    color: var(--text-muted);
}

.empty-state__message {
    font-size: var(--text-md);
    margin-bottom: var(--space-md);
}

/* Document Viewer */
.document-viewer {
    min-height: 100vh;
    background: var(--canvas);
    padding: var(--space-lg);
}

.document-viewer__container {
    max-width: 720px;
    margin: 0 auto;
}

.document-viewer__back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    transition: color var(--duration-fast) var(--easing);
}

.document-viewer__back:hover {
    color: var(--primary);
    text-decoration: none;
}

.document-viewer__title {
    font-size: var(--text-2xl);
    font-weight: var(--weight-semibold);
    margin-bottom: var(--space-xs);
    letter-spacing: -0.02em;
}

.document-viewer__content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-2xl) var(--space-xl);
}

.document-viewer__content h2 {
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
    letter-spacing: -0.01em;
}

.document-viewer__content h2:first-child {
    margin-top: 0;
}

.document-viewer__content h3 {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
}

.document-viewer__content p {
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-md);
    color: var(--text-secondary);
}

.document-viewer__content ul,
.document-viewer__content ol {
    margin-bottom: var(--space-md);
    padding-left: var(--space-lg);
    line-height: var(--leading-relaxed);
}

.document-viewer__content li {
    margin-bottom: var(--space-xs);
    color: var(--text-secondary);
}

.document-viewer__content strong {
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
}

.document-viewer__content a {
    color: var(--primary);
}

.document-viewer__content a:hover {
    color: var(--primary-hover);
}

.document-viewer__content code {
    background: var(--surface-hover);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-primary);
}

.document-viewer__content pre {
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    overflow-x: auto;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.document-viewer__content pre code {
    background: transparent;
    padding: 0;
}

.document-viewer__content blockquote {
    margin: 0 0 var(--space-md);
    padding-left: var(--space-md);
    border-left: 4px solid var(--border-strong);
    color: var(--text-muted);
}

.document-viewer__content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: var(--space-lg) auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--canvas);
}

/* Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-md);
    font-family: var(--font-base);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    line-height: 1;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration-fast) var(--easing);
    text-decoration: none;
}

/* Ensure anchor tags styled as buttons behave like buttons */
a.btn:hover {
    text-decoration: none;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn--primary {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

.btn--primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    text-decoration: none;
}

/* Ensure visited state doesn't override button colors */
a.btn--primary,
a.btn--primary:visited {
    color: var(--text-inverse);
}

.btn--secondary {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.btn--secondary:hover {
    background: var(--surface-hover);
    border-color: var(--text-secondary);
    text-decoration: none;
}

a.btn--secondary,
a.btn--secondary:visited {
    color: var(--text-primary);
}

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn--ghost:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    text-decoration: none;
}

a.btn--ghost,
a.btn--ghost:visited {
    color: var(--text-secondary);
}

a.btn--ghost:hover {
    color: var(--text-primary);
}

.btn--ghost.btn--active {
    background: var(--surface-hover);
    color: var(--text-primary);
    font-weight: var(--weight-medium);
}

.admin-table__danger-action {
    color: var(--danger);
}

.admin-table__danger-action:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.btn--danger {
    background: var(--danger);
    color: var(--text-inverse);
    border-color: var(--danger);
}

.btn--danger:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
    text-decoration: none;
}

a.btn--danger,
a.btn--danger:visited {
    color: var(--text-inverse);
}

.btn--xs {
    padding: var(--space-2xs) var(--space-xs);
    font-size: var(--text-xs);
}

.btn--sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-sm);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Form */
.form-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
}

.form-field__label {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
}

.form-field__input,
.form-field__select,
.form-field__textarea {
    padding: var(--space-xs) var(--space-sm);
    font-family: var(--font-base);
    font-size: var(--text-sm);
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: border-color var(--duration-fast) var(--easing),
    box-shadow var(--duration-fast) var(--easing);
}

/* An explicit shared height prevents Safari/macOS select chrome from misaligning adjacent controls. */
.form-field__input,
.form-field__select {
    height: 2.5rem;
}

.form-field__input:focus,
.form-field__select:focus,
.form-field__textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(61, 155, 143, 0.1);
}

.form-field__textarea {
    resize: vertical;
    min-height: 80px;
}

.form-field__help {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Footer */
.footer {
    margin-top: var(--space-xl);
    padding: var(--space-lg);
    border-top: 1px solid var(--border);
    font-size: var(--text-sm);
    color: var(--text-muted);
    text-align: center;
}

.footer p {
    margin: 0;
}

@media (max-width: 640px) {
    .header__container {
        position: relative;
        gap: var(--space-md);
    }

    .header__nav--desktop {
        display: none;
    }

    .header-menu {
        display: block;
    }

    .header__nav--dropdown {
        position: absolute;
        top: calc(100% + var(--space-xs));
        right: 0;
        z-index: 1;
        min-width: min(16rem, calc(100vw - var(--space-lg) - var(--space-lg)));
        padding: var(--space-xs);
        align-items: stretch;
        flex-direction: column;
        gap: var(--space-2xs);
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-lg);
    }

    .header__nav--dropdown .header__link,
    .header__nav--dropdown .btn {
        width: 100%;
        justify-content: flex-start;
    }

    .header__nav--dropdown .header__link,
    .header__nav--dropdown .header__link:visited {
        display: flex;
        align-items: center;
        justify-content: space-between;
        color: var(--primary);
    }

    .header__nav--dropdown .header__link:hover {
        background: #eaf4f2;
        color: var(--primary);
    }

    .header__nav--dropdown .btn,
    .header__nav--dropdown a.btn,
    .header__nav--dropdown a.btn:visited {
        padding: var(--space-xs) var(--space-sm);
        background: transparent;
        border-color: transparent;
        color: var(--text-secondary);
        font-size: var(--text-sm);
        font-weight: var(--weight-medium);
        line-height: var(--leading-normal);
    }

    .header__nav--dropdown .btn--primary,
    .header__nav--dropdown a.btn--primary,
    .header__nav--dropdown a.btn--primary:visited {
        justify-content: center;
        margin-top: var(--space-2xs);
        background: var(--primary);
        border-color: var(--primary);
        color: var(--text-inverse);
    }

    .header__nav--dropdown .btn--primary:hover,
    .header__nav--dropdown a.btn--primary:hover {
        background: var(--primary-hover);
        border-color: var(--primary-hover);
        color: var(--text-inverse);
        text-decoration: none;
    }

    .header__nav--dropdown .btn:not(.btn--primary):hover,
    .header__nav--dropdown a.btn:not(.btn--primary):hover {
        background: transparent;
        border-color: transparent;
        color: var(--text-primary);
        text-decoration: underline;
    }
}
