/* ==========================================================================
   Дневник — стеклянная тема
   --------------------------------------------------------------------------
   Один тёмный слой: аврора на фоне, матовые карточки поверх, тонкие световые
   кромки. Всё на CSS, без внешних шрифтов и картинок: Content-Security-Policy
   панели разрешает только свои файлы.
   ========================================================================== */

:root {
    --bg: #05060f;
    --ink: #eef1fb;
    --ink-soft: #c9cfe3;
    --muted: #98a1bb;
    --faint: #6d7693;

    --accent: #7c6cff;
    --accent-2: #22d3ee;
    --pink: #f472b6;
    --ok: #34d399;
    --warn: #fbbf24;
    --danger: #fb7185;

    --glass: rgba(255, 255, 255, 0.055);
    --glass-strong: rgba(255, 255, 255, 0.085);
    --stroke: rgba(255, 255, 255, 0.11);
    --stroke-soft: rgba(255, 255, 255, 0.07);

    --radius: 26px;
    --radius-sm: 16px;
    --radius-xs: 12px;

    --shadow: 0 30px 80px -24px rgba(0, 0, 0, 0.85);
    --shadow-soft: 0 16px 40px -24px rgba(0, 0, 0, 0.7);

    --font: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI",
        "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: -0.011em;
    background-color: var(--bg);
    background-image:
        radial-gradient(1100px 760px at 12% -12%, #1d1b52 0%, transparent 62%),
        radial-gradient(900px 680px at 92% 2%, #063a44 0%, transparent 58%),
        radial-gradient(900px 900px at 48% 118%, #2b1142 0%, transparent 62%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

::selection { background: rgba(124, 108, 255, 0.35); }

.hidden { display: none !important; }

/* --- фон: живые пятна света ---------------------------------------------- */

.sky {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    display: block;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.5;
    mix-blend-mode: screen;
    animation: drift 26s var(--ease) infinite alternate;
}

.orb-1 {
    width: 520px; height: 520px;
    top: -160px; left: -120px;
    background: radial-gradient(circle at 40% 40%, #6d5cff, transparent 68%);
}

.orb-2 {
    width: 460px; height: 460px;
    top: 6%; right: -140px;
    background: radial-gradient(circle at 55% 45%, #16b6c9, transparent 68%);
    animation-delay: -8s;
    animation-duration: 32s;
}

.orb-3 {
    width: 620px; height: 620px;
    bottom: -280px; left: 32%;
    background: radial-gradient(circle at 50% 50%, #d14f9b, transparent 66%);
    opacity: 0.3;
    animation-delay: -16s;
    animation-duration: 38s;
}

@keyframes drift {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    50%  { transform: translate3d(40px, -30px, 0) scale(1.08); }
    100% { transform: translate3d(-30px, 40px, 0) scale(0.96); }
}

/* --- стекло --------------------------------------------------------------- */

.glass {
    position: relative;
    background:
        linear-gradient(148deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.026));
    border: 1px solid var(--stroke);
    border-radius: var(--radius);
    backdrop-filter: blur(26px) saturate(160%);
    -webkit-backdrop-filter: blur(26px) saturate(160%);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.glass::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(140deg,
        rgba(255, 255, 255, 0.4), transparent 34%,
        transparent 68%, rgba(124, 108, 255, 0.3));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.55;
    pointer-events: none;
}

.glass-soft {
    background: linear-gradient(155deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018));
    border: 1px solid var(--stroke-soft);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
}

/* --- марка и кнопки ------------------------------------------------------- */

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 12px;
    background: linear-gradient(140deg, #8f7dff, #5b4ae8 56%, #21c9e0);
    box-shadow: 0 10px 24px -8px rgba(124, 108, 255, 0.8),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    color: #fff;
}

.brand-mark svg { width: 20px; height: 20px; }

.btn {
    --pad-y: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: var(--pad-y) 16px;
    border: 1px solid transparent;
    border-radius: 999px;
    font: inherit;
    font-weight: 560;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.18s var(--ease), background 0.18s, border-color 0.18s,
        box-shadow 0.18s, opacity 0.18s;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.1); }
.btn:active { transform: translateY(0) scale(0.985); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn svg { width: 16px; height: 16px; }

.btn-primary {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.16);
    background: linear-gradient(135deg, #8a7bff 0%, #5b4ae8 52%, #22b8d8 100%);
    box-shadow: 0 14px 34px -14px rgba(105, 92, 255, 0.95),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #9a8dff 0%, #6a59f0 52%, #37c8e6 100%);
    box-shadow: 0 18px 40px -14px rgba(105, 92, 255, 1);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--stroke);
}

.btn-danger {
    color: #fff;
    background: linear-gradient(135deg, #fb7185, #e11d48);
    box-shadow: 0 12px 30px -14px rgba(225, 29, 72, 0.9);
}

.btn-block { width: 100%; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: none;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--stroke-soft);
    background: rgba(255, 255, 255, 0.045);
    color: var(--ink-soft);
    cursor: pointer;
    transition: background 0.18s, color 0.18s, transform 0.18s var(--ease);
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.11); color: #fff; transform: translateY(-1px); }
.icon-btn svg { width: 17px; height: 17px; }

.icon-btn.danger:hover { background: rgba(251, 113, 133, 0.18); color: #ffd7de; }

/* --- вход ----------------------------------------------------------------- */

.auth-screen {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 28px 20px;
}

.auth-card {
    width: min(420px, 100%);
    padding: 36px 32px 28px;
    animation: rise 0.7s var(--ease) both;
}

.auth-card .brand-mark {
    width: 54px;
    height: 54px;
    border-radius: 17px;
    margin-bottom: 20px;
}

.auth-card .brand-mark svg { width: 27px; height: 27px; }

.auth-card h1 {
    margin: 0 0 6px;
    font-size: 30px;
    font-weight: 640;
    letter-spacing: -0.03em;
}

.auth-card .muted { margin: 0 0 26px; font-size: 14px; }

/* --- стартовая страница: Aurora ------------------------------------------ */

.auth-screen { padding: 44px 24px; }

.auth-shell {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 396px);
    align-items: center;
    gap: clamp(32px, 5vw, 76px);
    width: min(1120px, 100%);
    margin: 0 auto;
}

/* Свет зари за текстом: то же свечение, что в небе дневника. */
.auth-shell::before {
    content: "";
    position: absolute;
    z-index: 0;
    left: -24%;
    top: 50%;
    width: 760px;
    height: 760px;
    transform: translateY(-50%);
    background:
        radial-gradient(closest-side, rgba(124, 108, 255, 0.2), transparent 74%),
        radial-gradient(closest-side, rgba(34, 211, 238, 0.13), transparent 66%);
    filter: blur(24px);
    pointer-events: none;
}

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

.auth-hero { animation: rise 0.7s var(--ease) both; }

.hero-brand {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
}

.hero-brand .brand-mark { width: 50px; height: 50px; border-radius: 16px; }
.hero-brand .brand-mark svg { width: 27px; height: 27px; }

.hero-wordmark {
    display: flex;
    flex-direction: column;
    font-size: 21px;
    font-weight: 640;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.hero-wordmark span {
    margin-top: 3px;
    font-size: 10.5px;
    font-weight: 560;
    letter-spacing: 0.34em;
    text-transform: uppercase;
    color: var(--faint);
}

.auth-hero h1 {
    margin: 0 0 18px;
    max-width: 15ch;
    font-size: clamp(34px, 4.4vw, 56px);
    font-weight: 660;
    line-height: 1.03;
    letter-spacing: -0.04em;
    color: var(--ink);
}

@supports (background-clip: text) or (-webkit-background-clip: text) {
    .auth-hero h1 {
        background: linear-gradient(118deg, #ffffff 18%, #cfd6ff 56%, #93e8f7 96%);
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
    }
}

.hero-lead {
    margin: 0 0 30px;
    max-width: 46ch;
    font-size: 16px;
    line-height: 1.6;
    color: var(--ink-soft);
}

.hero-points {
    display: grid;
    gap: 16px;
    margin: 0 0 30px;
    padding: 0;
    max-width: 48ch;
    list-style: none;
}

.hero-points li {
    display: flex;
    gap: 13px;
    align-items: flex-start;
    font-size: 14px;
    line-height: 1.55;
    color: var(--muted);
}

.hero-points b {
    display: block;
    margin-bottom: 2px;
    font-weight: 600;
    color: var(--ink);
}

.point-dot {
    display: grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 32px;
    margin-top: 1px;
    border: 1px solid rgba(124, 108, 255, 0.28);
    border-radius: 11px;
    background: rgba(124, 108, 255, 0.13);
    color: #cfc9ff;
}

.point-dot svg { width: 16px; height: 16px; }

.hero-note {
    margin: 0;
    max-width: 44ch;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--faint);
}

.auth-card {
    width: 100%;
    padding: 32px 28px 26px;
    animation: rise 0.7s var(--ease) 0.08s both;
}

.auth-card-title {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 620;
    letter-spacing: -0.02em;
}

.auth-card .muted { margin: 0 0 22px; font-size: 13.5px; }

/* На узком экране — в столбик: сначала имя, потом вход. Подробности прячем,
   чтобы форма входа оставалась на первом экране. */
@media (max-width: 920px) {
    .auth-screen { padding: 32px 20px; }
    .auth-shell {
        grid-template-columns: minmax(0, 1fr);
        gap: 28px;
        width: min(460px, 100%);
    }
    .auth-shell::before {
        left: 50%;
        top: 6%;
        width: 100%;
        max-width: 520px;
        height: 480px;
        transform: translateX(-50%);
    }
    .hero-brand { margin-bottom: 22px; }
    .auth-hero h1 { max-width: none; font-size: clamp(30px, 7.4vw, 40px); }
    .hero-lead { margin-bottom: 0; font-size: 15px; }
    .hero-points,
    .hero-note { display: none; }
    .auth-card { padding: 26px 22px 22px; }
}

/* В iframe панели keepup: только карточка, без собственного героя. */
body.embed .auth-shell { grid-template-columns: minmax(0, 1fr); width: min(420px, 100%); }
body.embed .auth-hero { display: none; }

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

.field { display: flex; flex-direction: column; gap: 7px; }

.field > span {
    font-size: 12px;
    font-weight: 560;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.text-input,
textarea.text-input,
select.text-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--stroke);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.045);
    color: var(--ink);
    font: inherit;
    outline: none;
    transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
    color-scheme: dark;
}

textarea.text-input { resize: vertical; min-height: 132px; line-height: 1.6; }

.text-input::placeholder { color: var(--faint); }

.text-input:focus {
    border-color: rgba(124, 108, 255, 0.7);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 0 4px rgba(124, 108, 255, 0.16);
}

select.text-input {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 38px;
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    color: var(--ink-soft);
    cursor: pointer;
    user-select: none;
}

.check input,
.switch input {
    appearance: none;
    position: relative;
    width: 42px;
    height: 25px;
    flex: none;
    margin: 0;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background 0.2s var(--ease), border-color 0.2s;
}

.check input::after,
.switch input::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: #dfe3f3;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: transform 0.22s var(--ease), background 0.2s;
}

.check input:checked,
.switch input:checked {
    border-color: rgba(124, 108, 255, 0.5);
    background: linear-gradient(135deg, #7c6cff, #22d3ee);
}

.check input:checked::after,
.switch input:checked::after {
    transform: translateX(17px);
    background: #fff;
}

.form-error {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(251, 113, 133, 0.34);
    background: rgba(251, 113, 133, 0.12);
    color: #ffd6dd;
    font-size: 13.5px;
}

.auth-hint {
    margin: 22px 0 0;
    font-size: 12.5px;
    color: var(--faint);
    text-align: center;
}

.mono { font-family: var(--mono); font-size: 0.96em; }

/* --- каркас приложения ---------------------------------------------------- */

.app {
    max-width: 1250px;
    margin: 0 auto;
    padding: 16px 20px 72px;
}

.topbar {
    position: sticky;
    top: 14px;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 12px 10px 16px;
    border-radius: 999px;
    animation: rise 0.6s var(--ease) both;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.topbar-brand strong {
    display: block;
    font-size: 15.5px;
    font-weight: 620;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.topbar-brand .sub {
    display: block;
    font-size: 11.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    overflow: hidden;
}

.stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 11px;
    border-radius: 999px;
    border: 1px solid var(--stroke-soft);
    background: rgba(255, 255, 255, 0.04);
    font-size: 12.5px;
    color: var(--ink-soft);
    white-space: nowrap;
}

.stat b { font-weight: 620; color: var(--ink); }
.stat svg { width: 14px; height: 14px; opacity: 0.85; }
.stat.hot { border-color: rgba(251, 191, 36, 0.28); color: #ffe6ae; }
.stat.hot b { color: #ffe6ae; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* --- сетка ---------------------------------------------------------------- */

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1.04fr) minmax(0, 0.96fr);
    gap: 22px;
    align-items: start;
    margin-top: 22px;
}

.column { display: flex; flex-direction: column; gap: 22px; min-width: 0; }

/* --- редактор записи ------------------------------------------------------ */

.composer {
    padding: 22px 22px 18px;
    animation: rise 0.7s var(--ease) both;
}

.composer-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.composer-head h2 {
    margin: 0;
    font-size: 19px;
    font-weight: 620;
    letter-spacing: -0.025em;
}

.date-pill {
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--stroke-soft);
    background: rgba(255, 255, 255, 0.04);
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
}

.composer textarea {
    border: 1px solid transparent;
    background: rgba(6, 8, 20, 0.32);
    min-height: 126px;
    font-size: 15.5px;
    border-radius: 18px;
}

.composer textarea:focus {
    border-color: rgba(124, 108, 255, 0.55);
    background: rgba(6, 8, 20, 0.42);
}

.composer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.moods { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.mood-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 11px;
    border: 1px solid var(--stroke-soft);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.035);
    color: var(--ink-soft);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
    transition: background 0.16s, border-color 0.16s, color 0.16s, transform 0.16s var(--ease);
}

.mood-btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.08); }
.mood-btn[aria-pressed="true"] {
    color: #fff;
    border-color: var(--mood-color, var(--accent));
    background: color-mix(in srgb, var(--mood-color, var(--accent)) 24%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--mood-color, var(--accent)) 30%, transparent),
        0 8px 22px -12px var(--mood-color, var(--accent));
}

.mood-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--mood-color, var(--accent));
    box-shadow: 0 0 10px var(--mood-color, var(--accent));
    flex: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--stroke-soft);
    background: rgba(255, 255, 255, 0.045);
    color: var(--ink-soft);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.16s, border-color 0.16s, color 0.16s;
}

.chip:hover { background: rgba(255, 255, 255, 0.09); color: #fff; }

.chip-toggle[aria-expanded="true"] {
    border-color: rgba(124, 108, 255, 0.5);
    background: rgba(124, 108, 255, 0.16);
    color: #e5e1ff;
}

.tags-row .text-input { flex: 1 1 160px; min-width: 0; }

.task-fields {
    display: grid;
    grid-template-columns: 1fr 170px;
    gap: 10px;
    margin-top: 10px;
    padding: 12px;
    border-radius: 15px;
    border: 1px dashed rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.025);
    animation: fade 0.25s var(--ease) both;
}

.composer-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
}

.hint { font-size: 12px; color: var(--faint); }

/* --- сводка --------------------------------------------------------------- */

.summary-card {
    padding: 22px;
    overflow: hidden;
    animation: rise 0.72s var(--ease) both;
}

.summary-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.summary-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 620;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--muted);
}

.summary-head .spacer { flex: 1; }

.summary-text {
    margin: 0;
    font-size: 18px;
    line-height: 1.55;
    letter-spacing: -0.015em;
    color: #f3f5ff;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.summary-text.placeholder { color: var(--muted); font-size: 15px; white-space: normal; }

.summary-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
    font-size: 11.5px;
    color: var(--faint);
}

.summary-meta .chip { cursor: default; font-size: 11.5px; }

.summary-notice {
    margin-top: 12px;
    padding: 9px 12px;
    border-radius: 12px;
    border: 1px solid rgba(251, 191, 36, 0.26);
    background: rgba(251, 191, 36, 0.09);
    color: #ffe9b6;
    font-size: 12.5px;
}

.summary-snapshot {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

.snapshot {
    padding: 11px 13px;
    border-radius: 14px;
    border: 1px solid var(--stroke-soft);
    background: rgba(255, 255, 255, 0.03);
}

.snapshot h3 {
    margin: 0 0 6px;
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
}

.snapshot ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; }
.snapshot li { font-size: 12.5px; color: var(--ink-soft); overflow-wrap: anywhere; }
.snapshot li .hint { white-space: nowrap; }
.snapshot .empty { font-size: 12.5px; color: var(--faint); }

.summary-skeleton { display: grid; gap: 10px; }

/* --- задачи --------------------------------------------------------------- */

.tasks-card { padding: 20px 20px 16px; animation: rise 0.76s var(--ease) both; }

.card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.card-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 620;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--muted);
}

.card-head .count {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 11.5px;
    color: var(--ink-soft);
}

.card-head .spacer { flex: 1; }

.task-group + .task-group { margin-top: 14px; }

.task-group h3 {
    margin: 0 0 8px;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--faint);
    font-weight: 600;
}

.task {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 11px;
    border-radius: 14px;
    border: 1px solid transparent;
    transition: background 0.16s, border-color 0.16s;
}

.task:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--stroke-soft); }

.task-check {
    width: 21px;
    height: 21px;
    flex: none;
    margin-top: 1px;
    padding: 0;
    border-radius: 7px;
    border: 1.5px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    display: grid;
    place-items: center;
    color: transparent;
    transition: background 0.16s, border-color 0.16s, color 0.16s, transform 0.16s var(--ease);
}

.task-check:hover { border-color: var(--ok); color: rgba(52, 211, 153, 0.65); transform: scale(1.06); }
.task-check svg { width: 12px; height: 12px; }

.task-body { flex: 1; min-width: 0; }

.task-title {
    font-size: 13.5px;
    color: var(--ink-soft);
    overflow-wrap: anywhere;
    line-height: 1.4;
}

.task-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 3px;
    font-size: 11.5px;
    color: var(--faint);
    flex-wrap: wrap;
}

.task-due.overdue { color: #ffb3c0; }
.task-due.today { color: #ffe6ae; }
.task-due.soon { color: #b8e9ff; }

.task-source {
    padding: 1px 6px;
    border-radius: 6px;
    border: 1px solid rgba(124, 108, 255, 0.26);
    color: #d6d0ff;
    font-size: 10px;
    letter-spacing: 0.03em;
}

.task-remove { opacity: 0; transition: opacity 0.16s; }
.task:hover .task-remove, .task:focus-within .task-remove { opacity: 1; }

.task.done .task-title { color: var(--faint); text-decoration: line-through; }
.task.done .task-check {
    color: #06281d;
    border-color: transparent;
    background: linear-gradient(135deg, #34d399, #22d3ee);
}

/* --- лента записей -------------------------------------------------------- */

.timeline-wrap { animation: rise 0.8s var(--ease) both; }

.timeline-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 2px 14px;
    flex-wrap: wrap;
}

.timeline-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 620;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--muted);
}

.timeline-head .spacer { flex: 1; }

.segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 999px;
    border: 1px solid var(--stroke-soft);
    background: rgba(255, 255, 255, 0.035);
}

.segmented button {
    padding: 5px 11px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.16s, color 0.16s;
}

.segmented button[aria-pressed="true"] {
    background: rgba(255, 255, 255, 0.1);
    color: var(--ink);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.search {
    position: relative;
    flex: 1 1 140px;
    min-width: 120px;
    max-width: 230px;
}

.search svg {
    position: absolute;
    left: 11px;
    top: 50%;
    width: 14px;
    height: 14px;
    transform: translateY(-50%);
    color: var(--faint);
    pointer-events: none;
}

.search input {
    width: 100%;
    padding: 7px 10px 7px 31px;
    border-radius: 999px;
    border: 1px solid var(--stroke-soft);
    background: rgba(255, 255, 255, 0.04);
    color: var(--ink);
    font: inherit;
    font-size: 12.5px;
    outline: none;
    transition: border-color 0.16s, box-shadow 0.16s;
}

.search input:focus { border-color: rgba(124, 108, 255, 0.6); box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.14); }
.search input::placeholder { color: var(--faint); }

.day-group + .day-group { margin-top: 20px; }

.day-head {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 2px 9px;
    font-size: 12px;
    color: var(--faint);
}

.day-head strong {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
    letter-spacing: 0.01em;
}

.day-head .line { flex: 1; height: 1px; background: linear-gradient(90deg, var(--stroke-soft), transparent); }

.entry {
    position: relative;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 4px 12px;
    padding: 15px 16px;
    border-radius: 19px;
    border: 1px solid var(--stroke-soft);
    background: linear-gradient(150deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018));
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    box-shadow: var(--shadow-soft);
    transition: transform 0.2s var(--ease), border-color 0.2s, background 0.2s;
    animation: fade 0.4s var(--ease) both;
}

.entry + .entry { margin-top: 10px; }
.entry:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.14); }

.entry-time {
    grid-row: span 3;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--faint);
    padding-top: 3px;
    letter-spacing: -0.02em;
}

.entry-title {
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
    overflow-wrap: anywhere;
}

.entry-body {
    margin: 0;
    font-size: 14.5px;
    line-height: 1.58;
    color: var(--ink-soft);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.entry-foot {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    margin-top: 7px;
}

.tag {
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    font-size: 11px;
    color: var(--muted);
}

.entry-mood {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    color: var(--muted);
}

/* Задачи и комментарии — всегда во второй колонке, под текстом записи. */
.entry-tasks {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.entry-task {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 8px;
    border: 1px solid rgba(251, 191, 36, 0.22);
    background: rgba(251, 191, 36, 0.07);
    font-size: 11.5px;
    color: #ffe6ae;
}

.entry-task.overdue { border-color: rgba(251, 113, 133, 0.3); background: rgba(251, 113, 133, 0.09); color: #ffc7d1; }
.entry-task.done {
    border-color: rgba(52, 211, 153, 0.26);
    background: rgba(52, 211, 153, 0.08);
    color: #a7f3d0;
}
.entry-task svg { width: 11px; height: 11px; opacity: 0.8; }

/* запись закрыта комментарием */
.entry-resolved {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid rgba(52, 211, 153, 0.28);
    background: rgba(52, 211, 153, 0.1);
    font-size: 11px;
    color: #a7f3d0;
}

.entry-resolved svg { width: 11px; height: 11px; }

/* --- комментарии к записи ------------------------------------------------- */

.entry-comments {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--stroke-soft);
}

.comment {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 9px 11px;
    border-radius: 13px;
    border: 1px solid var(--stroke-soft);
    background: rgba(255, 255, 255, 0.028);
}

.comment.resolving {
    border-color: rgba(52, 211, 153, 0.24);
    background: rgba(52, 211, 153, 0.05);
}

.comment-head {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    color: var(--faint);
}

.comment-head .spacer { flex: 1; }

.comment-time { font-family: var(--mono); letter-spacing: -0.02em; }

.comment-head .icon-btn {
    width: 24px;
    height: 24px;
    opacity: 0;
    transition: opacity 0.16s;
}

.comment:hover .comment-head .icon-btn,
.comment:focus-within .comment-head .icon-btn { opacity: 1; }
.comment-head .icon-btn svg { width: 12px; height: 12px; }

.comment-badge {
    padding: 1px 7px;
    border-radius: 999px;
    border: 1px solid rgba(52, 211, 153, 0.28);
    background: rgba(52, 211, 153, 0.1);
    color: #a7f3d0;
}

.comment-body {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--ink-soft);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.comment-add {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px dashed var(--stroke);
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 11.5px;
    cursor: pointer;
    transition: border-color 0.16s, background 0.16s, color 0.16s;
}

.comment-add:hover {
    border-color: rgba(124, 108, 255, 0.45);
    background: rgba(124, 108, 255, 0.1);
    color: #fff;
}

.comment-add svg { width: 12px; height: 12px; }

/* цитата родительской записи в окне комментария */
.comment-quote {
    margin: 0;
    padding: 9px 11px;
    border-left: 2px solid rgba(124, 108, 255, 0.5);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.035);
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.check small {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: var(--faint);
}

.entry-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.16s, transform 0.16s;
}

.entry:hover .entry-actions, .entry:focus-within .entry-actions { opacity: 1; transform: none; }
.entry-actions .icon-btn { width: 30px; height: 30px; background: rgba(8, 10, 24, 0.55); }
.entry-actions .icon-btn svg { width: 14px; height: 14px; }

.empty {
    display: grid;
    place-items: center;
    gap: 8px;
    padding: 34px 20px;
    text-align: center;
    color: var(--faint);
    font-size: 13.5px;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 20px;
}

.empty svg { width: 26px; height: 26px; opacity: 0.6; }
.empty strong { display: block; color: var(--ink-soft); font-size: 14.5px; font-weight: 560; }

.load-more { display: flex; justify-content: center; margin-top: 16px; }

/* --- модальные окна и уведомления ----------------------------------------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(3, 5, 14, 0.66);
    backdrop-filter: blur(9px);
    -webkit-backdrop-filter: blur(9px);
    animation: fade 0.2s var(--ease) both;
}

.modal {
    width: min(560px, 100%);
    max-height: min(88vh, 780px);
    overflow: auto;
    padding: 24px;
    animation: rise 0.32s var(--ease) both;
}

.modal-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.modal-head h2 {
    margin: 0;
    font-size: 19px;
    font-weight: 620;
    letter-spacing: -0.025em;
}

.modal-head .spacer { flex: 1; }

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

.modal-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.modal-actions .spacer { flex: 1; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.switch-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--stroke-soft);
    background: rgba(255, 255, 255, 0.03);
}

.switch-row .text { flex: 1; min-width: 0; }
.switch-row strong { display: block; font-size: 13.5px; font-weight: 560; }
.switch-row span { display: block; font-size: 11.5px; color: var(--faint); margin-top: 2px; }

.modal-note {
    padding: 11px 13px;
    border-radius: 13px;
    border: 1px solid rgba(34, 211, 238, 0.2);
    background: rgba(34, 211, 238, 0.07);
    color: #bfefff;
    font-size: 12.5px;
    line-height: 1.5;
}

.toasts {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 9px;
    max-width: min(380px, calc(100vw - 36px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 12px 14px;
    border-radius: 15px;
    border: 1px solid var(--stroke);
    background: rgba(14, 17, 33, 0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
    font-size: 13px;
    color: var(--ink-soft);
    animation: toast-in 0.3s var(--ease) both;
    pointer-events: auto;
}

.toast svg { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--accent-2); }
.toast.error { border-color: rgba(251, 113, 133, 0.35); }
.toast.error svg { color: var(--danger); }
.toast.success svg { color: var(--ok); }
.toast.leaving { animation: toast-out 0.25s var(--ease) both; }

/* --- загрузка ------------------------------------------------------------- */

.spinner {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.28);
    border-top-color: #fff;
    animation: spin 0.7s linear infinite;
}

.skeleton {
    height: 14px;
    border-radius: 7px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.06));
    background-size: 220% 100%;
    animation: shimmer 1.4s linear infinite;
}

.skeleton.wide { height: 18px; }
.skeleton.block { height: 76px; border-radius: 16px; }

/* --- анимации ------------------------------------------------------------- */

@keyframes rise {
    from { opacity: 0; transform: translateY(14px) scale(0.995); }
    to { opacity: 1; transform: none; }
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes shimmer {
    0% { background-position: 120% 0; }
    100% { background-position: -80% 0; }
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateY(6px) scale(0.98); }
}

/* --- адаптив -------------------------------------------------------------- */

@media (max-width: 1020px) {
    .layout { grid-template-columns: minmax(0, 1fr); }
    .column-left, .column-right { display: contents; }
    .composer { order: 1; }
    .summary-card { order: 2; }
    .tasks-card { order: 3; }
    .timeline-wrap { order: 4; }
    .topbar-stats { display: none; }
}

@media (max-width: 720px) {
    .app { padding: 10px 12px 60px; }
    .topbar {
        top: 8px;
        gap: 10px;
        padding: 8px 8px 8px 12px;
        border-radius: 22px;
        flex-wrap: wrap;
    }
    .topbar-brand { flex: 1; }
    .topbar-actions { gap: 6px; }
    .topbar-actions .btn span.label { display: none; }
    .topbar-actions .btn { padding: 9px 11px; }
    .topbar-actions .btn svg { width: 17px; height: 17px; }
    .composer, .summary-card, .tasks-card { padding: 18px 16px 15px; }
    .layout { gap: 16px; margin-top: 16px; }
    .task-fields { grid-template-columns: 1fr; }
    .summary-snapshot { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .entry { grid-template-columns: 1fr; padding: 14px; }
    .entry-time { grid-row: auto; order: -1; padding: 0; }
    .entry-tasks, .entry-comments { grid-column: 1; }
    .comment-head .icon-btn { opacity: 1; }
    .entry-actions { opacity: 1; transform: none; }
    .timeline-head { gap: 8px; }
    .search { max-width: none; flex-basis: 100%; order: 3; }
    .summary-text { font-size: 16.5px; }
    .auth-card { padding: 28px 22px 22px; }
    .auth-card h1 { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
    .orb { animation: none; }
}

/* --- в панели keepup: без собственной шапки ------------------------------- */

body.embed .app { padding: 14px 14px 22px; max-width: none; }
body.embed .topbar {
    position: static;
    border-radius: 18px;
    margin-bottom: 14px;
    animation: none;
    padding: 8px 10px 8px 14px;
}
body.embed .topbar-brand { display: flex; }
body.embed .topbar-brand .brand-mark,
body.embed .topbar-brand strong { display: none; }
body.embed .topbar-brand .sub {
    display: block;
    font-size: 12.5px;
    color: var(--muted);
}
body.embed .topbar-stats { margin-left: auto; }
body.embed .layout { margin-top: 0; padding: 0; }
body.embed .auth-screen { min-height: 78vh; }
body.embed .app { animation: none; }
body.embed .sky { opacity: 0.75; }

/* ==========================================================================
   Чат по записям
   --------------------------------------------------------------------------
   Полноэкранный слой поверх дневника: вопрос слева-снизу, ответ — стеклянная
   карточка с датами и фрагментами записей. Работает и в iframe панели.
   ========================================================================== */

.chat-overlay {
    position: fixed;
    inset: 0;
    z-index: 95;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(3, 5, 14, 0.68);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: fade 0.2s var(--ease) both;
}

.chat-panel {
    width: min(840px, 100%);
    height: min(86vh, 780px);
    max-height: 86dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 28px;
    animation: rise 0.34s var(--ease) both;
}

.chat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--stroke-soft);
    flex: none;
}

.chat-mark {
    width: 36px;
    height: 36px;
    border-radius: 11px;
}

.chat-mark svg { width: 18px; height: 18px; }

.chat-title { min-width: 0; }

.chat-head .spacer { flex: 1; }

.chat-title h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 620;
    letter-spacing: -0.02em;
}

.chat-title p {
    margin: 2px 0 0;
    font-size: 11.5px;
    color: var(--faint);
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
}

.chat-messages::-webkit-scrollbar { width: 7px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 99px;
}

.chat-msg {
    max-width: 84%;
    padding: 12px 15px;
    border-radius: 17px;
    font-size: 14.5px;
    line-height: 1.55;
    white-space: normal;
    overflow-wrap: anywhere;
    animation: fade 0.28s var(--ease) both;
}

.chat-text {
    display: block;
    white-space: pre-wrap;
}

.chat-msg.user {
    align-self: flex-end;
    color: #f2f0ff;
    background:
        linear-gradient(135deg, rgba(124, 108, 255, 0.34), rgba(34, 211, 238, 0.14));
    border: 1px solid rgba(124, 108, 255, 0.42);
    border-bottom-right-radius: 6px;
    box-shadow: 0 14px 34px -24px rgba(124, 108, 255, 0.9);
}

.chat-msg.assistant {
    align-self: flex-start;
    color: var(--ink-soft);
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid var(--stroke-soft);
    border-bottom-left-radius: 6px;
}

.chat-msg.assistant strong { color: var(--ink); }

.chat-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    margin-top: 9px;
    font-size: 10.5px;
    color: var(--faint);
}

.chat-badge {
    padding: 1px 7px;
    border-radius: 6px;
    border: 1px solid rgba(124, 108, 255, 0.28);
    background: rgba(124, 108, 255, 0.1);
    color: #cfc8ff;
}

.chat-badge.warn {
    border-color: rgba(251, 191, 36, 0.3);
    background: rgba(251, 191, 36, 0.08);
    color: #ffe6ae;
}

.chat-sources {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    padding-top: 9px;
    border-top: 1px dashed var(--stroke-soft);
}

.chat-source {
    display: flex;
    gap: 9px;
    align-items: baseline;
    padding: 7px 10px;
    border-radius: 10px;
    border: 1px solid var(--stroke-soft);
    background: rgba(255, 255, 255, 0.03);
    font-size: 11.5px;
    line-height: 1.4;
}

.chat-source-date {
    color: #cfc8ff;
    font-weight: 600;
    white-space: nowrap;
}

.chat-source-text {
    color: var(--muted);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.chat-empty {
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    max-width: 430px;
    color: var(--faint);
    font-size: 13px;
    padding: 20px;
}

.chat-empty strong {
    color: var(--ink-soft);
    font-size: 15.5px;
    font-weight: 560;
}

.chat-empty-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin-bottom: 6px;
    border-radius: 18px;
    border: 1px solid var(--stroke);
    background: rgba(124, 108, 255, 0.1);
    color: #cfc8ff;
}

.chat-empty-icon svg { width: 25px; height: 25px; }

.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 14px;
}

.chat-suggestion {
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    color: var(--ink-soft);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.16s, border-color 0.16s, color 0.16s;
}

.chat-suggestion:hover {
    background: rgba(124, 108, 255, 0.16);
    border-color: rgba(124, 108, 255, 0.4);
    color: #fff;
}

.chat-typing {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 13px 16px;
    border-radius: 17px;
    border-bottom-left-radius: 6px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid var(--stroke-soft);
}

.chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    animation: chat-blink 1.1s infinite ease-in-out;
}

.chat-typing span:nth-child(2) { animation-delay: 0.16s; }
.chat-typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes chat-blink {
    0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

.chat-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--stroke-soft);
    flex: none;
}

.chat-input {
    flex: 1;
    min-height: 46px;
    max-height: 132px;
    padding: 12px 14px;
    border-radius: 15px;
    border: 1px solid var(--stroke);
    background: rgba(6, 8, 20, 0.36);
    color: var(--ink);
    font: inherit;
    font-size: 14.5px;
    line-height: 1.45;
    resize: none;
    outline: none;
    transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}

.chat-input::placeholder { color: var(--faint); }

.chat-input:focus {
    border-color: rgba(124, 108, 255, 0.65);
    background: rgba(6, 8, 20, 0.46);
    box-shadow: 0 0 0 4px rgba(124, 108, 255, 0.14);
}

.chat-send {
    width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 50%;
    flex: none;
}

.chat-send svg { width: 18px; height: 18px; }

.chat-foot {
    margin: 0;
    padding: 0 16px 12px;
    font-size: 11px;
    color: var(--faint);
    flex: none;
}

@media (max-width: 720px) {
    .chat-overlay {
        padding: 0;
        place-items: stretch;
    }
    .chat-panel {
        width: 100%;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        animation: fade 0.2s var(--ease) both;
    }
    .chat-panel::before { display: none; }
    .chat-head { padding: 13px 14px; }
    .chat-messages { padding: 14px; }
    .chat-msg { max-width: 92%; font-size: 14px; }
    .chat-form { padding: 10px 12px; }
    .chat-foot { padding: 0 14px 10px; }
    .chat-title p { display: none; }
}

/* Уведомления не накрывают поле ввода, пока открыт чат. */
body.chat-open .toasts {
    bottom: 96px;
}

@media (max-width: 720px) {
    body.chat-open .toasts {
        bottom: 148px;
    }
    .chat-form {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
}
