/* ===== ПЕРЕМЕННЫЕ ===== */
:root {
    --bg-primary: #1A1410;
    --bg-secondary: #2A1F1A;
    --bg-card: rgba(42, 31, 26, 0.7);
    --bg-input: rgba(255, 255, 255, 0.03);
    --bg-hover: rgba(230, 161, 122, 0.08);

    --text-primary: #F5E6D3;
    --text-secondary: #B8A89A;
    --text-muted: #7A6A5E;
    --text-inverse: #1A1410;

    --accent-primary: #E6A17A;
    --accent-secondary: #C49B7A;
    --accent-glow: rgba(230, 161, 122, 0.15);

    --border-light: rgba(230, 161, 122, 0.1);
    --border-medium: rgba(230, 161, 122, 0.2);
    --border-focus: rgba(230, 161, 122, 0.4);

    --shadow-card: 0 8px 40px rgba(0, 0, 0, 0.7);
    --shadow-glow: 0 0 30px rgba(230, 161, 122, 0.04);

    --radius-main: 24px 24px 24px 6px;
    --radius-card: 16px 16px 16px 4px;
    --radius-btn: 18px 18px 18px 4px;
    --radius-input: 16px 16px 16px 4px;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Playfair Display', Georgia, serif;

    --transition-speed: 0.2s;
}

/* ===== ОБЩИЕ СТИЛИ ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    background-image: radial-gradient(ellipse at 50% 0%, #2A1F1A 0%, var(--bg-primary) 80%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 16px 12px 30px;
    margin: 0;
}

#app {
    max-width: 420px;
    width: 100%;
}

/* ===== ЭКРАНЫ ===== */
.screen {
    display: none;
    flex-direction: column;
    gap: 14px;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-main);
    padding: 24px 20px 28px;
    box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255, 255, 255, 0.02);
    animation: fadeIn 0.3s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== КНОПКА НАЗАД ===== */
.back-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    align-self: flex-start;
    padding: 4px 0 8px;
    cursor: pointer;
    font-weight: 300;
    letter-spacing: 0.5px;
    transition: var(--transition-speed);
}
.back-btn:active { opacity: 0.4; transform: scale(0.97); }
.back-btn::before { content: "← "; }

/* ===== ТИПОГРАФИКА ===== */
h1 {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 400;
    letter-spacing: 4px;
    color: var(--text-primary);
    margin-bottom: 2px;
}
h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}
.subhead {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: -6px;
    margin-bottom: 4px;
    font-weight: 300;
    letter-spacing: 0.5px;
}

/* ===== ОПЦИИ (СПИСКИ ВЫБОРА) ===== */
.option-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 4px 0 6px;
}
.option-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-btn);
    padding: 14px 18px;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 56px;
    justify-content: center;
    position: relative;
    overflow: hidden;
}
.option-btn:active { transform: scale(0.97); }
.option-btn .main {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.3px;
}
.option-btn .hint {
    font-size: 0.8rem;
    font-weight: 300;
    color: var(--text-muted);
    letter-spacing: 0.2px;
}
.option-btn.selected {
    background: var(--accent-glow);
    border-color: var(--border-medium);
    box-shadow: var(--shadow-glow);
}
.option-btn.selected .main { color: var(--text-primary); }
.option-btn.selected .hint { color: var(--text-secondary); }
.option-btn.custom {
    border-style: dashed;
    border-color: var(--border-light);
    background: transparent;
}
.option-btn.custom .main { color: var(--text-muted); }

/* ===== КНОПКИ ДЕЙСТВИЙ ===== */
.action-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-btn);
    padding: 16px 18px;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-align: center;
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.5px;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}
.action-btn:active {
    transform: scale(0.97);
    opacity: 0.7;
}
.action-btn.primary {
    background: rgba(230, 161, 122, 0.08);
    border-color: var(--border-medium);
    box-shadow: var(--shadow-glow);
}
.action-btn.secondary {
    background: rgba(255, 255, 255, 0.01);
    border-color: var(--border-light);
}
.action-btn.accent {
    background: rgba(230, 161, 122, 0.12);
    border-color: rgba(230, 161, 122, 0.25);
}
.action-btn.skip {
    background: transparent;
    border-color: var(--border-light);
    border-style: dashed;
    color: var(--text-muted);
}
.action-btn .icon {
    font-size: 1.1rem;
    color: var(--text-primary);
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}
.action-btn.skip .icon { color: var(--text-muted); }

/* ===== ПОЛЯ ВВОДА ===== */
.input-field {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-input);
    padding: 16px 18px;
    font-size: 1rem;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-weight: 300;
    min-height: 110px;
    resize: vertical;
    width: 100%;
    transition: var(--transition-speed);
    line-height: 1.7;
}
.input-field:focus {
    border-color: var(--border-focus);
    outline: none;
    box-shadow: 0 0 24px rgba(230, 161, 122, 0.04);
}
.input-field::placeholder {
    color: var(--text-muted);
    font-weight: 300;
}

/* ===== КАРТОЧКИ ===== */
.summary-card,
.preview-card,
.feed-card,
.moderation-card,
.union-card {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-card);
    padding: 22px 20px;
}
.summary-card .fantasy-text,
.preview-card .text,
.feed-card .text,
.moderation-card .text {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
    font-weight: 300;
    letter-spacing: 0.3px;
}

/* ===== ТЕГИ ===== */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}
.tags span,
.tag-cloud .tag-item,
.filter-bar .filter-btn,
.profile-selector .profile-tag {
    background: rgba(230, 161, 122, 0.04);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 4px 14px;
    font-size: 0.7rem;
    color: var(--accent-primary);
    font-weight: 300;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: var(--transition-speed);
}
.tags span:hover,
.tag-cloud .tag-item:hover,
.filter-bar .filter-btn:hover,
.profile-selector .profile-tag:hover {
    background: rgba(230, 161, 122, 0.08);
}
.tag-cloud .tag-item.selected,
.filter-bar .filter-btn.active,
.profile-selector .profile-tag.active {
    background: rgba(230, 161, 122, 0.08);
    border-color: var(--border-medium);
    color: var(--text-primary);
}

/* ===== ЛЕНТА (ПОСТЫ) ===== */
.feed-card {
    margin-bottom: 14px;
    transition: var(--transition-speed);
}
.feed-card .post-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.feed-card .post-header .avatar {
    font-size: 1.6rem;
    width: 36px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-speed);
}
.feed-card .post-header .avatar:active { transform: scale(0.9); }
.feed-card .post-header .name {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.3px;
    cursor: pointer;
}
.feed-card .post-header .date {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: auto;
}
.feed-card .text { font-size: 0.95rem; line-height: 1.7; }
.feed-card .tags span {
    background: rgba(230, 161, 122, 0.03);
    border: 1px solid rgba(230, 161, 122, 0.03);
    padding: 3px 12px;
    border-radius: 14px;
    font-size: 0.65rem;
    color: var(--accent-primary);
}
.feed-card .reactions {
    display: flex;
    gap: 14px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 300;
    flex-wrap: wrap;
}
.feed-card .reactions span {
    cursor: pointer;
    transition: var(--transition-speed);
    padding: 4px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-light);
    user-select: none;
}
.feed-card .reactions span:active { transform: scale(0.95); }
.feed-card .reactions span.active {
    background: var(--accent-glow);
    border-color: var(--border-medium);
    color: var(--text-primary);
}
.feed-card .reactions span.disabled {
    opacity: 0.3;
    pointer-events: none;
}
.feed-card .actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.feed-card .actions .mini-btn {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 6px 14px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-speed);
    font-weight: 300;
    letter-spacing: 0.3px;
    flex: 1;
    text-align: center;
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.feed-card .actions .mini-btn:active {
    transform: scale(0.97);
    background: var(--bg-hover);
}
.feed-card .favorite-btn {
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: var(--transition-speed);
    margin-left: auto;
}
.feed-card .favorite-btn.active { color: var(--accent-primary); }

/* ===== ПОИСК, ФИЛЬТРЫ ===== */
.search-box {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 18px 18px 18px 4px;
    padding: 12px 18px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 300;
    width: 100%;
    transition: var(--transition-speed);
    font-family: var(--font-family);
}
.search-box:focus {
    border-color: var(--border-focus);
    outline: none;
    box-shadow: 0 0 24px rgba(230, 161, 122, 0.04);
}
.search-box::placeholder { color: var(--text-muted); }

.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 4px 0 6px;
}
.filter-bar .filter-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 30px;
    padding: 6px 16px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-speed);
}
.filter-bar .filter-btn:active { transform: scale(0.95); }
.filter-bar .filter-btn.active {
    background: var(--accent-glow);
    border-color: var(--border-medium);
    color: var(--text-primary);
}

/* ===== БЛОКИ (КОНСТРУКТОР) ===== */
.block-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.block-item {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 16px 16px 16px 4px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: var(--transition-speed);
}
.block-item:active { transform: scale(0.97); }
.block-item .block-label {
    font-size: 0.9rem;
    font-weight: 300;
    color: var(--text-primary);
}
.block-item .block-status {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.block-item .block-status.done { color: var(--accent-primary); }

/* ===== ДИАЛОГ ===== */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.dialog-overlay.active { display: flex; }
.dialog-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-main);
    padding: 28px 24px;
    max-width: 340px;
    width: 100%;
    box-shadow: var(--shadow-card);
    animation: dialogIn 0.25s ease;
}
@keyframes dialogIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}
.dialog-box .dialog-icon {
    font-size: 2rem;
    color: var(--accent-primary);
    text-align: center;
    margin-bottom: 12px;
}
.dialog-box .dialog-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.dialog-box .dialog-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    font-weight: 300;
    margin-bottom: 18px;
    line-height: 1.5;
}
.dialog-box .dialog-actions {
    display: flex;
    gap: 10px;
}
.dialog-box .dialog-actions .action-btn { flex: 1; min-height: 44px; padding: 12px; }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(42, 31, 26, 0.9);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: 18px 18px 18px 4px;
    padding: 14px 28px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 300;
    box-shadow: var(--shadow-card);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 999;
    max-width: 90%;
    text-align: center;
    letter-spacing: 0.3px;
}
.toast.show { opacity: 1; pointer-events: auto; }

/* ===== ПРОФИЛЬ ===== */
.profile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.profile-header .avatar { font-size: 3.2rem; }
.profile-header .info { flex: 1; }
.profile-header .info .name {
    font-size: 1.2rem;
    font-weight: 400;
}
.profile-header .info .username {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.profile-header .info .birth {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.profile-stats {
    display: flex;
    gap: 12px;
    margin: 8px 0;
    flex-wrap: wrap;
}
.profile-stats .stat {
    background: var(--bg-input);
    border-radius: 12px;
    padding: 8px 14px;
    text-align: center;
    flex: 1;
    min-width: 60px;
}
.profile-stats .stat .num {
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--text-primary);
}
.profile-stats .stat .label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* ===== УВЕДОМЛЕНИЯ, БЭДЖИ ===== */
.notification-btn {
    position: relative;
    background: var(--bg-input);
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition-speed);
}
.notification-btn:active { transform: scale(0.9); }
.notification-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--accent-primary);
    color: var(--bg-primary);
    font-size: 0.6rem;
    font-weight: 600;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.notification-btn .badge.hidden { display: none; }

/* ===== КНОПКА ПРОФИЛЯ В ШАПКЕ ===== */
.profile-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 30px;
    transition: var(--transition-speed);
}
.profile-btn:active { transform: scale(0.95); }
.profile-btn .avatar-small { font-size: 1.4rem; }
.profile-btn .name-small { font-size: 0.8rem; font-weight: 300; }

/* ===== ЧЕКБОКС ===== */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}
.checkbox-group input[type="checkbox"] {
    accent-color: var(--accent-primary);
    width: 18px;
    height: 18px;
    cursor: pointer;
}
.checkbox-group label {
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
}

/* ===== КАРТОЧКИ СОЮЗОВ ===== */
.union-card {
    margin-bottom: 10px;
}
.union-card .members {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0;
}
.union-card .members .member {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-input);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
}
.union-card .members .member .avatar { font-size: 1.2rem; }
.union-card .union-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}
.union-card .union-actions .mini-btn {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 4px 12px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-speed);
    flex: 1;
    text-align: center;
}
.union-card .union-actions .mini-btn:active {
    transform: scale(0.95);
    background: var(--bg-hover);
}

/* ===== ПРОФИЛЬ-СЕЛЕКТОР ===== */
.profile-selector {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin: 6px 0;
}
.profile-selector .profile-tag {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-speed);
}
.profile-selector .profile-tag:active { transform: scale(0.95); }
.profile-selector .profile-tag.active {
    background: var(--accent-glow);
    border-color: var(--border-medium);
    color: var(--text-primary);
}

/* ===== КАРТОЧКИ МОДЕРАЦИИ ===== */
.moderation-card {
    margin-bottom: 14px;
}
.moderation-card .author-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.moderation-card .author-info .avatar { font-size: 1.4rem; }
.moderation-card .author-info .name { font-size: 0.8rem; color: var(--text-secondary); }
.moderation-card .mod-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.moderation-card .mod-actions .action-btn {
    flex: 1;
    min-height: 38px;
    padding: 8px;
    font-size: 0.8rem;
}

/* ===== АВАТАРЫ ПРИ СОЗДАНИИ ПРОФИЛЯ ===== */
.avatar-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin: 8px 0 12px;
}
.avatar-grid .avatar-option {
    font-size: 2.4rem;
    padding: 8px 12px;
    border-radius: 16px;
    background: var(--bg-input);
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition-speed);
    user-select: none;
}
.avatar-grid .avatar-option:active { transform: scale(0.95); }
.avatar-grid .avatar-option.selected {
    border-color: var(--accent-primary);
    background: var(--accent-glow);
}
.profile-avatar {
    font-size: 4rem;
    text-align: center;
    margin-bottom: 8px;
}

/* ===== ВСПОМОГАТЕЛЬНЫЕ КЛАССЫ ===== */
.muted {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 300;
}
.hidden { display: none !important; }

/* ===== АДАПТИВ ===== */
@media (max-width: 400px) {
    .screen { padding: 18px 14px 22px; }
    h1 { font-size: 1.8rem; letter-spacing: 3px; }
    h2 { font-size: 1.3rem; }
    .option-btn { padding: 12px 14px; min-height: 48px; }
    .option-btn .main { font-size: 0.9rem; }
    .option-btn .hint { font-size: 0.7rem; }
    .action-btn { padding: 14px 14px; font-size: 0.9rem; min-height: 44px; }
    .block-item { padding: 10px 14px; }
    .block-item .block-label { font-size: 0.8rem; }
    .dialog-box { padding: 24px 20px; }
    .feed-card { padding: 14px 12px; }
    .search-box { font-size: 0.85rem; padding: 10px 14px; }
    .tag-cloud .tag-item { font-size: 0.7rem; padding: 4px 10px; }
    .avatar-grid .avatar-option { font-size: 1.8rem; padding: 6px 10px; }
    .profile-header .avatar { font-size: 2.4rem; }
    .profile-btn .avatar-small { font-size: 1.2rem; }
    .profile-btn .name-small { font-size: 0.7rem; }
    .notification-btn { font-size: 1rem; }
    .filter-bar .filter-btn { font-size: 0.65rem; padding: 4px 12px; }
}

/* ===== ПРОФИЛЬ — КНОПКИ ДЕЙСТВИЙ ===== */
.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}