
:root {
    --chat-width: 1080px;
    --chat-font-size: 16px;
    --panel: rgba(10, 12, 17, 0.96);
    --panel-soft: rgba(16, 19, 27, 0.94);
    --input: rgba(7, 9, 14, 0.9);
    --hover: rgba(255, 255, 255, 0.09);
    --line: rgba(205, 210, 221, 0.28);
    --line-strong: rgba(220, 224, 233, 0.46);
    --text: #f3f4f7;
    --muted: #adb3c0;
    --dim: #747c8b;
    --violet: #d0b6f4;
    --cyan: #a8e4ea;
    --gold: #f2d494;
    --green: #9ee7ba;
    --red: #ffadb2;
    --blue: #b9dcf8;
}

* {
    box-sizing: border-box;
    letter-spacing: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: transparent;
}

body {
    color: var(--text);
    font-family: "Segoe UI Variable Text", "Segoe UI", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    user-select: none;
}

button,
input,
textarea {
    color: inherit;
    font: inherit;
}

button {
    border: 0;
}

.chat-root {
    position: fixed;
    inset: 0;
    pointer-events: none;
}

.chat-root[hidden] {
    display: none;
}

.chat-stack {
    position: absolute;
    top: clamp(18px, 2vh, 28px);
    left: clamp(18px, 1.5vw, 28px);
    display: flex;
    width: min(var(--chat-width), calc(100vw - 36px));
    max-height: calc(100vh - 46px);
    flex-direction: column;
    justify-content: flex-start;
    gap: 6px;
}

.messages {
    display: flex;
    min-height: 0;
    max-height: calc(100vh - 112px);
    flex: 0 1 auto;
    flex-direction: column;
    justify-content: flex-start;
    gap: 1px;
    overflow: hidden;
    padding: 3px 1px 5px;
}

.message {
    width: fit-content;
    max-width: 100%;
    max-height: 2.2em;
    flex: 0 0 auto;
    overflow: hidden;
    padding: 1px 0;
    color: var(--text);
    font-size: var(--chat-font-size);
    font-weight: 560;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow:
        -1px -1px 0 rgba(0, 0, 0, 0.94),
        1px -1px 0 rgba(0, 0, 0, 0.94),
        -1px 1px 0 rgba(0, 0, 0, 0.94),
        1px 1px 0 rgba(0, 0, 0, 0.94),
        0 2px 5px rgba(0, 0, 0, 0.9);
    opacity: 1;
    transform: translateY(0);
    animation: message-in 170ms ease-out both;
    transition:
        max-height 190ms ease,
        padding 190ms ease,
        opacity 160ms ease,
        transform 190ms ease;
}

.message.is-leaving {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    transform: translateY(-7px);
}

.message.is-static {
    animation: none;
}

.message-kind-me {
    color: var(--violet);
}

.message-kind-do {
    color: var(--cyan);
}

.message-kind-b {
    color: #c7cad2;
}

.message-kind-shout {
    color: var(--gold);
    font-weight: 680;
}

.message-kind-whisper_out,
.message-kind-whisper_in {
    color: var(--blue);
}

.message-kind-notice {
    color: var(--red);
}

.sender {
    color: #ffffff;
    font-weight: 720;
}

.message-kind-me .sender {
    color: inherit;
}

.message-id {
    color: #b5bac5;
    font-size: 0.94em;
    font-weight: 620;
}

.message-time {
    color: #8e95a3;
    font-size: 0.86em;
    font-weight: 620;
    font-variant-numeric: tabular-nums;
}

.result {
    font-weight: 760;
}

.message-kind-try_success .result {
    color: var(--green);
}

.message-kind-try_failure .result {
    color: var(--red);
}

.composer {
    display: flex;
    width: 100%;
    height: 44px;
    flex: 0 0 44px;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    opacity: 0;
    pointer-events: none;
    transform: translateY(5px);
    transition: opacity 110ms ease, transform 150ms ease;
}

.is-input .composer {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.is-input.is-settings-open .composer {
    opacity: 0.58;
    pointer-events: none;
}

.tool-button {
    display: grid;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    place-items: center;
    border-radius: 4px;
    background: transparent;
    color: #d2d5dc;
    cursor: pointer;
    font-family: "Segoe UI Symbol", "Segoe UI", sans-serif;
    font-size: 22px;
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.9);
    transition: background-color 110ms ease, color 110ms ease, transform 110ms ease;
}

.tool-button:hover,
.tool-button.is-active {
    background: rgba(10, 12, 17, 0.82);
    color: #ffffff;
}

.tool-button:active {
    transform: scale(0.93);
}

.settings-toggle span {
    display: block;
    transition: transform 180ms ease;
}

.settings-toggle.is-active span {
    transform: rotate(45deg);
}

.input-shell {
    position: relative;
    display: flex;
    min-width: 0;
    height: 44px;
    flex: 1;
    align-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 3px;
    background: var(--input);
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.28);
    transition: border-color 110ms ease, background-color 110ms ease;
}

.input-shell:focus-within {
    border-color: rgba(208, 182, 244, 0.82);
    background: rgba(10, 12, 18, 0.96);
}

.input-shell.is-invalid {
    border-color: rgba(255, 133, 141, 0.88);
}

#chatInput {
    width: 100%;
    height: 42px;
    resize: none;
    overflow: hidden;
    padding: 10px 80px 9px 12px;
    border: 0;
    outline: 0;
    background: transparent;
    color: #ffffff;
    caret-color: #ffffff;
    font-size: var(--chat-font-size);
    font-weight: 520;
    line-height: 1.35;
    white-space: pre;
}

#chatInput::placeholder {
    color: #7d8492;
    font-size: 16px;
}

.input-counter {
    position: absolute;
    right: 43px;
    bottom: 5px;
    color: var(--dim);
    font-size: 9px;
    font-variant-numeric: tabular-nums;
    opacity: 0;
    pointer-events: none;
    transition: opacity 100ms ease;
}

.input-counter.is-warning,
.input-counter.is-invalid {
    opacity: 1;
}

.input-counter.is-warning {
    color: var(--gold);
}

.input-counter.is-invalid {
    color: var(--red);
}

.emoji-toggle {
    position: absolute;
    top: 4px;
    right: 4px;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 3px;
    background: transparent;
    color: #c7cbd4;
    cursor: pointer;
    font-family: "Segoe UI Symbol", sans-serif;
    font-size: 22px;
    transition: background-color 110ms ease, color 110ms ease, transform 110ms ease;
}

.emoji-toggle:hover,
.emoji-toggle.is-active {
    background: var(--hover);
    color: #ffffff;
}

.emoji-toggle:active {
    transform: scale(0.92);
}

.language-indicator {
    display: grid;
    width: 48px;
    height: 44px;
    flex: 0 0 48px;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 3px;
    background: var(--input);
    color: #f0f1f4;
    font-family: "Segoe UI Variable Text", "Segoe UI", sans-serif;
    font-size: 12px;
    font-weight: 760;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.28);
}

.emoji-panel,
.settings-panel {
    z-index: 5;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    background: var(--panel);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.38);
    pointer-events: auto;
}

.emoji-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    transform-origin: left top;
    animation: panel-in 150ms ease-out both;
}

.emoji-panel.is-flipped {
    top: auto;
    bottom: 50px;
    transform-origin: left bottom;
}

.emoji-panel[hidden],
.settings-panel[hidden],
.emoji-empty[hidden],
.emoji-grid[hidden] {
    display: none;
}

.emoji-panel {
    width: min(390px, 100%);
    height: 268px;
}

.emoji-toolbar {
    display: flex;
    min-height: 48px;
    align-items: center;
    padding: 6px;
    border-bottom: 1px solid var(--line);
}

.emoji-search {
    display: flex;
    width: 100%;
    min-width: 0;
    height: 36px;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.04);
}

.emoji-search:focus-within {
    border-color: rgba(208, 182, 244, 0.68);
}

.search-icon {
    position: relative;
    width: 13px;
    height: 13px;
    flex: 0 0 13px;
    border: 1.5px solid var(--muted);
    border-radius: 50%;
}

.search-icon::after {
    position: absolute;
    right: -4px;
    bottom: -3px;
    width: 5px;
    height: 1.5px;
    border-radius: 1px;
    background: var(--muted);
    content: "";
    transform: rotate(45deg);
}

.emoji-search input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 13px;
}

.emoji-search input::placeholder {
    color: var(--dim);
}

.emoji-grid {
    display: grid;
    height: 219px;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    align-content: start;
    gap: 2px;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 8px;
    scrollbar-color: rgba(208, 182, 244, 0.45) transparent;
    scrollbar-width: thin;
}

.emoji-item {
    display: grid;
    aspect-ratio: 1;
    min-width: 0;
    place-items: center;
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
    font-family: "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
    font-size: 20px;
    transition: background-color 100ms ease, transform 100ms ease;
}

.emoji-item:hover {
    background: var(--hover);
    transform: translateY(-1px);
}

.emoji-item:active {
    transform: scale(0.9);
}

.emoji-empty {
    display: grid;
    height: 219px;
    place-items: center;
    color: var(--dim);
    font-size: 14px;
}

.settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;
    width: min(270px, calc(100vw - 24px));
    padding: 0 9px 7px;
    transform-origin: center;
    animation: settings-window-in 140ms ease-out both;
}

.settings-header {
    display: flex;
    min-height: 36px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    cursor: grab;
    touch-action: none;
}

.settings-panel.is-dragging .settings-header {
    cursor: grabbing;
}

.settings-title {
    display: flex;
    min-width: 0;
    align-items: baseline;
    gap: 6px;
}

.settings-title strong {
    color: #ffffff;
    font-size: 12px;
    font-weight: 720;
}

.settings-title span {
    color: var(--dim);
    font-size: 9px;
    font-weight: 560;
}

.settings-actions {
    display: flex;
    align-items: center;
    gap: 1px;
    cursor: default;
}

.settings-action {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    border-radius: 3px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-family: "Segoe UI Symbol", sans-serif;
    font-size: 16px;
    transition: background-color 110ms ease, color 110ms ease, transform 110ms ease;
}

.settings-action:hover {
    background: var(--hover);
    color: #ffffff;
}

.reset-settings:active {
    transform: rotate(-30deg) scale(0.92);
}

.settings-close span {
    color: inherit;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
}

.settings-close:active {
    transform: scale(0.9);
}

.setting-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 2px 8px;
    padding-top: 5px;
}

.setting-row label {
    color: #d7dae1;
    font-size: 11px;
    font-weight: 580;
}

.setting-row output {
    min-width: 44px;
    color: #ffffff;
    font-size: 11px;
    font-weight: 680;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.setting-row input[type="range"] {
    width: 100%;
    height: 10px;
    grid-column: 1 / -1;
    margin: 0;
    accent-color: #b69cdb;
    cursor: pointer;
}

.setting-row-toggle {
    min-height: 28px;
    padding-top: 5px;
}

.setting-toggle {
    position: relative;
    width: 30px;
    height: 16px;
    margin: 0;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    appearance: none;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: border-color 120ms ease, background-color 120ms ease;
}

.setting-toggle::after {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #a8afbc;
    content: "";
    transition: left 120ms ease, background-color 120ms ease;
}

.setting-toggle:checked {
    border-color: rgba(208, 182, 244, 0.76);
    background: rgba(182, 156, 219, 0.34);
}

.setting-toggle:checked::after {
    left: 16px;
    background: #decaf8;
}

.setting-toggle:focus-visible {
    outline: 1px solid #decaf8;
    outline-offset: 2px;
}

.toast {
    position: absolute;
    left: clamp(74px, calc(3vw + 48px), 106px);
    bottom: clamp(78px, calc(4.5vh + 52px), 104px);
    max-width: min(520px, calc(100vw - 80px));
    padding: 8px 11px;
    border: 1px solid rgba(255, 149, 156, 0.46);
    border-radius: 3px;
    background: rgba(34, 16, 21, 0.96);
    color: #ffd2d5;
    font-size: 13px;
    font-weight: 620;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 120ms ease, transform 140ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@keyframes message-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes panel-in {
    from {
        opacity: 0;
        transform: translateY(7px) scale(0.99);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes settings-window-in {
    from {
        opacity: 0;
        transform: scale(0.98);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 680px) {
    .chat-stack {
        top: 14px;
        left: 14px;
        width: calc(100vw - 28px);
        max-height: calc(100vh - 28px);
    }

    .messages {
        max-height: calc(100vh - 96px);
    }

    .emoji-panel {
        left: 0;
        width: 100%;
    }

    .emoji-toolbar {
        align-items: center;
    }

    .emoji-search {
        width: 100%;
    }

    .emoji-categories {
        justify-content: space-between;
    }

    .emoji-panel {
        height: 260px;
    }

    .emoji-grid,
    .emoji-empty {
        height: 211px;
    }

    .emoji-grid {
        grid-template-columns: repeat(9, minmax(0, 1fr));
    }

    .tool-button {
        width: 38px;
        flex-basis: 38px;
    }

    .language-indicator {
        width: 44px;
        flex-basis: 44px;
    }

    #chatInput {
        padding-left: 10px;
    }

    .toast {
        left: 58px;
        bottom: 68px;
        max-width: calc(100vw - 72px);
    }
}

@media (max-height: 720px) and (min-width: 681px) {
    .emoji-panel {
        height: 244px;
    }

    .emoji-grid,
    .emoji-empty {
        height: 191px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
    