/* ==========================================================================
   Franktoberfest — Night Kitchen
   Dark navy surface, warm amber accent, mobile-first with a bottom tab bar.
   Token names from the original inline stylesheet are preserved so any
   leftover inline style="var(--...)" keeps rendering correctly.
   ========================================================================== */

:root {
    /* Original token names, remapped to the dark palette */
    --bg: #0e1424;
    --surface: #1b2748;
    --card: #17203c;
    --accent: #e8a838;
    --accent-2: #4f97d4;
    --text: #eef2fa;
    --text-muted: #7e8eb0;
    --border: #2a3760;
    --input-bg: #1b2748;
    --input-border: #2f3d66;

    /* Additions */
    --bg-elev: #131c33;
    --card-2: #1b2748;
    --border-soft: #263355;
    --text-dim: #c3cee6;
    --accent-strong: #f5c850;
    --accent-ink: #17203a;
    --danger: #e0685a;
    --danger-ink: #2a0f0b;

    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-pill: 999px;

    --tabbar-h: 84px;
    --shadow-1: 0 2px 8px rgba(0, 0, 0, 0.28);
    --shadow-2: 0 10px 34px rgba(0, 0, 0, 0.46);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html { background: var(--bg); }

body {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* transparent so the fixed .app-bg layer behind it is visible;
       html carries the base colour */
    background: transparent;
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    position: relative;
    overflow-x: hidden;
}

/* === Atmosphere: a glass of beer ========================================= */
/* Dark navy above the surface, beer below, foam on the line between.
   Tuned darker than a pint in daylight so the dark UI still reads on top. */

.app-bg {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    background: var(--bg);
    overflow: hidden;
}
/* Light coming through the top of the glass */
.app-bg::before {
    content: "";
    position: absolute;
    top: -240px;
    left: 50%;
    width: 760px;
    height: 560px;
    margin-left: -380px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(232, 168, 56, 0.16) 0%, rgba(232, 168, 56, 0.05) 45%, rgba(232, 168, 56, 0) 70%);
}

.beer-fill {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 58%;
    overflow: hidden;
    background: linear-gradient(to top,
        #96590f 0%,
        #a4651a 26%,
        #ad7020 52%,
        #a06a24 76%,
        #8a5c26 100%);
}
/* Darken the very bottom so the tab bar has something to sit against */
.beer-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(10, 14, 26, 0.55) 0%, rgba(10, 14, 26, 0) 34%);
}

.beer-wave {
    position: absolute;
    left: -10%;
    bottom: 57.4%;
    width: 120%;
    height: 44px;
    overflow: visible;
    z-index: 1;
}
.beer-wave .wave1 { fill: #b0742a; animation: waveRock 7s ease-in-out infinite alternate; }
.beer-wave .wave2 { fill: #9a6320; opacity: 0.7; animation: waveRock2 9s ease-in-out infinite alternate-reverse; }
@keyframes waveRock {
    0%   { transform: translateX(-15px) translateY(-2px); }
    100% { transform: translateX(15px) translateY(2px); }
}
@keyframes waveRock2 {
    0%   { transform: translateX(12px) translateY(1px); }
    100% { transform: translateX(-12px) translateY(-3px); }
}

/* Foam — warm off-white rather than paper white, so it reads at night */
.beer-foam {
    position: absolute;
    left: -12%;
    bottom: 57.4%;
    width: 124%;
    height: 74px;
    overflow: visible;
    z-index: 2;
    animation: foamDrift 7s ease-in-out infinite alternate;
}
.beer-foam path { fill: #e6dcc6; }
.beer-foam2 {
    position: absolute;
    left: -12%;
    bottom: 58.2%;
    width: 124%;
    height: 42px;
    overflow: visible;
    z-index: 3;
    animation: foamDrift2 9s ease-in-out infinite alternate-reverse;
}
.beer-foam2 path { fill: #f3ecdc; opacity: 0.9; }
@keyframes foamDrift {
    0%   { transform: translateX(-6px) translateY(0); }
    100% { transform: translateX(6px) translateY(-3px); }
}
@keyframes foamDrift2 {
    0%   { transform: translateX(5px) translateY(-2px); }
    100% { transform: translateX(-5px) translateY(2px); }
}

/* Bubbles rise through the beer and pop at the foam line */
.bubble {
    position: absolute;
    bottom: -24px;
    border-radius: 50%;
    background: radial-gradient(circle at 32% 28%,
        rgba(255, 250, 232, 0.85) 0%,
        rgba(255, 244, 214, 0.45) 55%,
        rgba(255, 240, 200, 0.12) 100%);
    opacity: 0;
    animation: bubbleRise linear infinite;
    will-change: transform, opacity;
}
@keyframes bubbleRise {
    0%   { transform: translate3d(0, 0, 0) scale(0.55); opacity: 0; }
    12%  { opacity: 0.6; }
    55%  { transform: translate3d(9px, -30vh, 0) scale(1); opacity: 0.5; }
    90%  { opacity: 0.16; }
    100% { transform: translate3d(-7px, -56vh, 0) scale(0.7); opacity: 0; }
}
/* Frozen bubbles and a rocking foam line would just be noise — hold them still */
@media (prefers-reduced-motion: reduce) {
    .bubble { display: none; }
}

/* === Klaus backdrop ====================================================== */
/* Sits above .app-bg (-2) and below page content. The image URL lives only on
   the .klaus-active rules, so the file is not downloaded until the tab is opened. */

.klaus-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.45s ease;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center 16%;
}
.klaus-active .klaus-bg {
    opacity: 1;
    background-image: url("/static/img/klaus.jpg");
}
/* Scrim — keeps the chat readable over a busy photograph */
.klaus-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom,
        rgba(10, 15, 28, 0.78) 0%,
        rgba(10, 15, 28, 0.52) 30%,
        rgba(10, 15, 28, 0.62) 62%,
        rgba(10, 15, 28, 0.88) 100%);
}
/* Let Klaus show through his own card */
.klaus-active #tab-klaus .card {
    background: rgba(23, 32, 60, 0.74);
    border-color: rgba(232, 168, 56, 0.34);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}
/* Muted grey drops to 3.5:1 against the bright part of the photo — lift the
   intro line to --text-dim, which measures 7.3:1 through the same stack */
.klaus-active #tab-klaus .chat-intro {
    color: var(--text-dim);
}
.klaus-active #tab-klaus .chat-msg.bot-msg {
    background: rgba(27, 39, 72, 0.9);
}
.klaus-active #tab-klaus .chat-form input {
    background: rgba(27, 39, 72, 0.9);
}

/* === Layout ============================================================== */

.no-tabbar .container { padding-bottom: 40px; }

.container {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px);
}

/* === Top bar ============================================================= */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 62px;
    padding: 10px 0 4px;
}
.brand {
    font-family: 'UnifrakturMaguntia', serif;
    font-size: 1.65rem;
    line-height: 1.15;
    color: var(--accent);
    letter-spacing: 0.5px;
    text-decoration: none;
}
.brand-sub {
    color: var(--text-muted);
    font-size: 0.86rem;
    margin: -2px 0 14px;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.icon-btn {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    border-radius: var(--r-md);
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    transition: color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.icon-btn svg { width: 21px; height: 21px; }

.notif-badge {
    position: absolute;
    top: 6px;
    right: 5px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: var(--r-pill);
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 0.62rem;
    font-weight: 800;
    line-height: 17px;
    text-align: center;
    border: 2px solid var(--bg);
}

.notif-bell-wrap { position: relative; }

/* User menu */
.usermenu-wrap { position: relative; }
.usermenu {
    display: none;
    position: absolute;
    top: 50px;
    right: 0;
    min-width: 200px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-2);
    padding: 6px;
    z-index: 1200;
}
.usermenu.show { display: block; }
.usermenu-name {
    padding: 8px 12px 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 6px;
}
.usermenu a {
    display: block;
    padding: 11px 12px;
    border-radius: var(--r-sm);
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 600;
}
.usermenu a:hover { background: var(--card-2); color: var(--text); }

/* === Cards =============================================================== */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    margin-bottom: 16px;
}
.card h2 {
    color: var(--text);
    font-size: 1.22rem;
    font-weight: 800;
    letter-spacing: -0.3px;
    margin-bottom: 14px;
}
.card-hint {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 14px;
}

.info-row { margin-bottom: 18px; }
.info-row:last-child { margin-bottom: 0; }
.info-row .label {
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.4px;
}
.info-row .value {
    font-size: 1rem;
    color: var(--text-dim);
    margin-top: 4px;
}
.description { line-height: 1.7; }
.home-content { line-height: 1.75; }
.home-text { font-size: 1rem; color: var(--text-dim); margin-bottom: 18px; }
.home-photos { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 18px; }
.home-photo { max-width: 100%; border-radius: var(--r-md); border: 1px solid var(--border); }

/* === Buttons ============================================================= */

.btn,
.comment-form button[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 11px 20px;
    border-radius: var(--r-md);
    border: none;
    background: var(--accent);
    color: var(--accent-ink);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s, transform 0.06s;
}
.btn:hover,
.comment-form button[type="submit"]:hover { filter: brightness(1.08); }
.btn:active,
.comment-form button[type="submit"]:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
}
.btn-ghost:hover { background: var(--card-2); filter: none; }

.btn-cancel {
    background: transparent !important;
    border: 1px solid var(--border);
    color: var(--text-muted) !important;
    margin-left: 6px;
}

.small-btn {
    min-height: 38px;
    padding: 8px 14px;
    font-size: 0.82rem;
    font-weight: 700;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--card-2);
    color: var(--text-dim);
    cursor: pointer;
    font-family: inherit;
}
.small-btn:hover { border-color: var(--accent); color: var(--text); }
.small-btn.danger { color: var(--danger); border-color: rgba(224, 104, 90, 0.4); }
.small-btn.danger:hover { background: var(--danger); color: var(--danger-ink); border-color: var(--danger); }

.inline-form { display: inline; }

/* === Forms =============================================================== */

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 13px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: #6b7a9c; }
input[type="checkbox"], input[type="number"] { accent-color: var(--accent); }
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232, 168, 56, 0.16);
}
input:disabled { opacity: 0.55; }
textarea { resize: vertical; min-height: 88px; line-height: 1.55; }

.field-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.3px;
    margin-bottom: 6px;
}
.admin-form input,
.admin-form textarea { margin-bottom: 16px; }
.admin-form .btn { margin-top: 2px; }
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    min-height: 44px;
}
.checkbox-row input { width: auto; }

.error {
    background: rgba(224, 104, 90, 0.12);
    border: 1px solid rgba(224, 104, 90, 0.4);
    color: #f0a79b;
    padding: 11px 14px;
    border-radius: var(--r-md);
    margin-bottom: 14px;
    font-size: 0.9rem;
}
.notice {
    background: rgba(79, 151, 212, 0.12);
    border: 1px solid rgba(79, 151, 212, 0.4);
    color: #a9cef0;
    padding: 11px 14px;
    border-radius: var(--r-md);
    margin-bottom: 14px;
    font-size: 0.9rem;
}

/* Inline prompt banner (add your email) */
.banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-md);
    padding: 12px 10px 12px 14px;
    margin-bottom: 14px;
    font-size: 0.88rem;
    color: var(--text-dim);
}
.banner a { color: var(--accent); }
.banner-close {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--r-sm);
}
.banner-close:hover { color: var(--text); background: var(--card-2); }
.banner-close svg { width: 16px; height: 16px; }

/* === Tab navigation ====================================================== */

.tab-content { display: none; }
.tab-content.active { display: block; }

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bg-elev);
    border-top: 1px solid var(--border-soft);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: start;
}
.tab-btn {
    height: var(--tabbar-h);
    padding: 12px 2px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.1px;
    cursor: pointer;
    transition: color 0.15s;
}
.tab-btn svg { width: 22px; height: 22px; }
.tab-btn:hover { color: var(--text-dim); }
.tab-btn.is-active { color: var(--accent); font-weight: 800; }

/* === Discussion feed ===================================================== */

.post-composer { margin-bottom: 16px; }
.composer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 9px 10px 9px 12px;
}
.composer-row textarea {
    flex-grow: 1;
    border: none;
    background: none;
    padding: 6px 0;
    min-height: 40px;
    font-size: 0.95rem;
}
.composer-row textarea:focus { box-shadow: none; }
.composer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
}
.composer-tools { display: flex; gap: 2px; }
.composer-image-btn,
.composer-poll-btn {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-md);
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}
.composer-image-btn:hover,
.composer-poll-btn:hover { color: var(--accent); background: rgba(232, 168, 56, 0.1); }
.composer-image-btn svg,
.composer-poll-btn svg { width: 21px; height: 21px; }
.composer-image-btn input[type="file"] { display: none; }

.image-preview { position: relative; margin-top: 12px; max-width: 320px; }
.image-preview img { width: 100%; border-radius: var(--r-md); border: 1px solid var(--border); display: block; }
.preview-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(6, 10, 20, 0.78);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.preview-remove:hover { background: rgba(6, 10, 20, 0.95); }
.preview-remove svg { width: 15px; height: 15px; }

.posts-feed { margin-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 32px 16px;
    font-size: 0.94rem;
}

.post-card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 11px;
}
.post-card.pinned { border-left: 3px solid var(--accent); }
.pin-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.9px;
    text-transform: uppercase;
}
.pin-badge svg { width: 13px; height: 13px; }

.post-header { display: flex; align-items: center; gap: 11px; }
.post-avatar, .reply-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 800;
    font-size: 1rem;
    flex-shrink: 0;
}
.reply-avatar { width: 30px; height: 30px; font-size: 0.8rem; background: var(--accent-2); color: var(--bg); }
.post-meta { display: flex; flex-direction: column; min-width: 0; }
.post-author { font-weight: 700; color: var(--text); font-size: 0.95rem; }
.post-time { color: var(--text-muted); font-size: 0.76rem; }
.post-body {
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 0.98rem;
    color: var(--text-dim);
    overflow-wrap: anywhere;
}

.post-image-wrap, .reply-image-wrap { margin-top: 2px; }
.post-image {
    max-width: 100%;
    max-height: 460px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    cursor: zoom-in;
    display: block;
}
.reply-image {
    max-width: 100%;
    max-height: 280px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    cursor: zoom-in;
    display: block;
    margin-top: 6px;
}

/* Reactions */
.reaction-display { display: flex; gap: 6px; flex-wrap: wrap; }
.reaction-display:empty { display: none; }
.reaction-bubble {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 30px;
    padding: 0 11px;
    border-radius: var(--r-pill);
    background: var(--card-2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s;
}
.reaction-bubble:hover { border-color: var(--accent); }
.reaction-bubble.mine {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: var(--accent);
    font-weight: 700;
}
.reaction-bubble.small { min-height: 26px; padding: 0 9px; font-size: 0.76rem; }

.reaction-detail { display: none; }
.reaction-detail.show { display: block; }
.reaction-detail-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 11px;
    background: var(--card-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-sm);
    margin-bottom: 4px;
    font-size: 0.84rem;
    color: var(--text-dim);
}
.reaction-detail-emoji { font-size: 1.1em; flex-shrink: 0; }
.reaction-detail-names { color: var(--text-muted); }

/* Action row */
.post-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid var(--border-soft);
}
.post-action-btn {
    flex-grow: 1;
    min-height: 44px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: var(--r-md);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    transition: color 0.15s, background 0.15s;
}
.post-action-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.post-action-btn:hover { background: var(--card-2); color: var(--text); }
.post-action-btn.danger { color: var(--danger); }
.post-action-btn.danger:hover { background: rgba(224, 104, 90, 0.14); color: var(--danger); }
/* flex-shrink:0 — without it the row overflows and squeezes these below 44px */
.post-action-btn.icon-only { flex-grow: 0; flex-shrink: 0; width: 44px; padding: 0; }
.post-action-btn.small {
    flex-grow: 0;
    flex-shrink: 0;
    min-height: 44px;
    width: 44px;
    padding: 0;
    font-size: 0.78rem;
}
.post-action-btn.small svg { width: 17px; height: 17px; }
.post-actions .inline-form { display: contents; }

/* Emoji picker — inline row, not a popover */
.reaction-picker {
    display: none;
    gap: 2px;
    flex-wrap: wrap;
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 5px;
}
.reaction-picker.show { display: flex; }
.picker-emoji {
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    border-radius: var(--r-sm);
    transition: background 0.12s, transform 0.1s;
}
.picker-emoji:hover { background: rgba(255, 255, 255, 0.07); transform: scale(1.12); }

/* Replies */
.reply-form { margin-top: 2px; }
.reply-form textarea { min-height: 64px; }
.reply-form .btn { margin-top: 10px; }
.inline-edit { margin-top: 8px; }
.comment-form textarea { margin-bottom: 0; }

.replies-section { margin-top: 2px; }
.replies-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 10px 0 0;
    background: none;
    border: none;
    color: var(--accent);
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
}
.replies-toggle svg { width: 14px; height: 14px; transition: transform 0.18s; }
.replies-toggle.open svg { transform: rotate(180deg); }
.replies-collapsed {
    margin-top: 8px;
    padding-left: 12px;
    border-left: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.reply-item { display: flex; gap: 9px; }
.reply-content { flex: 1; min-width: 0; }
.reply-bubble {
    background: var(--card-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 9px 12px;
}
.reply-author { font-weight: 700; font-size: 0.86rem; color: var(--text); }
.reply-time { color: var(--text-muted); font-size: 0.72rem; margin-left: 7px; }
.reply-body {
    margin-top: 3px;
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-dim);
    overflow-wrap: anywhere;
}
.reply-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-top: 4px;
    flex-wrap: wrap;
}
.reply-actions .inline-form { display: contents; }

/* === Polls =============================================================== */

.poll-composer {
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px;
    margin-bottom: 16px;
}
.poll-composer h3 { font-size: 1rem; font-weight: 800; margin-bottom: 12px; color: var(--text); }
.poll-form input[type="text"] { margin-bottom: 9px; }
.poll-add-option {
    width: 100%;
    min-height: 44px;
    background: none;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    border-radius: var(--r-md);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    margin-bottom: 12px;
}
.poll-add-option:hover { border-color: var(--accent); color: var(--accent); }
.poll-composer-actions { display: flex; gap: 8px; justify-content: flex-end; }

.poll-question { font-weight: 800; font-size: 1.02rem; color: var(--text); }
.poll-options { display: flex; flex-direction: column; gap: 8px; }
.poll-option {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--card-2);
    color: var(--text-dim);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.94rem;
    text-align: left;
    overflow: hidden;
    transition: border-color 0.15s;
}
.poll-option:hover { border-color: var(--accent); }
.poll-option.selected { border-color: var(--accent); border-width: 1.5px; color: var(--text); font-weight: 700; }
.poll-option-text { position: relative; z-index: 2; }
.poll-option-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(232, 168, 56, 0.16);
    transition: width 0.35s ease-out;
}
.poll-option.selected .poll-option-bar { background: rgba(232, 168, 56, 0.26); }
.poll-option-count {
    position: relative;
    z-index: 2;
    margin-left: auto;
    font-weight: 800;
    color: var(--accent);
    min-width: 28px;
    text-align: right;
}
.poll-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border-soft);
}
.poll-total { color: var(--text-muted); font-size: 0.78rem; }

/* === RSVP ================================================================ */

.rsvp-section { display: flex; flex-direction: column; gap: 10px; }
.rsvp-group {
    display: flex;
    gap: 5px;
    padding: 5px;
    border-radius: var(--r-md);
    background: var(--card-2);
}
.rsvp-btn {
    flex: 1 1 0;
    min-height: 46px;
    padding: 12px 4px;
    border-radius: var(--r-sm);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    transition: background 0.15s, color 0.15s;
}
.rsvp-btn:hover { background: var(--surface); color: var(--text); }
.rsvp-btn.going.active { background: var(--accent-2); border-color: var(--accent-2); color: #08111f; }
.rsvp-btn.maybe.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.rsvp-btn.not_going.active { background: #55637f; border-color: #55637f; color: #f2f5fb; }

.rsvp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.rsvp-head h2 { margin-bottom: 0; }
.rsvp-tally { color: var(--text-muted); font-size: 0.84rem; white-space: nowrap; }

.rsvp-stack {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    margin-top: 12px;
    margin-left: -8px;
    padding: 4px 8px;
    background: none;
    border: none;
    border-radius: var(--r-sm);
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}
.rsvp-stack:hover { background: var(--surface); }
.rsvp-stack .chevron { margin-left: auto; color: var(--text-dim); transition: transform 0.2s; width: 16px; height: 16px; }
.rsvp-stack.open .chevron { transform: rotate(180deg); }

.invited-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-soft);
}
.invited-list[hidden] { display: none; }
.invited-chip {
    padding: 5px 11px;
    border-radius: var(--r-pill);
    background: var(--surface);
    border: 1px solid var(--border-soft);
    color: var(--text);
    font-size: 0.82rem;
}
.avatar-stack { display: flex; }
.stack-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}
.stack-avatar + .stack-avatar { margin-left: -8px; }
.stack-avatar.s1 { background: var(--accent); color: var(--accent-ink); }
.stack-avatar.s2 { background: var(--accent-2); color: #08111f; }
.stack-avatar.s3 { background: #4e6b58; color: #eef4ea; }
.stack-avatar.s4 { background: #8b5e3c; color: #f5e6d3; }
.stack-avatar.s5 { background: #55637f; color: #f2f5fb; }
.rsvp-stack-text { color: var(--text-dim); font-size: 0.84rem; }

.rsvp-roster {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border-soft);
}

.plus-ones {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
    padding-top: 14px;
    border-top: 1px solid var(--border-soft);
}
.plus-ones label { color: var(--text-muted); font-size: 0.88rem; }
.plus-ones input { width: 86px; flex-shrink: 0; text-align: center; }

.rsvp-list { display: flex; flex-direction: column; }
.rsvp-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-dim);
}
.rsvp-item:last-child { border-bottom: none; }
.rsvp-badge {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.4px;
    padding: 5px 11px;
    border-radius: var(--r-pill);
    white-space: nowrap;
    flex-shrink: 0;
}
/* Explicit foreground colors — the original left these inheriting dark text */
.rsvp-badge.going { background: var(--accent-2); color: #08111f; }
.rsvp-badge.maybe { background: var(--accent); color: var(--accent-ink); }
.rsvp-badge.not_going { background: #55637f; color: #f2f5fb; }

/* === Notifications ======================================================= */

.notif-panel {
    display: none;
    position: fixed;
    z-index: 1100;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-2);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.notif-panel.show { display: block; }
.notif-panel-header {
    position: sticky;
    top: 0;
    background: var(--card);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text);
    font-weight: 800;
}
.notif-mark-read {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--accent);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 8px;
    border-radius: var(--r-sm);
}
.notif-mark-read:hover { background: var(--card-2); }
.notif-item {
    display: flex;
    gap: 11px;
    align-items: flex-start;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 0.88rem;
    color: var(--text-dim);
    cursor: pointer;
}
.notif-item:hover { background: var(--card-2); }
.notif-item.unread { background: rgba(232, 168, 56, 0.08); }
.notif-icon { font-size: 1.05em; flex-shrink: 0; }
.notif-content { flex: 1; min-width: 0; }
.notif-msg { color: var(--text-dim); }
.notif-time { color: var(--text-muted); font-size: 0.78rem; margin-top: 3px; }
.notif-empty { padding: 28px 16px; text-align: center; color: var(--text-muted); font-size: 0.88rem; }
.notif-footer { padding: 12px 16px; border-top: 1px solid var(--border-soft); }
.notif-footer .btn-ghost { width: 100%; }

.notif-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 16, 0.6);
    z-index: 1050;
}
.notif-backdrop.show { display: block; }

.flash-highlight { animation: flashHl 2s ease-out; }
@keyframes flashHl {
    0% { background: rgba(232, 168, 56, 0.3); }
    100% { background: transparent; }
}

/* === Klaus chat ========================================================== */

.chat-intro { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 16px; }
/* Once the conversation starts the intro has done its job — reclaim the space
   for the chat, and keep more of Klaus visible behind the card. Browsers
   without :has() simply keep showing it. */
.card:has(#chat-messages:not(:empty)) .chat-intro { display: none; }
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 46vh;
    overflow-y: auto;
    margin-bottom: 16px;
}
.chat-msg {
    padding: 11px 15px;
    border-radius: var(--r-md);
    max-width: 86%;
    word-wrap: break-word;
    font-size: 0.95rem;
    line-height: 1.55;
}
.chat-msg.user-msg {
    background: var(--accent);
    color: var(--accent-ink);
    margin-left: auto;
    border-bottom-right-radius: 4px;
    font-weight: 600;
}
.chat-msg.bot-msg {
    background: var(--card-2);
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.chat-msg.bot-msg.loading { color: var(--text-muted); font-style: italic; }
.chat-form { display: flex; gap: 10px; }
.chat-form input { flex: 1; }
.chat-form button { flex-shrink: 0; }

/* === Lightbox ============================================================ */

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 7, 14, 0.92);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
}
.lightbox.show { display: flex; }
.lightbox img {
    max-width: 92vw;
    max-height: 92vh;
    border-radius: var(--r-sm);
    object-fit: contain;
    transform-origin: center center;
    transition: transform 0.05s ease-out;
    -webkit-user-drag: none;
    user-select: none;
}

/* === Admin =============================================================== */

.admin-table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.admin-table th, .admin-table td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-dim);
    font-size: 0.9rem;
}
.admin-table th {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}
.admin-table td:last-child { white-space: nowrap; }

/* === Auth pages ========================================================== */

.auth-wrap { padding-top: 8vh; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .brand { font-size: 2.6rem; display: inline-block; }
.auth-brand p { color: var(--text-muted); font-size: 0.95rem; margin-top: 2px; }
.login-box { max-width: 420px; margin: 0 auto; }
.login-box input { margin-bottom: 12px; }
.login-box .btn { width: 100%; }
.auth-foot { margin-top: 16px; color: var(--text-muted); font-size: 0.86rem; text-align: center; }
.auth-foot a { color: var(--accent); }
a { color: var(--accent); }

/* === PWA prompt ========================================================== */

.pwa-prompt {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: rgba(5, 8, 16, 0.72);
    padding: 16px;
    padding-bottom: calc(16px + var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
    justify-content: center;
}
.pwa-prompt-card {
    max-width: 520px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-2);
}
.pwa-prompt-icon { color: var(--accent); flex-shrink: 0; display: flex; }
.pwa-prompt-icon svg { width: 30px; height: 30px; }
.pwa-prompt-text { flex: 1; }
.pwa-prompt-text strong { color: var(--text); font-size: 0.94rem; display: block; margin-bottom: 3px; }
.pwa-prompt-text p { color: var(--text-muted); font-size: 0.84rem; }
.pwa-prompt-actions { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.pwa-prompt-btn {
    min-height: 40px;
    padding: 9px 16px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    white-space: nowrap;
}
.pwa-prompt-btn.primary {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: var(--accent);
    font-weight: 700;
}

/* === Accessibility ======================================================= */

:focus-visible {
    outline: 2px solid var(--accent-strong);
    outline-offset: 2px;
    border-radius: 4px;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* === Mobile ============================================================== */

@media (max-width: 767px) {
    /* Klaus tab: push the chat card to the bottom of the viewport so the
       portrait above it is never covered. .container starts at the top of the
       page, so 100svh here is exact no matter what sits above the panel
       (subtitle, email banner) — no JS measuring, and the card stays in normal
       flow so the on-screen keyboard still behaves. */
    .klaus-active .container {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
        min-height: 100svh;
    }
    .klaus-active #tab-klaus {
        display: flex;
        flex-direction: column;
        flex-grow: 1;
    }
    .klaus-active #tab-klaus .card {
        margin-top: auto;
        margin-bottom: 0;
    }
    /* Keep the card from growing tall enough to reach his face again */
    .klaus-active .chat-messages { max-height: 30svh; }

    .notif-panel {
        left: 8px;
        right: 8px;
        bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 8px);
        border-radius: var(--r-lg);
        max-height: 62vh;
    }
}

@media (max-width: 380px) {
    .brand { font-size: 1.4rem; }
    .tab-btn { font-size: 0.6rem; }
    .tab-btn svg { width: 21px; height: 21px; }
    .card { padding: 16px; }
    .post-action-btn { font-size: 0.76rem; gap: 5px; }
}

/* === Desktop ============================================================= */

@media (min-width: 768px) {
    .container { padding-bottom: 40px; }

    .tabbar {
        position: static;
        height: auto;
        padding-bottom: 0;
        margin-bottom: 20px;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: var(--r-lg);
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 4px;
        padding: 5px;
    }
    .tab-btn {
        height: auto;
        flex-direction: row;
        justify-content: center;
        gap: 8px;
        padding: 11px 8px;
        border-radius: var(--r-md);
        font-size: 0.86rem;
    }
    .tab-btn svg { width: 18px; height: 18px; }
    .tab-btn:hover { background: var(--card-2); }
    .tab-btn.is-active { background: var(--accent); color: var(--accent-ink); }

    .rsvp-section { flex-direction: column; }
    .rsvp-btn { width: auto; }
    .plus-ones { width: 100%; justify-content: flex-start; }

    .notif-panel {
        position: absolute;
        top: 50px;
        right: 0;
        width: 380px;
        max-height: 60vh;
        border-radius: var(--r-md);
    }

    /* Natural-width actions — full-width buttons are a phone affordance */
    .post-actions { gap: 6px; }
    .post-action-btn { flex-grow: 0; padding: 0 16px; }
    .notif-backdrop { display: none !important; }

    .pwa-prompt { padding-bottom: 16px; }

    /* Landscape crop when available; portrait is the fallback layer beneath */
    .klaus-active .klaus-bg {
        background-image: url("/static/img/klaus-wide.jpg"), url("/static/img/klaus.jpg");
        background-position: center 22%, center 16%;
    }
}
