:root {
    --bg: #ffffff;
    --bg-soft: #f4f4f2;
    --text: #121212;
    --text-muted: #6b6b66;
    --bubble: #f0efeb;
    --bubble-border: rgba(18, 18, 18, 0.06);
    --glass: rgba(255, 255, 255, 0.62);
    --glass-border: rgba(18, 18, 18, 0.08);
    --accent: #e3a008;
    --accent-ink: #8a5a00;
    --shadow: 0 10px 30px rgba(18, 18, 18, 0.06);
    --header-offset: 14px;
    --header-h: 78px;
    --timer-h: 188px;
    --radius: 22px;
    --radius-pill: 999px;
    --font-brand: "Syne", sans-serif;
    --font-body: "Manrope", sans-serif;
    --font-news: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
    color-scheme: light;
}

html[data-theme="dark"] {
    --bg: #0c0c0c;
    --bg-soft: #161616;
    --text: #f3f2ee;
    --text-muted: #9a9a94;
    --bubble: #1a1a1a;
    --bubble-border: rgba(243, 242, 238, 0.08);
    --glass: rgba(22, 22, 22, 0.58);
    --glass-border: rgba(243, 242, 238, 0.12);
    --accent: #f0b429;
    --accent-ink: #f6d37a;
    --shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--bg);
}

.feed {
    position: relative;
    flex: 1;
    width: min(720px, 100%);
    margin: 0 auto;
    padding: 12px 16px calc(var(--timer-h) + 20px);
}

/* жёлтое свечение всегда у верха экрана, не уезжает с подгрузкой */
.page::before {
    content: "";
    position: fixed;
    left: 50%;
    top: 0;
    width: min(1200px, 160vw);
    height: 380px;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 0;
    background: radial-gradient(
        ellipse 70% 55% at 50% 0%,
        color-mix(in srgb, var(--accent) 18%, transparent),
        transparent 70%
    );
}

.page > * {
    position: relative;
    z-index: 1;
}

.feed::before {
    display: none;
}

.feed > * {
    position: relative;
    z-index: 1;
}

body.timer-off {
    --timer-h: 24px;
}

.page {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.glass-bubble {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
}

.top {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: center;
    padding: var(--header-offset) 16px 8px;
    pointer-events: none;
}

.brand {
    pointer-events: auto;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    margin: 0;
    border: 0;
    cursor: pointer;
    color: var(--text);
    padding: 8px 18px 8px 12px;
    border-radius: var(--radius-pill);
    font: inherit;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.brand-main {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.brand:hover {
    transform: translateY(-1px);
}

.brand:active {
    transform: translateY(0);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    color: #111;
    background: linear-gradient(145deg, #ffd45a, var(--accent));
    box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 35%, transparent);
    animation: brandPulse 3.6s ease-in-out infinite;
}

.brand-name {
    font-family: var(--font-brand);
    font-weight: 800;
    font-size: clamp(1.35rem, 4vw, 1.7rem);
    letter-spacing: -0.04em;
    line-height: 1;
}

.brand-tip {
    display: block;
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1.2;
    color: var(--text-muted);
    letter-spacing: 0.01em;
    opacity: 0.95;
    max-height: 1.5em;
    overflow: hidden;
    transform: translateY(0);
    transform-origin: top center;
    transition:
        opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        max-height 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        margin 0.55s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: opacity, transform, max-height;
}

.brand-tip.is-hidden {
    opacity: 0;
    transform: translateY(-10px);
    max-height: 0;
    margin: 0;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .brand-tip {
        transition: opacity 0.2s ease, max-height 0.2s ease;
        transform: none;
        will-change: auto;
    }

    .brand-tip.is-hidden {
        transform: none;
    }
}

.feed-status {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    padding: 28px 0;
}

.feed-status[hidden],
[hidden] {
    display: none !important;
}

.top-sentinel {
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 4px 0 10px;
}

.top-sentinel.is-loading,
.top-sentinel.is-end {
    min-height: 36px;
}

.bubbles {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.bubble {
    background: var(--bubble);
    border: 1px solid var(--bubble-border);
    border-radius: var(--radius);
    padding: 16px 18px 14px;
    box-shadow: var(--shadow);
    animation: bubbleIn 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
    transform-origin: center top;
}

.bubble.is-new {
    outline: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
}

.bubble-text {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font-news);
    font-optical-sizing: auto;
    font-size: 1.125rem;
    line-height: 1.65;
    font-weight: 400;
    letter-spacing: 0.005em;
}

.bubble-meta {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.bubble-meta a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
}

.bubble-meta a:hover {
    color: var(--accent-ink);
    text-decoration: underline;
}

.bubble-date {
    margin-left: auto;
    text-align: right;
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    opacity: 0.2;
}

.badge-source {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s ease, opacity 0.15s ease;
}

.badge-source:hover {
    color: var(--accent-ink);
    text-decoration: underline;
    opacity: 1;
}

.badge:has(.badge-source:hover) {
    opacity: 1;
}

.timer-wrap {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    justify-content: center;
    padding: 0 16px calc(14px + env(safe-area-inset-bottom));
    pointer-events: none;
}

.timer-wrap.is-hidden {
    display: none;
}

.scroll-down {
    position: fixed;
    right: 16px;
    bottom: calc(var(--timer-h) + 8px);
    z-index: 35;
    width: 48px;
    height: 48px;
    border: 0;
    padding: 0;
    border-radius: 16px;
    display: grid;
    place-items: center;
    color: var(--text);
    background: var(--glass);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
    cursor: pointer;
    transform: translateX(0);
    opacity: 1;
    transition:
        transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
        opacity 0.25s ease,
        bottom 0.2s ease;
}

.scroll-down.is-hidden {
    transform: translateX(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
}

body.timer-off .scroll-down {
    bottom: calc(16px + env(safe-area-inset-bottom));
}

.scroll-down:hover {
    color: var(--accent-ink);
}

.scroll-down:active {
    transform: translateX(0) scale(0.96);
}

.scroll-down.is-hidden:active {
    transform: translateX(calc(100% + 24px));
}

.timer-bar {
    pointer-events: auto;
    width: min(720px, 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius);
}

.timer-heading {
    font-family: var(--font-brand);
    font-weight: 800;
    letter-spacing: -0.03em;
    font-size: 1.08rem;
    line-height: 1.1;
}

.timer-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.timer-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timer-col-right {
    text-align: right;
    align-items: flex-end;
}

.timer-value-row {
    display: inline-flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 6px;
}

.forecast-hint {
    border: 0;
    background: transparent;
    color: var(--accent-ink);
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.forecast-hint:hover {
    opacity: 1;
    transform: scale(1.08);
}

.forecast-hint.is-default {
    opacity: 0.35;
}

.action-btn {
    margin-top: 12px;
    width: 100%;
    border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
    background: color-mix(in srgb, var(--accent) 18%, var(--bg));
    color: var(--text);
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.action-btn:disabled {
    opacity: 0.55;
    cursor: wait;
}

#installAppBlock .settings-hint {
    margin-top: 10px;
}

.settings-block .settings-row + .action-btn {
    margin-top: 14px;
}

.settings-block > .settings-hint + .settings-row {
    margin-top: 14px;
}

.fake-calc {
    margin-top: 14px;
}

.fake-calc-bar {
    height: 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text) 10%, transparent);
    overflow: hidden;
}

.fake-calc-bar > span {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, #ffd45a, var(--accent));
    transition: width 0.35s ease;
}

.fake-calc-step {
    margin-top: 8px;
    font-size: 0.84rem;
    color: var(--text-muted);
}

.settings-status {
    margin-top: 10px;
    font-size: 0.84rem;
    color: var(--text-muted);
}

.forecast-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.forecast-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    color: var(--text-muted);
    font-size: 0.84rem;
}

.forecast-summary {
    margin: 0;
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.35;
}

.forecast-reason {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.55;
    font-size: 0.98rem;
}

.forecast-signals {
    margin: 0;
    padding-left: 1.1em;
    color: var(--text-muted);
    line-height: 1.45;
}

.forecast-empty {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.5;
}

.forecast-history {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
}

.forecast-history-title {
    font-weight: 700;
    margin-bottom: 10px;
}

.forecast-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.forecast-history-item {
    padding: 10px 12px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--text) 5%, transparent);
    font-size: 0.88rem;
    line-height: 1.4;
}

.forecast-history-item strong {
    font-weight: 700;
}

.forecast-history-meta {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.timer-label {
    color: var(--text-muted);
    font-size: 0.84rem;
    font-weight: 600;
}

.timer-value {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: clamp(0.78rem, 2.7vw, 0.98rem);
    letter-spacing: 0.01em;
    line-height: 1.3;
}

.timer-col-right .timer-value {
    text-align: right;
}

.timer-days {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.poly-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 2px;
    padding-top: 10px;
    border-top: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
}

.poly-card {
    text-decoration: none;
    color: inherit;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.poly-card:hover .poly-value {
    color: var(--accent-ink);
}

.poly-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.poly-value {
    font-weight: 700;
    font-size: clamp(0.78rem, 2.5vw, 0.92rem);
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
}

.poly-card:last-child {
    text-align: right;
    align-items: flex-end;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    margin: 0;
    padding: 0;
    background: rgba(10, 10, 10, 0.38);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
}

.modal-panel {
    position: relative;
    z-index: 1;
    width: min(420px, 100%);
    max-height: min(92dvh, calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
    border-radius: 28px;
    padding: 18px 18px 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: bubbleIn 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-shrink: 0;
}

.modal-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.modal-title {
    margin: 0;
    font-family: var(--font-brand);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 12px;
    background: color-mix(in srgb, var(--text) 8%, transparent);
    color: var(--text);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.settings-block + .settings-block {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
}

.settings-label {
    font-weight: 700;
    margin-bottom: 10px;
}

.settings-label-sub {
    margin-top: 14px;
    margin-bottom: 8px;
    font-size: 0.92rem;
}

.settings-hint {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 4px;
}

.settings-hint-center {
    text-align: center;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.settings-row .settings-label {
    margin-bottom: 0;
}

.segment {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.segment-btn {
    border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
    background: color-mix(in srgb, var(--bg) 55%, transparent);
    color: var(--text);
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.settings-row-input {
    margin-top: 12px;
    align-items: center;
}

.settings-row-input .settings-label-sub {
    margin: 0;
}

.push-coef-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.push-coef-field input {
    width: 4.2rem;
    border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
    background: color-mix(in srgb, var(--bg) 55%, transparent);
    color: var(--text);
    border-radius: 12px;
    padding: 8px 10px;
    font: inherit;
    font-weight: 600;
    text-align: center;
}

.push-coef-field input:focus {
    outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
    outline-offset: 1px;
}

.push-coef-suffix {
    color: var(--text-muted);
    font-weight: 600;
}

.segment-btn.is-active {
    background: color-mix(in srgb, var(--accent) 22%, var(--bg));
    border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

.switch {
    position: relative;
    width: 54px;
    height: 30px;
    border: 0;
    border-radius: 999px;
    padding: 0;
    background: color-mix(in srgb, var(--text) 18%, transparent);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.switch[aria-checked="true"] {
    background: color-mix(in srgb, var(--accent) 75%, #111);
}

.switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.switch[aria-checked="true"] .switch-thumb {
    transform: translateX(24px);
}

@keyframes brandPulse {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

@keyframes bubbleIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .brand-mark,
    .bubble,
    .modal-panel {
        animation: none;
    }
}

@media (max-width: 640px) {
    .modal {
        align-items: flex-end;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .modal-panel {
        width: 100%;
        max-height: min(92dvh, calc(100dvh - env(safe-area-inset-top) - 8px));
        border-radius: 24px 24px 18px 18px;
    }

    .feed {
        padding-left: 14px;
        padding-right: 14px;
    }

    .bubble {
        border-radius: 18px;
        padding: 14px 14px 12px;
    }

    .timer-wrap {
        padding-left: 14px;
        padding-right: 14px;
    }

    .timer-cols {
        gap: 10px;
    }

    .timer-value {
        font-size: 0.76rem;
    }
}
