/* ===================== RESET & BASE ===================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0d1117;
    --bg2: #161b22;
    --bg3: #1c2128;
    --bg4: #21262d;
    --border: #30363d;
    --border-light: #3d444d;
    --accent: #00c896;
    --accent2: #00a87f;
    --accent-dim: rgba(0, 200, 150, 0.12);
    --accent-glow: rgba(0, 200, 150, 0.25);
    --text: #e6edf3;
    --text2: #8b949e;
    --text3: #6e7681;
    --meta: #4589ff;
    --google: #f28b30;
    --tiktok: #ff2d55;
    --metrics: #a371f7;
    --check: #3fb950;
    --lifehack: #ffa657;
    --font-main: 'Manrope', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --header-h: 56px;
    --nav-h: 48px;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 2px;
}

/* ===================== HEADER ===================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(13, 17, 23, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
    padding: 0 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.logo-icon {
    color: var(--accent);
    font-size: 22px;
    line-height: 1;
}

.logo-text {
    font-family: var(--font-mono);
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.3px;
}

.logo-text em {
    font-style: normal;
    color: var(--accent);
}

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

.btn-icon {
    position: relative;
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    color: var(--text2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.btn-icon:hover {
    background: var(--bg3);
    color: var(--text);
}

.btn-icon:active {
    background: var(--bg4);
}

.badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    background: var(--accent);
    color: #000;
    font-size: 10px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

/* ===================== SEARCH BAR ===================== */
.search-bar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 0 16px 10px;
}

.search-bar.open {
    display: flex;
}

.search-bar input {
    flex: 1;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-main);
    font-size: 14px;
    padding: 8px 12px;
    outline: none;
    transition: border-color 0.15s;
}

.search-bar input:focus {
    border-color: var(--accent);
}

.search-bar input::placeholder {
    color: var(--text3);
}

.search-clear {
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
}

/* ===================== SEARCH RESULTS ===================== */
.search-results {
    position: fixed;
    top: calc(var(--header-h) + 42px);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 90;
    overflow-y: auto;
    padding: 16px;
}

.search-results .no-results {
    color: var(--text2);
    text-align: center;
    margin-top: 48px;
    font-size: 15px;
}

.search-result-item {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.search-result-item:hover {
    border-color: var(--accent);
    background: var(--bg3);
}

.search-result-item h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.search-result-item .result-section {
    font-size: 12px;
    color: var(--accent);
    font-family: var(--font-mono);
}

/* ===================== NAV TABS ===================== */
.nav-tabs {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    z-index: 99;
    background: rgba(22, 27, 34, 0.95);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    height: var(--nav-h);
}

.nav-tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 14px;
    height: 100%;
    border: none;
    background: transparent;
    color: var(--text2);
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-icon {
    font-size: 12px;
    opacity: 0.8;
}

/* Tab accent colors by section */
#navTabs .tab[data-section="meta"].active {
    color: var(--meta);
    border-bottom-color: var(--meta);
}

#navTabs .tab[data-section="google"].active {
    color: var(--google);
    border-bottom-color: var(--google);
}

#navTabs .tab[data-section="tiktok"].active {
    color: var(--tiktok);
    border-bottom-color: var(--tiktok);
}

#navTabs .tab[data-section="metrics"].active {
    color: var(--metrics);
    border-bottom-color: var(--metrics);
}

#navTabs .tab[data-section="checklists"].active {
    color: var(--check);
    border-bottom-color: var(--check);
}

#navTabs .tab[data-section="lifehacks"].active {
    color: var(--lifehack);
    border-bottom-color: var(--lifehack);
}

/* ===================== MAIN CONTENT ===================== */
.main {
    padding: calc(var(--header-h) + var(--nav-h) + 16px) 12px 32px;
    max-width: 680px;
    margin: 0 auto;
}

/* ===================== SECTIONS ===================== */
.section {
    display: none;
}

.section.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.section-header h1 {
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.section-header p {
    font-size: 13px;
    color: var(--text2);
    margin-top: 4px;
}

/* Color per section */
#section-meta .section-header h1 {
    color: var(--meta);
}

#section-google .section-header h1 {
    color: var(--google);
}

#section-tiktok .section-header h1 {
    color: var(--tiktok);
}

#section-metrics .section-header h1 {
    color: var(--metrics);
}

#section-checklists .section-header h1 {
    color: var(--check);
}

#section-lifehacks .section-header h1 {
    color: var(--lifehack);
}

/* ===================== CATEGORY GROUPS ===================== */
.category-group {
    margin-bottom: 24px;
}

.group-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text3);
    margin-bottom: 10px;
    padding-left: 2px;
}

/* ===================== CARDS ===================== */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    transition: border-color 0.15s;
}

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

.card-head {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
}

.card-icon {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 1px;
}

.card-head h3 {
    flex: 1;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.4;
}

.card p {
    font-size: 13.5px;
    color: var(--text2);
    line-height: 1.65;
    margin-bottom: 8px;
}

.card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.card ul li {
    font-size: 13.5px;
    color: var(--text2);
    padding: 5px 0 5px 14px;
    position: relative;
    line-height: 1.6;
    border-bottom: 1px solid var(--bg3);
}

.card ul li:last-child {
    border-bottom: none;
}

.card ul li::before {
    content: '–';
    position: absolute;
    left: 0;
    color: var(--text3);
}

.card ul li strong {
    color: var(--text);
    font-weight: 600;
}

.card code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg4);
    color: var(--accent);
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid var(--border);
    word-break: break-all;
    overflow-wrap: break-word;
}

/* ===================== TIP ===================== */
.tip {
    margin-top: 10px;
    padding: 9px 12px;
    background: var(--accent-dim);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 12.5px;
    color: #a0f0dc;
    line-height: 1.55;
}

/* ===================== FORMULA GRID ===================== */
.formula-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
}

.formula-item {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.formula-name {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.formula-eq {
    font-size: 11.5px;
    color: var(--text2);
    line-height: 1.4;
}

/* ===================== CHECKLIST ===================== */
.checklist {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.checklist label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    font-size: 13.5px;
    color: var(--text2);
    cursor: pointer;
    border-bottom: 1px solid var(--bg3);
    line-height: 1.5;
    transition: color 0.15s;
}

.checklist label:last-child {
    border-bottom: none;
}

.checklist label:hover {
    color: var(--text);
}

.checklist input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 2px solid var(--border-light);
    border-radius: 4px;
    background: var(--bg3);
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 1px;
    position: relative;
}

.checklist input[type="checkbox"]:checked {
    background: var(--check);
    border-color: var(--check);
}

.checklist input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: -1px;
    left: 2px;
    font-size: 12px;
    color: #000;
    font-weight: 700;
}

.checklist label:has(input:checked) {
    color: var(--text3);
    text-decoration: line-through;
    text-decoration-color: var(--text3);
}

/* ===================== BOOKMARK BUTTON ===================== */
.bookmark-btn {
    background: none;
    border: none;
    color: var(--text3);
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s, transform 0.15s;
    flex-shrink: 0;
    margin-left: auto;
}

.bookmark-btn:hover {
    color: var(--accent);
    transform: scale(1.2);
}

.bookmark-btn.active {
    color: var(--accent);
}

/* ===================== MODAL ===================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    display: none;
    align-items: flex-end;
    backdrop-filter: blur(4px);
}

.modal-overlay.open {
    display: flex;
    animation: overlayIn 0.2s ease;
}

@keyframes overlayIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    width: 100%;
    max-height: 80vh;
    background: var(--bg2);
    border-top: 1px solid var(--border-light);
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.25s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 700;
}

.modal-body {
    overflow-y: auto;
    padding: 12px 16px 24px;
    flex: 1;
}

.empty-state {
    text-align: center;
    color: var(--text3);
    font-size: 14px;
    margin-top: 24px;
}

.bookmark-card-item {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: border-color 0.15s;
}

.bookmark-card-item:hover {
    border-color: var(--accent);
}

.bookmark-card-item span {
    font-size: 13px;
    color: var(--text);
    flex: 1;
    line-height: 1.4;
}

.bookmark-remove {
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.bookmark-remove:hover {
    background: var(--bg4);
    color: var(--tiktok);
}

/* ===================== RESPONSIVE ===================== */
@media (min-width: 480px) {
    .formula-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

@media (min-width: 680px) {
    .main {
        padding-left: 20px;
        padding-right: 20px;
    }

    .card {
        padding: 18px;
    }
}

/* ===================== INSTALL BANNER ===================== */
.install-banner {
    position: fixed;
    bottom: 16px;
    left: 12px;
    right: 12px;
    background: var(--bg3);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
    z-index: 150;
    animation: slideUp 0.3s ease;
}

.install-banner p {
    flex: 1;
    font-size: 13px;
    color: var(--text);
    margin: 0;
}

.install-banner p strong {
    color: var(--accent);
}

.install-btn {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius-sm);
    padding: 7px 14px;
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.install-dismiss {
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    font-size: 14px;
}

/* ===================== HIGHLIGHT ON SEARCH ===================== */
mark {
    background: var(--accent-glow);
    color: var(--accent);
    border-radius: 2px;
    padding: 0 1px;
}