/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Theme variables.
 *
 * Dark palette switched 2026-05-08 from the navy mix to the gray
 * Discord-style scheme used in tmp/design/*-prototype.html. Reasoning:
 * the prototypes are the source-of-truth for visual design; navy didn't
 * match. Hex values are lifted verbatim from the prototypes.
 *
 * If a component had hardcoded the navy colors (rare — most use var()
 * tokens), those need follow-up audits. Search for #1a1a2e / #16213e /
 * #0f3460 / #1e2a4a hex strings and migrate to the new scheme.
 */
:root[data-theme="dark"] {
    /* v2 design tokens — sourced verbatim from
       tmp/design/freescord-v2-app-prototype.html. Hierarchy:
       base      (#15171a) — page background under everything
       tertiary  (#1e1f22) — servers rail (darkest visible surface)
       secondary (#2a2c30) — chat / library / settings body
       primary   (#2b2d31) — channels sidebar (panel surface)
       elev      (#34363c) — elevated cards / popovers
       hover     (#383a40) — interactive hover states */
    --bg-base:      #15171a;
    --bg-primary:   #2b2d31;
    --bg-secondary: #2a2c30;
    --bg-tertiary:  #1e1f22;
    --bg-input:     #1e1f22;
    --bg-elev:      #34363c;
    --bg-hover:     #383a40;
    --text-primary:   #f2f3f5;
    --text-secondary: #b9bbbe;
    --text-muted:     #949ba4;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --danger: #ed4245;
    --danger-hover: #c03537;
    --success: #57f287;
    --warning: #f5b94d;
    --border: #2a2c30;
    --border-faint:  rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.12);
    --shadow: rgba(0, 0, 0, 0.3);
    --z-notify: 10001;
    /* Accent tints + state colors. */
    --accent-tint-strong: rgba(88, 101, 242, 0.16);
    --accent-tint-soft:   rgba(88, 101, 242, 0.08);
    --error:              #f23f42;
    --error-tint:         rgba(242, 63, 66, 0.16);
    --warning-tint:       rgba(245, 185, 77, 0.14);
    /* Radii — v2 prototype scale. Старые радиусы --radius-card/cover/row
       сохранены как алиасы, поэтому существующие места не сломаются. */
    --radius-xl:    16px;
    --radius-lg:    12px;
    --radius-md:    10px;
    --radius-sm:    8px;
    --radius-card:  12px;   /* alias of --radius-lg */
    --radius-cover: 8px;    /* alias of --radius-sm */
    --radius-row:   6px;
    --radius-pill:  9999px;
    /* Glassmorphism — для модалок и drawer'ов. */
    --glass-bg:   rgba(40, 42, 47, 0.78);
    --glass-blur: blur(18px) saturate(140%);
    /* Transitions — три скорости. --transition-cover оставлен как алиас. */
    --transition-fast:    140ms cubic-bezier(0.2, 0, 0.2, 1);
    --transition-medium:  260ms cubic-bezier(0.2, 0, 0.2, 1);
    --transition-slow:    420ms cubic-bezier(0.16, 1, 0.3, 1);
    --transition-cover:   380ms cubic-bezier(0.16, 1, 0.3, 1);
    /* Шрифты — Manrope для body, JetBrains Mono для tabular/labels. */
    --font-body:          'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-mono:          'JetBrains Mono', ui-monospace, Consolas, monospace;
}

:root[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f2f3f5;
    --bg-tertiary: #e3e5e8;
    --bg-input: #ebedef;
    --text-primary: #2e3338;
    --text-secondary: #4f5660;
    --text-muted: #96989d;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --danger: #ed4245;
    --danger-hover: #c03537;
    --success: #57f287;
    --warning: #fee75c;
    --border: #e0e0e0;
    --border-faint: rgba(0, 0, 0, 0.06);
    --shadow: rgba(0, 0, 0, 0.1);
    --z-notify: 10001;
}

html, body {
    height: 100%;
    height: 100dvh;
    /* JS-driven var for iOS Safari where dvh is unreliable (visualViewport.height on resize) */
    height: var(--vvh, 100dvh);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    overflow: hidden; /* prevent page-level scroll — only inner scroll areas (.chat-messages) scroll */
}

/* Pin html/body to the viewport so iOS Safari can't auto-scroll them up when the
   on-screen keyboard appears. Without this, focusing an input makes Safari shift
   the whole page up to "reveal" the input — pushing header/messages off-screen
   and leaving the input flush with the status bar with empty space below. */
html {
    position: fixed;
    inset: 0;
    width: 100%;
    overflow: hidden;
}
body {
    position: relative;
    width: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

/* iOS Safari zooms into inputs with font-size < 16px on focus — prevent globally on touch devices */
@media (pointer: coarse) and (hover: none) {
    input, textarea, select {
        font-size: 16px !important;
    }
}

#app {
    height: 100%;
    height: 100dvh;
    height: var(--vvh, 100dvh);
    display: flex;
    flex-direction: column;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ─── view-enter animation ───
   Слайд справа на 320ms при mount нового view. Применяй класс
   .view-enter на root-элемент компонента ТОЛЬКО когда юзер
   действительно навигирует в новый view (push), а не на каждый
   re-render. Подробнее в commit-сообщении phase 15. */
.view-enter {
    animation: viewSlideEnter 320ms cubic-bezier(0.16, 1, 0.3, 1);
}
.view-back {
    animation: viewSlideBack 320ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes viewSlideEnter {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes viewSlideBack {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
    .view-enter, .view-back { animation: none; }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
