:root {
    --bg: #0B0F19;
    --card: #0F172A;
    --card-2: #111A2E;
    --border: #1E293B;
    --border-hi: #334155;
    --text: #F8FAFC;
    --muted: #94A3B8;
    --sky: #38BDF8;
    --sky-dark: #0284C7;
    --emerald: #34D399;
    --amber: #F59E0B;
    --purple: #A855F7;
    --danger: #EF4444;
}

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

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    overflow-x: clip;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
    body {
        padding-bottom: 24px;
    }
}

a {
    color: var(--sky);
}

button, a, .hbb-nav-link, .hbb-bottom-item {
    -webkit-touch-callout: none;
}

/* Header & Navigation */
.hbb-header {
    position: sticky;
    top: 0;
    z-index: 900;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.hbb-header-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 68px;
}

.hbb-brand-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}

.hbb-brand-logo {
    height: 54px;
    width: auto;
    max-width: 230px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.75)) brightness(1.12) contrast(1.08);
    transition: transform 0.2s ease, filter 0.2s ease;
}

.hbb-brand-link:hover .hbb-brand-logo {
    transform: scale(1.02);
    filter: drop-shadow(0 4px 16px rgba(56, 189, 248, 0.45)) brightness(1.18) contrast(1.1);
}

@media (max-width: 600px) {
    .hbb-brand-logo {
        height: 44px;
        max-width: 175px;
    }
}

.hbb-nav {
    display: none;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

@media (min-width: 768px) {
    .hbb-nav {
        display: flex;
    }
}

.hbb-nav-link {
    text-decoration: none;
    color: #CBD5E1;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 12px;
    border-radius: 9px;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.hbb-nav-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.hbb-nav-link.active {
    color: var(--sky);
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.35);
}

.hbb-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hbb-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--border-hi);
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    padding: 7px 12px;
    border-radius: 999px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.hbb-pill-btn:hover {
    border-color: var(--sky);
    color: var(--sky);
}

.hbb-pill-btn.admin {
    border-color: rgba(245, 158, 11, 0.45);
    color: var(--amber);
}

/* Main Content Wrapper */
.hbb-main {
    flex: 1;
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 18px 14px 36px;
}

.hbb-container-narrow {
    max-width: 680px;
    margin: 0 auto;
}

/* Common Card & Form Elements */
.hbb-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.hbb-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.hbb-card-title {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.hbb-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.15);
    color: var(--sky);
    border: 1px solid rgba(56, 189, 248, 0.35);
    white-space: nowrap;
}

.hbb-badge.emerald {
    background: rgba(16, 185, 129, 0.15);
    color: var(--emerald);
    border-color: rgba(16, 185, 129, 0.35);
}

.hbb-badge.amber {
    background: rgba(245, 158, 11, 0.15);
    color: var(--amber);
    border-color: rgba(245, 158, 11, 0.35);
}

.hbb-badge.danger {
    background: rgba(239, 68, 68, 0.15);
    color: #FCA5A5;
    border-color: rgba(239, 68, 68, 0.35);
}

.hbb-input,
.hbb-select,
.hbb-textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border-hi);
    border-radius: 10px;
    color: var(--text);
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease;
}

.hbb-input:focus,
.hbb-select:focus,
.hbb-textarea:focus {
    border-color: var(--sky);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.hbb-label {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.hbb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #0284C7 0%, #2563EB 100%);
    color: #FFFFFF;
    border: none;
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.35);
}

.hbb-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(56, 189, 248, 0.45);
}

.hbb-btn:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
}

.hbb-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #1E293B;
    border: 1px solid #334155;
    color: var(--text);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.hbb-btn-secondary:hover {
    border-color: var(--sky);
}

.hbb-btn-emerald {
    background: linear-gradient(135deg, #059669 0%, #10B981 100%);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
}

.hbb-btn-amber {
    background: linear-gradient(135deg, #D97706 0%, #F59E0B 100%);
    color: #071326;
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.3);
}

.hbb-btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #FCA5A5;
    box-shadow: none;
}

.hbb-alert {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 14px;
}

.hbb-alert.ok {
    background: rgba(16, 185, 129, 0.16);
    border: 1px solid rgba(16, 185, 129, 0.45);
    color: var(--emerald);
}

.hbb-alert.err {
    background: rgba(239, 68, 68, 0.16);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #FCA5A5;
}

/* Mobile Sticky Bottom Tab Bar */
.hbb-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 950;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
    .hbb-bottom-nav {
        display: none;
    }
}

.hbb-bottom-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    padding: 4px 2px;
    border-radius: 8px;
}

.hbb-bottom-item.active {
    color: var(--sky);
}

/* Footer */
.hbb-footer {
    border-top: 1px solid var(--border);
    padding: 16px 14px;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    margin-top: auto;
}

.hbb-footer a {
    color: var(--muted);
    text-decoration: none;
    margin: 0 8px;
}

.hbb-footer a:hover {
    color: var(--sky);
}

/* AI Coach Floating Launcher & Drawer */
.hbb-ai-fab {
    position: fixed;
    right: 16px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    z-index: 960;
    background: linear-gradient(135deg, #0284C7, #1D4ED8);
    color: #FFFFFF;
    border: 1px solid rgba(56, 189, 248, 0.6);
    border-radius: 999px;
    padding: 10px 15px;
    font-size: 12.5px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.55);
}

@media (min-width: 768px) {
    .hbb-ai-fab {
        bottom: 22px;
        right: 22px;
    }
}

.hbb-ai-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 15, 25, 0.72);
    backdrop-filter: blur(4px);
    z-index: 9990;
    display: none;
}

.hbb-ai-overlay.open { display: block; }

.hbb-ai-drawer {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    max-width: 410px;
    background: var(--bg);
    border-left: 1px solid var(--border-hi);
    z-index: 9995;
    display: none;
    flex-direction: column;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.8);
}

.hbb-ai-drawer.open { display: flex; }

.hbb-ai-head {
    padding: 14px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.hbb-ai-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hbb-ai-msg {
    max-width: 88%;
    padding: 10px 13px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
}

.hbb-ai-msg.user {
    align-self: flex-end;
    background: #0284C7;
    color: #FFFFFF;
}

.hbb-ai-msg.model {
    align-self: flex-start;
    background: var(--card);
    border: 1px solid var(--border-hi);
    color: var(--text);
}

.hbb-ai-form {
    padding: 12px;
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

.hbb-ai-act-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(56, 189, 248, 0.14);
    border: 1px solid var(--sky);
    color: var(--sky);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 11.5px;
    font-weight: 800;
    cursor: pointer;
    margin: 4px 4px 0 0;
}
