:root {
    /* === Colors (narrovel.com palette) === */
    --bg: #060509;
    --bg-2: #0c0a14;
    --bg-3: #11091e;
    --text: #f4f2fa;
    --text-2: #bcb8d0;
    --text-3: #8884a0;

    /* Sky-blue accents */
    --p1: #38bdf8;
    --p2: #0ea5e9;
    --p3: #7dd3fc;
    --p-soft: rgba(56, 189, 248, 0.18);
    --grad: linear-gradient(135deg, #0ea5e9, #38bdf8, #7dd3fc);
    --grad-w: linear-gradient(135deg, #0284c7, #0ea5e9, #38bdf8, #7dd3fc, #bae6fd);

    /* Glass / depth */
    --lg-bg: rgba(15, 25, 40, 0.65);
    --lg-bg-2: rgba(15, 25, 40, 0.85);
    --lg-b: rgba(255, 255, 255, 0.06);
    --lg-bh: rgba(125, 211, 252, 0.22);
    --lg-hi: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    --lg-sh: 0 8px 40px rgba(0, 0, 0, 0.3);
    --lg-shh: 0 20px 60px rgba(14, 165, 233, 0.18);

    /* Status colors */
    --green: #34d399;
    --red: #fb7185;
    --yellow: #fbbf24;

    /* Geometry */
    --r: 20px;
    --r-sm: 14px;
    --r-pill: 100px;
    --pad: clamp(1rem, 4vw, 1.5rem);
    --tabbar-h: 64px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --ease: cubic-bezier(.19, 1, .22, 1);

    /* Typography */
    --font: 'Manrope', system-ui, -apple-system, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    font-size: 1rem;
    min-height: 100dvh;
    overflow-x: hidden;
    position: relative;
    padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px);
}
::selection { background: var(--p2); color: #fff; }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4 { font-weight: 700; line-height: 1.15; letter-spacing: -.025em; }
.grad, em {
    font-style: normal;
    background: var(--grad-w);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: var(--p1);
}
@supports not (background-clip: text) {
    .grad, em { background: none; -webkit-text-fill-color: currentColor; color: var(--p3); }
}

a { color: inherit; text-decoration: none; }
button { font: inherit; border: none; background: none; color: inherit; }
@media (hover: hover) { button { cursor: pointer; } }

a:focus-visible, button:focus-visible, .btn:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--p1);
    outline-offset: 2px;
    border-radius: 6px;
}

button, .btn, a, .tab { -webkit-tap-highlight-color: transparent; }

/* === Mesh background === */
.bg-mesh {
    position: fixed; inset: 0; z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 70% 55% at 10% 0%, rgba(14, 165, 233, 0.14), transparent 55%),
        radial-gradient(ellipse 55% 45% at 95% 100%, rgba(56, 189, 248, 0.10), transparent 55%),
        radial-gradient(ellipse 60% 40% at 50% 50%, rgba(125, 211, 252, 0.05), transparent 60%);
}
.bg-mesh::after {
    content: '';
    position: absolute; inset: 0;
    background-image: radial-gradient(circle at 50% 50%, rgba(125, 211, 252, 0.035) 0, transparent .6px);
    background-size: 4px 4px;
    opacity: .4;
}
.page, main, .container, .page-header, .profile-head, .chat-header, .chat-container, .chat-compose, .tabbar, .sticky-actions, .toast { position: relative; z-index: 1; }
.bg-mesh { z-index: 0; }

.container {
    max-width: 720px;
    margin: 0 auto;
    padding-left: var(--pad);
    padding-right: var(--pad);
    padding-top: var(--pad);
    padding-bottom: var(--pad);
}

/* === Footer / studio badge === */
.app-footer {
    position: relative; z-index: 1;
    text-align: center;
    padding: 20px var(--pad) calc(var(--tabbar-h) + var(--safe-b) + 24px);
}
.studio-badge {
    display: inline-flex; gap: 6px; align-items: center;
    font-size: 0.78rem; font-family: var(--mono);
    padding: 6px 14px;
    border-radius: var(--r-pill);
    background: var(--lg-bg);
    border: 1px solid var(--lg-b);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    transition: border-color 0.2s var(--ease), transform 0.15s var(--ease);
}
.studio-badge:active { transform: scale(0.97); }
.studio-badge .muted { color: var(--text-3); }
.studio-badge .grad { font-weight: 700; }

/* === Icons === */
.ic { display: inline-block; vertical-align: middle; flex-shrink: 0; line-height: 0; }
.ic-cat {
    padding: 8px;
    background: var(--lg-bg);
    border: 1px solid var(--lg-b);
    border-radius: var(--r-sm);
    box-sizing: content-box;
    color: var(--p3);
    transition: color 0.2s ease, border-color 0.2s ease;
}
.btn .ic { margin-right: 6px; }
.btn-icon-only { padding: 10px; }
.btn-icon-only .ic { margin: 0; }

/* === Page header === */
.page-header {
    padding: 20px var(--pad) 12px;
    max-width: 100%;
    overflow-x: hidden;
}
.page-header h1 {
    font-size: clamp(1.5rem, 5vw, 2rem);
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.page-header .lead {
    color: var(--text-2);
    margin-top: 6px;
    font-size: .95rem;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

/* === Cards === */
.card {
    position: relative;
    background: var(--lg-bg);
    border: 1px solid var(--lg-b);
    border-radius: var(--r);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--lg-sh);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    transition: border-color 0.25s var(--ease), transform 0.2s var(--ease), box-shadow 0.25s var(--ease);
    max-width: 100%;
    overflow-wrap: anywhere;
    word-wrap: break-word;
}
.card::before {
    content: '';
    position: absolute; inset: 0;
    border-radius: inherit;
    box-shadow: var(--lg-hi);
    pointer-events: none;
}
.card:active { transform: scale(0.99); }
.card-link { display: block; }
.card-link:active { border-color: var(--lg-bh); }

.card-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-3);
    flex-wrap: wrap;
    min-width: 0;
}
.card-head .cat {
    display: inline-flex; gap: 6px; align-items: center;
    color: var(--p3); font-weight: 600;
    min-width: 0;
    overflow-wrap: anywhere;
}
.card-head .cat .ic { color: var(--p3); }
.card-body {
    color: var(--text); line-height: 1.5; font-size: 0.93rem;
    word-wrap: break-word; overflow-wrap: anywhere;
    min-width: 0;
}
.card-link .card-body {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-link { min-height: 96px; }
.card-foot {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 10px; font-size: 0.85rem; color: var(--text-2);
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
    overflow-wrap: anywhere;
}
.card-foot .muted { color: var(--text-3); min-width: 0; overflow-wrap: anywhere; }
.card-foot .rate { font-weight: 600; font-family: var(--mono); }
.card-foot .rate.pos { color: var(--green); }
.card-foot .rate.neg { color: var(--red); }
.card-foot .rate.zero { color: var(--text-3); }

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 18px;
    border-radius: var(--r-pill);
    font-weight: 600;
    font-size: 0.95rem;
    transition: opacity 0.2s ease, transform 0.15s var(--ease), box-shadow 0.25s var(--ease);
    max-width: 100%;
    text-align: center;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
    background: var(--grad);
    color: #fff;
    box-shadow: 0 8px 30px rgba(14, 165, 233, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.btn-secondary {
    background: var(--lg-bg);
    color: var(--text);
    border: 1px solid var(--lg-b);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
}
.btn-block { display: flex; width: 100%; }

@media (hover: hover) {
    .btn:hover { transform: translateY(-1px); box-shadow: var(--lg-shh); }
    .btn-primary:hover { box-shadow: 0 12px 36px rgba(14, 165, 233, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.22); }
    .card-link:hover { border-color: var(--lg-bh); box-shadow: var(--lg-sh), var(--lg-shh); }
    .btn-secondary:hover { border-color: var(--lg-bh); }
}

/* === Vote buttons === */
.vote-row { display: flex; gap: 10px; margin-bottom: 12px; }
.btn-vote {
    flex: 1; padding: 12px;
    background: var(--lg-bg);
    border: 1px solid var(--lg-b);
    border-radius: var(--r-pill);
    color: var(--text);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-weight: 600;
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
    min-width: 0;
}
.btn-vote .vote-count { transition: transform 0.25s ease; min-width: 14px; font-family: var(--mono); }
.btn-vote .ic { transition: transform 0.25s ease; }
.btn-vote:active { transform: scale(0.97); }
.btn-vote:active .ic { transform: scale(1.25); }
.btn-vote.active.like .vote-count, .btn-vote.active.dislike .vote-count {
    transform: scale(1.1);
}
.btn-vote.active.like { background: rgba(52, 211, 153, 0.18); border-color: var(--green); color: var(--green); }
.btn-vote.active.dislike { background: rgba(251, 113, 133, 0.18); border-color: var(--red); color: var(--red); }

/* === Toast === */
.toast {
    position: fixed;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
    left: 50%; transform: translateX(-50%);
    background: var(--lg-bg-2);
    border: 1px solid var(--lg-bh);
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    box-shadow: var(--lg-sh);
    color: var(--text);
    padding: 11px 18px;
    border-radius: var(--r-pill);
    font-size: 0.9rem;
    font-weight: 600;
    max-width: 90vw;
    z-index: 200;
    animation: toast-in 0.3s var(--ease);
    overflow-wrap: anywhere;
    word-wrap: break-word;
}
.toast-error { border-color: rgba(251, 113, 133, 0.6); color: #fda4af; }
.toast-success { border-color: rgba(52, 211, 153, 0.5); color: #6ee7b7; }
@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* === Tabbar (pill style) === */
.tabbar {
    position: fixed;
    left: 8px; right: 8px;
    bottom: calc(8px + var(--safe-b));
    height: var(--tabbar-h);
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    background: rgba(15, 12, 28, 0.75);
    backdrop-filter: blur(40px) saturate(1.4);
    -webkit-backdrop-filter: blur(40px) saturate(1.4);
    border: 1px solid var(--lg-b);
    border-radius: var(--r-pill);
    box-shadow: var(--lg-sh);
    z-index: 100;
    max-width: calc(100% - 16px);
}
.tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    color: var(--text-3);
    border-radius: var(--r-pill);
    transition: color 0.2s var(--ease), background 0.2s var(--ease), transform 0.15s var(--ease);
    min-width: 0;
    padding: 4px 6px;
    position: relative;
}
.tab .tab-l {
    font-size: 0.68rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.tab.active {
    color: #fff;
    background: var(--p-soft);
    box-shadow: var(--lg-hi);
}
.tab.active .ic { color: var(--p3); filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.6)); }
.tab:active { transform: scale(0.96); }

/* === Stats === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 12px 0;
}
.stat {
    background: var(--lg-bg);
    border: 1px solid var(--lg-b);
    border-radius: var(--r-sm);
    padding: 14px 8px;
    text-align: center;
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    min-width: 0;
    overflow-wrap: anywhere;
}
.stat-v {
    font-size: 1.4rem;
    font-weight: 800;
    background: var(--grad-w);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: var(--p1);
    font-family: var(--mono);
}
@supports not (background-clip: text) {
    .stat-v { background: none; -webkit-text-fill-color: currentColor; color: var(--p3); }
}
.stat-l { font-size: 0.68rem; color: var(--text-3); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.05em; }

/* === Chips / cats-row (карусель категорий) === */
.cats-wrap {
    position: relative;
    margin: 14px 0 6px;
    min-width: 0;
    max-width: 100%;
}
.cats-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 24px 12px;
    margin: 0 -24px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scroll-padding-left: 24px;
    scroll-behavior: smooth;
    min-width: 0;
}
.cats-row::-webkit-scrollbar { display: none; }
/* fade-gradients на обоих краях */
.cats-wrap::before, .cats-wrap::after {
    content: '';
    position: absolute; top: 0; bottom: 12px;
    width: 28px;
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.2s var(--ease);
}
.cats-wrap::before { left: 0; background: linear-gradient(to right, var(--bg) 30%, transparent); }
.cats-wrap::after { right: 0; background: linear-gradient(to left, var(--bg) 30%, transparent); }
.cats-wrap[data-edge-start="1"]::before { opacity: 0; }
.cats-wrap[data-edge-end="1"]::after { opacity: 0; }

.cat-chip, .chip {
    flex-shrink: 0;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    padding: 10px 16px;
    min-height: 42px;
    border-radius: var(--r-pill);
    background: var(--lg-bg);
    border: 1px solid var(--lg-b);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-2);
    white-space: nowrap;
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    scroll-snap-align: start;
    transition: background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.15s var(--ease), box-shadow 0.25s var(--ease);
}
.cat-chip:active, .chip:active { transform: scale(0.96); }
.cat-chip .ic { color: var(--p3); }
.cat-chip.active .ic, .chip.active .ic { color: #fff; }
.cat-chip.active, .chip.active {
    background: var(--grad);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 22px rgba(14, 165, 233, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.22);
    font-weight: 600;
}
@media (hover: hover) {
    .cat-chip:hover { border-color: var(--lg-bh); color: var(--text); }
}

/* === Empty state === */
.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-3);
    overflow-wrap: anywhere;
    word-wrap: break-word;
}
.empty .ic-empty {
    width: 64px; height: 64px;
    margin: 0 auto 12px;
    padding: 14px;
    background: var(--lg-bg);
    border: 1px solid var(--lg-b);
    border-radius: var(--r);
    color: var(--p3);
    box-shadow: var(--lg-sh);
}
.empty .h { color: var(--text); font-size: 1.1rem; margin-bottom: 6px; font-weight: 600; }

.section-h {
    font-size: 1.05rem;
    margin: 22px 0 10px;
    color: var(--text);
}

/* === How-to steps === */
.howto-steps { margin: 6px 0 24px; display: flex; flex-direction: column; gap: 10px; }
.step {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 14px 16px;
    background: var(--lg-bg);
    border: 1px solid var(--lg-b);
    border-radius: var(--r);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    box-shadow: var(--lg-sh);
    min-width: 0;
    overflow-wrap: anywhere;
}
.step-num {
    flex-shrink: 0;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: var(--grad);
    color: #fff;
    border-radius: 50%;
    font-weight: 800;
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.4);
    font-family: var(--mono);
}
.step-body { min-width: 0; flex: 1; }
.step-h { font-weight: 700; font-size: 0.98rem; margin-bottom: 3px; }
.step-t { color: var(--text-2); font-size: 0.9rem; line-height: 1.5; overflow-wrap: anywhere; }

/* === FAQ / details === */
.qa-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.qa {
    background: var(--lg-bg);
    border: 1px solid var(--lg-b);
    border-radius: var(--r-sm);
    overflow: hidden;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}
.qa-q {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 14px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.93rem;
    list-style: none;
    min-width: 0;
}
.qa-q::-webkit-details-marker { display: none; }
.qa-q span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.qa-chev { color: var(--p3); transition: transform 0.25s var(--ease); }
.qa[open] .qa-chev { transform: rotate(90deg); }
.qa-a { padding: 0 14px 14px; color: var(--text-2); font-size: 0.9rem; line-height: 1.55; overflow-wrap: anywhere; }

/* === Link list === */
.link-list { display: flex; flex-direction: column; gap: 6px; }
.link-row {
    display: flex; align-items: center; gap: 10px;
    padding: 14px;
    background: var(--lg-bg);
    border: 1px solid var(--lg-b);
    border-radius: var(--r-sm);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: var(--text);
    font-weight: 600;
    transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
    min-width: 0;
}
.link-row:active { border-color: var(--lg-bh); transform: scale(0.98); }
.link-row span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.link-row-chev { color: var(--text-3); flex-shrink: 0; }
@media (hover: hover) {
    .link-row:hover { border-color: var(--lg-bh); }
}

/* === Rule list === */
.rule-h {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 10px;
    font-size: 1rem;
    color: var(--text);
}
.rule-list { list-style: none; }
.rule-list li {
    padding: 6px 0 6px 18px;
    color: var(--text-2);
    font-size: 0.92rem;
    position: relative;
    overflow-wrap: anywhere;
}
.rule-list li::before {
    content: '·';
    position: absolute; left: 4px; top: 0;
    color: var(--p3);
    font-size: 1.4rem; line-height: 1;
}

/* === Categories grid === */
.cats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: 8px;
    margin-bottom: 100px;
}
@media (max-width: 360px) {
    .cats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.cat-tile {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px;
    padding: 14px 8px;
    background: var(--lg-bg);
    border: 1px solid var(--lg-b);
    border-radius: var(--r-sm);
    cursor: pointer;
    text-align: center;
    transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.15s var(--ease);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    min-width: 0;
}
.cat-tile:active { transform: scale(0.97); }
.cat-tile.on {
    border-color: var(--lg-bh);
    background: var(--p-soft);
    box-shadow: var(--lg-sh);
}
.cat-tile input { display: none; }
.cat-tile-ic { color: var(--text-2); transition: color 0.2s var(--ease); }
.cat-tile.on .cat-tile-ic { color: var(--p3); }
.cat-tile-l { font-size: 0.82rem; color: var(--text-2); font-weight: 600; overflow-wrap: anywhere; }
.cat-tile.on .cat-tile-l { color: var(--text); }
.cat-tile-check {
    position: absolute; top: 6px; right: 6px;
    width: 20px; height: 20px;
    opacity: 0; transition: opacity 0.2s var(--ease);
    color: var(--p1);
}
.cat-tile.on .cat-tile-check { opacity: 1; }

/* === Sticky actions === */
.sticky-actions {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
    padding: 12px var(--pad);
    background: rgba(12, 10, 20, 0.96);
    border-top: 1px solid var(--lg-b);
    display: flex; align-items: center; gap: 12px;
    z-index: 50;
    max-width: 100%;
}
.sticky-actions .sticky-counter { flex: 1; color: var(--text-2); font-size: 0.9rem; min-width: 0; overflow-wrap: anywhere; }
.sticky-actions .btn { padding: 10px 18px; }

/* === Vacancy detail nav (prev/next) === */
.sticky-nav { gap: 8px; padding: 10px var(--pad); }
.sticky-nav .nav-btn {
    flex: 1;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 12px 8px;
    border-radius: var(--r-pill);
    background: var(--lg-bg);
    border: 1px solid var(--lg-b);
    color: var(--text);
    font-weight: 600;
    font-size: 0.92rem;
    min-height: 44px;
    min-width: 0;
    transition: border-color 0.2s var(--ease), transform 0.15s var(--ease);
}
.sticky-nav .nav-btn:active { transform: scale(0.97); }
.sticky-nav .nav-btn.disabled {
    opacity: 0.35;
    pointer-events: none;
    cursor: not-allowed;
}
.sticky-nav .nav-meta {
    flex: 0 0 auto;
    padding: 8px 12px;
    border-radius: var(--r-pill);
    color: var(--text-3);
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid transparent;
    text-align: center;
    font-family: var(--mono);
}
.sticky-nav .nav-meta:active { background: var(--lg-bg); }

/* === Fields === */
.field { margin-bottom: 14px; min-width: 0; }
.field label { display: block; font-size: 0.85rem; color: var(--text-2); margin-bottom: 6px; }
.field input, .field textarea, .field select {
    width: 100%;
    padding: 12px;
    background: var(--bg-3);
    border: 1px solid var(--lg-b);
    border-radius: var(--r-sm);
    color: var(--text);
    font: inherit;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
    max-width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus {
    outline: none;
    border-color: var(--p2);
    box-shadow: 0 0 0 3px var(--p-soft);
}
.field textarea { resize: vertical; min-height: 100px; }
.char-counter {
    text-align: right;
    font-size: 0.78rem;
    color: var(--text-3);
    margin-top: 4px;
    font-family: var(--mono);
}

/* === Toggle group === */
.toggle-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
    background: var(--bg-3);
    border: 1px solid var(--lg-b);
    border-radius: var(--r-sm);
    padding: 4px;
}
.toggle-group label {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-2);
    transition: background 0.2s var(--ease), color 0.2s var(--ease);
    min-width: 0;
    overflow-wrap: anywhere;
}
.toggle-group input[type="radio"] { display: none; }
.toggle-group input[type="radio"]:checked + label,
.toggle-group label.active {
    background: var(--grad);
    color: #fff;
    font-weight: 600;
}

/* === Alerts === */
.alert {
    padding: 12px;
    border-radius: var(--r-sm);
    margin-bottom: 12px;
    font-size: 0.9rem;
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    overflow-wrap: anywhere;
    word-wrap: break-word;
    min-width: 0;
}
.alert-error { background: rgba(251, 113, 133, 0.15); border: 1px solid rgba(251, 113, 133, 0.4); color: #fda4af; }
.alert-info { background: var(--p-soft); border: 1px solid var(--lg-bh); color: var(--p3); }
.alert-success { background: rgba(52, 211, 153, 0.12); border: 1px solid rgba(52, 211, 153, 0.35); color: #6ee7b7; }

/* === Profile === */
.profile-head {
    display: flex; align-items: center; gap: 14px;
    padding: 18px var(--pad);
    flex-wrap: wrap;
    min-width: 0;
}
.profile-head > div:not(.avatar) { min-width: 0; flex: 1; }
.avatar {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: var(--grad-w);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 1.6rem;
    border: 2px solid var(--lg-b);
    box-shadow: var(--lg-sh);
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.8rem; }
.avatar-sm { width: 40px; height: 40px; font-size: 1rem; border-width: 1px; }
.avatar-fallback {
    text-transform: uppercase;
    background: var(--grad-w);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
@supports not (background-clip: text) {
    .avatar-fallback { background: none; -webkit-text-fill-color: currentColor; color: #fff; }
}

.profile-name {
    font-size: 1.15rem; font-weight: 700;
    overflow-wrap: anywhere;
    word-wrap: break-word;
    min-width: 0;
}
.profile-sub {
    color: var(--text-3); font-size: 0.85rem; margin-top: 2px;
    overflow-wrap: anywhere;
    word-wrap: break-word;
    min-width: 0;
}
.profile-sub code {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--text-3);
}

/* Welcome card on home */
.welcome-card { margin-top: 18px; }
.welcome-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    overflow-wrap: anywhere;
}
.welcome-row > div:not(.avatar) { min-width: 0; flex: 1; }

/* === KV row === */
.kv-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--lg-b);
    gap: 12px;
    min-width: 0;
    flex-wrap: wrap;
}
.kv-row:last-child { border-bottom: none; }
.kv-k { color: var(--text-3); font-size: 0.9rem; flex-shrink: 0; }
.kv-v {
    color: var(--text); font-weight: 600; font-size: 0.95rem;
    text-align: right;
    overflow-wrap: anywhere;
    word-wrap: break-word;
    min-width: 0;
    font-family: var(--mono);
}

/* === Copy row === */
.copy-row {
    display: flex; gap: 6px; align-items: center;
    background: var(--bg-3);
    border: 1px solid var(--lg-b);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    margin-bottom: 10px;
    min-width: 0;
    max-width: 100%;
}
.copy-row input {
    flex: 1;
    min-width: 0;
    background: transparent; border: none; color: var(--text);
    font-family: var(--mono); font-size: 0.85rem;
    overflow-wrap: anywhere;
}
.copy-row button {
    color: var(--p3);
    font-weight: 600;
    padding: 4px 10px;
    flex-shrink: 0;
    border-radius: var(--r-pill);
    transition: background 0.2s var(--ease);
}
.copy-row button:active { background: var(--p-soft); transform: scale(0.95); }

/* === Chat === */
.chat-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 12px 16px;
    background: rgba(12, 10, 20, 0.92);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    position: sticky; top: 0; z-index: 5;
    border-bottom: 1px solid var(--lg-b);
    max-width: 100%;
    overflow-x: hidden;
}
.chat-h-left {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    min-width: 0;
    flex: 1;
}

.chat-container {
    display: flex; flex-direction: column; gap: 10px;
    padding: 16px 12px calc(96px + var(--tabbar-h) + var(--safe-b));
    min-height: 100dvh;
    max-width: 100%;
    overflow-x: hidden;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    max-width: 82%;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    line-height: 1.4;
    min-width: 0;
    box-shadow: var(--lg-sh);
}
.chat-bubble.user {
    background: var(--grad);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 6px;
}
.chat-bubble.staff, .chat-bubble.admin {
    background: var(--lg-bg);
    color: var(--text);
    align-self: flex-start;
    border: 1px solid var(--lg-b);
    border-bottom-left-radius: 6px;
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
}
.chat-text {
    font-size: 0.95rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-wrap: break-word;
    min-width: 0;
}
.chat-meta {
    font-size: 0.7rem; opacity: 0.7; margin-top: 4px;
    display: flex; gap: 4px;
    flex-wrap: wrap;
    min-width: 0;
}

.chat-compose {
    position: fixed;
    bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
    left: 8px; right: 8px;
    display: flex; align-items: flex-end; gap: 8px;
    padding: 8px 10px;
    background: rgba(12, 10, 20, 0.96);
    border: 1px solid var(--lg-b);
    border-radius: 28px;
    box-shadow: var(--lg-sh);
    z-index: 4;
    max-width: calc(100% - 16px);
}
.chat-compose textarea {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    background: transparent;
    color: var(--text);
    border: none;
    border-radius: 22px;
    font-size: 0.95rem; line-height: 1.4;
    resize: none; min-height: 40px; max-height: 200px;
    font-family: inherit;
    overflow-wrap: anywhere;
}
.chat-compose textarea:focus { outline: none; }
.btn-send {
    width: 40px; height: 40px;
    border-radius: 50%; border: none;
    background: var(--grad); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.4);
    transition: transform 0.15s var(--ease);
}
.btn-send:active { transform: scale(0.92); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Status badges === */
.status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: var(--r-pill);
    font-size: 0.75rem; font-weight: 600;
    white-space: nowrap;
}
.status-open { background: var(--p-soft); color: var(--p3); }
.status-in_progress { background: rgba(245, 158, 11, 0.18); color: var(--yellow); }
.status-closed { background: rgba(136, 132, 160, 0.15); color: var(--text-3); }

/* === Icon-only button === */
.btn-icon-only {
    width: 40px; height: 40px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--lg-b); background: var(--lg-bg); color: var(--text);
    flex-shrink: 0;
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    transition: transform 0.15s var(--ease), border-color 0.2s var(--ease);
}
.btn-icon-only:active { transform: scale(0.94); }
@media (hover: hover) {
    .btn-icon-only:hover { border-color: var(--lg-bh); }
}

/* === Pagination === */
.pagi {
    display: flex; justify-content: center; gap: 8px;
    margin: 16px 0;
    flex-wrap: wrap;
}
.pagi a, .pagi span {
    padding: 8px 14px;
    border-radius: var(--r-pill);
    background: var(--lg-bg);
    border: 1px solid var(--lg-b);
    font-size: 0.9rem;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    font-family: var(--mono);
}
.pagi .now {
    background: var(--grad);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.3);
}

/* === Ref link (referral.html) === */
.ref-link {
    overflow-wrap: anywhere;
    word-wrap: break-word;
    min-width: 0;
}

/* === Ticket row === */
.ticket-row {
    overflow-wrap: anywhere;
    word-wrap: break-word;
    min-width: 0;
}

/* === Global overflow safety net === */
.container, .page-header, main, footer, header.chat-header, .chat-compose {
    max-width: 100%;
    overflow-x: hidden;
}
/* prevent overflow on long unbroken strings (URLs, usernames) anywhere */
.card, .card-body, .chat-bubble, .chat-text, .kv-row, .profile-sub, .profile-name,
.alert, .empty, .ticket-row, .ref-link, code, .copy-row input, p {
    word-wrap: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
}

/* horizontal-scroll containers must have min-width: 0 so flexbox doesn't overflow */
.cats-row { min-width: 0; max-width: 100%; }

/* === Monospace for code-like things === */
code, .mono {
    font-family: var(--mono);
    font-size: 0.85em;
}
