/* ============================ Virian AI ============================ */

/* Inter is served from our own static files (no requests to Google).
   Variable font: one file per character set covers weights 400–700; the
   browser downloads only the sets a page actually uses. License: fonts/Inter-OFL.txt */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/inter-latin.7fdd70479c23.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/inter-latin-ext.9c323913ada2.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/inter-cyrillic.d0222a5e7c4f.woff2") format("woff2");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/inter-cyrillic-ext.38aca987fd31.woff2") format("woff2");
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

:root,
:root[data-theme="dark"] {
    --bg:          #0a1a1a;
    --bg-soft:     #0f2323;
    --bg-elev:     #162d2c;
    --border:      #1e3a38;
    --text:        #e2eeec;
    --text-muted:  #7aa8a5;
    --accent:      #00C4BB;
    --accent-2:    #00E5DA;
    --accent-soft: rgba(0, 196, 187, 0.15);
    --user-bubble: linear-gradient(135deg, #009E97, #00C4BB);
    --danger:      #ff5c7c;
    --radius:      16px;
    --shadow:      0 10px 40px rgba(0, 0, 0, 0.45);
    --scroll-thumb:       rgba(122, 168, 165, 0.32);
    --scroll-thumb-hover: rgba(122, 168, 165, 0.55);
    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg:          #f0fafa;
    --bg-soft:     #ffffff;
    --bg-elev:     #e6f5f4;
    --border:      #b8dedd;
    --text:        #0a2827;
    --text-muted:  #4a7a78;
    --accent:      #009E97;
    --accent-2:    #00C4BB;
    --accent-soft: rgba(0, 158, 151, 0.12);
    --user-bubble: linear-gradient(135deg, #009E97, #00C4BB);
    --danger:      #e23b5e;
    --shadow:      0 10px 34px rgba(0, 80, 76, 0.12);
    --scroll-thumb:       rgba(74, 122, 120, 0.30);
    --scroll-thumb-hover: rgba(74, 122, 120, 0.50);
    color-scheme: light;
}

/* ---- Scrollbars: thin, in the theme's colors, on a transparent track ---- */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
.messages:hover,
.composer textarea:hover { scrollbar-color: var(--scroll-thumb-hover) transparent; }
/* Safari ignores scrollbar-color; Chrome/Firefox ignore these when it's set. */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    background-clip: padding-box;
    border: 3px solid transparent;
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-thumb-hover); }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    font-size: 17px;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* Smooth theme switching */
body, .app, .chat, .chat-head, .composer, .composer textarea,
.bubble, .header-user, .header-search-box input,
.btn-icon, .msg-avatar {
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.hidden { display: none !important; }

/* ---- Icons ---- */
.icon { width: 20px; height: 20px; display: block; }
button svg { pointer-events: none; }

/* ============================ Auth ============================ */
.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    background:
        radial-gradient(900px 500px at 20% -10%, rgba(0, 158, 151, 0.18), transparent),
        radial-gradient(900px 500px at 90% 110%, rgba(0, 196, 187, 0.14), transparent),
        var(--bg);
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 40px 32px;
    box-shadow: var(--shadow);
}

.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-logo { display: inline-flex; color: var(--accent); }
.auth-logo .icon { width: 48px; height: 48px; }
.auth-brand h1 { font-size: 26px; margin-top: 8px; letter-spacing: -0.5px; }
.auth-subtitle { color: var(--text-muted); font-size: 16px; margin-top: 6px; }

.auth-form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field span { font-size: 15px; color: var(--text-muted); }
.field input {
    background: var(--bg-elev);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    color: var(--text);
    font-family: inherit;
    font-size: 17px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-primary {
    margin-top: 8px;
    background: var(--user-bubble);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 16px;
    font-family: inherit;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, filter 0.15s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(0.98); }

.auth-error {
    background: rgba(255, 92, 124, 0.12);
    border: 1px solid rgba(255, 92, 124, 0.4);
    color: var(--danger);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 15px;
    margin-bottom: 18px;
}
.auth-hint { text-align: center; color: var(--text-muted); font-size: 14px; margin-top: 20px; }

/* ============================ App layout ============================ */
.chat-page { overflow: hidden; }
.app {
    height: 100vh;
    height: 100dvh; /* iOS Safari: реальная видимая высота без chrome браузера */
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg);
    padding: 14px 0;
}

/* ---------------------------- Chat ---------------------------- */
.chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    max-width: 1080px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

/* ---- Header ---- */
.chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
    flex-shrink: 0;
}

.chat-head-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}
.brand-logo { display: inline-flex; color: var(--accent); }
.brand-logo .icon { width: 26px; height: 26px; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; white-space: nowrap; }

/* Header right: user pill + controls */
.chat-head-right { display: flex; align-items: center; gap: 10px; }

.header-user {
    display: flex;
    align-items: center;
    gap: 7px;
    height: 48px;
    padding: 0 8px 0 12px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--bg-soft);
    white-space: nowrap;
}
.header-user .icon { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; }
.header-username { font-size: 15px; font-weight: 600; color: var(--text); }
.header-user .btn-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    margin-left: 2px;
    transition: background 0.12s, color 0.12s;
}
.header-user .btn-logout:hover { background: var(--bg-elev); color: var(--danger); }
.header-user .btn-logout .icon { width: 18px; height: 18px; }

/* Theme toggle */
.icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: block; }

/* ---- Unified controls (language + theme) ---- */
.controls { display: flex; align-items: center; gap: 10px; }
.top-controls {
    position: fixed;
    top: 20px; right: 20px;
    z-index: 30;
}

.control-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    min-width: 48px;
    padding: 0 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--bg-soft);
    color: var(--text);
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.control-btn:hover { background: var(--bg-elev); border-color: var(--accent); }
.control-btn:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
.control-btn .icon { width: 24px; height: 24px; }
.control-btn .chevron { width: 18px; height: 18px; color: var(--text-muted); }
.theme-toggle { width: 48px; padding: 0; }

.lang-switch { position: relative; }
.lang-current { font-size: 16px; font-weight: 700; letter-spacing: 0.5px; }
.lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 132px;
    background: var(--bg-soft);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 6px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 2px;
    animation: rise 0.16s ease;
}
.lang-menu button {
    display: flex;
    align-items: center;
    background: transparent;
    border: none;
    border-radius: 9px;
    padding: 13px 18px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
}
.lang-menu button:hover { background: var(--bg-elev); }
.lang-menu button.active { background: var(--accent-soft); color: var(--accent); }

/* ============================ Messages ============================ */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.load-sentinel { height: 1px; flex-shrink: 0; }
.load-more-spinner { display: flex; justify-content: center; padding: 10px 0; flex-shrink: 0; }

.greeting-sub { margin-top: 6px; opacity: 0.8; }

.welcome-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 28px;
}
.chip {
    padding: 13px 22px;
    border: 1.5px solid var(--border);
    border-radius: 14px;
    background: var(--bg-soft);
    color: var(--text);
    font-family: inherit;
    font-size: 15.5px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.1s;
    line-height: 1.4;
}
.chip:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip:active { transform: scale(0.97); }

.msg { display: flex; gap: 12px; max-width: 80%; animation: rise 0.25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
    flex-shrink: 0;
    width: 40px; height: 40px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.msg-avatar .icon { width: 23px; height: 23px; }
.msg.assistant .msg-avatar { background: var(--accent-soft); color: var(--accent); }
.msg.user .msg-avatar { background: var(--user-bubble); color: #fff; border-color: transparent; }

.msg-body { display: flex; flex-direction: column; gap: 6px; }
.bubble {
    padding: 13px 18px;
    border-radius: 18px;
    font-size: 17.5px;
    line-height: 1.65;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.msg.user .bubble { white-space: pre-wrap; }
.msg.assistant .bubble {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-top-left-radius: 4px;
}
.msg.user .bubble {
    background: var(--user-bubble);
    color: #fff;
    border-top-right-radius: 4px;
}
.msg-meta { font-size: 13px; color: var(--text-muted); padding: 0 4px; }
.msg.user .msg-meta { text-align: right; }

/* Event line inside the chat (not a message): e.g. "voice chat ended" */
.chat-note {
    align-self: center;
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
    max-width: 90%;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-elev);
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    animation: rise 0.25s ease;
}
.chat-note.error { color: var(--danger); }
.chat-note-time { font-size: 12px; opacity: 0.8; font-variant-numeric: tabular-nums; }

/* ============================ Markdown inside bubble ============================ */
.bubble p { margin: 0 0 0.6em; }
.bubble p:last-child { margin-bottom: 0; }

.bubble h1, .bubble h2, .bubble h3,
.bubble h4, .bubble h5, .bubble h6 {
    margin: 0.9em 0 0.4em;
    font-weight: 700;
    line-height: 1.3;
}
.bubble h1:first-child, .bubble h2:first-child,
.bubble h3:first-child { margin-top: 0; }
.bubble h1 { font-size: 1.25em; }
.bubble h2 { font-size: 1.12em; }
.bubble h3 { font-size: 1em; }

.bubble ul, .bubble ol {
    margin: 0.4em 0 0.6em 1.4em;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.bubble li { line-height: 1.55; }
.bubble li > ul, .bubble li > ol { margin-top: 3px; margin-bottom: 0; }

.bubble strong { font-weight: 700; }
.bubble em { font-style: italic; }

.bubble code {
    font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
    font-size: 0.88em;
    background: rgba(0, 0, 0, 0.18);
    border-radius: 5px;
    padding: 2px 6px;
}
:root[data-theme="light"] .bubble code { background: rgba(0, 0, 0, 0.07); }

.bubble pre {
    margin: 0.6em 0;
    border-radius: 10px;
    overflow-x: auto;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.06);
}
:root[data-theme="light"] .bubble pre {
    background: rgba(0, 0, 0, 0.06);
    border-color: var(--border);
}
.bubble pre code {
    background: transparent;
    padding: 14px 16px;
    display: block;
    font-size: 0.87em;
    line-height: 1.6;
    border-radius: 0;
}

.bubble blockquote {
    margin: 0.5em 0;
    padding: 8px 14px;
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    border-radius: 0 8px 8px 0;
    color: var(--text-muted);
    font-style: italic;
}

.bubble hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.8em 0;
}

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

.bubble table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.6em 0;
    font-size: 0.93em;
}
.bubble th, .bubble td {
    border: 1px solid var(--border);
    padding: 7px 12px;
    text-align: left;
}
.bubble th { background: var(--bg-elev); font-weight: 600; }

/* Play button for AI voice replies */
.bubble-audio { margin-top: 10px; }
.btn-play {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--accent-soft);
    border: 1.5px solid var(--border);
    color: var(--accent);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}
.btn-play:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-play:active { transform: scale(0.93); }
.btn-play .icon { width: 18px; height: 18px; }

.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--text-muted);
    animation: blink 1.2s infinite both;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* ============================ Composer ============================ */
.composer-wrap {
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}
.composer-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 5px 0;
    transition: color 0.2s;
    flex-shrink: 0;
}
.composer-toggle:hover { color: var(--text); }
.composer-toggle .icon {
    width: 18px; height: 18px;
    transition: transform 0.25s ease;
}
.composer-wrap.collapsed .composer-toggle .icon { transform: rotate(180deg); }
.composer-wrap.collapsed .composer textarea { display: none; }

.composer {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 4px 24px 20px;
}
.composer textarea {
    width: 100%;
    resize: none;
    min-height: 68px;
    max-height: 240px;
    background: var(--bg-elev);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    padding: 14px 18px;
    color: var(--text);
    font-family: inherit;
    font-size: 18px;
    line-height: 1.6;
}
.composer textarea:focus { outline: none; border-color: var(--accent); }
.composer textarea::placeholder { color: var(--text-muted); }

.composer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.composer-buttons { display: flex; gap: 12px; }
.toggle-group { display: flex; align-items: center; gap: 16px; }

.voice-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.voice-toggle .icon { width: 20px; height: 20px; color: var(--text-muted); }
.voice-toggle input:checked ~ .icon { color: var(--accent); }
.voice-toggle input { display: none; }
.toggle-track {
    width: 50px; height: 28px;
    background: var(--border);
    border-radius: 999px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-thumb {
    position: absolute;
    top: 3px; left: 3px;
    width: 22px; height: 22px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.voice-toggle input:checked + .toggle-track { background: var(--accent); }
.voice-toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(22px); }
.toggle-label { font-size: 16px; color: var(--text-muted); white-space: nowrap; }
.voice-toggle input:checked ~ .toggle-label { color: var(--text); font-weight: 600; }
.voice-toggle input:disabled ~ .toggle-track,
.voice-toggle input:disabled ~ .toggle-label,
.voice-toggle input:disabled ~ .icon { opacity: 0.6; cursor: not-allowed; }

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 22px;
    border-radius: 16px;
    border: 1.5px solid var(--border);
    font-family: inherit;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, background 0.15s, filter 0.15s, border-color 0.15s;
}
.btn-action .btn-ico { display: inline-flex; }
.btn-action .icon { width: 26px; height: 26px; }
.btn-action:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
.btn-mic { background: var(--bg-elev); color: var(--text); }
.btn-mic:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn-mic.recording {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
    animation: pulse 1.2s infinite;
}
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 92, 124, 0.5); } 50% { box-shadow: 0 0 0 10px rgba(255, 92, 124, 0); } }
.btn-send { background: var(--user-bubble); color: #fff; border: none; }
.btn-send:hover { filter: brightness(1.08); }
.btn-send:active, .btn-mic:active { transform: scale(0.97); }
.btn-mic:disabled { opacity: 0.5; cursor: default; }
.btn-send:disabled { opacity: 0.5; cursor: default; }

.status-bar {
    padding: 8px 24px 16px;
    font-size: 15px;
    color: var(--text-muted);
    text-align: center;
}
.status-bar.error { color: var(--danger); }

/* ===================== "Still there?" dialog ===================== */
.idle-dialog {
    margin: auto;
    width: min(340px, calc(100% - 32px));
    padding: 32px 28px 28px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--bg-soft);
    color: var(--text);
    text-align: center;
    box-shadow: var(--shadow);
}
.idle-dialog::backdrop {
    background: rgba(4, 16, 16, 0.55);
    backdrop-filter: blur(3px);
}
.idle-dialog[open] { animation: idle-in 0.2s ease-out; }
@keyframes idle-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }

.idle-timer {
    position: relative;
    width: 112px;
    height: 112px;
    margin: 0 auto 20px;
}
.idle-timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.idle-track,
.idle-arc { fill: none; stroke-width: 6; }
.idle-track { stroke: var(--border); }
.idle-arc {
    stroke: var(--accent);
    stroke-linecap: round;
    stroke-dasharray: 100;
    stroke-dashoffset: 0;
}
/* The arc drains over the countdown and turns red for the last few seconds. */
.idle-dialog.counting .idle-arc {
    animation: idle-drain var(--idle-duration, 15s) linear forwards;
}
@keyframes idle-drain {
    0%   { stroke-dashoffset: 0;   stroke: var(--accent); }
    60%  { stroke: var(--accent); }
    72%  { stroke: var(--danger); }
    100% { stroke-dashoffset: 100; stroke: var(--danger); }
}
.idle-seconds {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 40px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease;
}
.idle-dialog.urgent .idle-seconds { color: var(--danger); }

.idle-title { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
.idle-text {
    font-size: 16px;
    line-height: 1.45;
    color: var(--text-muted);
    margin-bottom: 24px;
}
.idle-btn { width: 100%; justify-content: center; }

@media (prefers-reduced-motion: reduce) {
    .idle-dialog[open] { animation: none; }
    .idle-dialog.counting .idle-arc { animation: none; }
}

/* ============================ Responsive ============================ */
@media (max-width: 760px) {
    .app { padding: 0; }
    .chat { border-radius: 0; border-left: none; border-right: none; box-shadow: none; }
    .chat-head { gap: 12px; padding: 12px 16px; }
    .header-username { display: none; }
    .msg { max-width: 90%; }
    .messages { padding: 20px 16px; }
    .composer { padding: 4px 16px 16px; }
    .composer-actions { flex-direction: column; align-items: stretch; gap: 14px; }
    .composer-buttons { width: 100%; }
    .btn-action { flex: 1; justify-content: center; }
}

/* ============================ Mobile small (≤ 480px) ============================ */
@media (max-width: 480px) {
    /* Auth: flex вместо grid-center — не режет карточку на коротких экранах,
       dvh учитывает реальную видимую область iOS Safari */
    .auth-page {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        min-height: 100dvh;
        padding: 80px 16px 32px;
    }
    .auth-card { padding: 28px 20px; }

    /* Chat header: уменьшаем все элементы чтобы влезли в 375px */
    .chat-head { gap: 6px; padding: 10px 12px; }
    .control-btn { height: 40px; min-width: 40px; padding: 0 10px; font-size: 14px; }
    .control-btn .chevron { display: none; }
    .lang-current { font-size: 14px; }
    .theme-toggle { width: 40px; }
    .header-user { height: 40px; padding: 0 6px 0 10px; gap: 5px; }
    .header-user .btn-logout { width: 28px; height: 28px; }

    /* Composer: иконки без текста — "Голосовой ввод" и "Отправить" не влезают */
    .btn-action .btn-label { display: none; }
    .btn-action { padding: 0 20px; }

    /* Оба тумблера остаются в одну строку — прячем подписи, оставляем иконку+переключатель */
    .toggle-group { gap: 12px; }
    .toggle-label { display: none; }
}

/* Совсем маленькие экраны (≤ 360px): скрываем текст бренда, оставляем логотип */
@media (max-width: 360px) {
    .brand-name { display: none; }
}
