:root {
    --yellow: #FFCF3F;
    --ink: #1E1A3A;
    --blue: #2340D6;
    --muted: #5A5470;
    --white: #fff;

    --bg: var(--yellow);
    --text: var(--ink);
    --surface: var(--white);
    --fill: var(--ink);
    --on-fill: var(--yellow);
    --shadow: var(--ink);
    --shadow-deep: #000;
    --line: rgba(30, 26, 58, .35);
    --line-soft: rgba(30, 26, 58, .3);
    --chip-shade: rgba(30, 26, 58, .18);
    --scrim: rgba(30, 26, 58, .55);
    --chat-bg: #FFF4CC;
    --bubble: var(--white);
    --bubble-shadow: rgba(30, 26, 58, .15);
    --scrollbar: rgba(30, 26, 58, .25);
    --input-bg: var(--white);
    --input-border: var(--ink);
    --input-disabled-bg: #F7F5EE;
    --input-disabled-border: rgba(30, 26, 58, .35);
    --self-bg: rgba(255, 255, 255, .45);
    --focus: var(--blue);
    --status-bg: var(--ink);
    --status-text: var(--white);
    --mine-bg: var(--ink);
    --mine-text: var(--white);
    --mine-muted: rgba(255, 255, 255, .7);
    --banner-bg: var(--ink);
    --banner-text: var(--white);
    --counter-bg: var(--ink);
    --kick-bg: var(--ink);
    --kick-text: var(--white);
    --kick-hover: var(--chip-2);
    --full-bg: var(--ink);
    --full-text: var(--chip-2);
    color-scheme: light;

    --chip-1: #7FC8A9;
    --chip-2: #E57F6B;
    --chip-3: #9DB4E8;
    --chip-4: #D59BE0;
    --chip-5: #F5A15B;
    --chip-6: #8ED1D6;
    --chip-7: #C3D98A;
    --chip-8: #F2F0FF;
}

html[data-theme="dark"] {
    --bg: #14111E;
    --text: #F6F1E6;
    --muted: #C2B9D2;
    --surface: #2A2640;
    --fill: var(--yellow);
    --on-fill: var(--ink);
    --shadow: #07060C;
    --shadow-deep: #07060C;
    --line: rgba(246, 241, 230, .28);
    --line-soft: rgba(246, 241, 230, .24);
    --chip-shade: rgba(0, 0, 0, .35);
    --scrim: rgba(6, 5, 12, .72);
    --chat-bg: #1C1830;
    --bubble: #342F4E;
    --bubble-shadow: rgba(0, 0, 0, .45);
    --scrollbar: rgba(246, 241, 230, .22);
    --input-bg: #1C1830;
    --input-border: rgba(246, 241, 230, .4);
    --input-disabled-bg: #161322;
    --input-disabled-border: rgba(246, 241, 230, .18);
    --self-bg: rgba(255, 255, 255, .08);
    --focus: var(--yellow);
    --status-bg: #3A3458;
    --status-text: var(--text);
    --mine-bg: #322C4C;
    --mine-text: var(--text);
    --mine-muted: rgba(246, 241, 230, .7);
    --banner-bg: var(--yellow);
    --banner-text: var(--ink);
    --counter-bg: #100E18;
    --kick-bg: var(--chip-2);
    --kick-text: var(--ink);
    --kick-hover: #9d4034;
    --full-bg: var(--chip-2);
    --full-text: var(--ink);
    color-scheme: dark;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
}

body {
    color: var(--text);
    font-family: Rubik, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select {
    font-family: inherit;
    color: inherit;
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

/* Каркас страницы */
.page {
    max-width: 430px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding: 20px 20px 28px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

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

.logo {
    font-size: 22px;
    font-weight: 900;
    letter-spacing: -0.01em;
}

.h {
    font-size: 36px;
    font-weight: 900;
    line-height: 1.05;
    margin: 8px 0 0;
}

.muted {
    color: var(--muted);
    font-size: 14px;
}

.hand {
    font-family: Caveat, cursive;
    font-weight: 700;
}

/* Текстовая кнопка-ссылка в шапке */
.link-btn {
    background: none;
    border: 0;
    padding: 6px 2px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
    cursor: pointer;
}

.link-btn:hover {
    text-decoration-thickness: 3px;
}

/* Основная кнопка */
.cta {
    height: 58px;
    width: 100%;
    border: 0;
    border-radius: 18px;
    font: 700 19px Rubik, sans-serif;
    cursor: pointer;
    transition: transform .08s, box-shadow .08s, opacity .15s;
}

.cta.ink {
    background: var(--fill);
    color: var(--on-fill);
    box-shadow: 0 5px 0 var(--shadow-deep);
}

.cta.blue {
    background: var(--blue);
    color: var(--white);
    box-shadow: 0 5px 0 var(--shadow);
}

.cta:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 var(--shadow-deep);
}

.cta:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
}

html[data-theme="dark"] .cta:disabled {
    opacity: 1;
    background: #3A3458;
    color: rgba(246, 241, 230, .5);
    box-shadow: none;
}

/* Синяя «карта» */
.card {
    background: var(--blue);
    color: var(--white);
    border-radius: 28px;
    padding: 22px 22px 24px;
    box-shadow: 0 8px 0 var(--shadow);
    transform: rotate(-1.5deg);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.card-label {
    font-size: 14px;
    font-weight: 500;
    opacity: .85;
}

/* Поле ввода в стиле карты: белая линия снизу */
.line-input {
    background: transparent;
    border: 0;
    border-bottom: 3px solid rgba(255, 255, 255, .55);
    border-radius: 0;
    color: var(--white);
    font: 700 24px Rubik, sans-serif;
    padding: 4px 0 8px;
    outline: none;
    width: 100%;
}

.line-input::placeholder {
    color: rgba(255, 255, 255, .5);
}

.line-input:focus {
    border-bottom-color: var(--white);
}

/* Модалки: JS показывает их через style.display = 'block' */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    overflow-y: auto;
    padding: 12vh 20px 40px;
    background: var(--scrim);
    backdrop-filter: blur(2px);
}

.modal-content {
    position: relative;
    max-width: 390px;
    margin: 0 auto;
    animation: card-in .18s ease-out;
}

@keyframes card-in {
    from { transform: translateY(16px) rotate(-1.5deg); opacity: 0; }
    to   { transform: translateY(0) rotate(-1.5deg); opacity: 1; }
}

.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.theme-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    box-shadow: 0 3px 0 var(--shadow);
    transition: transform .08s, box-shadow .08s;
}

.theme-btn svg {
    width: 22px;
    height: 22px;
    display: block;
}

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

.theme-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 var(--shadow);
}