/* ===== Reset & base ===== */
:root {
    --bg: #0f1115;
    --bg-elev: #16191f;
    --bg-elev-2: #1c2028;
    --border: #2a2f38;
    --text: #e8eaee;
    --text-muted: #8c95a4;
    --accent: #4ea1ff;
    --accent-hover: #6cb4ff;
    --pos: #3cd17c;
    --pos-bg: #1a2c22;
    --neg: #ff7376;
    --neg-bg: #2c1d1f;
    --shadow: 0 2px 8px rgba(0,0,0,0.25);
}

* { box-sizing: border-box; }

html { font-size: 16px; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

code {
    background: var(--bg-elev-2);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

.wrap {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== Header / nav ===== */
.site-header {
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(8px);
}
.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    padding-bottom: 14px;
}
.brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}
.brand:hover { text-decoration: none; color: var(--accent); }

.main-nav { display: flex; gap: 4px; align-items: center; }
.main-nav a {
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.95rem;
}
.main-nav a:hover { color: var(--text); background: var(--bg-elev-2); text-decoration: none; }
.main-nav a.active { color: var(--text); background: var(--bg-elev-2); }
.main-nav a.nav-admin {
    border: 1px solid var(--border);
    margin-left: 8px;
}

/* ===== Main / hero ===== */
.site-main { padding: 32px 0 80px; min-height: 60vh; }

.hero { text-align: center; padding: 24px 0 32px; }
.hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0 0 12px;
    letter-spacing: -0.02em;
}
.hero .lead {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 560px;
    margin: 0 auto 28px;
}

/* ===== Search ===== */
.search-container {
    position: relative;
    max-width: 480px;
    margin: 0 auto;
}
#search-bar {
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    transition: border-color 0.15s;
}
#search-bar:focus { border-color: var(--accent); }
#search-results {
    list-style: none;
    margin: 6px 0 0;
    padding: 6px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    position: absolute;
    left: 0; right: 0;
    max-height: 320px;
    overflow-y: auto;
    z-index: 5;
}
#search-results li {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
}
#search-results li:hover { background: var(--bg-elev-2); }
#search-results li.no-results {
    cursor: default;
    color: var(--text-muted);
    justify-content: center;
}
.r-cat { color: var(--text-muted); font-size: 0.9em; }

/* ===== App grid (homepage + similar) ===== */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 40px;
}
.app-grid-compact { margin-top: 16px; }

.app-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    gap: 14px;
    transition: border-color 0.15s, transform 0.15s;
    color: var(--text);
}
.app-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.app-card-thumb {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-elev-2);
    display: flex;
    align-items: center;
    justify-content: center;
}
.app-card-thumb img { width: 100%; height: 100%; object-fit: contain; }
.app-card-thumb-fallback {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-muted);
}
.app-card-body h3 {
    margin: 0 0 4px;
    font-size: 1.05rem;
    color: var(--text);
}
.app-card-body .category {
    margin: 0 0 6px;
    font-size: 0.8rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.app-card-body .desc {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ===== App detail page ===== */
.breadcrumb {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}
.breadcrumb span { color: var(--text); }

.app-hero {
    display: flex;
    gap: 28px;
    align-items: flex-start;
    margin-bottom: 32px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border);
}
.app-hero-thumb {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
    border-radius: 16px;
    overflow: hidden;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}
.app-hero-thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb-fallback-lg {
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-muted);
}
.app-hero-meta { flex: 1; min-width: 0; }
.eyebrow {
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.8rem;
    font-weight: 600;
    margin: 0 0 6px;
}
.app-hero-meta h1 {
    font-size: 2.25rem;
    font-weight: 800;
    margin: 0 0 12px;
    letter-spacing: -0.02em;
}
.app-hero-meta .lead {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin: 0 0 20px;
}
.app-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== Badges ===== */
.badges {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 36px;
}
.badge {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-elev);
}
.badge.pos { border-color: rgba(60, 209, 124, 0.3); background: var(--pos-bg); }
.badge.neg { border-color: rgba(255, 115, 118, 0.3); background: var(--neg-bg); }
.badge-icon {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}
.badge.pos .badge-icon { background: var(--pos); color: #0a1a10; }
.badge.neg .badge-icon { background: var(--neg); color: #2a0d0e; }
.badge strong { display: block; margin-bottom: 2px; }
.badge p { margin: 0; color: var(--text-muted); font-size: 0.85rem; }

/* ===== Meta grid + notes ===== */
.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    padding: 20px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 36px;
}
.meta-grid h4 {
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    margin: 0 0 6px;
}
.meta-grid p { margin: 0; font-weight: 500; }

.notes { margin-bottom: 36px; }
.notes h2, .similar h2 {
    font-size: 1.25rem;
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.prose { color: var(--text); }
.prose p { margin: 0 0 1em; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose a { color: var(--accent); }

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #0a1623; }
.btn-primary:hover { background: var(--accent-hover); color: #0a1623; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg-elev-2); }

/* ===== Auth ===== */
.auth-card {
    max-width: 360px;
    margin: 60px auto;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
}
.auth-card h1 { margin: 0 0 20px; font-size: 1.5rem; text-align: center; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; }
.auth-card label span { font-size: 0.85rem; color: var(--text-muted); }
.auth-card input {
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
}
.auth-card input:focus { outline: none; border-color: var(--accent); }
.auth-card button { margin-top: 6px; }

.form-error {
    background: var(--neg-bg);
    border: 1px solid rgba(255, 115, 118, 0.35);
    color: var(--neg);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

/* ===== Admin sub-nav ===== */
.admin-subnav {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    overflow-x: auto;
}
.admin-subnav a {
    color: var(--text-muted);
    padding: 10px 16px;
    border-bottom: 2px solid transparent;
    font-size: 0.95rem;
}
.admin-subnav a:hover { color: var(--text); text-decoration: none; }
.admin-subnav a.active { color: var(--text); border-bottom-color: var(--accent); }
.admin-subnav a.logout { margin-left: auto; color: var(--text-muted); }

/* ===== Admin: dashboard + lists ===== */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}
.stat-num { font-size: 2.5rem; font-weight: 700; margin: 0; line-height: 1; }
.stat-label { color: var(--text-muted); margin: 6px 0 12px; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.05em; }

.admin-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.admin-toolbar h1 { margin: 0; font-size: 1.5rem; }

.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.admin-table th, .admin-table td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table th {
    background: var(--bg-elev-2);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.admin-table .row-thumb {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: contain;
    background: var(--bg-elev-2);
}
.row-thumb-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-muted);
}
.flag-pos { color: var(--pos); text-align: center; }
.flag-neg { color: var(--neg); text-align: center; }
.admin-table .actions { white-space: nowrap; }
.admin-table .actions a, .admin-table .actions form { margin-right: 8px; font-size: 0.9rem; }

.link-button {
    background: none;
    border: none;
    color: var(--neg);
    cursor: pointer;
    padding: 0;
    font: inherit;
    text-decoration: underline;
}
.link-button:hover { color: var(--accent-hover); }

/* ===== Admin: forms ===== */
.form-grid { max-width: 720px; }
.form-grid fieldset {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 20px 20px;
    margin: 0 0 20px;
    background: var(--bg-elev);
}
.form-grid legend {
    padding: 0 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
.form-grid label span { font-size: 0.85rem; color: var(--text-muted); }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label.check {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}
.form-grid label.check span { color: var(--text); font-size: 1rem; }
.form-grid input[type=text],
.form-grid input[type=url],
.form-grid input[type=password],
.form-grid select,
.form-grid textarea {
    padding: 10px 12px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    width: 100%;
}
.form-grid textarea { resize: vertical; min-height: 140px; }
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus { outline: none; border-color: var(--accent); }

.form-actions { display: flex; gap: 10px; }

/* ===== 404 ===== */
.not-found { text-align: center; padding: 80px 0; }
.not-found h1 { font-size: 5rem; margin: 0; color: var(--text-muted); }
.not-found p { color: var(--text-muted); margin: 10px 0 20px; }

/* ===== CMS page ===== */
.cms-page { max-width: 720px; margin: 0 auto; }
.cms-page h1 { font-size: 2rem; margin: 0 0 24px; }

/* ===== Footer ===== */
.site-footer {
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    padding: 40px 0 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.footer-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 32px;
    margin-bottom: 28px;
}
.footer-col h4 {
    color: var(--text);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 12px;
}
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin-bottom: 8px; }
.footer-col p { margin: 0; line-height: 1.6; }
.footer-bottom {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ===== Monaco editor host ===== */
.monaco-wrap {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: #1e1e1e;
}
.monaco-host {
    width: 100%;
    height: 360px;
    min-height: 200px;
}

/* ===== Form hints / counters / SEO ===== */
.hint {
    color: var(--text-muted);
    font-weight: normal;
    font-size: 0.85em;
}
.counter {
    align-self: flex-end;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 4px;
}
.seo-fields .seo-tip {
    background: var(--bg-elev-2);
    border-left: 3px solid var(--accent);
    padding: 10px 14px;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 16px;
}
.seo-fields .seo-tip strong { color: var(--text); }

/* ===== Thumbnail picker ===== */
.thumb-edit {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 18px;
    align-items: start;
}
.thumb-preview {
    width: 120px;
    height: 120px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.thumb-preview img { width: 100%; height: 100%; object-fit: contain; }
.thumb-preview-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 0 8px;
}
.thumb-inputs { min-width: 0; }
.thumb-inputs input[type=file] {
    padding: 6px 0;
    background: transparent;
    border: none;
    color: var(--text);
}

/* ===== Inline-edit cells in admin tables ===== */
.admin-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0 0 14px;
}
.cell-edit {
    cursor: text;
    position: relative;
    transition: background 0.15s;
}
.cell-edit:hover {
    background: var(--bg-elev-2);
}
.cell-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.cell-edit-input {
    width: 100%;
    padding: 4px 6px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--accent);
    border-radius: 4px;
    font: inherit;
    box-sizing: border-box;
}
.cell-check {
    text-align: center;
    transition: background 0.15s;
}
.cell-check input[type=checkbox] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
}
.cell-select select {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 8px;
    font: inherit;
}
.flash-ok { background: rgba(60, 209, 124, 0.18) !important; }
.flash-err { background: rgba(255, 115, 118, 0.18) !important; }

/* ===== /admin/sections layout ===== */
.section-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 20px;
}
.section-col {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
}
.section-col-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.section-col-head h2 {
    margin: 0;
    font-size: 1.05rem;
}
.section-col-count {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.section-col-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
    font-style: italic;
}
.section-row {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.section-row:last-child { border-bottom: none; }
.section-row-main {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}
.section-row-meta { color: var(--text-muted); font-size: 0.8rem; }
.section-row-pick select { width: 100%; }

/* ===== App card external-link badge ===== */
.app-card-wrap {
    position: relative;
}
.app-card-external {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--bg-elev-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    line-height: 1;
    z-index: 2;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.app-card-external:hover {
    background: var(--accent);
    color: #0a1623;
    border-color: var(--accent);
    text-decoration: none;
}

/* ===== Recommendations search dropdown ===== */
#rec-search { /* reuse #search-bar look */
    width: 100%;
    padding: 14px 18px;
    font-size: 1rem;
    background: var(--bg-elev);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    transition: border-color 0.15s;
}
#rec-search:focus { border-color: var(--accent); }

#rec-search-results {
    list-style: none;
    margin: 6px 0 0;
    padding: 6px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    position: absolute;
    left: 0; right: 0;
    max-height: 420px;
    overflow-y: auto;
    z-index: 5;
    text-align: left;
}
.rec-r {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
}
.rec-r:hover { background: var(--bg-elev-2); }
.rec-r-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: baseline;
}
.rec-r-name { font-weight: 500; color: var(--text); }
.rec-r-section {
    color: var(--accent);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.rec-r-apps {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.rec-r-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-elev-2);
    border-radius: 999px;
    padding: 3px 10px 3px 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.rec-r-chip img {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: contain;
}
.rec-r-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
    line-height: 1.4;
}

/* ===== Recommendations page ===== */
.hero-tight { padding: 8px 0 24px; }

.rec-sections {
    display: flex;
    flex-direction: column;
    gap: 40px;
    margin-top: 16px;
}
.rec-section-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.01em;
}
.rec-cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}
.rec-cat-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px 20px;
    color: var(--text);
    transition: border-color 0.15s, transform 0.15s;
    display: block;
}
.rec-cat-card:hover {
    border-color: var(--accent);
    text-decoration: none;
    transform: translateY(-1px);
}
.rec-cat-card h3 {
    margin: 0 0 4px;
    font-size: 1.1rem;
    color: var(--text);
}
.rec-cat-count {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.rec-cat-desc {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.55;
}

/* ===== Mobile ===== */
@media (max-width: 600px) {
    .hero h1 { font-size: 1.75rem; }
    .app-hero { flex-direction: column; gap: 18px; }
    .app-hero-meta h1 { font-size: 1.5rem; }
    .main-nav { gap: 0; }
    .main-nav a { padding: 6px 8px; font-size: 0.85rem; }
}
