:root {
    --primary: #22a06b;
    --primary-dark: #1a7f52;
    --primary-light: #e3f5ec;
    --bg: #f2f4f7;
    --card: #ffffff;
    --text: #495057;
    --text-secondary: #74788d;
    --text-muted: #adb5bd;
    --border: #eff2f7;
    --hover: #f8f9fb;
    --like: #f46a6a;
    --online: #34c38f;
    --shadow: 0 2px 4px rgba(0,0,0,.04);
    --shadow-lg: 0 4px 20px rgba(0,0,0,.08);
    --radius: 8px;
    --radius-lg: 12px;
    --header-height: 70px;
    --mobile-nav-height: 0px;
    --sidebar-width: 260px;
    --right-width: 300px;
}

html.night-mode {
    --bg: #1a1d21;
    --card: #22252a;
    --text: #e9ecef;
    --text-secondary: #adb5bd;
    --text-muted: #6c757d;
    --border: #2f343a;
    --hover: #2a2e34;
    --primary-light: #1a3d2e;
    --shadow: 0 2px 4px rgba(0,0,0,.2);
    color-scheme: dark;
}

html.night-mode body {
    background: var(--bg);
    color: var(--text);
}

html.night-mode select,
html.night-mode input,
html.night-mode textarea {
    background: var(--hover);
    color: var(--text);
    border-color: var(--border);
}

html.night-mode .search-form input {
    background: var(--hover);
    color: var(--text);
}

html.night-mode .feed-filter-select {
    background: var(--card);
    color: var(--text);
}

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

html {
    overflow-x: hidden;
}

body {
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

html {
    overflow-x: clip;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; color: var(--primary-dark); }
img { max-width: 100%; }

.icon-svg { flex-shrink: 0; display: block; }

/* Header */
.top-header {
    background: var(--card);
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: var(--shadow);
    border-bottom: 1px solid var(--border);
    overflow: visible;
}

.header-inner {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 24px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
    letter-spacing: -.5px;
}

.search-form {
    flex: 1;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
}

.search-form input,
.search-page-form input {
    width: 100%;
    padding: 10px 14px 10px 42px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--hover);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color .2s, background .2s;
}

.search-form input:focus,
.search-page-form input:focus {
    background: var(--card);
    border-color: var(--primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    overflow: visible;
}

.header-menu-wrap {
    position: relative;
}

.header-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    max-width: min(320px, calc(100vw - 24px));
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 400;
    overflow: hidden;
}

.header-panel.open { display: block; }

#header-menu-create {
    width: 260px;
    padding: 8px 0;
}

.header-panel-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
}

.header-panel-item:hover {
    background: var(--hover);
    color: var(--primary);
    text-decoration: none;
}

.header-panel-icon {
    display: flex;
    color: var(--primary);
    flex-shrink: 0;
}

.header-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
}

.header-panel-action {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
}

.header-panel-action:hover { text-decoration: underline; }

.header-panel-body {
    max-height: 280px;
    overflow-y: auto;
}

.header-panel-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.header-panel-list {
    list-style: none;
}

.header-panel-list li {
    border-bottom: 1px solid var(--border);
}

.header-panel-list li:last-child { border-bottom: none; }

.header-notif-item {
    padding: 10px 12px;
}

.header-notif-item .header-panel-user {
    padding: 0;
}

.header-notif-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    padding-left: 44px;
}

.header-panel-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text);
    text-decoration: none;
}

.header-panel-user:hover {
    background: var(--hover);
    text-decoration: none;
}

.header-panel-user-info {
    flex: 1;
    min-width: 0;
}

.header-panel-user-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-panel-preview {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-panel-unread {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.header-panel-foot {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.header-panel-foot a {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary);
}

.header-sound-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-secondary);
    cursor: pointer;
}

.header-sound-toggle input {
    accent-color: var(--primary);
}

html.night-mode .header-panel {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.header-action-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    transition: background .2s, color .2s;
}

.header-action-btn:hover,
.header-action-btn.active {
    background: var(--primary-light);
    color: var(--primary);
}

.header-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--like);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Author display:flex overrides UA [hidden]; keep empty badge invisible. */
.header-badge[hidden],
.mobile-top-nav-badge[hidden] {
    display: none !important;
}

.profile-menu-wrap { position: relative; }

.profile-menu-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px 4px 4px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--card);
    cursor: pointer;
    color: var(--text-secondary);
}

.profile-menu-btn:hover { background: var(--hover); }

.profile-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    max-width: min(280px, calc(100vw - 24px));
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    padding: 8px 0;
    z-index: 300;
    overflow: hidden;
}

.profile-dropdown.open { display: block; }

.dropdown-item .icon-svg {
    color: var(--primary);
    flex-shrink: 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
    padding: 10px 16px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    text-align: left;
    overflow: hidden;
}

.dropdown-item > span:not(.dropdown-badge) {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-item:hover { background: var(--hover); color: var(--text); }

.dropdown-user { font-weight: 600; }

.dropdown-static { cursor: default; justify-content: flex-start; }
.dropdown-static:hover { background: transparent; }

.dropdown-badge {
    flex-shrink: 0;
    margin-left: auto;
    padding: 2px 8px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

.dropdown-lang {
    padding: 8px 16px;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

.dropdown-lang .lang-switcher {
    flex-wrap: wrap;
    justify-content: center;
}

.dropdown-lang .lang-btn {
    color: var(--text-secondary);
    background: var(--hover);
    border-color: var(--border);
}

.dropdown-lang .lang-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

html.night-mode .profile-menu-btn {
    background: var(--card);
    border-color: var(--border);
    color: var(--text-secondary);
}

html.night-mode .profile-dropdown {
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

html.night-mode .dropdown-lang .lang-btn {
    background: var(--hover);
    border-color: var(--border);
    color: var(--text-secondary);
}

html.night-mode .dropdown-lang .lang-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

html.night-mode .dropdown-badge {
    background: #1a3d2e;
    color: #4cd99a;
}

html.night-mode .header-action-btn:hover,
html.night-mode .header-action-btn.active {
    background: #1a3d2e;
    color: var(--primary);
}

/* Layout */
.page-layout {
    width: 100%;
    max-width: 100%;
    margin: 20px 0;
    padding: 0 24px;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--right-width);
    gap: 20px;
    align-items: start;
}

.page-layout > * {
    min-width: 0;
}

.main-content { min-width: 0; }

.sidebar {
    position: sticky;
    top: calc(var(--header-height) + 20px);
    min-width: 0;
}

.messages-page.page-layout .sidebar-right { display: none; }
.messages-page.page-layout { grid-template-columns: var(--sidebar-width) 1fr; }

/* Side nav */
.side-nav {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 12px 0;
    border: 1px solid var(--border);
}

.side-nav-label {
    padding: 12px 20px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
}

.side-nav-section { padding: 4px 0; }

.side-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    transition: background .15s, color .15s;
}

.side-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    flex-shrink: 0;
    color: var(--primary);
}

.side-nav-item:hover {
    background: var(--hover);
    color: var(--text);
    text-decoration: none;
}

.side-nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.side-nav-item.active .side-nav-icon,
.side-nav-item:hover .side-nav-icon {
    color: var(--primary);
}

/* Cards */
.card,
.composer-card,
.post-card,
.widget,
.empty-state {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

/* Stories */
.stories-bar { padding: 16px 20px; }

.stories-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--text);
}

.stories-list {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding: 2px 2px 6px;
}

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: none;
    background: none;
    cursor: pointer;
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: 12px;
    max-width: 76px;
    padding: 0;
}

.story-item > span {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

.story-create-wrap {
    position: relative;
    display: inline-flex;
    padding: 0 4px 4px 0;
}

.story-ring {
    padding: 3px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
}

.story-ring.is-unseen {
    background: var(--primary);
}

.story-ring.is-seen {
    background: var(--border);
}

.story-ring.is-own.is-unseen {
    background: var(--primary);
}

.profile-avatar-wrap.has-story .profile-hero-avatar {
    box-shadow: none;
    cursor: pointer;
}

button.story-open-avatar {
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    display: inline-flex;
    line-height: 0;
    cursor: pointer;
}

button.story-open-avatar .profile-hero-avatar {
    display: block;
}

.profile-avatar-wrap.has-story button.story-open-avatar {
    border-radius: 50%;
    display: block;
}

.story-thumb {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    border: none;
    background: var(--hover, #eee);
}

.story-thumb img,
.story-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.story-thumb .avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.story-plus {
    position: absolute;
    right: 0;
    bottom: 0;
    z-index: 2;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--card);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
    pointer-events: none;
}

/* Story create modal */
.story-create-modal {
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.story-create-card {
    position: relative;
    width: min(960px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
}

.story-create-close {
    position: absolute;
    top: -8px;
    right: -8px;
    z-index: 2;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

.story-create-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
    gap: 16px;
}

.story-create-drop {
    min-height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #0b0b0b;
}

.story-create-drop.is-dragover {
    outline: 2px dashed var(--primary);
}

.story-create-drop-inner {
    text-align: center;
    max-width: 320px;
}

.story-create-drop-icon {
    color: var(--text-muted);
    margin-bottom: 12px;
}

.story-create-drop-inner p {
    color: var(--text-muted);
    margin: 0 0 16px;
}

.story-create-bg-btn {
    display: block;
    margin: 12px auto 0;
    border: none;
    background: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 14px;
}

.story-create-bg-btn:hover {
    text-decoration: underline;
}

.story-bg-layer {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: #111;
}

.story-draw-layer {
    position: absolute;
    inset: 0;
    z-index: 3;
    width: 100%;
    height: 100%;
    pointer-events: none;
    touch-action: none;
}

.story-editor-canvas.tool-brush .story-draw-layer {
    pointer-events: auto;
    cursor: crosshair;
}

.story-tool-panels {
    margin: 8px 0 12px;
}

.story-tool-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-md);
    background: var(--hover-bg, rgba(0, 0, 0, 0.04));
}

.story-tool-panel[hidden] {
    display: none !important;
}

.story-color-row,
.story-bg-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.story-swatch,
.story-bg-preset {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: var(--swatch, #fff);
    cursor: pointer;
    padding: 0;
}

.story-bg-preset {
    border-radius: 8px;
    width: 42px;
    height: 42px;
}

.story-swatch.is-active,
.story-bg-preset.is-active,
.story-filter-btn.is-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(34, 160, 107, 0.25);
}

.story-slider-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.story-slider-row input[type="range"] {
    width: 100%;
}

.story-filter-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.story-filter-btn {
    border: 1px solid var(--border);
    background: var(--card-bg, var(--card));
    color: var(--text);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
}

.story-create-preview {
    width: min(100%, 320px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.story-editor-canvas {
    --story-edit-max-h: min(640px, calc(100dvh - 200px), calc(100vh - 200px));
    position: relative;
    width: min(100%, 360px, calc(var(--story-edit-max-h) * 9 / 16));
    aspect-ratio: 9 / 16;
    height: auto;
    max-height: var(--story-edit-max-h);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #000;
    touch-action: none;
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}

.story-editor-canvas.is-dragging {
    cursor: grabbing;
}

.story-editor-canvas.tool-text {
    cursor: text;
}

.story-media-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
}

.story-media-layer img,
.story-media-layer video {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: contain;
    transform-origin: center center;
    pointer-events: none;
}

.story-overlays {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
}

.story-overlay-text {
    position: absolute;
    max-width: 85%;
    padding: 4px 8px;
    border: 2px dashed transparent;
    border-radius: 6px;
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
    cursor: move;
    pointer-events: auto;
    word-break: break-word;
    outline: none;
}

.story-overlay-text.is-active {
    border-color: rgba(255, 255, 255, 0.75);
}

.story-overlay-text:empty::before {
    content: attr(data-placeholder);
    color: rgba(255, 255, 255, 0.55);
}

.story-editor-hint {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

.story-tool {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 8px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    background: none;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.story-tool:hover {
    background: var(--hover-bg);
}

.story-tool.is-active {
    background: var(--primary-soft, rgba(34, 139, 34, 0.12));
    color: var(--primary);
    font-weight: 600;
}

.story-tools-list li {
    list-style: none;
}

.story-tool.is-muted {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    color: var(--text-muted);
    opacity: 0.7;
    font-size: 14px;
}

.story-create-tools {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
}

.story-tools-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.story-create-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
}

.story-meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.story-meta-row img {
    border-radius: 50%;
    object-fit: cover;
}

.story-privacy-row select {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    background: var(--card-bg);
    color: var(--text);
}

.story-publish-btn {
    width: 100%;
}

.story-publish-btn:disabled {
    opacity: 0.55;
}

/* Story viewer — light theme */
.story-viewer {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(242, 244, 247, 0.92);
}

.story-viewer[hidden] {
    display: none !important;
}

.story-viewer-backdrop {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: blur(28px) brightness(1.05) saturate(0.9);
    transform: scale(1.08);
    opacity: 0.45;
}

.story-viewer-frame {
    --story-max-h: min(860px, calc(100dvh - 40px), calc(100vh - 40px));
    position: relative;
    z-index: 1;
    width: min(100%, 480px, calc(var(--story-max-h) * 9 / 16));
    aspect-ratio: 9 / 16;
    height: auto;
    max-height: var(--story-max-h);
    border-radius: 18px;
    overflow: hidden;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.story-viewer-progress {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 3;
    display: flex;
    gap: 4px;
}

.story-progress-bar {
    flex: 1;
    height: 3px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.story-progress-fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--primary);
    transition: width 0.05s linear;
}

.story-viewer-header {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 28px 14px 10px;
    color: var(--text);
    background: linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.55), transparent);
}

.story-viewer-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.story-viewer-more-wrap {
    position: relative;
}

.story-viewer-more {
    border: none;
    background: none;
    color: var(--text);
    font-size: 24px;
    line-height: 1;
    width: 36px;
    height: 36px;
    cursor: pointer;
    border-radius: 50%;
}

.story-viewer-more:hover {
    background: rgba(0, 0, 0, 0.06);
}

.story-viewer-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 180px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px 0;
    box-shadow: var(--shadow-lg);
    z-index: 6;
}

.story-viewer-menu:not([hidden]) {
    display: block;
}

.story-viewer-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.story-viewer-menu-item:hover {
    background: var(--hover);
}

.story-viewer-menu-danger {
    color: var(--like);
}

.story-viewer-confirm {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    width: min(320px, calc(100% - 32px));
    padding: 18px 16px;
    border-radius: var(--radius-lg);
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    text-align: center;
    pointer-events: auto;
}

.story-viewer-confirm-actions[hidden] {
    display: none !important;
}

.story-viewer-confirm[hidden] {
    display: none !important;
}

.story-viewer-confirm-text {
    margin: 0 0 14px;
    font-size: 15px;
    line-height: 1.35;
}

.story-viewer-confirm-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.story-viewer-confirm .btn-danger {
    background: #c62828;
    border-color: #c62828;
    color: #fff;
}

.story-viewer-confirm .btn-danger:disabled {
    opacity: 0.65;
    cursor: wait;
}

.story-viewer-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.story-viewer-user img {
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--card);
    box-shadow: 0 0 0 1px var(--border);
}

.story-viewer-name {
    display: block;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
    font-size: 14px;
}

.story-viewer-time {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
}

.story-viewer-close {
    border: none;
    background: none;
    color: var(--text);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.story-viewer-close:hover {
    background: rgba(0, 0, 0, 0.06);
}

.story-viewer-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    background: var(--hover);
}

.story-viewer-media-wrap {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--hover);
    z-index: 1;
}

.story-viewer-media-wrap img,
.story-viewer-media-wrap video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: var(--hover);
}

.story-viewer-media-wrap img[hidden],
.story-viewer-media-wrap video[hidden] {
    display: none !important;
}

.story-viewer-empty {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    color: var(--text-secondary);
    text-align: center;
    font-size: 14px;
    pointer-events: none;
}

.story-viewer-empty[hidden] {
    display: none !important;
}

.story-nav {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 35%;
    border: none;
    background: transparent;
    cursor: pointer;
    z-index: 3;
}

.story-nav-prev { left: 0; }
.story-nav-next { right: 0; }

.story-viewer-footer {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px 16px;
    background: linear-gradient(transparent, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.96));
}

.story-reply-input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 10px 14px;
    background: var(--card);
    color: var(--text);
}

.story-reply-input::placeholder {
    color: var(--text-muted);
}

.story-like-btn,
.story-share-btn {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.95;
    transition: transform .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
}

.story-like-btn:disabled,
.story-share-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.story-like-btn.is-active,
.story-share-btn.is-active,
.story-like-btn:hover,
.story-share-btn:hover {
    background: rgba(34, 160, 107, 0.12);
    color: var(--primary);
    border-color: rgba(34, 160, 107, 0.3);
}

.story-like-btn.is-active,
.story-share-btn.is-active {
    transform: scale(1.06);
}

@media (max-width: 860px) {
    .story-create-layout {
        grid-template-columns: 1fr;
    }

    .story-create-drop {
        min-height: 320px;
    }

    .story-viewer {
        padding: 0;
        background: var(--bg);
    }

    .story-viewer-frame {
        --story-max-h: min(100dvh, 100vh);
        width: min(100vw, calc(var(--story-max-h) * 9 / 16));
        max-height: var(--story-max-h);
        border-radius: 0;
        box-shadow: none;
        border: none;
    }
}

/* Composer */
.composer-card { padding: 16px 20px; }

.composer-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
}

.composer-form textarea {
    flex: 1;
    min-width: 200px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 48px;
    outline: none;
    background: var(--hover);
    color: var(--text);
}

.composer-form textarea:focus { border-color: var(--primary); background: var(--card); }

.composer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: flex-end;
}

.composer-tool {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--hover);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.composer-tool:hover { background: var(--primary-light); color: var(--primary); }

/* Feed filters */
.feed-filters {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    flex-wrap: wrap;
}

.feed-filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

/* Widgets */
.widget { padding: 16px; }

.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.widget h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.widget-refresh {
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
}

.widget-refresh:hover { color: var(--primary); }

.widget-link { font-size: 12px; color: var(--primary); }

.widget-empty { color: var(--text-muted); font-size: 13px; }

.widget-promoted { background: linear-gradient(135deg, #22a06b 0%, #178f5c 100%); color: #fff; border: none; }
.widget-promoted h3 { color: #fff; }
.widget-promoted .widget-refresh { color: rgba(255,255,255,.8); }
.widget-promoted .widget-empty { color: rgba(255,255,255,.7); }

.promoted-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.promoted-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: #fff;
    font-size: 11px;
    text-align: center;
}

.promoted-item:hover { opacity: .9; color: #fff; }
.promoted-item .avatar { border: 2px solid rgba(255,255,255,.5); }

.trend-card { padding-top: 4px; }
.trend-tag { font-size: 11px; color: var(--primary); font-weight: 600; }
.trend-title { font-size: 13px; margin-top: 4px; color: var(--text); }

.online-list { list-style: none; }
.online-list li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    color: var(--text);
    text-decoration: none;
}
.online-list li a:hover { color: var(--primary); }
.online-dot {
    width: 8px; height: 8px;
    background: var(--online);
    border-radius: 50%;
    margin-left: auto;
}

.side-nav-feed {
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

/* User mini card */
.widget-user-mini {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
}

.user-mini-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
    min-width: 0;
    flex: 1;
}

.user-mini-link:hover { color: var(--primary); }

.user-mini-name {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-mini-add {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-decoration: none;
}

.user-mini-add:hover { background: var(--primary); color: #fff; }

/* Recommend lists */
.widget-recommend { padding: 14px 16px; }

.recommend-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.recommend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.recommend-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    color: var(--text);
    text-decoration: none;
}

.recommend-main:hover { color: var(--primary); }

.recommend-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.recommend-icon-page {
    background: #e3f5ec;
    color: var(--primary);
}

.recommend-icon-group {
    background: #d4f0e3;
    color: #178f5c;
}

.recommend-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.recommend-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recommend-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.recommend-action {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--hover);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    text-decoration: none;
    flex-shrink: 0;
    line-height: 1;
}

.recommend-action:hover {
    background: var(--primary);
    color: #fff;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 16px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
}

.sidebar-copyright {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.sidebar-lang-wrap {
    position: relative;
    margin-bottom: 10px;
}

.sidebar-lang-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 0;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.sidebar-lang-toggle:hover,
.sidebar-lang-toggle[aria-expanded="true"] {
    color: var(--primary);
}

.sidebar-lang-chevron {
    display: flex;
    opacity: 0.7;
}

.sidebar-lang-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    min-width: 160px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 20;
    overflow: hidden;
}

.sidebar-lang-menu:not([hidden]) {
    display: block;
}

.sidebar-lang-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text);
}

.sidebar-lang-option:hover {
    background: var(--hover);
    color: var(--primary);
}

.sidebar-lang-option.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.lang-flag { font-size: 16px; }

.sidebar-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.sidebar-links a {
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-links a:hover { color: var(--primary); }

/* Channels (news pages) */
.channel-list { display: flex; flex-direction: column; gap: 12px; }

.channel-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
}

.channel-main {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
    color: var(--text);
    text-decoration: none;
}

.channel-main:hover { color: var(--primary); }

.channel-avatar {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--primary-light);
}

.channel-avatar-lg {
    width: 80px;
    height: 80px;
}

.channel-info { min-width: 0; }
.channel-info h3 { font-size: 16px; margin-bottom: 4px; }

.channel-category {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 4px;
}

.channel-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 4px 0;
}

.channel-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.channel-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    padding: 20px;
    margin-bottom: 16px;
}

.channel-header-info { flex: 1; min-width: 200px; }
.channel-header-info h1 { font-size: 22px; margin-bottom: 6px; }

.channel-follow-form { flex-shrink: 0; }

.recommend-follow-form { margin: 0; }

.recommend-follow-form .recommend-action {
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.channel-feed { margin-top: 8px; }

/* Pages discover (Sngine-style) */
.pages-page.page-layout {
    display: block;
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow-x: hidden;
}

.pages-discover {
    width: 100%;
    max-width: 100%;
    padding: 0 24px 24px;
}

.pages-hero {
    background: linear-gradient(135deg, var(--primary) 0%, #1a7f52 100%);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    color: #fff;
    overflow: hidden;
}

.pages-hero-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    padding: 28px 32px;
}

.pages-hero-text h1 {
    font-size: 28px;
    margin-bottom: 4px;
}

.pages-hero-text p {
    opacity: 0.9;
    font-size: 14px;
}

.pages-hero-search {
    display: flex;
    gap: 8px;
    flex: 1;
    max-width: 520px;
    min-width: 240px;
}

.pages-hero-search input {
    flex: 1;
    padding: 10px 14px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
}

.pages-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 16px;
    margin-bottom: 16px;
    overflow: hidden;
}

.pages-tabs {
    display: flex;
    gap: 0;
    overflow-x: auto;
    min-width: 0;
}

.pages-tab {
    padding: 14px 18px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.pages-tab:hover {
    color: var(--primary);
    text-decoration: none;
}

.pages-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.pages-body {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 0;
    align-items: stretch;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    min-height: 360px;
}

.pages-body-single {
    grid-template-columns: 1fr;
}

.pages-body .pages-categories.card {
    border: none;
    border-radius: 0;
    box-shadow: none;
    border-right: 1px solid var(--border);
    margin: 0;
    align-self: stretch;
}

.pages-body-single .pages-categories.card {
    border-right: none;
}

.pages-body .pages-main .empty-state.card,
.pages-body .pages-main .pages-empty {
    border: none;
    box-shadow: none;
    background: transparent;
}

.pages-categories {
    padding: 12px 0;
    position: sticky;
    top: calc(var(--header-height) + 20px);
    max-height: calc(100vh - var(--header-height) - 40px);
    overflow-y: auto;
}

.pages-categories ul { list-style: none; }

.pages-categories a {
    display: block;
    padding: 8px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
}

.pages-categories a:hover,
.pages-categories a.active {
    background: var(--primary-light);
    color: var(--primary);
    text-decoration: none;
}

.pages-main {
    min-width: 0;
    overflow: hidden;
    padding: 16px;
}

.pages-main-full { grid-column: 1 / -1; }

.pages-main-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.pages-main-head h2 {
    font-size: 18px;
}

.pages-filters select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    font-size: 13px;
    margin-left: 8px;
}

.pages-filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.pages-card {
    padding: 20px 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.pages-card-link {
    color: var(--text);
    text-decoration: none;
}

.pages-card-link:hover {
    color: var(--primary);
    text-decoration: none;
}

.pages-card-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 10px;
    background: var(--primary-light);
}

.pages-card h3 {
    font-size: 15px;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pages-card-likes {
    font-size: 12px;
    color: var(--text-muted);
}

.pages-like-form { margin-top: auto; }

.pages-empty {
    padding: 48px 24px;
    text-align: center;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 500;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
}

.modal-overlay.open { display: flex; }

.modal-card {
    width: 100%;
    max-width: 560px;
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    margin: auto 0;
}

.modal-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-head h2 {
    flex: 1;
    font-size: 18px;
}

.modal-icon { color: var(--primary); display: flex; }

.modal-close {
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 4px;
}

.modal-error {
    margin: 12px 20px 0;
    padding: 10px 12px;
    background: #fde8e8;
    color: #c0392b;
    border-radius: var(--radius);
    font-size: 13px;
}

.modal-form {
    padding: 16px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.modal-form input,
.modal-form select,
.modal-form textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    background: var(--hover);
    color: var(--text);
}

.modal-form select {
    max-height: none;
}

.modal-form small {
    color: var(--text-muted);
    font-size: 12px;
}

.slug-input-wrap {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--hover);
    overflow: hidden;
}

.slug-prefix {
    padding: 10px 0 10px 12px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.slug-input-wrap input {
    border: none;
    background: transparent;
    flex: 1;
    min-width: 0;
    padding-left: 0;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
}

.modal-checkbox {
    flex-direction: row !important;
    align-items: center;
    gap: 10px !important;
    color: var(--text) !important;
    cursor: pointer;
}

.modal-checkbox input {
    width: auto;
    accent-color: var(--primary);
}

.modal-hint {
    display: block;
    margin-top: -8px;
    color: var(--text-muted);
    font-size: 12px;
}

.group-cover {
    background: linear-gradient(135deg, #2a3f47 0%, #1a7f52 100%);
}

.group-search-form {
    display: flex;
    gap: 8px;
}

.group-search-form input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--hover);
    color: var(--text);
    font-size: 13px;
}

.group-info-list li {
    font-size: 13px;
    padding: 4px 0;
}

html.night-mode .modal-error {
    background: #3d2020;
    color: #f5a5a5;
}

/* Static pages (about, privacy, terms) */
.static-page.page-layout {
    display: block;
    margin: 0;
    padding: 0;
}

.static-page-wrap {
    width: 100%;
    padding: 0 24px 48px;
}

.static-hero {
    background: linear-gradient(135deg, var(--primary) 0%, #1a7f52 100%);
    color: #fff;
    text-align: center;
    padding: 56px 24px 96px;
    margin-bottom: -56px;
}

.static-hero h1 {
    font-size: 32px;
    font-weight: 600;
}

.static-content {
    max-width: 820px;
    margin: 0 auto;
    padding: 32px 40px;
    position: relative;
    z-index: 1;
}

.static-content h3 {
    color: var(--primary);
    font-size: 18px;
    margin: 24px 0 12px;
}

.static-content p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 12px;
}

/* People search */
.people-page {
    width: 100%;
    max-width: 100%;
    padding: 0 24px 24px;
}

.people-toolbar {
    margin-bottom: 16px;
}

.people-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 16px;
    align-items: start;
}

.people-main {
    padding: 20px;
    min-width: 0;
}

.people-section-title {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.people-suggest-list {
    list-style: none;
}

.people-suggest-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.people-suggest-item:last-child {
    border-bottom: none;
}

.people-suggest-main {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
    min-width: 0;
}

.people-suggest-main:hover {
    text-decoration: none;
    color: var(--primary);
}

.people-suggest-name {
    font-weight: 500;
}

.people-add-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--primary);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.people-add-btn:hover {
    background: var(--primary-light);
}

.people-filters {
    padding: 20px;
    position: sticky;
    top: calc(var(--header-height) + 20px);
}

.people-filters h3 {
    font-size: 16px;
    margin-bottom: 16px;
}

.people-filter-form label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.people-filter-form input {
    width: 100%;
    margin-top: 4px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
}

/* Events */
.event-date-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius);
    background: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
}

/* Floating action buttons */
.fab-bar {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 900;
}

.fab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    color: var(--primary);
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s;
}

.fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    text-decoration: none;
    color: var(--primary);
}

@media (max-width: 900px) {
    .pages-body { grid-template-columns: 1fr; }
    .pages-body .pages-categories.card { border-right: none; border-bottom: 1px solid var(--border); }
    .pages-categories { position: static; max-height: none; }
    .pages-hero-inner { flex-direction: column; align-items: stretch; }
    .pages-hero-search { max-width: none; }
    .people-layout { grid-template-columns: 1fr; }
    .people-filters { position: static; }
    .settings-page-wrap { grid-template-columns: 1fr; }
    .settings-sidebar { position: static; }
    .settings-privacy-grid { grid-template-columns: 1fr; }
    .settings-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .pages-discover { padding: 0 12px 16px; }
    .people-page { padding: 0 12px 16px; }
    .static-page-wrap { padding: 0 12px 32px; }
    .static-content { padding: 24px 20px; }
    .pages-toolbar { flex-direction: column; align-items: stretch; }
    .pages-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .fab-bar { right: 16px; bottom: 16px; }
}

.profile-widget h3 { font-size: 15px; margin-bottom: 4px; }

/* Avatars */
.avatar { border-radius: 50%; object-fit: cover; background: var(--primary-light); flex-shrink: 0; }
.avatar-sm { width: 36px; height: 36px; }
.avatar-md { width: 48px; height: 48px; }
.avatar-lg { width: 64px; height: 64px; }
.avatar-xl { width: 120px; height: 120px; }

/* Posts */
.post-card { padding: 16px 20px; }

.post-header { display: flex; gap: 12px; margin-bottom: 12px; }
.post-meta { display: flex; flex-direction: column; gap: 2px; }
.post-author { font-weight: 600; color: var(--primary); text-decoration: none; }
.post-wall-info { font-size: 12px; color: var(--text-secondary); }
.post-time { font-size: 12px; color: var(--text-muted); }
.post-content { margin-bottom: 12px; word-wrap: break-word; }
.post-image img { border-radius: var(--radius); margin-bottom: 10px; }

.post-actions {
    display: flex;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
}
.action-btn:hover { background: var(--hover); }
.action-btn.liked { color: var(--like); }

/* Comments */
.comments-section { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.comment { display: flex; gap: 8px; margin-bottom: 10px; }
.comment-body { background: var(--hover); border-radius: var(--radius); padding: 8px 12px; flex: 1; }
.comment-author { font-weight: 600; font-size: 13px; color: var(--primary); text-decoration: none; }
.comment-body p { margin: 2px 0; font-size: 13px; }
.comment-body time { font-size: 11px; color: var(--text-muted); }
.comment-form { display: flex; gap: 8px; align-items: center; }
.comment-form input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
    background: var(--hover);
    color: var(--text);
}
.comment-form button {
    border: none;
    background: var(--primary);
    color: white;
    width: 32px; height: 32px;
    border-radius: 50%;
    cursor: pointer;
}

/* Profile page (Sngine-style) */
.profile-page.page-layout {
    display: block;
    margin: 0;
    padding: 0;
}

.profile-page-inner {
    width: 100%;
    padding: 0 24px 24px;
}

.profile-upload-error {
    margin-bottom: 16px;
}

/* Image crop modal (Sngine-style) */
.crop-modal-card {
    max-width: 640px;
    width: calc(100% - 32px);
}

.crop-modal-hint {
    margin: 0 24px 16px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: #e8f4fd;
    color: #3d6b8a;
    font-size: 13px;
    line-height: 1.5;
}

.crop-modal-body {
    margin: 0 24px;
    max-height: min(60vh, 480px);
    background: #1a1d21;
    border-radius: var(--radius);
    overflow: hidden;
}

.crop-modal-body .cropper-container {
    max-height: min(60vh, 480px);
}

.crop-image-source {
    display: block;
    max-width: 100%;
}

.crop-modal-actions {
    padding: 16px 24px 24px;
    justify-content: flex-end;
}

html.night-mode .crop-modal-hint {
    background: #1a3d4d;
    color: #9ecae8;
}

.profile-hero.card {
    overflow: visible;
    margin-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    position: relative;
    z-index: 10;
}

.profile-cover {
    position: relative;
    height: 260px;
    background: #3a3f47;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background-size: cover;
    background-position: center;
    overflow: visible;
}

.profile-cover.has-image {
    background-color: #2a2e34;
    cursor: default;
}

.profile-cover.is-editing {
    cursor: ns-resize;
}

.profile-cover.is-editing.is-dragging {
    cursor: grabbing;
}

.profile-cover-editor {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 16px 20px 20px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
    color: #fff;
    z-index: 3;
}

.profile-cover-editor-hint {
    font-size: 13px;
    margin-bottom: 10px;
    opacity: 0.95;
}

.profile-cover-slider {
    width: 100%;
    margin-bottom: 12px;
    accent-color: var(--primary);
}

.profile-cover-editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.profile-cover-menu-wrap {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 15;
}

.profile-dropdown-menu {
    position: absolute;
    min-width: 220px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 6px 0;
    z-index: 30;
}

.profile-dropdown-menu:not([hidden]) {
    display: block;
}

.profile-cover-menu {
    top: calc(100% + 8px);
    right: 0;
}

.profile-cover-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.profile-cover-menu-item:hover:not(:disabled) {
    background: var(--hover);
    color: var(--primary);
}

.profile-cover-menu-item:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.profile-cover-menu-danger {
    color: #e85d6f;
}

.profile-cover-menu-danger:hover:not(:disabled) {
    background: #fff0f2;
    color: #c93b4f;
}

.profile-cover-edit {
    position: relative;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    z-index: 4;
}

.profile-cover-edit:hover { background: #fff; }

.profile-hero-bar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 0 24px 20px;
    --profile-avatar-overlap: 56px;
    margin-top: calc(-1 * var(--profile-avatar-overlap));
    position: relative;
    z-index: 2;
}

.profile-hero-user {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    min-width: 0;
}

.profile-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    z-index: 3;
}

.profile-avatar-wrap.has-story {
    padding: 5px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 6px 18px rgba(34, 160, 107, 0.22);
}

.profile-avatar-wrap.has-story.is-seen {
    background: var(--border);
    box-shadow: none;
}

.profile-avatar-menu-wrap {
    position: absolute;
    right: 2px;
    bottom: 2px;
    z-index: 12;
    pointer-events: auto;
}

.profile-avatar-edit {
    position: relative;
    width: 34px;
    height: 34px;
    border: 3px solid var(--card);
    border-radius: 50%;
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    z-index: 12;
    pointer-events: auto;
}

.profile-avatar-edit:hover {
    background: var(--hover);
    color: var(--primary);
}

.profile-avatar-menu {
    bottom: calc(100% + 8px);
    left: 0;
}

.profile-avatar-menu:not([hidden]) {
    display: block;
}

.profile-avatar-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.profile-avatar-menu-item:hover:not(:disabled) {
    background: var(--hover);
    color: var(--primary);
}

.profile-avatar-menu-item:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.profile-avatar-menu-danger {
    color: #e85d6f;
}

.profile-avatar-menu-danger:hover:not(:disabled) {
    background: #fff0f2;
    color: #c93b4f;
}

.profile-upload-form {
    display: none;
}

.profile-file-input {
    position: fixed;
    left: -9999px;
    top: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.profile-hero-avatar {
    border: 4px solid var(--card);
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.profile-hero-text {
    min-width: 0;
    /* Keep name below the cover; extra lines (city) grow downward */
    padding-top: var(--profile-avatar-overlap, 56px);
    padding-bottom: 6px;
}

.profile-hero-text h1 {
    font-size: 24px;
    color: var(--text);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-hero-city {
    color: var(--text-secondary);
    font-size: 13px;
}

.profile-hero-nick {
    margin: 0 0 4px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
}

.profile-hero-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    padding-bottom: 8px;
}

.profile-tabs {
    display: flex;
    gap: 0;
    overflow-x: auto;
    margin-bottom: 20px;
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: 0 16px;
    scrollbar-width: thin;
}

.profile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 88px;
    padding: 12px 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    border-bottom: 2px solid transparent;
    flex-shrink: 0;
    transition: color .15s, border-color .15s;
}

.profile-tab-icon {
    display: flex;
    color: var(--primary);
}

.profile-tab:hover {
    color: var(--primary);
    text-decoration: none;
}

.profile-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.profile-tab-label {
    text-align: center;
    line-height: 1.2;
}

.profile-subtabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    overflow-x: auto;
}

.profile-subtab {
    padding: 12px 18px;
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}

.profile-subtab:hover {
    color: var(--primary);
    text-decoration: none;
}

.profile-subtab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.profile-friends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.profile-friend-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
}

.profile-friend-card:hover {
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--primary);
}

.profile-friend-card h3 {
    font-size: 14px;
    margin-top: 10px;
}

.profile-content-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.profile-content-box h2 {
    font-size: 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-content-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    align-items: start;
}

.profile-widgets {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: calc(var(--header-height) + 20px);
}

.profile-main { min-width: 0; }

.profile-composer .composer-form input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    min-width: 0;
}

.profile-composer .composer-submit {
    border: none;
    background: var(--primary-light);
    color: var(--primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-feed-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.profile-feed-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.profile-merits-widget h3,
.profile-completion-widget h3 {
    font-size: 15px;
    margin-bottom: 12px;
}

.merits-list {
    list-style: none;
    margin-bottom: 12px;
}

.merits-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.merits-list li:last-child { border-bottom: none; }

.merit-icon { color: var(--primary); flex-shrink: 0; }
.merit-label { flex: 1; min-width: 0; }
.merit-value { font-weight: 600; color: var(--text-secondary); }

.btn-block {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.completion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.completion-percent {
    font-weight: 700;
    color: var(--primary);
}

.completion-bar {
    height: 6px;
    background: var(--hover);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}

.completion-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
}

.completion-list {
    list-style: none;
}

.completion-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.completion-list li.completion-action {
    cursor: pointer;
    border-radius: var(--radius);
    padding: 6px 8px;
    margin: 0 -8px;
}

.completion-list li.completion-action:hover {
    background: var(--hover);
    color: var(--primary);
}

.completion-list li.done { color: var(--text); }

.completion-status {
    display: flex;
    color: var(--primary);
    flex-shrink: 0;
}

.completion-list li:not(.done) .completion-status { color: var(--text-muted); }

.empty-state-profile {
    text-align: center;
    padding: 48px 24px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.edit-profile-card label {
    display: block;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.edit-profile-card input,
.edit-profile-card textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    background: var(--hover);
    color: var(--text);
}

html.night-mode .profile-cover {
    background-color: #2a2e34;
}

html.night-mode .profile-cover-edit {
    background: rgba(34, 37, 42, 0.92);
    color: var(--text);
}

@media (max-width: 1000px) {
    .profile-content-grid { grid-template-columns: 260px 1fr; }
}

@media (max-width: 860px) {
    .profile-content-grid { grid-template-columns: 1fr; }
    .profile-widgets { position: static; }
    .profile-hero-bar { flex-direction: column; align-items: flex-start; }
    .profile-hero-actions { padding-bottom: 0; }
}

@media (max-width: 500px) {
    .profile-page-inner { padding: 0 12px 16px; }
    .profile-cover { height: 180px; }
    .profile-hero-bar {
        padding: 0 16px 16px;
        --profile-avatar-overlap: 44px;
    }
    .profile-tab { min-width: 72px; padding: 10px 6px; font-size: 11px; }
}

/* Friends */
.friends-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    padding: 10px 12px;
    margin-bottom: 16px;
}

.friends-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
}

.friends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.friend-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 20px;
    text-align: center;
}
.friend-card a { color: var(--text); text-decoration: none; }
.friend-card h3 { font-size: 14px; margin-top: 10px; }
.friend-card p { font-size: 12px; color: var(--text-secondary); }
.friend-status { font-size: 12px; color: var(--text-muted); }
.friend-card-actions { display: flex; gap: 6px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

/* Search */
.search-page-form { display: flex; gap: 10px; margin-bottom: 20px; }
.search-page-form input { flex: 1; padding: 12px 16px; border-radius: var(--radius); }
.search-results { display: flex; flex-direction: column; gap: 10px; }
.search-result-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.search-result-main { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; flex: 1; }
.search-result-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Messages — Telegram-style app shell */
.messages-page.page-layout,
.messages-app-page.page-layout {
    display: block;
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow: hidden;
}

main.messages-app-page ~ .fab-bar {
    display: none;
}

.tg-messages {
    display: flex;
    height: calc(100vh - var(--header-height) - var(--mobile-nav-height));
    min-height: 480px;
    background: var(--bg);
    color: var(--text);
}

.tg-dialogs {
    width: min(380px, 34vw);
    min-width: 280px;
    max-width: 420px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--card);
    border-right: 1px solid var(--border);
}

.tg-dialogs-head {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.tg-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 20px;
    background: var(--hover);
    border: 1px solid var(--border);
}

.tg-search-icon {
    display: flex;
    color: var(--text-muted);
}

.tg-search input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.tg-search input::placeholder {
    color: var(--text-muted);
}

.tg-dialogs-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.tg-dialog {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text);
    text-decoration: none;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.tg-dialog:hover {
    background: var(--hover);
    color: var(--text);
    text-decoration: none;
}

.tg-dialog.is-active {
    background: var(--primary-light);
    color: var(--text);
}

.tg-dialog-avatar {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.tg-dialog-body {
    flex: 1;
    min-width: 0;
}

.tg-dialog-top,
.tg-dialog-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tg-dialog-name {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tg-dialog-time {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.tg-dialog.is-active .tg-dialog-time {
    color: var(--text-secondary);
}

.tg-dialog-preview {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.tg-dialog.is-active .tg-dialog-preview {
    color: var(--text-secondary);
}

.tg-you {
    color: var(--primary);
}

.tg-dialog.is-active .tg-you {
    color: var(--primary-dark);
}

.tg-unread {
    flex-shrink: 0;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tg-chat {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.tg-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    min-height: 60px;
}

.tg-chat-back {
    display: none;
    color: var(--primary);
    padding: 4px;
}

.tg-chat-user {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
    color: inherit;
    text-decoration: none;
}

.tg-chat-user:hover {
    color: inherit;
    text-decoration: none;
}

.tg-chat-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
}

.tg-chat-user-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tg-chat-name {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.tg-chat-status {
    font-size: 13px;
    color: var(--primary);
}

.tg-chat-actions {
    display: flex;
    gap: 4px;
}

.tg-chat-action {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
}

.tg-chat-action:hover {
    background: var(--hover);
    color: var(--text);
}

.tg-chat-feed {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tg-date-sep {
    display: flex;
    justify-content: center;
    margin: 10px 0 6px;
}

.tg-date-sep span {
    background: var(--card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 12px;
}

.tg-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: min(72%, 560px);
    align-self: flex-start;
}

.tg-msg.is-own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.tg-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.tg-bubble {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px 14px 14px 4px;
    padding: 8px 12px 6px;
    box-shadow: var(--shadow);
    max-width: 100%;
}

.tg-msg.is-own .tg-bubble {
    background: var(--primary-light);
    border-color: transparent;
    border-radius: 14px 14px 4px 14px;
}

.tg-bubble-text {
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
    padding-right: 52px;
    color: var(--text);
}

.tg-bubble-meta {
    position: absolute;
    right: 8px;
    bottom: 5px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1;
}

.tg-checks {
    letter-spacing: -2px;
    font-size: 12px;
}

.tg-checks.is-read {
    color: var(--primary);
}

.tg-composer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px 14px;
    background: var(--card);
    border-top: 1px solid var(--border);
}

.tg-composer-wrap {
    position: relative;
    background: var(--card);
    border-top: 1px solid var(--border);
}

.tg-composer-wrap .tg-composer {
    border-top: none;
    padding-top: 8px;
}

.tg-composer-emoji {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.tg-composer-emoji:hover,
.tg-composer-emoji.is-open {
    background: var(--hover);
    color: var(--primary);
}

.tg-composer-input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 12px 16px;
    background: var(--hover);
    color: var(--text);
    font-size: 15px;
    outline: none;
}

.tg-composer-input::placeholder {
    color: var(--text-muted);
}

.tg-composer-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.tg-composer-send:hover {
    background: var(--primary-dark);
}

.tg-emoji-panel {
    border-bottom: 1px solid var(--border);
    background: var(--card);
    max-height: 280px;
    display: flex;
    flex-direction: column;
}

.tg-emoji-panel[hidden] {
    display: none !important;
}

.tg-emoji-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 10px 0;
    border-bottom: 1px solid var(--border);
}

.tg-emoji-tab {
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tg-emoji-tab.is-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tg-emoji-pane {
    display: none;
    overflow-y: auto;
    padding: 10px;
    max-height: 230px;
}

.tg-emoji-pane.is-active {
    display: block;
}

.tg-emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    gap: 4px;
}

.tg-emoji-btn {
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tg-emoji-btn:hover {
    background: var(--hover);
}

.tg-sticker-pack-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.tg-sticker-pack-tab {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: 2px solid transparent;
    border-radius: 10px;
    background: var(--hover);
    padding: 4px;
    cursor: pointer;
    overflow: hidden;
}

.tg-sticker-pack-tab.is-active {
    border-color: var(--primary);
}

.tg-sticker-pack-tab img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tg-sticker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
}

.tg-sticker-pick {
    border: none;
    background: var(--hover);
    border-radius: 12px;
    padding: 6px;
    cursor: pointer;
    aspect-ratio: 1;
}

.tg-sticker-pick img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tg-sticker-pick:hover {
    background: var(--primary-light);
}

.tg-store-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tg-store-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 12px;
    background: var(--hover);
}

.tg-store-item img,
.tg-store-cover {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 10px;
    background: var(--card);
    flex-shrink: 0;
}

.tg-store-meta {
    flex: 1;
    min-width: 0;
}

.tg-store-meta strong {
    display: block;
    font-size: 14px;
}

.tg-store-meta span {
    font-size: 12px;
    color: var(--text-muted);
}

.tg-sticker-suggest {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.tg-sticker-suggest[hidden] {
    display: none !important;
}

.tg-sticker-suggest-label {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.tg-sticker-suggest-item {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 10px;
    background: var(--card);
    padding: 4px;
    cursor: pointer;
}

.tg-sticker-suggest-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tg-bubble.is-sticker {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 4px 8px 20px 4px;
}

.tg-msg.is-own .tg-bubble.is-sticker {
    background: transparent;
}

.tg-sticker-img {
    width: min(160px, 42vw);
    height: auto;
    display: block;
}

.tg-bubble.is-sticker .tg-bubble-meta {
    right: 4px;
    bottom: 2px;
}

.tg-composer-mic {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.tg-composer-mic:hover,
.tg-composer-mic.is-recording {
    color: #e53935;
    background: var(--hover);
}

.tg-composer-video-note {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.tg-composer-video-note:hover,
.tg-composer-video-note.is-recording {
    color: var(--primary);
    background: var(--hover);
}

.tg-composer.is-recording-voice,
.tg-composer.is-recording-video-note {
    display: none;
}

.tg-voice-record {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--card);
    border-top: 1px solid var(--border);
}

.tg-voice-record[hidden] {
    display: none !important;
}

.tg-video-note-record {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 16px 14px 18px;
    background: var(--card);
    border-top: 1px solid var(--border);
}

.tg-video-note-record[hidden] {
    display: none !important;
}

.tg-video-note-preview-wrap {
    position: relative;
    width: 180px;
    height: 180px;
}

.tg-video-note-preview {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    object-fit: cover;
    background: #111;
    transform: scaleX(-1);
}

.tg-video-note-rec-ring {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 3px solid #e53935;
    animation: tg-voice-pulse 1s ease infinite;
    pointer-events: none;
}

.tg-video-note-record-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 360px;
}

.tg-video-note-record-actions .tg-voice-rec-time {
    text-align: center;
}

.tg-bubble.is-video-note {
    background: transparent !important;
    border: none;
    box-shadow: none;
    padding: 4px 8px 22px 4px;
    min-width: 0;
}

.tg-msg.is-own .tg-bubble.is-video-note {
    background: transparent !important;
}

.tg-bubble.is-video-note .tg-bubble-meta {
    right: 10px;
    bottom: 2px;
}

.tg-video-note {
    position: relative;
    width: min(200px, 56vw);
    height: min(200px, 56vw);
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    background: #111;
    box-shadow: 0 0 0 2px var(--border);
}

.tg-video-note-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #111;
}

.tg-video-note-play {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

.tg-video-note.is-playing .tg-video-note-play {
    opacity: 0;
    pointer-events: none;
}

.tg-video-note-time {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.65);
    pointer-events: none;
}

.tg-voice-rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e53935;
    animation: tg-voice-pulse 1s ease infinite;
}

@keyframes tg-voice-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.tg-voice-rec-time {
    flex: 1;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.tg-voice-cancel,
.tg-voice-send {
    border: none;
    border-radius: 18px;
    padding: 8px 14px;
    font-weight: 600;
    cursor: pointer;
}

.tg-voice-cancel {
    background: var(--hover);
    color: var(--text);
}

.tg-voice-send {
    background: var(--primary);
    color: #fff;
}

.tg-bubble.is-voice {
    min-width: 200px;
    max-width: min(280px, 72vw);
}

.tg-voice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0 2px;
}

.tg-voice audio {
    display: none;
}

.tg-voice-play {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.12);
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.tg-msg.is-own .tg-voice-play {
    background: rgba(255, 255, 255, 0.22);
}

.tg-voice.is-playing .tg-voice-play {
    background: var(--primary);
    color: #fff;
}

.tg-voice-wave {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 22px;
    flex: 1;
}

.tg-voice-wave span {
    width: 3px;
    border-radius: 2px;
    background: currentColor;
    opacity: 0.55;
    height: 40%;
}

.tg-voice-wave span:nth-child(2) { height: 70%; }
.tg-voice-wave span:nth-child(3) { height: 45%; }
.tg-voice-wave span:nth-child(4) { height: 90%; }
.tg-voice-wave span:nth-child(5) { height: 55%; }
.tg-voice-wave span:nth-child(6) { height: 75%; }
.tg-voice-wave span:nth-child(7) { height: 35%; }
.tg-voice-wave span:nth-child(8) { height: 60%; }

.tg-voice.is-playing .tg-voice-wave span {
    animation: tg-wave 0.9s ease-in-out infinite;
}

.tg-voice.is-playing .tg-voice-wave span:nth-child(2) { animation-delay: 0.1s; }
.tg-voice.is-playing .tg-voice-wave span:nth-child(3) { animation-delay: 0.2s; }
.tg-voice.is-playing .tg-voice-wave span:nth-child(4) { animation-delay: 0.05s; }
.tg-voice.is-playing .tg-voice-wave span:nth-child(5) { animation-delay: 0.15s; }
.tg-voice.is-playing .tg-voice-wave span:nth-child(6) { animation-delay: 0.25s; }
.tg-voice.is-playing .tg-voice-wave span:nth-child(7) { animation-delay: 0.08s; }
.tg-voice.is-playing .tg-voice-wave span:nth-child(8) { animation-delay: 0.18s; }

@keyframes tg-wave {
    0%, 100% { transform: scaleY(0.55); }
    50% { transform: scaleY(1); }
}

.tg-voice-time {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    opacity: 0.85;
    min-width: 2.5em;
}

.msg-toast {
    position: fixed;
    top: 72px;
    right: 16px;
    z-index: 11500;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: min(360px, calc(100vw - 32px));
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.msg-toast[hidden] {
    display: none !important;
}

.msg-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.msg-toast-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--hover);
}

.msg-toast-body {
    min-width: 0;
    flex: 1;
}

.msg-toast-name {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.25;
    margin-bottom: 2px;
    color: var(--text);
}

.msg-toast-text {
    font-size: 13px;
    line-height: 1.35;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 720px) {
    .msg-toast {
        top: auto;
        bottom: 88px;
        left: 12px;
        right: 12px;
        max-width: none;
    }
}

.call-overlay {
    position: fixed;
    inset: 0;
    z-index: 12000;
    background: rgba(8, 12, 16, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.call-overlay[hidden] {
    display: none !important;
}

.call-card {
    position: relative;
    width: min(420px, 100%);
    min-height: 420px;
    border-radius: 24px;
    background: #12161c;
    color: #fff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 28px 20px 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.call-remote-video,
.call-local-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.call-local-video {
    inset: auto 14px 110px auto;
    width: 112px;
    height: 150px;
    border-radius: 14px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    z-index: 2;
}

.call-card.is-audio .call-remote-video,
.call-card.is-audio .call-local-video {
    display: none;
}

.call-peer-avatar {
    width: 112px;
    height: 112px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 16px;
    z-index: 1;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.call-card.is-video.has-remote .call-peer-avatar {
    display: none;
}

.call-peer-name {
    font-size: 22px;
    font-weight: 700;
    z-index: 1;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
}

.call-status {
    margin-top: 8px;
    margin-bottom: 28px;
    color: rgba(255, 255, 255, 0.78);
    z-index: 1;
}

.call-actions {
    display: flex;
    gap: 18px;
    z-index: 3;
}

.call-btn {
    width: 58px;
    height: 58px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
}

.call-btn[hidden] {
    display: none !important;
}

.call-btn-accept {
    background: #22a06b;
}

.call-btn-reject {
    background: #e53935;
}

.call-btn-mute {
    background: rgba(255, 255, 255, 0.18);
}

.call-btn-mute.is-muted {
    background: rgba(255, 255, 255, 0.35);
}

.admin-sticker-emoji-form {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    justify-content: center;
}

.admin-sticker-emoji-form input {
    width: 52px;
    text-align: center;
    font-size: 18px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.tg-chat-empty {
    flex: 1;
    background: var(--bg);
}

.tg-empty-hint {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

@media (max-width: 900px) {
    .tg-dialogs {
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    .tg-messages.has-chat .tg-dialogs {
        display: none;
    }

    .tg-messages:not(.has-chat) .tg-chat {
        display: none;
    }

    .tg-messages.has-chat .tg-chat {
        width: 100%;
        flex: 1;
        min-width: 0;
    }

    .tg-chat-back {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .tg-msg {
        max-width: 88%;
    }
}

@media (max-width: 768px) {
    .messages-layout { grid-template-columns: 1fr; }
    .dialogs-list { display: none; }

    .tg-messages {
        min-height: 0;
        height: calc(100dvh - var(--header-height) - var(--mobile-nav-height));
    }
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 18px; border: none; border-radius: var(--radius);
    font-size: 14px; font-family: inherit; cursor: pointer;
    text-decoration: none; white-space: nowrap;
    transition: background .2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--primary-light); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; }

.badge {
    display: inline-block; padding: 6px 12px;
    border-radius: var(--radius); font-size: 12px;
    background: var(--hover); color: var(--text-secondary);
}
.badge-success { background: #d4f5e9; color: #0d9f6e; }

/* Empty state */
.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-secondary);
}
.empty-illustration { margin-bottom: 16px; }
.empty-state .btn { margin-top: 16px; }

.page-title, .section-title { font-size: 20px; font-weight: 600; margin-bottom: 16px; }
.info-list { list-style: none; font-size: 13px; }
.info-list li { padding: 6px 0; color: var(--text-secondary); }

/* Auth */
.auth-page {
    background: linear-gradient(135deg, var(--primary) 0%, #3dbf84 100%);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
}
.auth-container { width: 100%; max-width: 420px; padding: 20px; }
.auth-box {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 36px;
    box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; margin-bottom: 20px; font-size: 32px; font-weight: 700; color: var(--primary); }
.auth-top {
    display: flex; align-items: center; justify-content: center;
    position: relative; margin-bottom: 16px; min-height: 36px;
}
.auth-top .auth-logo { margin-bottom: 0; }
.auth-top .lang-switcher { position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
.lang-switcher { display: flex; gap: 4px; align-items: center; }
.lang-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 32px; height: 28px; padding: 0 8px;
    border-radius: 6px; font-size: 11px; font-weight: 700;
    text-decoration: none; color: var(--text-secondary);
    background: var(--hover); border: 1px solid var(--border);
}
.lang-btn:hover, .lang-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.auth-box h1 { text-align: center; font-size: 20px; margin-bottom: 20px; }
.auth-form label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--text-secondary); }
.auth-form input {
    display: block; width: 100%; margin-top: 4px;
    padding: 10px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 14px; outline: none;
    background: var(--hover); color: var(--text);
}
.auth-form input:focus { border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.auth-link { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-secondary); }
.alert { padding: 10px 12px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13px; }
.alert-error { background: #fde8e8; color: #c33; border: 1px solid #f5c6c6; }

.fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    text-decoration: none;
    color: var(--primary);
}

/* Settings page */
.settings-page.page-layout {
    display: block;
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow-x: hidden;
}

.settings-page-wrap {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 20px;
    width: 100%;
    max-width: 100%;
    padding: 20px 24px 32px;
    align-items: start;
}

.settings-sidebar {
    padding: 0;
    overflow: hidden;
    position: sticky;
    top: calc(var(--header-height) + 20px);
}

.settings-sidebar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 18px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 14px;
}

.settings-nav { padding: 8px 0; }

.settings-nav-group {
    border-bottom: 1px solid var(--border);
}

.settings-nav-group:last-child { border-bottom: none; }

.settings-nav-link,
.settings-nav-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 18px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
}

.settings-nav-link:hover,
.settings-nav-toggle:hover {
    background: var(--hover);
    color: var(--primary);
    text-decoration: none;
}

.settings-nav-group.active > .settings-nav-link,
.settings-nav-group.active > .settings-nav-toggle,
.settings-nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
}

.settings-nav-icon {
    display: flex;
    color: var(--primary);
    flex-shrink: 0;
}

.settings-nav-chevron {
    margin-left: auto;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.settings-nav-group.open .settings-nav-chevron {
    transform: rotate(90deg);
}

.settings-nav-subs {
    display: none;
    padding: 4px 0 8px 44px;
    border-left: 2px solid var(--border);
    margin-left: 26px;
}

.settings-nav-group.open .settings-nav-subs { display: block; }

.settings-nav-sub {
    display: block;
    padding: 7px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    border-radius: var(--radius);
    margin-right: 12px;
}

.settings-nav-sub:hover,
.settings-nav-sub.active {
    color: var(--primary);
    background: var(--primary-light);
    text-decoration: none;
}

.settings-main {
    padding: 24px 28px;
    min-width: 0;
}

.settings-section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    color: var(--primary);
}

.settings-section-head h1 {
    font-size: 20px;
    color: var(--text);
}

.settings-section-head-row {
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.settings-section-head-row > div {
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-form label.settings-field {
    display: block;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.settings-form label.settings-field > span {
    display: block;
    margin-bottom: 6px;
}

.settings-form input[type="text"],
.settings-form input[type="email"],
.settings-form input[type="password"],
.settings-form input[type="date"],
.settings-form textarea,
.settings-form select,
.settings-privacy-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    font-size: 14px;
}

.settings-input-icon {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 12px;
    background: var(--card);
}

.settings-input-icon input {
    border: none;
    padding: 10px 0;
    flex: 1;
    background: transparent;
}

.settings-field-group { margin-bottom: 24px; }

.settings-field-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
}

.settings-field-label-spaced { margin-top: 24px; }

.settings-hint {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 12px;
}

.settings-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.settings-alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
}

.settings-alert-success {
    background: #e8f7ef;
    color: #1a7f52;
    border: 1px solid #b8e6cf;
}

.settings-alert-error {
    background: #fde8e8;
    color: #c33;
    border: 1px solid #f5c6c6;
}

.settings-warning-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: #fff3e0;
    color: #b26a00;
    margin-bottom: 20px;
    font-size: 13px;
}

.settings-warning-banner-orange {
    background: #ffe8e0;
    color: #c45c3e;
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.settings-toggle-info {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    min-width: 0;
}

.settings-toggle-info strong {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
}

.settings-toggle-info p {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
}

.settings-switch {
    width: 44px;
    height: 24px;
    appearance: none;
    background: #ccc;
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}

.settings-switch::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
}

.settings-switch:checked {
    background: var(--primary);
}

.settings-switch:checked::before {
    transform: translateX(20px);
}

.settings-privacy-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 20px;
}

.settings-privacy-field span {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.settings-table-wrap { overflow-x: auto; }

.settings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.settings-table th,
.settings-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.settings-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
}

.settings-badge-active {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e8f7ef;
    color: var(--primary);
    font-size: 11px;
    font-weight: 600;
}

.btn-danger-outline {
    background: #fff;
    color: #e85d6f;
    border: 1px solid #f5b8c0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-danger-outline:hover {
    background: #fff0f2;
}

.btn-danger-icon {
    background: #fff0f2;
    color: #e85d6f;
    border: 1px solid #f5b8c0;
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.settings-inline-form { display: inline; }

.settings-blocked-list { list-style: none; }

.settings-blocked-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.settings-blocked-main {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
}

.settings-blocked-main:hover {
    color: var(--primary);
    text-decoration: none;
}

.settings-placeholder,
.settings-empty {
    padding: 32px 0;
    text-align: center;
    color: var(--text-muted);
}

.site-footer {
    text-align: center; padding: 24px;
    color: var(--text-muted); font-size: 12px;
}
.footer-inner { display: flex; justify-content: center; gap: 16px; }

/* Reels / Clips viewer */
.reels-page.page-layout {
    display: block;
    margin: 0;
    padding: 0;
    max-width: 100%;
    overflow: hidden;
}

.reels-page .top-header {
    position: relative;
    z-index: 30;
}

.reels-alert {
    margin: 12px 24px 0;
}

.reels-page-empty {
    padding: 0 24px 24px;
}

main.reels-page ~ .fab-bar {
    display: none;
}

/* Reels watch layout — follows site light/dark theme */
.reels-watch {
    display: flex;
    flex-wrap: wrap;
    height: calc(100vh - var(--header-height) - var(--mobile-nav-height));
    min-height: 520px;
    background: var(--bg);
    color: var(--text);
}

.reels-mobile-nav {
    display: none;
}

.reels-watch-sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px 14px;
    background: var(--card);
    border-right: 1px solid var(--border);
}

.reels-watch-brand {
    margin: 0 10px 16px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.reels-watch-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.reels-watch-nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    transition: background 0.15s ease;
}

.reels-watch-nav-item:hover {
    background: var(--hover);
    color: var(--text);
}

.reels-watch-nav-item.is-active {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.reels-watch-nav-icon {
    display: flex;
    color: var(--text-secondary);
}

.reels-watch-nav-item.is-active .reels-watch-nav-icon {
    color: var(--primary);
}

.reels-watch-publish {
    margin-top: auto;
    justify-content: center;
}

.reels-watch-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 12px 20px;
    background: var(--bg);
}

.reels-watch-main-empty {
    justify-content: center;
}

.reels-watch-frame {
    position: relative;
    height: min(calc(100vh - var(--header-height) - 24px), 880px);
    aspect-ratio: 9 / 16;
    max-width: min(420px, calc(100vw - 340px));
    border-radius: 12px;
    overflow: hidden;
    background: #111;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 16px 48px rgba(0, 0, 0, 0.55);
}

.reels-viewport {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    scroll-behavior: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    background: #000;
}

.reels-viewport::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.reel-slide {
    position: relative;
    height: 100%;
    min-height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    overflow: hidden;
    background: #000;
    touch-action: pan-y;
}

.reel-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    touch-action: pan-y;
}

.reel-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #000;
    /* Let vertical swipes scroll the viewport instead of sticking to the video */
    pointer-events: none;
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
}

.reel-video-missing {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #fff;
    font-size: 14px;
    padding: 24px;
    text-align: center;
}

.reel-top-fabs {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.reel-mute-fab {
    position: relative;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(8px);
}

.reel-mute-fab:hover {
    background: rgba(0, 0, 0, 0.65);
}

.reel-autoscroll-btn.is-on {
    background: rgba(34, 160, 107, 0.75);
}

.reel-autoscroll-btn.is-on:hover {
    background: rgba(34, 160, 107, 0.9);
}

.reel-meta {
    position: absolute;
    left: 0;
    right: 64px;
    bottom: 0;
    z-index: 4;
    padding: 14px 14px 18px;
    background: none;
    color: #fff;
    pointer-events: none;
}

.reel-meta a,
.reel-meta button {
    pointer-events: auto;
}

.reel-author-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.reel-author-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.9);
    display: block;
}

.reel-author-text {
    min-width: 0;
    flex: 1;
}

.reel-author-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.reel-author-name {
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.reel-author-name:hover {
    text-decoration: underline;
}

.reel-follow-btn {
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.reel-follow-btn:hover {
    text-decoration: underline;
}

.reel-sound-line {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reel-sound-line .icon-svg {
    flex-shrink: 0;
}

.reel-caption {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.reel-caption-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
}

.reel-caption[data-expanded="1"] .reel-caption-text {
    display: block;
    -webkit-line-clamp: unset;
}

.reel-caption-more {
    display: inline;
    margin-left: 4px;
    border: none;
    background: none;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.reel-actions {
    position: absolute;
    right: 8px;
    bottom: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 5;
}

.reel-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    color: #fff;
    cursor: pointer;
    padding: 0;
    min-width: 48px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.65);
}

.reel-action:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.reel-action-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.28);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

.reel-action-count {
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
}

.reel-like-btn.liked,
.reel-like-btn.liked .reel-action-icon {
    color: #4599ff;
}

.reel-save-btn.is-saved .reel-action-icon {
    color: #f7b928;
}

.reel-more-wrap {
    position: relative;
}

.reel-more-menu {
    position: absolute;
    right: calc(100% + 8px);
    bottom: 0;
    min-width: 180px;
    background: rgba(30, 30, 30, 0.96);
    border-radius: var(--radius-lg);
    padding: 6px 0;
    box-shadow: var(--shadow-lg);
}

.reel-more-menu:not([hidden]) {
    display: block;
}

.reel-more-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    color: #fff;
    font-size: 14px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.reel-more-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.reel-more-danger {
    color: #ff8a9a;
}

.reel-delete-form {
    margin: 0;
}

.reels-watch-rail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}

.reels-rail-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.reels-rail-btn:hover:not(:disabled) {
    background: var(--hover);
}

.reels-rail-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.reel-dislike-btn.disliked,
.reel-dislike-btn.disliked .reel-action-icon {
    color: #ff8a9a;
}

.reel-comments-modal {
    z-index: 1200;
    align-items: stretch;
    justify-content: flex-end;
}

.reel-comments-card {
    width: min(400px, 100%);
    height: 100%;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.reel-comments-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.reel-comments-head h2 {
    margin: 0;
    font-size: 18px;
}

.reel-comments-close {
    border: none;
    background: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
}

.reel-comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reel-comment-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.reel-comment-item img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.reel-comment-body {
    flex: 1;
    min-width: 0;
}

.reel-comment-author {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}

.reel-comment-text {
    margin: 2px 0 0;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.reel-comment-time {
    font-size: 11px;
    color: var(--text-muted);
}

.reel-comments-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 24px 8px;
    font-size: 14px;
}

.reel-comments-form {
    display: flex;
    gap: 8px;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--border);
}

.reel-comments-form input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 10px 14px;
    background: var(--hover);
    color: var(--text);
    outline: none;
}

.reel-share-btn.is-copied::after {
    content: ' ✓';
    font-size: 12px;
}

@media (max-width: 900px) {
    .reels-watch-page {
        --header-height: 0px;
        --mobile-nav-height: 0px;
    }

    body:has(.reels-watch-page) {
        overflow: hidden;
        background: #000;
    }

    body:has(.reels-watch-page) .top-header {
        display: none !important;
    }

    body:has(.reels-watch-page) .fab-bar {
        display: none !important;
    }

    .reels-watch-page.page-layout {
        margin: 0;
        padding: 0;
        max-width: none;
        min-height: 100dvh;
    }

    .reels-watch {
        flex-direction: column;
        height: 100dvh;
        min-height: 0;
    }

    .reels-watch-sidebar {
        display: none;
    }

    .reels-mobile-nav {
        display: none !important;
    }

    .reels-mobile-back {
        display: flex;
        position: absolute;
        top: max(10px, env(safe-area-inset-top));
        left: 10px;
        z-index: 20;
        width: 40px;
        height: 40px;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: rgba(0, 0, 0, 0.45);
        color: #fff;
        text-decoration: none;
        backdrop-filter: blur(8px);
    }

    .reels-watch-main,
    .reels-watch-main-empty {
        flex: 1;
        min-height: 0;
        width: 100%;
    }

    .reels-watch-frame {
        max-width: 100%;
        width: 100%;
        height: 100dvh;
        border-radius: 0;
        aspect-ratio: auto;
        max-height: none;
    }
}

.reels-mobile-back {
    display: none;
}

@media (max-width: 640px) {
    .reels-watch-main {
        padding: 0;
        gap: 0;
        position: relative;
        min-height: 0;
    }

    .reels-watch-frame {
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        border-radius: 0;
        aspect-ratio: auto;
        max-height: none;
    }

    .reels-viewport {
        scroll-snap-type: y mandatory;
        scroll-padding: 0;
    }

    .reel-slide {
        height: 100%;
        min-height: 100%;
        max-height: 100%;
    }

    .reels-watch-rail {
        display: none !important;
    }

    .reel-top-fabs {
        top: max(12px, env(safe-area-inset-top));
        right: 12px;
        left: auto;
        z-index: 10;
    }
}

.profile-clips-strip {
    margin-bottom: 16px;
    padding: 14px 16px;
}

.profile-clips-strip-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.profile-clips-strip-head h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    margin: 0;
}

.profile-clips-strip-more {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
}

.profile-clips-strip-row {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.profile-clips-strip-item {
    flex: 0 0 88px;
    width: 88px;
    height: 140px;
    border-radius: 10px;
    overflow: hidden;
    background: #111;
    display: block;
}

.profile-clips-strip-item img,
.profile-clips-strip-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-clips-strip-missing {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: #8d98a5;
}

.profile-reels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.profile-reel-card {
    position: relative;
    display: block;
    aspect-ratio: 9 / 16;
    border-radius: var(--radius);
    overflow: hidden;
    background: #111;
    text-decoration: none;
    color: #fff;
}

.profile-reel-card video,
.profile-reel-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-reel-stats {
    position: absolute;
    left: 8px;
    bottom: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.55);
    padding: 4px 8px;
    border-radius: 12px;
}

.profile-reel-caption {
    position: absolute;
    left: 8px;
    right: 8px;
    top: 8px;
    font-size: 11px;
    line-height: 1.3;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Clip upload modal (VK-style) */
.clip-upload-modal {
    background: rgba(0, 0, 0, 0.82);
    align-items: center;
    padding: 24px 16px;
}

.clip-upload-modal.is-editing {
    align-items: flex-start;
}

.clip-upload-card {
    width: 100%;
    max-width: 420px;
    color: #e8edf2;
}

.clip-upload-modal.is-editing .clip-upload-card {
    max-width: 980px;
}

.clip-upload-step-pick {
    text-align: center;
    padding: 8px 0 12px;
}

.clip-upload-title {
    margin: 0 0 12px;
    font-size: 22px;
    font-weight: 700;
}

.clip-upload-intro {
    margin: 0 0 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #b6c0cc;
}

.clip-upload-specs {
    margin: 0 0 24px;
    padding-left: 18px;
    color: #9aa6b2;
    font-size: 13px;
    line-height: 1.5;
}

.clip-upload-dropzone {
    padding: 28px 20px 24px;
    margin-bottom: 16px;
    border-radius: 18px;
    background: #2b3038;
}

.clip-upload-dropzone.is-dragover {
    outline: 2px dashed var(--primary);
    outline-offset: 4px;
}

.clip-upload-illustration {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.clip-upload-primary,
.clip-upload-secondary {
    display: block;
    width: 100%;
    border: none;
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.clip-upload-primary {
    background: #e8edf2;
    color: #1a1d21;
}

.clip-upload-primary:hover {
    background: #fff;
}

.clip-upload-secondary {
    margin-top: 12px;
    background: #3a4049;
    color: #e8edf2;
}

.clip-upload-secondary:hover {
    background: #454c57;
}

.clip-author-tips {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #23272e;
    text-align: left;
    font-size: 13px;
    line-height: 1.5;
    color: #b6c0cc;
}

.clip-upload-legal {
    margin: 20px 0 0;
    font-size: 13px;
    line-height: 1.5;
    color: #8d98a5;
}

.clip-upload-legal a {
    color: #5b9cff;
    text-decoration: none;
}

.clip-upload-legal a:hover {
    text-decoration: underline;
}

.clip-upload-step-edit {
    background: #2b3038;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #3a4049;
}

.clip-upload-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #3a4049;
    font-size: 14px;
    color: #c5ced8;
}

.clip-upload-progress-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.clip-upload-close {
    border: none;
    background: transparent;
    color: #9aa6b2;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.clip-upload-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 0;
    min-height: 420px;
}

.clip-upload-main {
    padding: 18px;
    border-right: 1px solid #3a4049;
}

.clip-field {
    display: block;
    margin-bottom: 18px;
}

.clip-field-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
}

.clip-field textarea {
    width: 100%;
    min-height: 96px;
    padding: 12px 14px;
    border: 1px solid #454c57;
    border-radius: 12px;
    background: #23272e;
    color: #e8edf2;
    font-size: 14px;
    resize: vertical;
}

.clip-field textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.clip-upload-cover {
    margin-bottom: 18px;
}

.clip-cover-placeholders {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.clip-cover-slot {
    flex: 0 0 52px;
    width: 52px;
    height: 72px;
    border-radius: 8px;
    background: #23272e center / cover no-repeat;
    border: 2px solid #454c57;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
}

.clip-cover-slot.is-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(34, 160, 107, 0.25);
}

.clip-cover-slot.is-loading {
    cursor: wait;
    opacity: 0.55;
    background: linear-gradient(90deg, #23272e 25%, #2e343d 50%, #23272e 75%);
    background-size: 200% 100%;
    animation: clip-cover-shimmer 1.2s ease-in-out infinite;
}

@keyframes clip-cover-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.clip-cover-slot:disabled {
    cursor: wait;
    opacity: 0.55;
}

.clips-grid-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.clip-cover-hint {
    margin: 10px 0 0;
    font-size: 12px;
    color: #8d98a5;
}

.clip-settings-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.clip-settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid #3a4049;
    font-size: 14px;
}

.clip-settings-item.is-muted {
    color: #8d98a5;
}

.clip-settings-item strong {
    color: #9aa6b2;
    font-weight: 500;
}

.clip-toggle {
    width: 40px;
    height: 22px;
    border: none;
    border-radius: 11px;
    background: #454c57;
    position: relative;
    flex-shrink: 0;
    cursor: pointer;
    padding: 0;
}

.clip-toggle.is-on {
    background: var(--primary);
}

.clip-toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.15s ease;
}

.clip-toggle.is-on::after {
    content: '';
    position: absolute;
    top: 3px;
    left: auto;
    right: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
}

.clip-cover-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.clip-cover-upload-btn {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    margin: 0;
}

.reel-action.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.clip-upload-preview {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.clip-preview-frame {
    position: relative;
    aspect-ratio: 9 / 16;
    border-radius: 12px;
    overflow: hidden;
    background: #111;
}

.clip-preview-frame video,
.clip-preview-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.clip-preview-cover {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: #111;
}

.clip-preview-cover[hidden] {
    display: none !important;
}

.clip-preview-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    text-align: center;
    font-size: 13px;
    color: #c5ced8;
    background: rgba(0, 0, 0, 0.55);
}

.clip-preview-loading[hidden] {
    display: none;
}

.clip-preview-meta {
    margin: 0;
    font-size: 13px;
}

.clip-preview-meta dt {
    color: #8d98a5;
    margin-top: 10px;
}

.clip-preview-meta dt:first-child {
    margin-top: 0;
}

.clip-preview-meta dd {
    margin: 4px 0 0;
    word-break: break-all;
}

.clip-link-muted {
    color: #8d98a5;
}

.clip-upload-legal-side {
    margin-top: auto;
    font-size: 12px;
}

.clip-upload-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-top: 1px solid #3a4049;
}

.clip-delete-draft {
    border: none;
    background: transparent;
    color: #e8edf2;
    font-size: 14px;
    cursor: pointer;
    padding: 8px 0;
}

.clip-delete-draft:hover {
    color: #ff8a9a;
}

.clip-publish-btn {
    border: none;
    border-radius: 12px;
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 600;
    background: #e8edf2;
    color: #1a1d21;
    cursor: pointer;
}

.clip-publish-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.clip-publish-btn:not(:disabled):hover {
    background: #fff;
}

@media (max-width: 860px) {
    .clip-upload-body {
        grid-template-columns: 1fr;
    }

    .clip-upload-main {
        border-right: none;
        border-bottom: 1px solid #3a4049;
    }

    .clip-upload-preview {
        order: -1;
    }

    .clip-preview-frame {
        max-height: 280px;
        width: min(100%, 220px);
        margin: 0 auto;
    }
}

/* Clips hub & stats */
.clips-hub-page.page-layout {
    display: block;
    max-width: 100%;
    padding: 16px 24px 32px;
}

.clips-stats-page.page-layout {
    display: block;
    max-width: 100%;
    padding: 16px 24px 32px;
}

.clips-hub {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
    align-items: start;
}

.clips-hub-main {
    min-width: 0;
}

.clips-hub-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: calc(var(--header-height) + 16px);
}

.clips-author-switcher-wrap {
    position: relative;
}

.clips-author-switcher {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    text-align: left;
    box-shadow: var(--shadow-sm);
}

.clips-author-switcher:hover {
    background: var(--hover-bg);
}

.clips-author-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.clips-author-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.clips-author-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clips-author-open {
    font-size: 12px;
    color: var(--primary);
}

.clips-author-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 40;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 6px 0;
    max-height: 320px;
    overflow-y: auto;
}

.clips-author-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
}

.clips-author-option img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.clips-author-option span:not(.clips-author-check) {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clips-author-option:hover {
    background: var(--hover-bg);
}

.clips-author-option.is-active {
    font-weight: 600;
}

.clips-author-check {
    color: var(--primary);
    flex-shrink: 0;
}

.clips-sidebar-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 14px;
    box-shadow: var(--shadow-sm);
}

.clips-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.clips-sidebar-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

.clips-publish-btn {
    white-space: nowrap;
}

.clips-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.clips-nav-item {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
}

.clips-nav-item:hover {
    background: var(--hover-bg);
}

.clips-nav-item.active {
    background: var(--primary-soft, rgba(34, 139, 34, 0.12));
    color: var(--primary);
    font-weight: 600;
}

.clips-stats-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    color: var(--text);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.clips-stats-link:hover {
    background: var(--hover-bg);
}

.clips-stats-link.active {
    box-shadow: inset 0 0 0 2px var(--primary);
}

.clips-stats-link span:nth-child(2) {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.clips-stats-icon {
    color: var(--primary);
}

.clips-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 420px;
    padding: 48px 24px;
    gap: 16px;
}

.clips-empty-icon {
    color: var(--text-muted);
    opacity: 0.7;
}

.clips-empty-state p {
    margin: 0;
    color: var(--text-muted);
    max-width: 360px;
}

.clips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.clips-grid-card {
    position: relative;
    display: block;
    aspect-ratio: 9 / 16;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #111;
    text-decoration: none;
}

.clips-grid-card video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.clips-grid-missing {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--text-muted);
}

.clips-grid-views {
    position: absolute;
    left: 8px;
    bottom: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 12px;
}

.clips-search-form {
    display: flex;
    gap: 10px;
    padding: 14px;
    margin-bottom: 16px;
}

.clips-search-input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--input-bg, var(--card-bg));
    color: var(--text);
}

.reels-back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    text-decoration: none;
}

.clip-upload-author-note {
    margin: 0 0 12px;
    font-size: 13px;
    color: #b8bec8;
}

.clips-stats-header {
    padding: 16px 18px;
    margin-bottom: 16px;
}

.clips-stats-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.clips-stats-author-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.clips-stats-author-inline img {
    border-radius: 50%;
    object-fit: cover;
}

.clips-stats-open-link {
    display: block;
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
}

.clips-stats-period {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.clips-stats-title {
    margin: 0 0 12px;
    font-size: 22px;
}

.clips-stats-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.clips-stats-tab {
    padding: 8px 14px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
    background: var(--hover-bg);
}

.clips-stats-tab.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.clips-stats-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    padding: 18px;
    margin-bottom: 16px;
}

.clips-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 4px;
}

.clips-metric-value {
    font-size: 22px;
    font-weight: 700;
}

.clips-metric-label {
    font-size: 12px;
    color: var(--text-muted);
}

.clips-stats-chart {
    padding: 18px;
    margin-bottom: 16px;
}

.clips-chart-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.clips-chart-head h2 {
    margin: 0 0 4px;
    font-size: 16px;
}

.clips-chart-head p {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}

.clips-chart-filter,
.clips-chart-filters {
    font-size: 13px;
    color: var(--text-muted);
}

.clips-chart-filters {
    display: flex;
    gap: 10px;
}

.clips-chart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    gap: 10px;
    color: var(--text-muted);
    text-align: center;
}

.clips-chart-empty p {
    margin: 0;
}

@media (max-width: 960px) {
    .clips-hub {
        grid-template-columns: 1fr;
    }

    .clips-hub-sidebar {
        position: static;
        order: -1;
    }
}

/* Mobile top navigation — hidden on desktop */
.mobile-top-nav {
    display: none;
}

/* Responsive */
@media (max-width: 1100px) {
    .page-layout { grid-template-columns: 220px 1fr; }
    .sidebar-right { display: none; }
}

@media (max-width: 768px) {
    :root {
        --header-height: 56px;
        --mobile-nav-height: 52px;
    }

    .top-header {
        border-bottom: none;
    }

    .header-inner {
        padding: 0 12px;
        gap: 10px;
        border-bottom: 1px solid var(--border);
    }

    .logo {
        font-size: 20px;
    }

    .search-form {
        max-width: none;
        flex: 1;
        min-width: 0;
    }

    .search-form input {
        font-size: 14px;
        padding: 8px 12px 8px 36px;
    }

    .profile-menu-btn .icon-svg {
        display: none;
    }

    /* Friends + messages live in top tabs */
    .header-menu-friends,
    .header-menu-messages {
        display: none;
    }

    .mobile-top-nav {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        position: relative;
        top: auto;
        z-index: 1;
        height: var(--mobile-nav-height);
        background: var(--card);
        border-bottom: 1px solid var(--border);
        box-shadow: none;
    }

    .mobile-top-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-width: 0;
        padding: 6px 2px;
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 10px;
        line-height: 1.15;
        position: relative;
    }

    .mobile-top-nav-item:hover {
        color: var(--primary);
        text-decoration: none;
    }

    .mobile-top-nav-item.is-active {
        color: var(--primary);
        font-weight: 600;
    }

    .mobile-top-nav-icon {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-top-nav-badge {
        position: absolute;
        top: -6px;
        right: -10px;
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        border-radius: 999px;
        background: var(--like);
        color: #fff;
        font-size: 10px;
        font-weight: 700;
        line-height: 16px;
        text-align: center;
    }

    .mobile-top-nav-label {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        padding: 0 2px;
    }

    .page-layout {
        grid-template-columns: 1fr;
        margin: 12px 0;
        padding: 0 12px;
        gap: 12px;
    }

    .sidebar-left { display: none; }
    .search-form { max-width: none; }
    .messages-layout { grid-template-columns: 1fr; }
    .dialogs-list { display: none; }

    .fab-bar {
        display: none !important;
    }

    .tg-messages {
        min-height: 0;
        height: calc(100dvh - var(--header-height) - var(--mobile-nav-height));
    }

    .messages-app-page.page-layout {
        margin: 0;
        padding: 0;
    }

    .stories-bar {
        padding: 12px;
    }

    .composer-card {
        padding: 12px;
    }

    .post-card,
    .stories-bar,
    .composer-card,
    .feed-filters {
        border-radius: var(--radius-lg);
    }
}

@media (max-width: 500px) {
    .form-row { grid-template-columns: 1fr; }
    .header-action-btn:nth-child(n+3) { display: none; }

    .search-form input {
        padding-left: 34px;
    }

    .search-form .search-icon {
        left: 10px;
    }
}

/* Profile highlights + highlight modal */
.profile-highlights {
    padding: 14px 16px 10px;
    margin-bottom: 12px;
}

.profile-highlights-list {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.profile-highlight-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: none;
    background: none;
    cursor: pointer;
    flex-shrink: 0;
    max-width: 76px;
    color: var(--text-secondary);
    font-size: 12px;
    padding: 0;
}

.profile-highlight-ring {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: transparent;
    box-sizing: border-box;
}

.profile-highlight-ring img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.profile-highlight-ring.is-create {
    border-style: dashed;
    color: var(--primary);
    background: var(--hover);
}

.profile-highlight-plus,
.profile-highlight-empty {
    display: inline-flex;
    color: var(--primary);
}

.profile-highlight-label {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

.highlight-modal {
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1400;
}

.highlight-modal.open {
    display: flex;
}

.highlight-modal-card {
    position: relative;
    width: min(420px, 100%);
    padding: 22px 20px 18px;
}

.highlight-modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    border: none;
    background: none;
    font-size: 26px;
    cursor: pointer;
    color: var(--text-muted);
}

.highlight-modal-title {
    margin: 0 0 8px;
    font-size: 20px;
}

.highlight-modal-text {
    margin: 0 0 16px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.4;
}

.highlight-pick-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
    max-height: 220px;
    overflow: auto;
}

.highlight-pick-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: var(--radius);
    padding: 8px 10px;
    cursor: pointer;
    text-align: left;
    color: var(--text);
}

.highlight-pick-item:hover {
    border-color: var(--primary);
}

.highlight-pick-item img,
.highlight-pick-fallback {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--hover);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.highlight-create-row {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.highlight-create-row input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
    background: var(--hover);
    color: var(--text);
}

.highlight-modal-actions {
    display: flex;
    justify-content: flex-end;
}

/* Admin panel */
.admin-page .admin-main {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.admin-sidebar {
    padding: 14px 12px;
    position: sticky;
    top: calc(var(--header-height) + var(--mobile-nav-height) + 16px);
}

.admin-sidebar-head {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 4px 8px 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}

.admin-sidebar-head p {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.admin-sidebar-icon {
    color: var(--primary);
    display: inline-flex;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
}

.admin-nav-item:hover {
    background: var(--hover);
    color: var(--text);
}

.admin-nav-item.is-active {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}

.admin-nav-icon {
    display: inline-flex;
    color: var(--primary);
}

.admin-nav-badge {
    margin-left: auto;
    min-width: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--like);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.admin-lead {
    margin: -6px 0 16px;
    color: var(--text-secondary);
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.admin-stat {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.admin-stat-value {
    font-size: 28px;
    line-height: 1.1;
    color: var(--text);
}

.admin-stat-link {
    font-size: 13px;
    margin-top: 4px;
}

.admin-quick {
    padding: 16px 18px;
}

.admin-quick h2 {
    font-size: 16px;
    margin-bottom: 12px;
}

.admin-quick-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.admin-form {
    padding: 16px 18px;
    margin-bottom: 16px;
}

.admin-form h2 {
    font-size: 16px;
    margin-bottom: 12px;
}

.admin-hint {
    margin: 8px 0 14px;
    font-size: 13px;
    color: var(--text-muted);
}

.admin-rewards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px 14px;
    margin-bottom: 14px;
}

.admin-rewards-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
}

.admin-rewards-grid input {
    width: 100%;
}

.admin-packs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.admin-pack-card {
    padding: 12px;
    text-align: center;
}

.admin-pack-card.is-inactive {
    opacity: 0.55;
}

.admin-pack-link {
    display: block;
    color: inherit;
    text-decoration: none;
    margin-bottom: 10px;
}

.admin-pack-link img {
    width: 96px;
    height: 96px;
    object-fit: contain;
    margin: 0 auto 10px;
    display: block;
}

.admin-pack-placeholder {
    width: 96px;
    height: 96px;
    margin: 0 auto 10px;
    display: grid;
    place-items: center;
    color: var(--text-muted);
    background: var(--bg-soft, rgba(0, 0, 0, 0.04));
    border-radius: 12px;
}

.admin-pack-link h3 {
    font-size: 15px;
    margin-bottom: 4px;
}

.admin-stickers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.admin-sticker-card {
    padding: 12px;
    text-align: center;
}

.admin-sticker-card img {
    width: 88px;
    height: 88px;
    object-fit: contain;
    margin: 0 auto 10px;
    display: block;
}

.admin-sticker-card.is-inactive {
    opacity: 0.55;
}

.admin-sticker-card h3 {
    font-size: 14px;
    margin-bottom: 4px;
}

.admin-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.admin-sticker-actions,
.admin-report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.admin-reports-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-report-card {
    padding: 14px 16px;
}

.admin-report-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.admin-report-who {
    display: flex;
    gap: 10px;
    align-items: center;
    min-width: 0;
}

.admin-report-who p {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.admin-report-status {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--hover);
    color: var(--text-secondary);
    white-space: nowrap;
}

.admin-report-status.status-open { background: #fff3cd; color: #856404; }
.admin-report-status.status-reviewing { background: var(--primary-light); color: var(--primary-dark); }
.admin-report-status.status-resolved { background: #d4edda; color: #155724; }
.admin-report-status.status-rejected { background: #f8d7da; color: #721c24; }

.admin-report-details {
    margin: 8px 0;
    color: var(--text);
}

.admin-tabs {
    margin-bottom: 14px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.form-field select,
.form-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    font: inherit;
}

@media (max-width: 900px) {
    .admin-page .admin-main {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: static;
    }

    .admin-nav {
        flex-direction: row;
        overflow-x: auto;
    }

    .admin-nav-item {
        flex-shrink: 0;
    }

    .admin-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 500px) {
    .admin-stats {
        grid-template-columns: 1fr;
    }
}

.admin-economy-users {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.admin-economy-user {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    color: inherit;
    text-decoration: none;
}

.admin-economy-user:hover {
    background: var(--hover);
    color: inherit;
}

.admin-economy-user.is-selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.admin-economy-user p {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.admin-economy-balances {
    margin: 8px 0 14px !important;
    color: var(--text) !important;
}

.admin-ledger {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-ledger-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.admin-ledger-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.admin-ledger-body {
    min-width: 0;
    flex: 1;
}

.admin-ledger-delta {
    display: inline-block;
    margin-left: 8px;
    font-weight: 700;
}

.admin-ledger-delta.is-plus { color: var(--primary-dark); }
.admin-ledger-delta.is-minus { color: var(--like); }

.wallet-lead {
    margin: -4px 0 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

.wallet-balance-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 20px;
    margin-bottom: 16px;
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--primary) 12%, var(--card)), var(--card));
}

.wallet-balance-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.wallet-balance-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.wallet-section {
    padding: 16px 18px;
    margin-bottom: 16px;
}

.wallet-section h2 {
    font-size: 16px;
    margin-bottom: 12px;
}

.wallet-request-list,
.wallet-ledger-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wallet-request-item,
.wallet-ledger-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.wallet-request-item:last-child,
.wallet-ledger-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.wallet-request-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 160px;
    color: inherit;
    text-decoration: none;
}

.wallet-request-user strong {
    display: block;
}

.wallet-request-user small,
.wallet-ledger-row small {
    color: var(--text-muted);
    font-size: 12px;
}

.wallet-request-meta {
    flex: 1;
    min-width: 120px;
}

.wallet-request-meta p {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.wallet-request-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wallet-ledger-row {
    justify-content: space-between;
}

.wallet-ledger-row > div:first-child {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.wallet-ledger-amounts {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.wallet-ledger-delta {
    font-weight: 700;
}

.wallet-ledger-delta.is-plus { color: var(--primary-dark); }
.wallet-ledger-delta.is-minus { color: var(--like); }

.admin-voucher-codes {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-voucher-codes code,
.admin-voucher-row code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
    letter-spacing: 0.04em;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--hover);
}

.admin-voucher-table {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-voucher-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.admin-voucher-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.admin-voucher-row.is-used {
    opacity: 0.7;
}

.admin-voucher-row span {
    color: var(--text-secondary);
    font-size: 13px;
}

.form-field input[type="number"],
.form-field input[type="text"],
.form-field input[type="search"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    font: inherit;
}
