:root {
    /* Фирменный градиент MyWay Pro — тот же, что в лого и на входе в админ-панель */
    --accent: #4F8EF7;
    --accent-2: #7B61FF;
    --accent-grad: linear-gradient(135deg, #4F8EF7, #7B61FF);
    --bg: #0a0d16;
    --bg-glow: radial-gradient(900px 480px at 20% -12%, rgba(79,142,247,.20), transparent 60%),
               radial-gradient(700px 420px at 100% 0%, rgba(123,97,255,.16), transparent 55%),
               #0a0d16;
    --card: #141a26;
    --card-2: #1b2333;
    --border: #262f42;
    --text: #f2f4f8;
    --muted: #8b95a7;
    --shadow: 0 10px 28px -12px rgba(0,0,0,.55);
    --glow: 0 0 0 1px rgba(255,255,255,.03), 0 12px 30px -14px rgba(79,142,247,.35);
}
[data-theme="green"]  { --accent: #22c55e; --accent-2: #7ee787; --accent-grad: linear-gradient(135deg, #22c55e, #7ee787); }
[data-theme="purple"] { --accent: #a855f7; --accent-2: #f472b6; --accent-grad: linear-gradient(135deg, #a855f7, #f472b6); }
[data-theme="orange"] { --accent: #f97316; --accent-2: #fbbf24; --accent-grad: linear-gradient(135deg, #f97316, #fbbf24); }

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg-glow);
    background-attachment: fixed;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    padding-bottom: 84px;
    -webkit-font-smoothing: antialiased;
}
.container-app { max-width: 480px; margin: 0 auto; padding: 16px; }

.card {
    background: linear-gradient(180deg, var(--card), var(--card) 60%, var(--card-2));
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
    position: relative;
}
.card-flat { background: var(--card-2); border-radius: 14px; padding: 12px; }

h1, h2, h3 {
    margin: 0 0 8px;
    font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    letter-spacing: -0.2px;
}
h1 { font-weight: 800; }
h2, h3 { font-weight: 700; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: none; border-radius: 14px; padding: 12px 18px;
    font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none;
    transition: transform .1s ease, box-shadow .15s ease, filter .15s ease;
}
.btn-primary {
    background: var(--accent-grad); color: #fff;
    box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--accent) 65%, transparent);
}
.btn-primary:active { transform: translateY(1px) scale(.99); filter: brightness(1.04); }
.btn-outline { background: rgba(255,255,255,.03); color: var(--text); border: 1px solid var(--border); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-vk { background: #0077ff; color: #fff; }
.btn-vk:active { transform: translateY(1px) scale(.99); filter: brightness(1.05); }

.auth-divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: 12.5px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

input[type="text"], input[type="password"], input[type="email"], input[type="file"],
.form-control, .form-select, textarea.form-control {
    width: 100%; background: var(--card-2); border: 1px solid var(--border);
    color: var(--text); border-radius: 12px; padding: 12px 14px; font-size: 15px;
    margin-bottom: 12px; transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, .form-control:focus, .form-select:focus, textarea.form-control:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.top-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.avatar-circle {
    width: 52px; height: 52px; border-radius: 50%; object-fit: cover;
    background: var(--card-2); display: flex; align-items: center; justify-content: center;
    font-size: 22px; padding: 2px;
    background-image: linear-gradient(var(--card-2), var(--card-2)), var(--accent-grad);
    background-origin: border-box; background-clip: content-box, border-box;
    border: 2px solid transparent;
}

.stories-row-wrap { position: relative; }
.stories-row {
    display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 10px; margin-bottom: 16px;
    scrollbar-width: none; -ms-overflow-style: none;
}
.stories-row::-webkit-scrollbar { display: none; height: 0; }
.stories-nav-btn {
    display: none; position: absolute; top: 50%; transform: translateY(-56%);
    width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border);
    background: var(--card); color: var(--text); align-items: center; justify-content: center;
    cursor: pointer; z-index: 2; box-shadow: var(--shadow); font-size: 14px; padding: 0;
}
.stories-nav-btn.is-hidden { display: none !important; }
.stories-nav-prev { left: -4px; }
.stories-nav-next { right: -4px; }
.story-circle {
    flex: 0 0 auto; width: 96px; height: 128px; border-radius: 18px;
    padding: 3px; cursor: pointer;
    background-image: linear-gradient(var(--card-2), var(--card-2)), linear-gradient(135deg, var(--g1, var(--accent)), var(--g2, var(--accent-2)));
    background-origin: border-box; background-clip: padding-box, border-box;
    border: 3px solid transparent;
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
    text-align: center; font-size: 12.5px; overflow: hidden; position: relative;
    transition: transform .12s ease;
    box-shadow: var(--shadow);
}
.story-circle:active { transform: scale(.96); }
.story-circle.viewed {
    background-image: linear-gradient(var(--card-2), var(--card-2)), linear-gradient(135deg, var(--muted), var(--muted));
}
.story-circle img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 15px; }
.story-circle::after {
    content: ""; position: absolute; inset: 0; border-radius: 15px;
    background: linear-gradient(to top, rgba(0,0,0,.75) 0%, rgba(0,0,0,0) 55%);
}
.story-circle span {
    position: relative; z-index: 1; padding: 0 8px 8px; font-weight: 600;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.story-add {
    flex: 0 0 auto; width: 96px; height: 128px; border-radius: 18px;
    border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--border));
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; color: var(--accent);
}

/* ── Полноэкранный просмотр историй ── */
.story-viewer {
    position: fixed; inset: 0; z-index: 100; background: #000;
    display: none; align-items: stretch; justify-content: center;
}
.story-viewer.open { display: flex; }
.story-viewer-body {
    position: relative; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.story-viewer-body img {
    position: relative; z-index: 1; width: 100%; height: 100%;
    object-fit: contain; display: none; transition: opacity .2s ease;
}
.story-viewer-bg {
    position: absolute; inset: -20px; z-index: 0; overflow: hidden;
    background-size: cover; background-position: center;
    filter: blur(28px) brightness(.55) saturate(1.15);
    transform: scale(1.15);
}
.story-viewer-body { z-index: 1; }
.story-viewer-spinner {
    display: none; position: absolute; z-index: 1; width: 34px; height: 34px;
    border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff;
    animation: story-spin .8s linear infinite;
}
@keyframes story-spin { to { transform: rotate(360deg); } }
.story-viewer-scrim {
    position: absolute; left: 0; right: 0; bottom: 0; height: 200px; z-index: 1;
    background: linear-gradient(to top, rgba(0,0,0,.75), rgba(0,0,0,.35) 55%, rgba(0,0,0,0));
    pointer-events: none;
}
.story-viewer-text {
    position: absolute; left: 0; right: 0; bottom: 28px; z-index: 2; color: #fff;
    max-width: 480px; margin: 0 auto; padding: 0 20px;
}
.story-viewer-text h3 { margin: 0 0 6px; font-size: 19px; }
.story-viewer-text p { margin: 0; font-size: 14.5px; line-height: 1.5; color: rgba(255,255,255,.9); }
.story-viewer-progress {
    position: absolute; top: 12px; left: 0; right: 0; z-index: 3;
    display: flex; gap: 5px; max-width: 480px; margin: 0 auto; padding: 0 12px;
}
.story-viewer-seg { flex: 1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.3); overflow: hidden; }
.story-viewer-seg > i { display: block; height: 100%; width: 0; background: #fff; border-radius: 3px; }
.story-viewer-close {
    position: absolute; top: 8px; right: 8px; z-index: 3; width: 40px; height: 40px;
    border: none; background: transparent; color: #fff; font-size: 20px; cursor: pointer;
}
.story-viewer-tap { position: absolute; top: 0; bottom: 0; width: 35%; z-index: 2; cursor: pointer; }
.story-viewer-tap-left { left: 0; }
.story-viewer-tap-right { right: 0; }

/* История без фото — только текст: вместо размытой подложки и текста узкой
   полоской внизу растягиваем на весь экран собственный градиент истории
   (те же цвета, что у её кружка на главной), текст крупно по центру. */
.story-viewer.text-only .story-viewer-bg { filter: none; transform: none; }
.story-viewer.text-only .story-viewer-scrim { display: none; }
.story-viewer.text-only .story-viewer-text {
    position: static; height: 100%; width: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 60px 32px; box-sizing: border-box;
}
.story-viewer.text-only .story-viewer-text h3 { font-size: 28px; margin: 0 0 14px; }
.story-viewer.text-only .story-viewer-text p { font-size: 19px; line-height: 1.6; }

.stat-row { display: flex; gap: 10px; margin-bottom: 14px; }
.stat-tile {
    flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: 18px;
    padding: 16px 10px; text-align: center; box-shadow: var(--shadow);
    transition: transform .12s ease;
}
.stat-tile:active { transform: scale(.97); }
.stat-tile i {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 10px; font-size: 15px;
    background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent);
}
.stat-tile .val { font-size: 16px; font-weight: 800; margin: 8px 0 2px; font-family: "Manrope", sans-serif; }

.ring-wrap { display: flex; flex-direction: column; align-items: center; padding: 18px 0; }
.ring {
    width: 144px; height: 144px; border-radius: 50%; position: relative;
    background: conic-gradient(from -90deg, var(--accent) calc(var(--pct, 0) * 1%), var(--accent-2) calc(var(--pct, 0) * 1%) calc(var(--pct, 0) * 1% + 2%), var(--border) 0);
    filter: drop-shadow(0 8px 20px color-mix(in srgb, var(--accent) 30%, transparent));
}
.ring::after { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: var(--card); }
.ring .ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1; }
.ring .ring-text > div:first-child { font-family: "Manrope", sans-serif; font-weight: 800; }

.week-row { display: flex; justify-content: space-between; margin-top: 10px; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.week-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.week-dot.active { background: var(--accent-grad); box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 55%, transparent); }
.week-dot.today { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.list-item {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--card); border: 1px solid var(--border); border-radius: 16px;
    padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow);
    transition: transform .1s ease;
}
.list-item:active { transform: scale(.99); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }

.badge-status { padding: 3px 10px; border-radius: 100px; font-size: 12px; font-weight: 700; }
.badge-pending  { background: #3b3620; color: #f5c451; }
.badge-approved { background: #123a24; color: #4ade80; }
.badge-rejected { background: #3a1616; color: #f87171; }

.fab {
    position: fixed; right: 20px; bottom: 96px; width: 54px; height: 54px; border-radius: 50%;
    background: var(--accent-grad); color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 24px; box-shadow: 0 10px 26px -6px color-mix(in srgb, var(--accent) 65%, transparent); z-index: 20;
}

.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex; justify-content: space-around; align-items: center;
    background: rgba(16,20,30,.86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
.bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: var(--muted); font-size: 11px; padding: 6px 10px; border-radius: 14px;
    transition: color .15s ease, background .15s ease;
}
.bottom-nav a.active { color: #fff; background: var(--accent-grad); box-shadow: 0 6px 16px -4px color-mix(in srgb, var(--accent) 60%, transparent); }
.bottom-nav a i { font-size: 18px; }

/* ── Красивые загрузчики файлов (аватар / картинка истории) ── */
input.upload-input[type="file"] {
    position: absolute !important; width: 1px !important; height: 1px !important;
    padding: 0 !important; margin: -1px !important; opacity: 0 !important; overflow: hidden !important;
    border: 0 !important; clip: rect(0,0,0,0); white-space: nowrap;
}

.avatar-upload { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px; }
.avatar-upload-circle {
    position: relative; width: 96px; height: 96px; border-radius: 50%;
    background: var(--card-2); border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 34px; color: var(--muted); cursor: pointer; overflow: hidden;
    box-shadow: var(--shadow);
}
.avatar-upload-circle img { width: 100%; height: 100%; object-fit: cover; }
.avatar-upload-badge {
    position: absolute; right: -2px; bottom: -2px; width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent-grad); color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 15px; border: 3px solid var(--bg);
}
.avatar-upload-label { color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; }

.photo-upload-box {
    position: relative; width: 100%; min-height: 180px; border-radius: 16px;
    border: 2px dashed var(--border); background: var(--card-2);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; color: var(--muted); cursor: pointer; overflow: hidden; text-align: center; padding: 16px;
    margin-bottom: 12px;
}
.photo-upload-box.has-image { border-style: solid; border-color: var(--accent); color: transparent; }
.photo-upload-box img {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none;
}
.photo-upload-box.has-image img { display: block; }
.photo-upload-box .upload-icon { font-size: 30px; }
.photo-upload-box .upload-hint { font-size: 12.5px; }
.photo-upload-box.has-image .upload-icon,
.photo-upload-box.has-image .upload-hint { display: none; }
.photo-upload-box .change-badge {
    position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.6); color: #fff;
    font-size: 12px; padding: 5px 10px; border-radius: 100px; display: none; z-index: 1;
}
.photo-upload-box.has-image .change-badge { display: block; }

/* ── Шкала квиза профориентации (-2..+2) ── */
.quiz-scale { display: flex; justify-content: space-between; gap: 6px; }
.quiz-scale-opt {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 10px 0; border-radius: 10px; background: var(--card-2);
    border: 1px solid var(--border); cursor: pointer; font-size: 13px; color: var(--muted);
    transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.quiz-scale-opt:active { transform: scale(.95); }
.quiz-scale-opt input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.quiz-scale-opt:has(input:checked) {
    border-color: var(--accent); color: var(--text);
    background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 18%, var(--card)), var(--card));
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
}
.quiz-scale-labels { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11.5px; color: var(--muted); }

.messages { list-style: none; padding: 0; margin: 0 0 12px; }
.messages li { background: var(--card-2); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 10px; margin-bottom: 8px; font-size: 14px; }

/* ── Адаптация под компьютеры: боковое меню вместо нижнего таб-бара ── */
.side-nav-logo { display: none; }

@media (min-width: 900px) {
    /* На широких экранах старый фон (привязанный градиентами к верхним углам)
       превращался в плоское тёмное пятно по бокам и внизу — растягиваем
       подсветку на весь вьюпорт, чтобы фон оставался живым везде. */
    body {
        padding-bottom: 0; padding-left: 232px;
        background:
            radial-gradient(1100px 700px at 12% -10%, rgba(79,142,247,.20), transparent 60%),
            radial-gradient(900px 650px at 100% 0%, rgba(123,97,255,.18), transparent 58%),
            radial-gradient(900px 650px at 8% 105%, rgba(123,97,255,.14), transparent 58%),
            radial-gradient(1000px 700px at 100% 105%, rgba(79,142,247,.16), transparent 60%),
            var(--bg);
        background-attachment: fixed;
    }
    .container-app { max-width: 720px; margin: 0 auto; padding: 40px 24px 64px; }

    .bottom-nav {
        top: 0; bottom: 0; right: auto; left: 0; width: 232px;
        flex-direction: column; align-items: stretch; justify-content: flex-start;
        gap: 4px; padding: 24px 14px; border-top: none; border-right: 1px solid var(--border);
        background: var(--card);
    }
    .side-nav-logo {
        display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px;
        font-family: "Manrope", sans-serif; font-weight: 800; font-size: 16px; color: var(--text);
    }
    .side-nav-logo .brand-icon {
        width: 34px; height: 34px; border-radius: 10px; object-fit: cover; flex-shrink: 0;
    }
    .bottom-nav a {
        flex-direction: row; justify-content: flex-start; gap: 12px;
        font-size: 14.5px; font-weight: 600; padding: 11px 14px; border-radius: 12px;
    }
    .bottom-nav a i { font-size: 17px; width: 20px; text-align: center; }
    .bottom-nav a.active { box-shadow: none; }

    /* Строки историй/шкалы становятся удобнее на широком экране, но не растягиваются
       безгранично — они и так flex, просто получают больше воздуха. */
    .story-circle, .story-add { width: 108px; height: 140px; }
}

@media (min-width: 900px) and (hover: hover) {
    .bottom-nav a:hover { background: var(--card-2); color: var(--text); }
    .card:hover, .list-item:hover { box-shadow: var(--glow); }

    /* Лента историй на ПК: тонкий скроллбар, перетаскивание мышью и
       стрелки по краям при наведении — иначе прокрутить много историй
       можно было только свайпом, которого на компьютере нет. */
    .stories-row { cursor: grab; scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--accent) 55%, transparent) transparent; }
    .stories-row.is-dragging { cursor: grabbing; scroll-behavior: auto; user-select: none; }
    .stories-row::-webkit-scrollbar { display: block; height: 6px; }
    .stories-row::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 3px; }
    .stories-row::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--accent) 65%, transparent); }
    .stories-row::-webkit-scrollbar-track { background: transparent; }
    .stories-row-wrap:hover .stories-nav-btn:not(.is-hidden) { display: flex; }
    .stories-nav-btn:hover { background: var(--card-2); }
}
