:root {
    --navy: #1f3a60;
    --navy-dark: #15273f;
    --blue: #2b6cb0;
    --blue-dark: #234e86;
    --ink: #20303f;
    --muted: #64748b;
    --line: #e3e8ee;
    --bg: #f4f6f9;
    --card: #ffffff;
    --ok: #15803d;
    --warn: #b45309;
    --danger: #b91c1c;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.55;
    overflow-x: hidden;          /* never let the page scroll sideways on mobile */
}
img, iframe, video { max-width: 100%; height: auto; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.container-narrow { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* ---- Top bar (thin, dark) ---- */
.topbar { background: var(--navy-dark); color: #cdd6e2; font-size: 13px; }
.topbar .container { display: flex; align-items: center; justify-content: flex-end; height: 34px; }
.topbar a { color: #e8edf3; }
.topbar .lang { color: #aebacb; }
.topbar nav { display: flex; align-items: center; gap: 16px; }
.topbar form { display: inline; }
.topbar .linkbtn { background: none; border: 0; color: #e8edf3; cursor: pointer; font-size: 13px; padding: 0; }
.topbar .linkbtn:hover { text-decoration: underline; }

/* ---- Masthead (white, logo + wordmark) ---- */
.masthead { background: #fff; border-bottom: 1px solid var(--line); }
.masthead .container { display: flex; align-items: center; gap: 16px; min-height: 88px; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 14px; color: var(--navy); }
.brand:hover { text-decoration: none; }
.logo-icon { width: 52px; height: 52px; color: var(--navy); flex: 0 0 auto; }
.brand .wordmark { font-size: 26px; font-weight: 700; letter-spacing: .3px; line-height: 1.1; }
.brand .tagline { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); letter-spacing: .2px; }

/* ---- Main nav (light gray bar, uppercase) ---- */
.mainnav { background: #eef1f5; border-bottom: 3px solid var(--navy); }
.mainnav .container { display: flex; flex-wrap: wrap; gap: 4px; }
.mainnav a {
    color: #34465a; font-size: 13.5px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .4px; padding: 13px 16px; border-bottom: 3px solid transparent; margin-bottom: -3px;
}
.mainnav a:hover { color: var(--blue); text-decoration: none; }
.mainnav a.active { color: var(--blue); border-bottom-color: var(--blue); }

/* Line icons (inline SVG, monochrome via currentColor) */
.icon { flex: 0 0 auto; vertical-align: -0.15em; }
.mainnav a { display: inline-flex; align-items: center; gap: 7px; }
.btn { gap: 7px; }
.badge { gap: 4px; }
.badge .icon { width: 13px; height: 13px; }
.meta .icon { vertical-align: -0.12em; }
.icon-list { list-style: none; padding-left: 0; margin: 0; }
.icon-list li { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 7px; }
.icon-list li .icon { margin-top: 2px; }

/* Cookie consent bar */
.cookie-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; background: var(--navy); color: #eef2f7; box-shadow: 0 -2px 12px rgba(0,0,0,.18); }
.cookie-bar-inner { max-width: 1100px; margin: 0 auto; padding: 12px 16px; display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.cookie-bar-text { margin: 0; font-size: 13.5px; line-height: 1.5; flex: 1; min-width: 240px; }
.cookie-bar-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.cookie-bar .btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.55); }
@media (max-width: 760px) { .cookie-bar { bottom: 64px; } }

/* ---- Layout ---- */
main { padding: 28px 0 56px; }
.page-title { font-size: 26px; margin: 0 0 4px; color: var(--navy); }
.page-sub { color: var(--muted); margin: 0 0 22px; }

/* ---- Cards ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; margin-bottom: 16px; overflow-wrap: break-word; }
.card h3 { margin: 0 0 8px; color: var(--navy); }

/* ---- Question list cards (stacked: title → preview → vote+meta) ---- */
.qcard-title { margin: 0 0 6px; font-size: 18px; line-height: 1.3; }
.qcard-title a { color: var(--navy); }
.qcard-preview {
    margin: 0 0 12px; color: var(--ink);
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.qcard-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.qcard-foot .meta { margin: 0; }

/* ---- Bottom tab bar (mobile only; shown via media query) ---- */
.tabbar { display: none; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---- Stat tiles ---- */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; border-top: 3px solid var(--blue); }
.stat .num { font-size: 30px; font-weight: 700; color: var(--navy); }
.stat .lbl { color: var(--muted); font-size: 13px; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; background: var(--blue); color: #fff; padding: 9px 16px; border-radius: 6px; border: 0; cursor: pointer; font-size: 15px; }
.btn:hover { background: var(--blue-dark); text-decoration: none; }
.btn-ghost { background: #fff; color: var(--blue); border: 1px solid var(--blue); }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* ---- Forms ---- */
label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], textarea, select {
    width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; font-size: 15px; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(43,108,176,.25); border-color: var(--blue); }
textarea { min-height: 160px; resize: vertical; }
.help { color: var(--muted); font-size: 13px; margin-top: 4px; }
.checklist { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }
.checklist label { font-weight: 400; margin: 4px 0; display: flex; gap: 8px; align-items: center; }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 600; }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-gray { background: #eef1f5; color: #475569; }
.badge-ok { background: #dcfce7; color: var(--ok); }
.badge-warn { background: #fef3c7; color: var(--warn); }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-primary { background: #e1ecf8; color: var(--blue-dark); }

/* ---- Alerts ---- */
.alert { padding: 11px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-ok { background: #dcfce7; color: var(--ok); }
.alert-err { background: #fee2e2; color: var(--danger); }

/* ---- Misc ---- */
.meta { color: var(--muted); font-size: 13px; }
.reply { border-left: 3px solid var(--blue); padding: 4px 0 4px 14px; margin: 12px 0; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.pill { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px; color: var(--ink); }
.pill:hover { text-decoration: none; border-color: var(--blue); color: var(--blue); }
.pill.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.pagination { margin-top: 18px; display: flex; gap: 6px; flex-wrap: wrap; list-style: none; padding: 0; }
.pagination a, .pagination span { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 13px; }
footer.site { border-top: 3px solid var(--navy); background: #fff; padding: 22px 0; color: var(--muted); font-size: 13px; }

/* ---- Admin top ---- */
.admin-bar { background: var(--navy); color: #fff; }
.admin-bar .container { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.admin-bar .brand { color: #fff; gap: 10px; }
.admin-bar .brand .wordmark { font-size: 18px; }
.admin-bar .logo-icon { width: 30px; height: 30px; color: #fff; }
.admin-bar nav { display: flex; align-items: center; gap: 16px; }
.admin-bar nav a { color: #dbe4f0; font-size: 14px; }
.admin-bar .linkbtn { background: none; border: 0; color: #dbe4f0; cursor: pointer; font-size: 14px; }
.admin-nav { background: #fff; border-bottom: 1px solid var(--line); }
.admin-nav .container { display: flex; flex-wrap: wrap; gap: 4px; }
.admin-nav a { color: #34465a; font-size: 14px; padding: 12px 14px; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.admin-nav a:hover { color: var(--blue); text-decoration: none; }
.admin-nav a.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* ---- MP photos ---- */
.mp-photo { width: 96px; height: 96px; border-radius: 8px; object-fit: cover; background: #e3e8ee; border: 1px solid var(--line); }
.mp-photo-sm { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: #e3e8ee; border: 1px solid var(--line); flex: 0 0 auto; }
.mp-header { display: flex; gap: 18px; align-items: center; margin-bottom: 18px; }
.mp-card-row { display: flex; gap: 12px; align-items: center; }

/* ---- Honeypot ---- */
.hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

/* ---- Attachments ---- */
.attach-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.attach-img { width: 150px; height: 105px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.attach-video { width: 100%; max-width: 520px; aspect-ratio: 16 / 9; margin: 8px 0; }
.attach-video iframe { width: 100%; height: 100%; border: 0; border-radius: 8px; }
.attach-link { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; margin: 4px 6px 4px 0; font-size: 14px; }
.attach-item { position: relative; }
.attach-del { position: absolute; top: 4px; right: 4px; background: rgba(185,28,28,.9); color: #fff; border: 0; border-radius: 4px; cursor: pointer; font-size: 12px; padding: 1px 6px; }

/* ---- Masthead action buttons (propose + donate) ---- */
.masthead-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; flex: 0 0 auto; }
.support-btn { background: var(--danger); }
.support-btn:hover { background: #991b1b; }
@media (max-width: 600px) {
    .masthead .container { flex-wrap: wrap; row-gap: 8px; }
    .support-btn, .propose-btn { padding: 7px 11px; font-size: 13px; }
    .propose-btn { display: none; } /* logged-in users propose via the home CTA / profile on mobile */
}

/* ---- User menu dropdown (top bar, desktop) ---- */
.user-menu { position: relative; }
.user-trigger { background: none; border: 0; color: #e8edf3; cursor: pointer; font-size: 13px; padding: 0; font-family: inherit; }
.user-dropdown {
    display: none; position: absolute; right: 0; top: 100%; margin-top: 2px; min-width: 190px; z-index: 60;
    background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.14); padding: 6px 0;
}
/* invisible bridge so moving from the name into the menu doesn't cross a dead gap */
.user-menu::after { content: ''; position: absolute; right: 0; top: 100%; height: 8px; width: 190px; }
.user-menu:hover .user-dropdown, .user-menu:focus-within .user-dropdown, .user-menu.open .user-dropdown { display: block; }
.user-dropdown a, .user-dropdown .linkbtn {
    display: block; width: 100%; text-align: left; padding: 9px 16px; color: var(--ink); font-size: 14px;
    background: none; border: 0; cursor: pointer; font-family: inherit;
}
.user-dropdown a:hover, .user-dropdown .linkbtn:hover { background: #f1f4f8; text-decoration: none; color: var(--blue); }

/* ---- Charts (dependency-free CSS bars) ---- */
.chart { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 4px; }
.chart-row { display: grid; grid-template-columns: 116px 1fr 78px; align-items: center; gap: 10px; }
.chart-label { font-size: 13px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-track { background: #eef1f5; border-radius: 999px; height: 14px; overflow: hidden; }
.chart-bar { display: block; height: 100%; background: var(--blue); border-radius: 999px; min-width: 2px; }
.chart-val { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
@media (max-width: 600px) {
    .chart-row { grid-template-columns: 84px 1fr 64px; gap: 8px; }
    .chart-label { font-size: 12px; }
}

/* ---- Original email reveal ---- */
.orig-email > summary { cursor: pointer; color: var(--blue); font-size: 14px; list-style: none; }
.orig-email > summary::-webkit-details-marker { display: none; }
.orig-email > summary:hover { text-decoration: underline; }

/* ---- Reactions (👍/👎) ---- */
.reactions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.reactions form { margin: 0; }
.react-btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--line);
    border-radius: 999px; background: #fff; font-size: 14px; cursor: pointer; color: var(--ink);
}
.react-btn:hover { border-color: var(--blue); }
.react-btn.on-up { background: #dcfce7; border-color: var(--ok); color: var(--ok); font-weight: 600; }
.react-btn.on-down { background: #fee2e2; border-color: var(--danger); color: var(--danger); font-weight: 600; }
.react-static { font-size: 14px; color: var(--muted); }

/* ---- Share icons ---- */
.share-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.share-ico {
    display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px;
    border-radius: 50%; color: #fff; flex: 0 0 auto; transition: opacity .15s, transform .1s;
}
.share-ico:hover { text-decoration: none; opacity: .9; transform: translateY(-1px); }
.share-fb { background: #1877f2; }
.share-x  { background: #000; }
.share-tg { background: #29a9eb; }
.share-cp { background: #7360f2; }

/* ---- AI reply analysis panel ---- */
.ai-analysis { margin-top: 12px; padding: 12px 14px; background: #f6f8fc; border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: 0 8px 8px 0; }
.ai-analysis-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.ai-tag { font-size: 12px; font-weight: 700; color: var(--blue-dark); letter-spacing: .2px; }
.ai-summary { margin: 4px 0 8px; }
.ai-plain summary { cursor: pointer; font-weight: 600; color: var(--blue); font-size: 14px; }
.ai-plain p { margin: 6px 0 0; }
.ai-note { margin: 8px 0 0; color: #9ca3af; font-size: 11.5px; }

/* ---- Vote button ---- */
.vote { display: inline-flex; align-items: center; gap: 6px; }
.vote .count { font-weight: 700; }
.voted { background: var(--ok) !important; }

/* ---- Mobile / responsive ---- */
@media (max-width: 760px) {
    .container, .container-narrow { padding: 0 12px; }

    /* Replace the desktop top/main nav with a bottom tab bar */
    .topbar, .mainnav { display: none; }
    main { padding-bottom: 78px; }   /* room for the fixed tab bar */
    .tabbar {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
        background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(0,0,0,.06);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .tabbar a {
        flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 2px; padding: 8px 4px; font-size: 11px; color: var(--muted);
    }
    .tabbar a:hover { text-decoration: none; }
    .tabbar a .ico { font-size: 21px; line-height: 1; }
    .tabbar a.active { color: var(--blue); }

    /* Nav bars become a single horizontally-scrollable row instead of wrapping */
    .mainnav .container, .admin-nav .container {
        flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
    }
    .mainnav .container::-webkit-scrollbar, .admin-nav .container::-webkit-scrollbar { display: none; }
    .mainnav a, .admin-nav a { white-space: nowrap; padding-left: 12px; padding-right: 12px; }

    /* Wide tables scroll inside their card instead of blowing out the page */
    table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    th, td { white-space: nowrap; }

    main { padding: 18px 0 40px; }
    .page-title { font-size: 22px; }
    .card { padding: 14px; }

    /* Admin top bar wraps gracefully on small screens */
    .admin-bar .container { height: auto; min-height: 52px; flex-wrap: wrap; gap: 8px; padding-top: 8px; padding-bottom: 8px; }
    .admin-bar .brand .wordmark { font-size: 16px; }

    .mp-header { flex-wrap: wrap; gap: 12px; }
}

@media (max-width: 600px) {
    .masthead .container { min-height: 70px; }
    .brand .wordmark { font-size: 20px; }
    .brand .tagline { font-size: 11.5px; }
    .logo-icon { width: 40px; height: 40px; }
    .page-title { font-size: 20px; }
    .btn { padding: 10px 16px; }          /* comfortable tap target */
    .topbar nav { gap: 12px; }

    /* Compact vote button so question titles get the full width */
    .vote { flex-direction: column; gap: 0; padding: 8px 10px; line-height: 1.1; }
    .vote .vote-label { display: none; }
    .vote .count { font-size: 16px; }
}
