/* =====================================================
   CMM CORE ENGINE v3
   Single UI foundation for public pages and dashboard.
===================================================== */

:root {
    --cmm-primary: #16a34a;
    --cmm-primary-dark: #15803d;
    --cmm-primary-soft: #dcfce7;
    --cmm-bg: #f6f8fb;
    --cmm-surface: #ffffff;
    --cmm-surface-soft: #f9fafb;
    --cmm-border: #e5e7eb;
    --cmm-text: #111827;
    --cmm-muted: #6b7280;
    --cmm-danger: #dc2626;
    --cmm-warning: #f59e0b;
    --cmm-info: #2563eb;
    --cmm-radius-sm: 10px;
    --cmm-radius: 14px;
    --cmm-radius-lg: 18px;
    --cmm-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    --cmm-header-height: 104px;
    --cmm-bottom-nav-height: 72px;
    --cmm-content-x: 16px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--cmm-bg);
}

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

img {
    max-width: 100%;
    height: auto;
}

a {
    color: inherit;
}

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

.cmm-app {
    position: relative;
    width: 100%;
    max-width: 420px;
    min-height: 100vh;
    margin: 0 auto;
    background: var(--cmm-surface);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.cmm-main {
    flex: 1;
    width: 100%;
    padding: calc(var(--cmm-header-height) + 16px) var(--cmm-content-x) calc(var(--cmm-bottom-nav-height) + 72px + env(safe-area-inset-bottom));
}

/* =========================
   TYPOGRAPHY
========================= */
.cmm-title {
    margin: 0;
    font-size: 18px;
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.cmm-title-sm {
    margin: 4px 0 0;
    font-size: 14px;
    line-height: 1.35;
    font-weight: 700;
}

.cmm-subtitle {
    margin: 6px 0 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--cmm-muted);
}

.cmm-text-muted {
    color: var(--cmm-muted);
}

.cmm-center {
    text-align: center;
}

/* =========================
   HEADER
========================= */
.cmm-header {
    position: fixed;
    top: 0;
    left: 50%;
    z-index: 1000;
    width: 100%;
    max-width: 420px;
    min-height: var(--cmm-header-height);
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--cmm-border);
    backdrop-filter: blur(10px);
}

.cmm-header-inner {
    min-height: var(--cmm-header-height);
    padding: 12px var(--cmm-content-x) 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
}

.cmm-logo-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.cmm-logo {
    display: block;
    width: 76px;
    max-height: 54px;
    object-fit: contain;
}

.cmm-header-subtitle {
    margin-top: 3px;
}

/* =========================
   SECTIONS AND HERO
========================= */
.cmm-section {
    margin-top: 18px;
}

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

.cmm-section-head {
    margin-bottom: 12px;
}

.cmm-hero {
    padding: 12px 8px 4px;
    margin-bottom: 18px;
}

.cmm-hero-icon {
    width: 54px;
    height: 54px;
    margin: 0 auto 10px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cmm-primary);
    background: var(--cmm-primary-soft);
    font-size: 24px;
}

/* =========================
   GRID SYSTEM
========================= */
.cmm-grid {
    display: grid;
    gap: 12px;
}

.cmm-grid-2,
.cmm-grid-3,
.cmm-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cmm-grid-1 {
    grid-template-columns: 1fr;
}

/* =========================
   CARD AND ICON BASE
========================= */
.cmm-card {
    display: block;
    width: 100%;
    padding: 14px;
    border: 1px solid var(--cmm-border);
    border-radius: var(--cmm-radius);
    background: var(--cmm-surface);
    color: var(--cmm-text);
    text-align: center;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.cmm-card:hover {
    transform: translateY(-2px);
    border-color: rgba(22, 163, 74, 0.35);
    box-shadow: var(--cmm-shadow);
}

.cmm-icon,
.cmm-card > i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 7px;
    font-size: 22px;
    color: var(--cmm-primary);
}

/* =========================
   SOCIAL FOLLOW FLOAT
========================= */
.cmm-follow {
    position: fixed;
    left: 50%;
    bottom: calc(var(--cmm-bottom-nav-height) + 12px + env(safe-area-inset-bottom));
    z-index: 995;
    width: min(320px, calc(100% - 32px));
    max-width: 320px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    text-align: center;
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
}

.cmm-follow.hide {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(16px);
    pointer-events: none;
}

.cmm-follow span {
    width: 100%;
    margin-bottom: 2px;
    font-size: 11px;
    font-weight: 700;
    color: var(--cmm-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.cmm-follow a {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    text-decoration: none;
    font-size: 18px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cmm-follow a:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 22px rgba(15, 23, 42, 0.18);
}

.cmm-follow a:nth-of-type(1) { background: #1877f2; }
.cmm-follow a:nth-of-type(2) { background: linear-gradient(45deg, #f58529, #dd2a7b, #8134af, #515bd4); }
.cmm-follow a:nth-of-type(3) { background: #ff0000; }
.cmm-follow a:nth-of-type(4) { background: #25d366; }

/* =========================
   BOTTOM NAV
========================= */
.cmm-bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 0;
    z-index: 1001;
    width: 100%;
    max-width: 420px;
    min-height: calc(var(--cmm-bottom-nav-height) + env(safe-area-inset-bottom));
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: repeat(var(--cmm-bottom-nav-count, 4), minmax(0, 1fr));
    gap: 4px;
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid var(--cmm-border);
    backdrop-filter: blur(10px);
}

.cmm-bottom-nav > a,
.cmm-bottom-more > summary {
    min-width: 0;
    min-height: 48px;
    padding: 7px 4px;
    border: 0;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: transparent;
    color: var(--cmm-muted);
    font-size: clamp(9px, 2.6vw, 11px);
    line-height: 1;
    font-weight: 650;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    list-style: none;
    transition: background 0.2s ease, color 0.2s ease;
}

.cmm-bottom-nav > a i,
.cmm-bottom-more > summary i {
    font-size: clamp(15px, 4.2vw, 18px);
}

.cmm-bottom-nav > a.active,
.cmm-bottom-nav > a:hover,
.cmm-bottom-more.active > summary,
.cmm-bottom-more[open] > summary,
.cmm-bottom-more > summary:hover {
    color: var(--cmm-primary-dark);
    background: var(--cmm-primary-soft);
}

.cmm-bottom-more {
    position: relative;
    min-width: 0;
}

.cmm-bottom-more > summary::-webkit-details-marker {
    display: none;
}

.cmm-bottom-more-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
    width: min(210px, calc(100vw - 28px));
    padding: 8px;
    border: 1px solid var(--cmm-border);
    border-radius: 18px;
    display: grid;
    gap: 4px;
    background: #ffffff;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
}

.cmm-bottom-more-panel::after {
    content: '';
    position: absolute;
    right: 18px;
    bottom: -6px;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-right: 1px solid var(--cmm-border);
    border-bottom: 1px solid var(--cmm-border);
    transform: rotate(45deg);
}

.cmm-bottom-more-panel a {
    position: relative;
    z-index: 1;
    min-height: 40px;
    padding: 10px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    color: var(--cmm-text);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease;
}

.cmm-bottom-more-panel a i {
    width: 18px;
    flex: 0 0 18px;
    color: var(--cmm-primary);
    font-size: 14px;
    text-align: center;
}

.cmm-bottom-more-panel a.active,
.cmm-bottom-more-panel a:hover {
    color: var(--cmm-primary-dark);
    background: var(--cmm-primary-soft);
}

.cmm-bottom-more-panel a.danger {
    color: #991b1b;
}

.cmm-bottom-more-panel a.danger i {
    color: #dc2626;
}

.cmm-bottom-more-panel a.danger:hover {
    background: #fef2f2;
}

/* =========================
   EMPTY STATE
========================= */
.cmm-empty {
    padding: 18px;
    border: 1px dashed var(--cmm-border);
    border-radius: var(--cmm-radius);
    background: var(--cmm-surface-soft);
    text-align: center;
    color: var(--cmm-muted);
    font-size: 13px;
}

/* =========================
   RESPONSIVE SAFETY
========================= */
@media (min-width: 768px) {
    :root {
        --cmm-content-x: 18px;
    }

    .cmm-app,
    .cmm-header,
    .cmm-bottom-nav {
        max-width: 480px;
    }

    .cmm-grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .cmm-grid-4 {
        grid-template-columns: repeat(var(--cmm-bottom-nav-count, 4), minmax(0, 1fr));
    }
}

@media (max-width: 380px) {
    :root {
        --cmm-content-x: 12px;
    }

    .cmm-title {
        font-size: 16px;
    }

    .cmm-logo {
        width: 68px;
    }

    .cmm-card {
        padding: 12px;
    }
}
