:root {
    color-scheme: dark;
    --bg: #070908;
    --panel: #111412;
    --panel-2: #0c0f0d;
    --panel-3: #18201b;
    --text: #eef3ef;
    --muted: #8f9b94;
    --line: #253129;
    --accent: #21a366;
    --accent-2: #155f3c;
    --accent-soft: rgba(33, 163, 102, 0.14);
    --danger: #ff6b61;
    --warning: #f2b84b;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
}

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

button {
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease, filter 150ms ease;
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    cursor: default;
    opacity: 0.68;
    transform: none;
}

button svg {
    width: 18px;
    height: 18px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

button svg[xmlns] {
    pointer-events: none;
}

.primary-action,
.ghost-action,
.admin-toolbar button,
.file-button,
.model-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-action span,
.ghost-action span,
.admin-toolbar button span,
.model-action span {
    line-height: 1;
}

.icon-only {
    display: inline-grid !important;
    place-items: center;
    gap: 0;
}

.icon-only span {
    display: none;
}

.hidden {
    display: none !important;
}

.login-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--bg);
}

.login-panel {
    width: min(100%, 430px);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 30px;
    box-shadow: var(--shadow);
    animation: socomFadeInUp 320ms ease both;
}

.login-logo {
    width: min(320px, 100%);
    height: auto;
    display: block;
    margin: 0 auto 20px;
}

.login-panel h1,
.topbar h2,
.admin-dialog h2 {
    margin: 0;
    letter-spacing: 0;
}

.login-panel p,
.admin-dialog p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.login-form {
    display: grid;
    gap: 10px;
    margin-top: 22px;
}

.login-form label {
    font-size: 13px;
    color: var(--muted);
}

.login-form input,
.admin-toolbar input,
.admin-toolbar select {
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0 12px;
    background: #0f1319;
    color: var(--text);
}

.login-form button,
.primary-action,
.send-button,
.admin-toolbar button {
    border: 0;
    border-radius: 12px;
    background: var(--accent);
    color: #06110b;
    min-height: 40px;
    padding: 0 14px;
    font-weight: 700;
    box-shadow: none;
}

.secondary-action {
    min-height: 42px;
    width: fit-content;
    max-width: 100%;
    border: 1px solid rgba(255, 107, 97, 0.38);
    border-radius: 12px;
    background: rgba(255, 107, 97, 0.08);
    color: #ffb4ad;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
}

.secondary-action:hover {
    border-color: rgba(255, 107, 97, 0.7);
    background: rgba(255, 107, 97, 0.14);
}

.login-form button:hover,
.primary-action:hover,
.send-button:hover,
.admin-toolbar button:hover {
    filter: brightness(1.08);
}

.notice {
    min-height: 20px;
    color: var(--muted);
}

.app-shell {
    height: 100vh;
    height: 100dvh;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    overflow: hidden;
}

.sidebar {
    background: #080a0d;
    border-right: 1px solid var(--line);
    color: var(--text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    padding: 14px;
    position: sticky;
    top: 0;
}

.brand-row {
    display: grid;
    gap: 10px;
    align-items: start;
    padding: 8px 4px 16px;
    flex: 0 0 auto;
}

.brand-mark {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--accent);
    color: #06110b;
    font-weight: 800;
}

.brand-logo {
    width: min(190px, 100%);
    height: auto;
    object-fit: contain;
    border-radius: 0;
    background: transparent;
    padding: 0;
}

.brand-row span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.primary-action {
    width: 100%;
    margin-bottom: 12px;
    flex: 0 0 auto;
}

.chat-list {
    display: grid;
    gap: 6px;
    overflow: auto;
    min-height: 0;
    padding-right: 2px;
}

.chat-item {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    border-radius: 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px;
    padding: 6px;
}

.chat-item.renaming {
    grid-template-columns: 1fr;
}

.chat-item:hover,
.chat-item.active {
    background: var(--panel);
    border-color: var(--line);
}

.chat-open {
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    display: grid;
    gap: 4px;
    padding: 4px;
}

.chat-item span {
    color: var(--muted);
    font-size: 12px;
}

.chat-open strong,
.chat-open span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-rename {
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    opacity: 0;
}

.chat-row-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.chat-item:hover .chat-row-actions .chat-rename,
.chat-item.active .chat-row-actions .chat-rename,
.chat-rename:focus-visible {
    opacity: 1;
}

.chat-rename:hover {
    color: var(--text);
    border-color: var(--line);
    background: var(--panel-3);
}

.chat-delete:hover {
    color: var(--danger);
    border-color: rgba(255, 107, 97, 0.42);
}

.chat-rename-input {
    width: 100%;
    min-width: 0;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--panel-2);
    color: var(--text);
    outline: none;
    padding: 0 9px;
    font-size: 14px;
}

.chat-rename-input:focus {
    border-color: rgba(33, 163, 102, 0.58);
}

.sidebar-footer {
    margin-top: 12px;
    display: grid;
    gap: 8px;
    flex: 0 0 auto;
}

.sidebar-footer .ghost-action {
    width: 100%;
    justify-content: center;
}

.sidebar-backdrop {
    display: none;
}

.ghost-action,
.icon-button,
.admin-tab,
.admin-row button {
    min-height: 38px;
    border: 1px solid var(--line);
    color: var(--text);
    background: var(--panel);
    border-radius: 12px;
}

.ghost-action:hover,
.icon-button:hover,
.admin-tab:hover,
.admin-row button:hover {
    border-color: rgba(143, 178, 255, 0.42);
    background: var(--panel-3);
}

.chat-pane {
    min-width: 0;
    height: 100vh;
    height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    background: rgba(11, 13, 16, 0.92);
    backdrop-filter: none;
    border-bottom: 1px solid var(--line);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-menu-button {
    display: none !important;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    color: var(--text);
}

.messages {
    overflow: auto;
    min-height: 0;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.empty-state {
    margin: auto;
    width: min(100%, 620px);
    text-align: center;
    color: var(--muted);
}

.empty-state h1 {
    margin: 0 0 8px;
    font-size: clamp(28px, 4vw, 44px);
    font-weight: 700;
    letter-spacing: 0;
    color: var(--text);
}

.message {
    width: min(100%, 780px);
    display: grid;
    gap: 7px;
}

.message.user {
    align-self: flex-end;
    justify-items: end;
}

.message.assistant {
    align-self: center;
}

.bubble {
    border-radius: 14px;
    padding: 13px 15px;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.user .bubble {
    background: #1d6f49;
    color: #fff;
}

.assistant .bubble {
    background: var(--panel);
    border: 1px solid var(--line);
}

.markdown-body {
    white-space: normal;
}

.markdown-body > :first-child {
    margin-top: 0;
}

.markdown-body > :last-child {
    margin-bottom: 0;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre,
.markdown-body table {
    margin: 0 0 12px;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin: 18px 0 8px;
    line-height: 1.25;
    font-weight: 700;
    color: var(--text);
}

.markdown-body h1 {
    font-size: 24px;
}

.markdown-body h2 {
    font-size: 20px;
}

.markdown-body h3 {
    font-size: 17px;
}

.markdown-body ul,
.markdown-body ol {
    padding-left: 22px;
}

.markdown-body li + li {
    margin-top: 4px;
}

.markdown-body a {
    color: #8fb2ff;
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.md-image-link {
    max-width: 100%;
}

.md-image-link.has-preview {
    display: grid;
    gap: 8px;
    margin: 10px 0;
}

.md-image-link.has-preview img {
    display: block;
    max-width: min(100%, 520px);
    max-height: 360px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel-2);
}

.md-image-link a {
    overflow-wrap: anywhere;
    font-size: 13px;
}

.markdown-body code {
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 1px 5px;
    background: #0a0d13;
    color: #dbeafe;
    font-family: Consolas, Monaco, monospace;
    font-size: 0.92em;
}

.code-block {
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #080a0d;
    margin-bottom: 12px;
}

.code-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 34px;
    border-bottom: 1px solid var(--line);
    padding: 6px 8px;
    background: var(--panel-2);
}

.code-copy-button {
    margin-left: auto;
    min-height: 26px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
    padding: 0 9px;
    font-size: 12px;
    font-weight: 700;
}

.code-copy-button:hover {
    color: var(--text);
    border-color: rgba(33, 163, 102, 0.5);
}

.markdown-body pre {
    overflow: auto;
    border: 0;
    border-radius: 0;
    padding: 12px;
    background: #080a0d;
    margin: 0;
}

.markdown-body pre code {
    display: block;
    border: 0;
    padding: 0;
    background: transparent;
    white-space: pre;
}

.code-label {
    color: var(--muted);
    font-family: inherit;
    font-size: 12px;
}

.markdown-body blockquote {
    border-left: 3px solid #4f8cff;
    padding-left: 12px;
    color: var(--muted);
}

.md-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    margin-bottom: 12px;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid var(--line);
    padding: 8px 10px;
    text-align: left;
}

.markdown-body th {
    background: var(--panel-2);
}

.file-chip,
.upload-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    min-height: 30px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 10px;
    background: var(--panel-3);
    color: var(--muted);
    font-size: 13px;
}

.upload-chip {
    padding: 5px 6px 5px 10px;
    animation: socomFadeInUp 180ms ease both;
}

.upload-name {
    min-width: 0;
    max-width: min(340px, 62vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.remove-upload {
    flex: 0 0 auto;
    position: relative;
    display: block;
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
    border: 0 !important;
    border-radius: 50% !important;
    padding: 0 !important;
    background: #ef4444 !important;
    color: #05070a !important;
    cursor: pointer;
    line-height: 0 !important;
    box-shadow: none !important;
    appearance: none;
    -webkit-appearance: none;
    transition: background 140ms ease, transform 140ms ease;
}

.remove-upload::before,
.remove-upload::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 11px;
    height: 2px;
    border-radius: 999px;
    background: #05070a;
    transform-origin: center;
}

.remove-upload::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.remove-upload::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.remove-upload:hover {
    background: #f87171 !important;
}

.remove-upload:active {
    transform: scale(0.94);
}

.message-debug {
    width: min(100%, 980px);
    color: var(--muted);
    font-size: 12px;
}

.message-debug summary {
    cursor: pointer;
}

.message-debug pre,
.log-row pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: #080a0d;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    max-height: min(560px, 60vh);
    overflow: auto;
}

.composer {
    width: min(100% - 36px, 860px);
    justify-self: center;
    margin: 0 18px 18px;
    background: rgba(20, 24, 31, 0.96);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 10px;
    box-shadow: var(--shadow);
}

.composer-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 44px;
    gap: 8px;
    align-items: end;
}

.composer-row > * {
    min-width: 0;
}

.file-button {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--muted);
    background: var(--panel-2);
    padding: 0;
    cursor: pointer;
}

.file-button:hover {
    border-color: rgba(143, 178, 255, 0.42);
    color: var(--text);
    background: var(--panel-3);
}

.visually-hidden-file {
    position: absolute;
    z-index: -1;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.send-button {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0 !important;
    border-radius: 14px !important;
    position: relative;
    overflow: hidden;
}

.send-button svg {
    width: 19px;
    height: 19px;
}

.send-button:disabled {
    opacity: 1;
}

.send-button.is-waiting {
    color: #04120c;
}

.send-wait-ring {
    position: absolute;
    display: block;
    inset: 9px;
    border: 2px solid rgba(4, 18, 12, 0.2);
    border-top-color: #04120c;
    border-radius: 50%;
    animation: spin 760ms linear infinite;
}

.send-button.icon-only .send-wait-ring {
    display: block;
}

.composer textarea {
    resize: none;
    max-height: 160px;
    min-height: 42px;
    border: 0;
    outline: none;
    padding: 10px 6px;
    font-size: 16px;
    background: transparent;
    color: var(--text);
}

.upload-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.upload-status {
    min-height: 18px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.upload-status.error {
    color: #fca5a5;
}

.upload-progress,
.response-progress {
    position: relative;
    height: 4px;
    margin-top: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.upload-progress i,
.response-progress i {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: var(--accent);
    transition: width 160ms ease;
}

.upload-status:not(.active) .upload-progress {
    display: none;
}

.waiting-bubble {
    width: min(100%, 360px);
}

.waiting-bubble span {
    color: var(--muted);
}

.typing-dots {
    display: inline-flex;
    gap: 4px;
    margin-left: 8px;
    vertical-align: middle;
}

.typing-dots i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8fb2ff;
    animation: typingPulse 1.1s infinite ease-in-out;
}

.typing-dots i:nth-child(2) {
    animation-delay: 0.16s;
}

.typing-dots i:nth-child(3) {
    animation-delay: 0.32s;
}

.response-progress i {
    width: 42%;
    animation: responseProgress 1.35s infinite ease-in-out;
}

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

/* Adapted from animate.css fadeInUp and pulse, kept local for static PHP hosting. */
@keyframes socomFadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 16px, 0);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes responseProgress {
    0% {
        transform: translateX(-120%);
    }
    100% {
        transform: translateX(250%);
    }
}

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

.admin-dialog {
    width: min(1040px, calc(100% - 28px));
    max-height: calc(100dvh - 28px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 20px;
    background: var(--panel-2);
    color: var(--text);
    box-shadow: var(--shadow);
}

.admin-dialog::backdrop {
    background: rgba(0, 0, 0, 0.62);
}

.dialog-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: start;
}

.icon-button {
    width: 38px;
    height: 38px;
}

.confirm-dialog {
    width: min(420px, calc(100% - 28px));
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.danger-action {
    min-height: 38px;
    border: 1px solid rgba(255, 107, 97, 0.44);
    border-radius: 12px;
    background: rgba(255, 107, 97, 0.12);
    color: var(--danger);
    padding: 0 14px;
    font-weight: 700;
}

.danger-action:hover {
    background: rgba(255, 107, 97, 0.18);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 20px 0;
}

.stat {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    background: var(--panel);
}

.stat strong {
    display: block;
    font-size: 30px;
}

.stat span,
.admin-row small,
.log-meta,
.muted {
    color: var(--muted);
}

.admin-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 14px;
    overflow-x: auto;
}

.admin-tab {
    padding: 0 16px;
    margin-bottom: 10px;
}

.admin-tab.active {
    background: var(--accent);
    color: #04120c;
    border-color: transparent;
    font-weight: 800;
}

.admin-panel {
    display: none;
}

.admin-panel.active {
    display: grid;
    gap: 12px;
}

.admin-toolbar {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 150px auto auto;
    gap: 10px;
    align-items: center;
}

.admin-users,
.admin-logs {
    display: grid;
    gap: 8px;
}

.admin-logs {
    max-height: 420px;
    overflow: auto;
}

.admin-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(260px, auto);
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    background: var(--panel);
}

.admin-row.selected {
    border-color: rgba(79, 140, 255, 0.7);
}

.admin-user-identity {
    min-width: 0;
    display: grid;
    gap: 5px;
}

.admin-user-identity strong,
.admin-user-identity small {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.admin-row button.danger {
    color: var(--danger);
}

.admin-chat-browser {
    display: grid;
    grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
    gap: 14px;
    margin-top: 8px;
}

.admin-chat-browser h3 {
    margin: 0 0 10px;
    font-size: 15px;
}

.admin-chat-list,
.admin-chat-messages {
    min-height: 180px;
    max-height: 360px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    padding: 10px;
}

.admin-chat-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border-radius: 10px;
}

.admin-chat-row.selected,
.admin-chat-row:hover {
    background: var(--panel-2);
}

.admin-chat-open {
    min-width: 0;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
}

.admin-chat-open strong,
.admin-chat-open span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-chat-open span,
.admin-chat-message-meta {
    color: var(--muted);
    font-size: 12px;
}

.admin-chat-message {
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
}

.admin-chat-message:last-child {
    border-bottom: 0;
}

.admin-chat-message-body {
    margin-top: 5px;
    font-size: 13px;
}

.log-row,
.empty-admin {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 11px 12px;
    background: var(--panel);
}

.log-row.fail {
    border-color: rgba(255, 107, 97, 0.5);
}

.log-row summary {
    cursor: pointer;
    font-weight: 700;
}

.log-meta {
    margin-top: 8px;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.switch-row {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 14px;
    padding: 12px;
    color: var(--text);
}

.settings-block {
    display: grid;
    gap: 9px;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 14px;
    padding: 12px;
}

.settings-block label {
    color: var(--muted);
    font-size: 13px;
}

.settings-block small {
    color: var(--muted);
}

.model-picker {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto auto;
    gap: 10px;
}

.model-picker.compact-picker {
    grid-template-columns: minmax(180px, 1fr) auto;
}

.model-picker select {
    height: 42px;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0 12px;
    background: #0f1319;
    color: var(--text);
}

.model-picker input,
.settings-textarea {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    background: #0f1917;
    color: var(--text);
}

.model-picker input {
    height: 42px;
}

.settings-textarea {
    width: 100%;
    resize: vertical;
    line-height: 1.45;
}

.model-action {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel-2);
    color: var(--text);
    padding: 0 14px;
    box-shadow: none;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    flex-direction: row;
}

.model-action svg {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
}

.model-action:hover {
    border-color: rgba(33, 163, 102, 0.5);
    background: var(--panel-3);
    filter: none;
}

.inline-check {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    font-size: 14px;
}

.inline-check-compact {
    min-height: 42px;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel-2);
    padding: 0 12px;
}

.prompt-save-button {
    width: fit-content;
    margin-top: 10px;
}

.allowed-email-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.allowed-email-chip {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 9px;
    background: var(--panel-2);
    color: var(--muted);
    font-size: 12px;
}

.username-dialog {
    width: min(430px, calc(100% - 28px));
}

.compact-chat .messages {
    gap: 10px;
    padding-top: 18px;
    padding-bottom: 18px;
}

.compact-chat .bubble {
    padding: 10px 12px;
}

@media (max-width: 860px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        z-index: 20;
        left: 0;
        top: 0;
        width: min(86vw, 320px);
        transform: translateX(-105%);
        transition: transform 160ms ease;
        box-shadow: var(--shadow);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 19;
        border: 0;
        background: rgba(0, 0, 0, 0.52);
        opacity: 0;
        pointer-events: none;
        transition: opacity 160ms ease;
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-menu-button {
        display: grid !important;
        place-items: center;
        flex: 0 0 auto;
    }

    .topbar {
        padding: 10px 12px;
    }

    .messages {
        padding: 16px 10px;
    }

    .message {
        width: 100%;
    }

    .composer {
        width: calc(100% - 16px);
        margin: 0 8px 8px;
        border-radius: 14px;
        padding: 8px;
    }

    .composer-row {
        grid-template-columns: 40px minmax(0, 1fr) 44px;
        gap: 6px;
    }

    .composer button {
        padding: 0 10px;
    }

    .composer .send-button,
    .composer .file-button {
        padding: 0 !important;
    }

    .file-button {
        width: 40px;
        height: 40px;
    }

    .send-button {
        width: 44px;
        height: 44px;
    }

    .stats-grid,
    .admin-row,
    .admin-chat-browser,
    .admin-toolbar,
    .model-picker {
        grid-template-columns: 1fr;
    }

    .model-action,
    .prompt-save-button {
        width: 100%;
    }

    .chat-row-actions .chat-rename {
        opacity: 1;
    }

    .admin-row-actions {
        justify-content: stretch;
    }

    .admin-row-actions button {
        flex: 1 1 120px;
    }

    .admin-dialog {
        width: calc(100% - 12px);
        max-height: calc(100dvh - 12px);
        padding: 14px;
    }
}
