/* --- Global Styles --- */
:root {
    --primary-color: #6366f1;       /* Name Memorize Indigo */
    --primary-light: #eef2ff;
    --primary-hover: #4f46e5;
    --text-color: #1f2937;
    --text-light: #4b5563;
    --border-color: #e5e7eb;
    --bg-color: #f9fafb;
    --bg-white: #ffffff;
    --heading-color: var(--heading-color);
    --text-muted: #9ca3af;
    --danger-bg: #fef2f2;
    --danger-border: #fee2e2;
    --danger-text: #b91c1c;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

* { box-sizing: border-box; }

a { color: var(--primary-color); text-decoration: none; transition: all 0.2s; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

h1, h2, h3, h4 { font-family: 'Lora', serif; font-weight: 700; color: var(--heading-color); }
h1 { font-size: 2.25rem; margin-bottom: 1.5rem; }
h2 { font-size: 1.75rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.75rem; margin-top: 2.5rem; }
h3 { font-size: 1.25rem; margin-top: 2rem; font-family: 'Inter', sans-serif; font-weight: 600; }

p { margin-bottom: 1.25rem; color: var(--text-light); }

.subtitle { color: var(--text-light); margin-top: -1rem; margin-bottom: 2.5rem; font-weight: 300; }

/* --- Layout --- */
.help-container { display: flex; max-width: 1200px; margin: 0 auto; background: var(--bg-white); min-height: 100vh; box-shadow: 0 0 40px rgba(0,0,0,0.03); }
.help-sidebar { width: 280px; flex-shrink: 0; padding: 2rem; border-right: 1px solid var(--border-color); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.help-content { flex-grow: 1; padding: 3rem 4rem; max-width: calc(100% - 280px); position: relative; }

/* --- Sidebar --- */
.brand-link { display: flex; align-items: center; font-weight: 600; font-size: 1.1rem; color: var(--text-color); margin-bottom: 1rem; }
.brand-icon { width: 28px; height: 28px; border-radius: 6px; margin-right: 10px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.help-sidebar h3 { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); margin-top: 2rem; letter-spacing: 0.05em; }
.help-sidebar ul { list-style: none; padding: 0; margin: 0; }
.help-sidebar li a { display: block; padding: 0.5rem 0.75rem; border-radius: 6px; color: var(--text-light); font-size: 0.95rem; font-weight: 500; }
.help-sidebar li a:hover { background-color: var(--bg-color); color: var(--text-color); }
.help-sidebar li.active a { background-color: var(--primary-light); color: var(--primary-color); font-weight: 600; }

/* --- Category Grid --- */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; }
.category-card { display: block; background: var(--bg-white); border: 1px solid var(--border-color); border-radius: 12px; padding: 1.5rem; transition: 0.2s; }
.category-card:hover { border-color: var(--primary-light); transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05); }
.category-card h4 { margin: 0 0 0.5rem 0; color: var(--primary-color); font-family: 'Inter', sans-serif; font-size: 1.1rem; }
.category-card p { margin: 0; font-size: 0.95rem; color: var(--text-light); }
.category-card.coming-soon { background: var(--bg-color); }
.category-card.coming-soon:hover { border-color: var(--border-color); transform: none; box-shadow: none; }
.category-card.coming-soon h4 { color: var(--text-light); }
.category-grid.platform-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.platform-grid .category-card { padding: 1.25rem; }
.platform-grid .category-card p { overflow-wrap: anywhere; }
@media (max-width: 600px) {
    .category-grid.platform-grid { grid-template-columns: 1fr; }
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .help-container { flex-direction: column; }
    .help-sidebar { width: 100%; height: auto; position: relative; border-right: none; border-bottom: 1px solid var(--border-color); padding: 1rem 1.5rem; }
    .help-sidebar ul { display: flex; overflow-x: auto; gap: 0.5rem; }
    .help-sidebar li a { white-space: nowrap; background: var(--bg-color); }
    .help-content { width: 100%; max-width: 100%; padding: 2rem 1.5rem; }
}

/* --- LifeOrch Branding --- */
.lifeorch-brand {
    position: absolute;
    top: 1.25rem;
    right: 4rem;
}

.lifeorch-brand a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    transition: all 0.2s ease;
    line-height: 1;
}

.lifeorch-brand a:hover {
    color: var(--primary-color);
    border-color: var(--primary-light);
    background: var(--primary-light);
    text-decoration: none;
}

.lifeorch-brand img {
    width: 2.25em;
    height: 2.25em;
    border-radius: 3px;
    display: block;
    flex-shrink: 0;
}

/* --- Guide pages (generated by NumifyLife/tools/guides_html from the in-app guides) --- */
.help-content ul,
.help-content ol {
    color: var(--text-light);
    padding-left: 1.25rem;
    margin-bottom: 1.25rem;
}

.help-content li {
    margin-bottom: 0.5rem;
}

.help-content strong {
    color: var(--text-color);
}

.help-sidebar ul + h3 {
    margin-top: 1.5rem;
}

.guide-theme {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.guide-callout,
.guide-example {
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin: 1rem 0 1.5rem;
}

.guide-callout {
    background: var(--primary-light);
}

.guide-example {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
}

.guide-callout h4,
.guide-example h4 {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
}

.guide-callout p:last-child,
.guide-callout ul:last-child,
.guide-example p:last-child {
    margin-bottom: 0;
}

.plan-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 1.5rem;
    font-size: 0.95rem;
}

.plan-table th,
.plan-table td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-color);
}

.plan-table th:first-child,
.plan-table td:first-child {
    text-align: left;
}

.start-card {
    display: block;
    background: var(--primary-light);
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    transition: 0.2s;
}

.start-card:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05);
}

.start-label {
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary-color);
}

.start-card h4 {
    font-family: 'Inter', sans-serif;
    font-size: 1.2rem;
    margin: 0.25rem 0;
}

.start-card p {
    margin: 0;
    font-weight: 600;
}

/* Guide sections in the menu, grouped as in the app's Guides screen */
.help-sidebar .nav-section {
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 1rem 0 0.25rem 0.75rem;
}

.help-sidebar h3 + .nav-section {
    margin-top: 0.5rem;
}

.help-sidebar .nav-section + ul {
    margin-left: 0.75rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--border-color);
}

.help-sidebar .nav-section + ul li a {
    font-size: 0.9rem;
    padding: 0.35rem 0.6rem;
}

/* The language list at the top of the menu (generated <select class="help-language">) */
.help-language {
    display: block;
    width: 100%;
    margin: 0 0 0.5rem 0;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
    background-color: var(--bg-color);
    background-image: linear-gradient(45deg, transparent 50%, var(--text-light) 50%), linear-gradient(135deg, var(--text-light) 50%, transparent 50%);
    background-position: calc(100% - 1.05rem) 50%, calc(100% - 0.75rem) 50%;
    background-size: 0.3rem 0.3rem;
    background-repeat: no-repeat;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.help-language:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
    outline: none;
}

/* The menu folds on a phone (generated <details class="help-menu">); on a wide screen it is always open */
.help-menu > summary {
    display: none;
}

@media (max-width: 900px) {
    /* One labelled, swipeable row per group */
    .help-menu > summary {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        cursor: pointer;
        list-style: none;
        font-weight: 600;
        color: var(--text-color);
        padding: 0.6rem 0.75rem;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        background: var(--bg-color);
    }
    .help-menu > summary::-webkit-details-marker { display: none; }
    .help-menu > summary::after { content: '\25BE'; margin-left: auto; color: var(--text-light); }
    .help-menu[open] > summary::after { content: '\25B4'; }
    .help-menu-current { font-weight: 500; color: var(--primary-color); }
    .help-menu-current:not(:empty)::before { content: '\00B7'; margin-right: 0.5rem; color: var(--text-light); }
    .help-menu[open] > summary { margin-bottom: 0.5rem; }
    .help-language { font-size: 1rem; padding-top: 0.6rem; padding-bottom: 0.6rem; }
    .help-sidebar h3 { display: none; }
    .help-sidebar ul + h3 { margin-top: 0; }
    .help-sidebar ul { padding-bottom: 0.4rem; }
    .help-sidebar .nav-section { margin: 0.5rem 0 0.25rem 0; font-size: 0.75rem; color: var(--text-light); }
    .help-sidebar .nav-section + ul { margin-left: 0; padding-left: 0; border-left: none; }
}

/* --- Dark theme ------------------------------------------------------------
   Follows the browser/OS setting (prefers-color-scheme). Most colors come from the
   variables in :root, so the block below mostly re-points them. Use a variable,
   not a literal color, when adding styles to this file or to a page.
   The ":root ." rules cover light colors hard-coded in the pages' own <style>
   blocks (help.html download cards, contact.html form and popup); ":root" makes
   them more specific than those rules, which load after this file.
   QR codes keep their white background so phones can scan them.
   The same block is in vocabex/help, name_memorize/help and numify_life/help
   style.css; keep them in step. Tailwind pages use LifeOrch/site-dark.css. */
:root { color-scheme: light dark; }

/* App icons, in both themes: shaped like a launcher icon (rounded square). The
   icon files are each app's store icon (iOS App Store icon), opaque squares. */
.brand-icon,
.lifeorch-brand img { background-color: #ffffff; border-radius: 22%; }

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #818cf8;       /* links: indigo 400 reads on dark */
        --primary-light: rgba(129, 140, 248, 0.16);
        --primary-hover: #a5b4fc;
        --primary-fill: #4f46e5;        /* backgrounds behind white text */
        --text-color: #e5e7eb;
        --text-light: #cbd5e1;
        --text-muted: #9ca3af;
        --heading-color: #f9fafb;
        --border-color: #374151;
        --bg-color: #0b1120;
        --bg-white: #111827;
        --danger-bg: rgba(239, 68, 68, 0.12);
        --danger-border: rgba(239, 68, 68, 0.35);
        --danger-text: #fca5a5;
    }
    :root .help-container { box-shadow: none; }
    :root .category-card:hover { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5); }

    /* help.html download cards */
    :root .download-card { background: var(--bg-white); }
    :root .download-card:hover { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5); }
    :root .coming-soon-badge { background: rgba(251, 191, 36, 0.15); color: #fcd34d; border-color: rgba(251, 191, 36, 0.4); }

    /* contact.html */
    :root .form-group input:not([type="submit"]),
    :root .form-group textarea { background: var(--bg-color); color: var(--text-color); }
    :root .submit-button { background-color: var(--primary-fill); }
    :root .submit-button:hover { background-color: #6366f1; }
    :root .secondary-button,
    :root .copy-button,
    :root .success-box { background: var(--bg-white); }
    :root .manual-send-box pre { background-color: var(--bg-color); border-color: var(--border-color); color: var(--text-color); }
    :root #decoded-error-container { background-color: var(--danger-bg); border-color: var(--danger-border); border-left-color: #ef4444; }
    :root #decoded-error-container strong { color: var(--danger-text); }
    :root .error-message-content { background-color: rgba(0, 0, 0, 0.3); color: #fecaca; }
}
