:root {
    --bg-gradient: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-secondary: #a0a0a0;
    --accent: #ffd700;
    --nav-bg: rgba(15, 12, 41, 0.95);
    --error-color: #ff6b6b;
}
[data-theme="purple"] { --bg-gradient: linear-gradient(135deg, #240b36, #c31432); --accent: #ff00cc; }
[data-theme="ocean"] { --bg-gradient: linear-gradient(135deg, #001f3f, #005f73, #0a9396); --accent: #00ffff; }

/* --- ТЕМА NORDIC (Норвежский Минимализм) --- */
[data-theme="nordic"] {
    --bg-gradient: linear-gradient(180deg, #18191A, #2C2E31); /* Матовый графит */
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #Eaeaea;
    --text-secondary: #8b959e;
    --accent: #D6D6D6; /* Холодный белый/стальной */
    --nav-bg: #18191A;
    --error-color: #ff6b6b;

    /* Переопределяем радиусы для утилитарности */
    --radius-card: 4px;
    --radius-btn: 2px;
}

/* Специфичные стили для Nordic */
[data-theme="nordic"] * {
    letter-spacing: 0.5px; /* Воздух в тексте */
}

[data-theme="nordic"] .card,
[data-theme="nordic"] .btn,
[data-theme="nordic"] input,
[data-theme="nordic"] select,
[data-theme="nordic"] .widget,
[data-theme="nordic"] .bottom-nav,
[data-theme="nordic"] .nav-item,
[data-theme="nordic"] .modal {
    border-radius: var(--radius-card);
    border: 1px solid var(--glass-border);
    box-shadow: none; /* Убираем свечение, оставляем плоскость */
}

[data-theme="nordic"] .btn {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 1.5px;
}

[data-theme="nordic"] .btn:active {
    background: var(--accent);
    color: #000;
}

[data-theme="nordic"] .breathing-circle {
    border: 1px solid var(--accent);
    background: transparent;
    box-shadow: none;
}

/* ОБЕСЦВЕЧИВАНИЕ ЭМОДЗИ (Делаем их строгими) */
[data-theme="nordic"] .emoji-fix,
[data-theme="nordic"] h1,
[data-theme="nordic"] h2,
[data-theme="nordic"] h3,
[data-theme="nordic"] .nav-item span, /* Иконки меню */
[data-theme="nordic"] .planet-row span /* Иконки планет */
{
    filter: grayscale(100%) contrast(110%); /* Ч/Б стиль */
}

/* Убираем звезды в этой теме (лишний шум) */
[data-theme="nordic"] .star {
    display: none;
}
/* Вместо звезд добавляем "шум" или туман (опционально) */
[data-theme="nordic"] body::before {
    content: "";
    position: fixed;
    top:0; left:0; width:100%; height:100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: -1;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; }

body {
    background: var(--bg-gradient);
    background-attachment: fixed;

    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;

    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    height: var(--tg-viewport-height, 100vh);

    overflow: hidden;
    display: flex;
    flex-direction: column;

    z-index: 0;
}

/* Звезды */
.stars {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.8;
}
.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle infinite ease-in-out;
    will-change: transform, opacity; /* <--- ВАЖНО: Включает GPU ускорение */
}
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(0.5); } 50% { opacity: 1; transform: scale(1.2); } }

/* Страницы */
.page { display: none; animation: fadeIn 0.4s forwards; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* UI Элементы */
.card { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 24px; padding: 20px; margin-bottom: 12px; backdrop-filter: blur(20px); }
h1, h2, h3 { margin: 0 0 10px 0; font-weight: 600; }
h1 { font-size: 28px; }
p { color: #ddd; margin: 0; font-size: 15px; line-height: 1.5; }

/* Шапка профиля */
.profile-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 30px; }
.profile-info { display: flex; align-items: center; gap: 15px; }

.avatar-box {
    width: 56px; height: 56px; border-radius: 50%;
    background: rgba(255,255,255,0.1); border: 2px solid var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: bold; color: white; cursor: pointer;
    overflow: hidden;
}
.avatar-box img { width: 100%; height: 100%; object-fit: cover; }

.user-name h2 { font-size: 20px; margin: 0; }
.user-name span { font-size: 13px; color: var(--accent); opacity: 0.9; }

.settings-btn { width: 44px; height: 44px; border-radius: 14px; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); display: flex; align-items: center; justify-content: center; cursor: pointer; color: white; }

/* Виджеты */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.widget { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 20px; padding: 16px; height: 110px; display: flex; flex-direction: column; justify-content: space-between; }
.widget-value { font-size: 17px; font-weight: 700; color: white; }

/* Кнопки и инпуты */
.btn { background: var(--accent); color: #1a1a2e; border: none; padding: 14px; border-radius: 16px; font-size: 16px; font-weight: 600; width: 100%; cursor: pointer; margin-top: 20px; transition: opacity 0.2s; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

label { display: block; margin: 15px 0 8px; font-size: 14px; color: var(--text-secondary); }
input, select { width: 100%; padding: 14px 16px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; color: white; font-size: 16px; }

/* --- МОДАЛЬНОЕ ОКНО (PROFILE) --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;

    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);

    z-index: 10000; /* Подняли Z-Index до небес, чтобы точно было сверху */

    display: flex; /* Всегда flex, чтобы центровка работала */
    align-items: flex-end;
    justify-content: center;

    /* НОВАЯ ЛОГИКА СКРЫТИЯ (Вместо display: none) */
    visibility: hidden;
    opacity: 0;
    pointer-events: none; /* Чтобы клики проходили сквозь скрытое окно */

    transition: opacity 0.3s ease, visibility 0.3s;
}

/* Когда активно - делаем видимым */
.modal-overlay.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.modal {
    width: 100%;
    max-width: 600px;

    background: rgba(20, 20, 25, 0.95);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);

    border: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: none;
    border-radius: 24px 24px 0 0;

    /* Добавляем отступ для iPhone (полоска снизу) */
    padding: 30px 24px 50px 24px;
    padding-bottom: calc(50px + env(safe-area-inset-bottom));

    transform: translateY(100%); /* Исходно убрано вниз */
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);

    box-shadow: 0 -10px 40px rgba(0,0,0,0.6);

    max-height: 90vh;
    overflow-y: auto;
}

/* Когда оверлей активен - выдвигаем окно */
.modal-overlay.active .modal {
    transform: translateY(0);
}

/* --- ДЫХАНИЕ --- */
.breathing-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 0;
}

.breathing-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    box-shadow: 0 0 30px var(--accent);
    opacity: 0.6;
    transform: scale(1);
    transition: all 0.3s ease;
}

/* Класс для анимации */
.breathing-active {
    animation: breathe 12s infinite ease-in-out; /* Цикл 12 секунд (4 вдох, 4 задержка, 4 выдох) */
}

@keyframes breathe {
    0% { transform: scale(1); opacity: 0.4; }    /* Выдох */
    35% { transform: scale(1.8); opacity: 1; }   /* Вдох */
    65% { transform: scale(1.8); opacity: 1; }   /* Задержка */
    100% { transform: scale(1); opacity: 0.4; }  /* Выдох */
}

.breath-instruction {
    margin-top: 20px;
    font-size: 18px;
    font-weight: bold;
    min-height: 24px;
    transition: opacity 0.5s;
}

/* АНИМАЦИЯ ЗАГРУЗКИ (SKELETON) */
@keyframes pulse-opacity {
    0% { opacity: 0.4; }
    50% { opacity: 0.8; }
    100% { opacity: 0.4; }
}

.loading-pulse {
    animation: pulse-opacity 1.5s infinite ease-in-out;
    color: var(--accent);
    font-weight: 500;
    text-align: center;
    padding: 10px;
}

/* --- 1. ФИКС ДЛЯ iOS INPUTS --- */
input[type="date"],
input[type="time"],
select {
    -webkit-appearance: none; /* Убирает стандартный стиль iOS */
    appearance: none;
    background-color: rgba(255,255,255,0.05);
    color: white;
    font-family: inherit;
    font-size: 16px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    width: 100%;
    display: block;
    margin-bottom: 10px;
}

/* Кастомная стрелочка для Select */
.select-wrapper {
    position: relative;
    margin-bottom: 15px;
}

select {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.03); /* Почти прозрачный */
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 16px;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
}

select:focus {
    border-color: var(--accent); /* Подсветка рамки при выборе */
}

/* --- 2. СТИЛИЗАЦИЯ ЭМОДЗИ (Muted Gold Style) --- */

#daily-advice-text,
.widget-value,
.planet-row span:first-child,
#tarot-result {
}


/* --- 3. UI И СИММЕТРИЯ --- */
/* Центровка заголовков */
h1, h2, h3 {
    text-align: center;
    letter-spacing: 0.5px;
}

#app-container {
    flex: 1;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;

    padding: 20px 20px 160px 20px;

    max-width: 600px;
    width: 100%;
    margin: 0 auto;

    background: transparent;

    scrollbar-width: none;
    z-index: 1;
    position: relative;
}
#app-container::-webkit-scrollbar { display: none; /* Chrome/Safari */ }


/* --- МЕНЮ (Floating Dock) --- */
.bottom-nav {
    position: fixed; /* Жестко к экрану, а не к контейнеру */
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%); /* Всегда по центру экрана */

    width: 90%;
    max-width: 380px;
    height: 65px;

    background: rgba(18, 18, 24, 0.85);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);

    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px;

    display: flex;
    justify-content: space-between;
    padding: 0 10px;

    box-shadow: 0 15px 35px rgba(0,0,0,0.4);
    z-index: 1000; /* Ниже чем Модалка */
}

/* Анимация нажатия на пункты меню */
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;

    color: rgba(255, 255, 255, 0.4);
    transition: color 0.2s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.nav-item span {
    font-size: 10px;
    margin-top: 4px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* АКТИВНЫЙ ПУНКТ (Без фона, только цвет) */
.nav-item.active {
    color: var(--accent);
    background: transparent;
    transform: none;
    box-shadow: none;
}

/* Добавляем полоску-индикатор сверху*/
.nav-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    width: 20px;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 8px var(--accent);
}

/* --- БИОРИТМЫ --- */
.bio-row { margin-bottom: 15px; }

.bio-label {
    display: flex; justify-content: space-between;
    font-size: 13px; margin-bottom: 6px; font-weight: 500;
}

.progress-bg {
    width: 100%; height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px; overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease-out;
    box-shadow: 0 0 10px rgba(255,255,255,0.2);
}

/* --- АВТОПОИСК ГОРОДОВ --- */
.autocomplete-container {
    position: relative;
    width: 100%;
    margin-bottom: 15px;
}

.autocomplete-items {
    position: absolute;
    border: 1px solid var(--glass-border);
    border-bottom: none;
    border-top: none;
    z-index: 99;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a1a2e; /* Плотный фон, чтобы не просвечивало */
    border-radius: 0 0 12px 12px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.autocomplete-items div {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: var(--text-main);
    font-size: 15px;
}

.autocomplete-items div:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Скроллбар для списка */
.autocomplete-items::-webkit-scrollbar {
    width: 6px;
}
.autocomplete-items::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

/* Кнопки календаря */
.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 12px;
    border-radius: 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: center;
}

.btn-secondary:active {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(0.98);
}

ul {
    list-style-type: disc;
}
li {
    margin-bottom: 4px;
}

/* ACCORDION */
.accordion-item {
    cursor: pointer;
    transition: background 0.2s;
}
.accordion-item:active {
    background: rgba(255,255,255,0.05);
}
.accordion-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
}
.accordion-content {
    max-height: 0;
    overflow: hidden;
    padding: 0 15px;
    transition: max-height 0.3s ease-out, padding 0.3s;
    background: rgba(0,0,0,0.2);
}
.accordion-content.open {
    max-height: 1500px;
    padding: 0 15px 15px 15px;
}
.arrow {
    font-size: 10px;
    opacity: 0.5;
    transition: transform 0.3s;
}
.accordion-item.active .arrow {
    transform: rotate(180deg);
}
.content-text {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 10px;
    white-space: pre-wrap;
    opacity: 0.9;
}

/* Radio Buttons Custom Style */
.radio-box {
    flex: 1;
    cursor: pointer;
    position: relative;
}
.radio-box input {
    display: none;
}
.radio-box span {
    display: block;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    text-align: center;
    font-size: 14px;
    transition: all 0.2s;
}
.radio-box input:checked + span {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    font-weight: 600;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}