:root {
    --bg-page: #f8f7f4;
    --bg-card: #ffffff;
    --text-main: #111827;
    --text-muted: #64748b;
    --gold-main: #d4af37;
    --gold-dark: #aa820a;
    --gold-light: #fcf9ee;
    --border-color: #ede8df;
    --success: #15803d;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    --bottom-bar-height: 65px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    user-select: none;
    -webkit-user-select: none;
    overflow-x: hidden;
}

#app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: calc(var(--bottom-bar-height) + var(--safe-bottom) + 15px);
}

/* TOP APP BAR */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 18px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1f2937, #111827);
    color: var(--gold-main);
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--gold-main);
    font-size: 16px;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.25);
}

.user-greeting {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

.user-status {
    font-size: 11px;
    font-weight: 600;
    color: var(--gold-dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.academy-logo {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #1f2937;
}

.gold-text {
    color: var(--gold-main);
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    padding: 16px 16px 20px 16px;
}

.app-view {
    display: none;
    animation: fadeIn 0.25s ease-out;
}

.app-view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* HERO STATS */
.hero-stats-card {
    background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
    color: #ffffff;
    border-radius: 18px;
    padding: 20px 16px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 8px 24px rgba(17, 24, 39, 0.15);
    margin-bottom: 24px;
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.stats-item {
    text-align: center;
    flex: 1;
}

.stats-val {
    display: block;
    font-size: 24px;
    font-weight: 900;
    color: var(--gold-main);
    line-height: 1.1;
    font-family: 'Playfair Display', serif;
}

.stats-lbl {
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

.stats-divider {
    width: 1px;
    height: 32px;
    background: rgba(255, 255, 255, 0.12);
}

/* SECTION HEADERS */
.section-header {
    margin-bottom: 14px;
}

.section-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.3px;
}

.section-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

/* CERTIFICATES GALLERY */
.certificates-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.certificate-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease;
}

.cert-image-preview {
    width: 100%;
    aspect-ratio: 1.414;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid #ede8df;
    margin-bottom: 12px;
    background: #f1ede4;
}

.cert-badge-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.cert-id-tag {
    font-size: 11px;
    font-family: monospace;
    font-weight: 700;
    color: var(--gold-dark);
    background: var(--gold-light);
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid rgba(212, 175, 55, 0.25);
}

.cert-status-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 4px;
}

.cert-course-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 4px;
    line-height: 1.3;
}

.cert-student-name {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.cert-buttons-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.btn-cert-download {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: #f8f7f4;
    border: 1px solid #e2ddd4;
    color: #1e293b;
    font-size: 12px;
    font-weight: 700;
    padding: 10px 8px;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cert-download:active {
    background: #e2ddd4;
}

.btn-story-share {
    grid-column: span 2;
    background: linear-gradient(135deg, #d4af37, #aa820a);
    color: #ffffff;
    border: none;
    font-size: 13px;
    font-weight: 700;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-story-share:active {
    transform: scale(0.98);
}

/* ENROLLMENTS LIST */
.enrollments-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.enrollment-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--card-shadow);
}

.enrollment-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.enrollment-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
}

.progress-wrap {
    margin-bottom: 12px;
}

.progress-label-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.progress-bar-bg {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #d4af37, #15803d);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.btn-open-lesson {
    display: block;
    width: 100%;
    text-align: center;
    background: #111827;
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    padding: 10px 14px;
    border-radius: 8px;
    text-decoration: none;
}

/* PROMO BANNER */
.promo-banner {
    background: linear-gradient(135deg, #fdfbf7 0%, #f6f0e2 100%);
    border: 1px solid #ebd9b0;
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 20px;
    box-shadow: var(--card-shadow);
}

.promo-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #856404;
    background: #ffeeba;
    padding: 3px 8px;
    border-radius: 5px;
    margin-bottom: 8px;
}

.promo-title {
    font-size: 17px;
    font-weight: 800;
    color: #111827;
    margin-bottom: 4px;
}

.promo-desc {
    font-size: 13px;
    color: #4b5563;
    margin-bottom: 12px;
}

.btn-banner {
    background: #111827;
    color: #ffffff;
    border: none;
    font-size: 12px;
    font-weight: 700;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
}

/* CATEGORY FILTERS */
.category-filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 14px;
    scrollbar-width: none;
}

.category-filters::-webkit-scrollbar {
    display: none;
}

.filter-pill {
    white-space: nowrap;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: #475569;
    font-size: 12px;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-pill.active {
    background: #111827;
    color: #ffffff;
    border-color: #111827;
}

/* CATALOG GRID */
.catalog-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
}

.product-thumb-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #f1ede4;
}

.product-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-pill-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(4px);
    color: var(--gold-main);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 4px 8px;
    border-radius: 6px;
}

.product-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 6px;
    line-height: 1.3;
}

.product-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #f1f5f9;
}

.product-price {
    font-size: 20px;
    font-weight: 900;
    color: #111827;
    font-family: 'Playfair Display', serif;
}

.btn-buy-product {
    background: linear-gradient(135deg, #d4af37, #aa820a);
    color: #ffffff;
    border: none;
    font-size: 13px;
    font-weight: 700;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(212, 175, 55, 0.3);
    text-decoration: none;
}

.btn-buy-product:active {
    transform: scale(0.97);
}

/* PROFILE VIEW */
.profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 24px 16px;
    text-align: center;
    box-shadow: var(--card-shadow);
    margin-bottom: 20px;
}

.profile-avatar-large {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #111827;
    color: var(--gold-main);
    font-size: 26px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px auto;
    border: 3px solid var(--gold-main);
}

.profile-name {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
}

.profile-username {
    font-size: 13px;
    color: var(--gold-dark);
    font-weight: 600;
    margin-bottom: 6px;
}

.profile-contact-info {
    font-size: 12px;
    color: var(--text-muted);
}

.settings-list {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-bottom: 1px solid #f1f5f9;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-item:active {
    background: #f8fafc;
}

.setting-icon {
    font-size: 20px;
    width: 32px;
    text-align: center;
}

.setting-text {
    flex: 1;
}

.setting-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.setting-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.setting-arrow {
    color: #94a3b8;
    font-size: 16px;
}

/* BOTTOM NAV BAR */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-bar-height) + var(--safe-bottom));
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding-top: 8px;
    padding-bottom: var(--safe-bottom);
    z-index: 100;
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: #94a3b8;
    cursor: pointer;
    flex: 1;
    transition: color 0.2s ease;
}

.nav-icon {
    font-size: 20px;
}

.nav-label {
    font-size: 11px;
    font-weight: 600;
}

.nav-item.active {
    color: var(--gold-dark);
}

/* STORIES PREVIEW MODAL */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(6px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background: var(--bg-card);
    width: 100%;
    max-width: 420px;
    border-radius: 20px;
    padding: 20px;
    position: relative;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
}

.modal-title {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 4px;
}

.modal-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.canvas-preview-wrap {
    width: 100%;
    max-height: 380px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    margin-bottom: 14px;
    background: #111827;
}

#stories-canvas {
    max-width: 100%;
    max-height: 380px;
    object-fit: contain;
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, #d4af37, #aa820a);
    color: #ffffff;
    border: none;
    font-size: 14px;
    font-weight: 700;
    padding: 14px;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.35);
}

/* SPINNER */
.loading-spinner {
    text-align: center;
    padding: 30px 10px;
    color: var(--text-muted);
    font-size: 13px;
}

.gold-spin {
    width: 32px;
    height: 32px;
    border: 3px solid #ede8df;
    border-top-color: var(--gold-main);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.empty-state {
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: 16px;
    padding: 24px 16px;
    text-align: center;
}

.empty-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.trust-footer {
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.6;
}
