/* ============================================================
   БЭК — Общая тема (iOS Style)
   ============================================================ */

:root {
    /* Тёмная тема (по умолчанию) */
    --bg-primary: #000000;
    --bg-secondary: #0c0c0e;
    --bg-card: #1c1c1e;
    --bg-card-hover: #2c2c2e;
    --bg-input: #1c1c1e;
    --bg-elevated: #2c2c2e;

    --text-primary: #ffffff;
    --text-secondary: #8e8e93;
    --text-tertiary: #636366;
    --text-inverse: #000000;

    --accent: #0a84ff;
    --accent-hover: #409cff;
    --accent-pressed: #0060df;
    --accent-text: #ffffff;

    --success: #30d158;
    --danger: #ff453a;
    --warning: #ff9f0a;

    --separator: rgba(255, 255, 255, 0.08);
    --separator-strong: rgba(255, 255, 255, 0.15);
    --border: rgba(255, 255, 255, 0.1);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    --radius-card: 18px;
--radius-image: 14px;
--radius-pill: 20px;
--card-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

/* Светлая тема */
[data-theme="light"] {
    --bg-primary: #f2f2f7;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f2f2f7;
    --bg-input: #ffffff;
    --bg-elevated: #ffffff;

    --text-primary: #000000;
    --text-secondary: #8e8e93;
    --text-tertiary: #c7c7cc;
    --text-inverse: #ffffff;

    --accent: #007aff;
    --accent-hover: #0a84ff;
    --accent-pressed: #0060df;
    --accent-text: #ffffff;

    --success: #34c759;
    --danger: #ff3b30;
    --warning: #ff9500;

    --separator: rgba(60, 60, 67, 0.1);
    --separator-strong: rgba(60, 60, 67, 0.2);
    --border: rgba(60, 60, 67, 0.15);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.15);

    --radius-card: 18px;
--radius-image: 14px;
--radius-pill: 20px;
--card-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

/* ============================================================
   RESET & BASE
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    min-height: 100dvh;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
                 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
    overscroll-behavior-y: none;
}

body {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

a {
    color: var(--accent);
    text-decoration: none;
}

button, input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
}

input, textarea {
    outline: none;
}

img {
    max-width: 100%;
    display: block;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

.h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.5px; }
.h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.h3 { font-size: 17px; font-weight: 600; letter-spacing: -0.2px; }
.h4 { font-size: 15px; font-weight: 600; }

.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }

/* ============================================================
   LAYOUT
   ============================================================ */

.app-container {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 0 16px;
    padding-top: calc(12px + var(--safe-top));
    padding-bottom: calc(12px + var(--safe-bottom));
    padding-left: calc(16px + var(--safe-left));
    padding-right: calc(16px + var(--safe-right));
}

/* ============================================================
   NAVIGATION BAR (iOS style)
   ============================================================ */

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0 16px;
    gap: 12px;
}

.navbar-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.2px;
    flex: 1;
    text-align: center;
}

.navbar-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    color: var(--accent);
    font-size: 16px;
    transition: background 0.15s;
}
@media (hover: hover) {
.navbar-btn:hover {
    background: var(--bg-card-hover);
}
}

.navbar-btn:active {
    transform: scale(0.94);
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 16px;
}

.card-section {
    padding: 16px;
    border-bottom: 1px solid var(--separator);
}

.card-section:last-child {
    border-bottom: none;
}

/* iOS-style grouped list */
.list-group {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 20px;
}

.list-group-title {
    font-size: 13px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 0 16px 8px;
}

.list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    min-height: 48px;
    border-bottom: 1px solid var(--separator);
    transition: background 0.15s;
}

.list-row:last-child {
    border-bottom: none;
}

.list-row.clickable {
    cursor: pointer;
}

.list-row.clickable:active {
    background: var(--bg-card-hover);
}

.list-row-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    background: var(--accent);
    color: white;
}

.list-row-label {
    flex: 1;
    font-size: 15px;
}

.list-row-value {
    color: var(--text-secondary);
    font-size: 15px;
}

.list-row-chevron {
    color: var(--text-tertiary);
    font-size: 13px;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 20px;
    min-height: 48px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    transition: background 0.15s, transform 0.1s;
    width: 100%;
    border: none;
    cursor: pointer;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-text);
}

@media (hover: hover) {
    .btn-primary:hover:not(:disabled) {
        background: var(--accent-hover);
    }

.btn-secondary {
    background: var(--bg-card);
    color: var(--accent);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-card-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--accent);
}

.btn-ghost:hover {
    background: var(--bg-card-hover);
}
}

.btn-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ============================================================
   INPUTS
   ============================================================ */

.input-group {
    margin-bottom: 16px;
}

.input-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    padding: 0 4px;
    user-select: none;
    -webkit-user-select: none;
}

.input {
    width: 100%;
    padding: 14px 16px;
    min-height: 48px;
    background: var(--bg-input);
    border: 1px solid var(--separator-strong);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    transition: border-color 0.15s, background 0.15s;
    -webkit-appearance: none;
    appearance: none;
}

.input:focus {
    border-color: var(--accent);
    background: var(--bg-card);
}

.input::placeholder {
    color: var(--text-tertiary);
}

/* Автозаполнение — убрать жёлтый/синий фон браузера */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-primary);
    -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset;
    transition: background-color 5000s ease-in-out 0s;
    caret-color: var(--text-primary);
}

/* ============================================================
   AVATARS
   ============================================================ */

.avatar {
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
    min-width: 32px;
    min-height: 32px;
}

.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-md { width: 44px; height: 44px; font-size: 17px; }
.avatar-lg { width: 64px; height: 64px; font-size: 24px; }
.avatar-xl { width: 96px; height: 96px; font-size: 36px; }

/* ============================================================
   TOAST
   ============================================================ */

.toast {
    position: fixed;
    top: calc(16px + var(--safe-top));
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--separator-strong);
    z-index: 9999;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
    pointer-events: none;
    max-width: calc(90% - var(--safe-left) - var(--safe-right));
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-top: calc(20px + var(--safe-top));
    padding-bottom: calc(20px + var(--safe-bottom));
    padding-left: calc(20px + var(--safe-left));
    padding-right: calc(20px + var(--safe-right));
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 20px;
    width: 100%;
    max-width: 400px;
    max-height: 85dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--separator-strong);
    animation: modalIn 0.25s ease;
    overscroll-behavior: contain;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
}

/* ===== Музыка в профиле ===== */
.music-badge {
    font-size: 12px;
    opacity: 0.85;
    cursor: help;
}

/* ============================================================
   UTILITIES
   ============================================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ============================================================
   ADAPTIVE
   ============================================================ */

/* Узкие телефоны */
@media (max-width: 360px) {
    html, body { font-size: 14px; }
    .app-container { padding-left: 12px; padding-right: 12px; }
    .h1 { font-size: 28px; }
    .h2 { font-size: 20px; }
    .btn { font-size: 15px; padding: 13px 16px; }
    .input { font-size: 16px; padding: 13px 14px; } /* 16px оставляем — иначе зум */
}

/* Планшеты и десктоп */
@media (min-width: 768px) {
    .app-container {
        max-width: 720px;
        margin: 0 auto;
        padding-left: 24px;
        padding-right: 24px;
    }
}

@media (min-width: 1024px) {
    .app-container { max-width: 800px; }
}

/* Ландшафт телефона — уменьшить вертикальные отступы */
@media (max-height: 500px) and (orientation: landscape) {
    .modal { padding: 16px; }
    .modal-overlay { padding: 12px; }
    .toast { top: calc(8px + var(--safe-top)); }
}

/* Тёмная тема — автоопределение (если тема не выставлена вручную) */
@media (prefers-color-scheme: light) {
    html:not([data-theme]) {
        /* Если хочешь авто-тему — раскомментируй переменные светлой темы сюда */
    }
}

.post { border-radius: var(--radius-card); box-shadow: var(--card-shadow); }
.post-image { border-radius: var(--radius-image); }
.action-btn { border-radius: var(--radius-pill); }

:root {
    --tab-icon-size: 24px;
    --tab-icon-stroke: 2;
}

.tab-item .tab-icon {
    width: var(--tab-icon-size);
    height: var(--tab-icon-size);
}

.tab-item .tab-icon svg {
    stroke-width: var(--tab-icon-stroke);
}

:root {
    --tab-bounce-ease: cubic-bezier(0.34, 1.56, 0.64, 1);
    --tab-indicator-width: 20px;
    --tab-indicator-height: 3px;
    --accent-gradient-start: #0a84ff;
    --accent-gradient-end: #bf5af2;
}

:root {
    --profile-card-radius: 20px;
    --profile-card-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    --profile-avatar-size: 100px;
}

/* ============================================================
   SKELETON LOADERS
   ============================================================ */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-card) 0%,
        var(--bg-card-hover) 50%,
        var(--bg-card) 100%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Круглый skeleton (для аватарок) */
.skeleton-circle {
    border-radius: 50%;
}

/* Skeleton-строка (текст) */
.skeleton-line {
    height: 12px;
    margin-bottom: 8px;
    border-radius: 6px;
}
.skeleton-line.w-30 { width: 30%; }
.skeleton-line.w-50 { width: 50%; }
.skeleton-line.w-70 { width: 70%; }
.skeleton-line.w-90 { width: 90%; }
.skeleton-line.w-100 { width: 100%; }

/* Skeleton-карточка (пост, диалог) */
.skeleton-card {
    background: var(--bg-card);
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 10px;
}

/* Skeleton-пост (app.html) */
.skeleton-post {
    background: var(--bg-card);
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.skeleton-post-header {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: center;
}

.skeleton-post-body {
    margin-bottom: 12px;
}

/* Skeleton-диалог (messages.html) */
.skeleton-dialog {
    display: flex;
    gap: 12px;
    padding: 12px;
    align-items: center;
    margin-bottom: 4px;
}

.skeleton-dialog-info {
    flex: 1;
    min-width: 0;
}

/* Скрываем skeleton когда контент загружен */
.skeleton-hide {
    display: none !important;
}