:root {
    --bg: #212121;
    --bg-elevated: #171717;
    --bg-soft: #2a2a2a;
    --bg-muted: #303030;
    --bg-hover: #373737;
    --panel: #181818;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.14);
    --text: #ececec;
    --text-soft: #a8a8a8;
    --text-muted: #7d7d7d;
    --accent: #ffffff;
    --danger: #f28b82;
    --danger-soft: rgba(242, 139, 130, 0.12);
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Aptos", "Segoe UI", sans-serif;
    scrollbar-width: thin;
    scrollbar-color: #5b5b5b #1a1a1a;
}

body {
    overflow: hidden;
}

button,
input,
textarea {
    font: inherit;
}

* {
    scrollbar-width: thin;
    scrollbar-color: #5b5b5b #1a1a1a;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #4f4f4f 0%, #686868 100%);
    border: 2px solid #1a1a1a;
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #626262 0%, #7a7a7a 100%);
}

*::-webkit-scrollbar-corner {
    background: #1a1a1a;
}

.app-shell {
    position: relative;
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr);
    min-height: 100vh;
    height: 100vh;
    background:
        radial-gradient(circle at top center, rgba(255, 255, 255, 0.035), transparent 34%),
        var(--bg);
}

.app-shell.is-locked {
    display: block;
}

.app-shell.is-locked .sidebar,
.app-shell.is-locked .main-shell {
    display: none;
}

.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.08), transparent 28%),
        radial-gradient(circle at bottom right, rgba(255, 255, 255, 0.05), transparent 26%),
        rgba(18, 18, 18, 0.94);
    backdrop-filter: blur(16px);
    transition: opacity 180ms ease, visibility 180ms ease;
}

.auth-gate.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.access-gate {
    z-index: 42;
}

.auth-gate-shell {
    width: min(460px, 100%);
}

.auth-card {
    border-radius: 28px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.auth-card {
    padding: 28px;
    background: #121212;
}

.access-card {
    display: grid;
    gap: 18px;
}

.auth-step-head h2 {
    margin: 6px 0 10px;
    font-size: 30px;
    line-height: 1.02;
    letter-spacing: -0.04em;
    font-weight: 600;
}

.auth-step-label,
.auth-step-description,
.auth-phone-caption {
    margin: 0;
}

.auth-step-label,
.auth-field-label {
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 11px;
    font-weight: 600;
}

.auth-step-description,
.auth-phone-caption {
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.5;
}

.access-copy {
    margin: 0;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.6;
}

.access-meta {
    padding: 16px 18px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: #191919;
}

.access-meta .panel-kicker {
    margin-bottom: 8px;
}

.access-meta strong {
    display: block;
    font-size: 16px;
    font-weight: 600;
}

.auth-status {
    min-height: 22px;
    margin: 18px 0 10px;
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.45;
}

.auth-status.is-error {
    color: var(--danger);
}

.auth-status.is-success {
    color: #cfe7c7;
}

.auth-form {
    display: none;
    gap: 14px;
}

.auth-form.is-active {
    display: grid;
}

.auth-phone-caption {
    padding-top: 4px;
}

.auth-phone-field,
.auth-code-field {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 86px;
    padding: 18px 20px;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: #191919;
    overflow: hidden;
}

.auth-phone-field:focus-within,
.auth-code-field:focus-within {
    border-color: rgba(255, 255, 255, 0.26);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

.auth-capture-input {
    position: absolute;
    inset: 0;
    border: none;
    padding: 0;
    margin: 0;
    opacity: 0;
    background: transparent;
    color: transparent;
    caret-color: #ffffff;
}

.auth-phone-display,
.auth-code-display {
    position: relative;
    z-index: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    pointer-events: none;
}

.auth-phone-display {
    flex-wrap: nowrap;
}

.auth-mask-char {
    color: var(--text-muted);
    font-size: 26px;
    line-height: 1;
    letter-spacing: -0.04em;
}

.auth-mask-gap {
    width: 12px;
    flex: 0 0 12px;
}

.auth-phone-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.auth-digit-slot {
    min-width: 18px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-muted);
    font-size: 24px;
    line-height: 1;
    letter-spacing: -0.05em;
    text-align: center;
}

.auth-digit-slot.is-code {
    min-width: 36px;
    padding: 14px 0;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
    border-bottom-width: 1px;
}

.auth-digit-slot.is-filled {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.32);
}

.auth-actions-row {
    display: flex;
    gap: 10px;
}

.auth-actions-row > * {
    flex: 1;
}

.auth-submit-button {
    min-height: 56px;
    border-radius: 18px;
    font-size: 15px;
}

.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 12px;
    gap: 12px;
    background: #171717;
    border-right: 1px solid var(--line);
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-create,
.tab-button,
.ghost-button,
.danger-button,
.primary-button {
    border: none;
    cursor: pointer;
    transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.sidebar-create,
.tab-button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 12px;
    padding: 12px 14px;
    color: var(--text);
    background: transparent;
    text-align: left;
}

.sidebar-create {
    background: var(--bg-muted);
    font-weight: 600;
}

.sidebar-create span:first-child {
    display: inline-flex;
    width: 20px;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
}

.tab-button {
    color: var(--text-soft);
}

.tab-button.is-active {
    background: var(--bg-soft);
    color: var(--text);
}

.sidebar-create:hover,
.tab-button:hover,
.ghost-button:hover,
.danger-button:hover,
.primary-button:hover,
.thread-card:hover {
    transform: translateY(-1px);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.identity-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    border-radius: 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
}

.identity-card strong {
    font-size: 16px;
    font-weight: 600;
}

.identity-card label,
.settings-card label {
    display: block;
    font-size: 12px;
    color: var(--text-soft);
    margin-bottom: 8px;
}

.identity-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.45;
}

.identity-card .ghost-button {
    width: 100%;
    margin-top: 4px;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    color: var(--text);
    background: #212121;
    outline: none;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input:focus,
textarea:focus {
    border-color: rgba(255, 255, 255, 0.24);
}

.threads-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    overflow: hidden;
}

.sidebar-section-head {
    padding: 6px 4px 10px;
}

.panel-kicker {
    margin: 0;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 11px;
    font-weight: 600;
}

.thread-list,
.messages-feed,
.logs-feed,
.settings-grid {
    min-height: 0;
    overflow: auto;
}

.thread-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px;
}

.thread-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
}

.thread-card.is-active {
    background: var(--bg-soft);
    border-color: var(--line);
}

.thread-card h3 {
    margin: 0;
    font-size: 14px;
    line-height: 1.3;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-card p,
.thread-meta,
.message-meta,
.log-meta,
.settings-card p,
.empty-state {
    color: var(--text-soft);
    font-size: 12px;
}

.thread-card p {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.mini-danger {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 0;
    cursor: pointer;
}

.mini-danger:hover {
    color: var(--danger);
}

.main-shell {
    min-width: 0;
    min-height: 0;
    height: 100vh;
    overflow: hidden;
}

.tab-panel {
    display: none;
    min-height: 100%;
    height: 100%;
}

.tab-panel.is-active {
    display: block;
}

.chat-stage,
.settings-stage {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    height: 100%;
    padding: 16px 18px;
}

.chat-stage-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 6px 0 16px;
}

.chat-stage-copy h1,
.logs-head h2 {
    margin: 6px 0 0;
    font-size: 28px;
    line-height: 1.05;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.chat-stage-eyebrow {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.chat-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chat-stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
}

.chat-stat-label {
    color: var(--text-soft);
    font-size: 11px;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.chat-stat-value {
    color: var(--text);
    font-size: 11px;
    line-height: 1;
    font-weight: 600;
}

.chat-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 332px;
    gap: 16px;
    min-height: 0;
    height: 100%;
}

.chat-panel,
.logs-panel {
    min-height: 0;
    height: 100%;
    background: transparent;
}

.chat-panel {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
}

.messages-feed {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 12px 0 28px;
}

.message-card {
    max-width: 880px;
    padding: 0 18px;
}

.message-card.role-user {
    align-self: flex-end;
    width: min(76%, 760px);
    padding: 0;
}

.message-body {
    min-width: 0;
}

.message-card.role-user .message-body {
    padding: 16px 18px;
    border-radius: 18px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
}

.message-card.role-assistant {
    width: min(100%, 880px);
}

.message-meta {
    color: var(--text-muted);
}

.message-meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.message-latency-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.message-latency {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--line);
    color: var(--text-soft);
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;
}

.message-latency-popover {
    position: absolute;
    left: 0;
    top: calc(100% + 10px);
    z-index: 12;
    width: 320px;
    padding: 12px;
    border-radius: 14px;
    background: #141414;
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.message-latency-wrap:hover .message-latency-popover {
    opacity: 1;
    transform: translateY(0);
}

.latency-detail-total {
    display: block;
    margin-bottom: 10px;
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
}

.latency-detail-row {
    padding-top: 10px;
    margin-top: 10px;
    border-top: 1px solid var(--line);
}

.latency-detail-row:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.latency-detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
}

.latency-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    color: var(--text-soft);
    font-size: 11px;
}

.latency-detail-meta span {
    display: inline-flex;
    align-items: center;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
}

.message-block {
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid var(--line);
}

.message-block:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.message-block h4 {
    margin: 0 0 8px;
    color: var(--text-soft);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.message-body p,
.message-block p {
    margin: 0;
}

.message-body p + p,
.message-block p + p {
    margin-top: 12px;
}

.message-table-wrap {
    margin-top: 10px;
    overflow-x: auto;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
}

.message-table {
    width: 100%;
    min-width: 420px;
    border-collapse: collapse;
    font-size: 14px;
}

.message-table thead th {
    padding: 12px 14px;
    text-align: left;
    color: var(--text);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid var(--line);
}

.message-table tbody td {
    padding: 11px 14px;
    color: var(--text-soft);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: top;
}

.message-table tbody tr:first-child td {
    border-top: none;
}

.message-table tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.02);
}

.message-chart {
    margin-top: 18px;
    border-radius: 22px;
    border: 1px solid var(--line);
    background:
        radial-gradient(circle at top left, rgba(255, 138, 76, 0.12), transparent 34%),
        radial-gradient(circle at top right, rgba(92, 200, 255, 0.12), transparent 32%),
        rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

.message-chart-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 0;
}

.message-chart-head strong {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.message-chart-badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-soft);
    font-size: 10px;
    line-height: 1;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.message-chart-frame {
    padding: 12px 14px 14px;
}

.chart-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 6px;
}

.chart-svg {
    display: block;
    width: 100%;
    min-width: 680px;
    height: auto;
}

.chart-svg-radar {
    min-width: 520px;
}

.chart-grid-line {
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 1;
}

.chart-grid-line-vertical {
    stroke-dasharray: 3 5;
}

.chart-axis-line {
    stroke: rgba(255, 255, 255, 0.16);
    stroke-width: 1.4;
}

.chart-axis-label {
    fill: var(--text-muted);
    font-size: 11px;
}

.chart-bar,
.chart-point,
.chart-area,
.chart-bubble-point,
.chart-radar-area {
    transition: opacity 160ms ease, transform 160ms ease;
}

.chart-bar:hover,
.chart-point:hover,
.chart-bubble-point:hover,
.chart-radar-area:hover {
    opacity: 0.92;
}

.chart-radar-grid {
    fill: rgba(255, 255, 255, 0.015);
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 1;
}

.chart-radar-axis {
    stroke: rgba(255, 255, 255, 0.12);
    stroke-width: 1;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--text-soft);
    font-size: 12px;
}

.chart-legend-swatch,
.chart-series-swatch {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--swatch);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
    flex: 0 0 auto;
}

.chart-empty-state {
    padding: 18px 16px;
    border-radius: 16px;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

.chart-series-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.chart-series-card {
    padding: 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.chart-series-card-head {
    margin-bottom: 10px;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.chart-ring-svg {
    display: block;
    width: min(220px, 100%);
    margin: 0 auto;
}

.chart-ring-total {
    fill: var(--text);
    font-size: 16px;
    font-weight: 700;
}

.chart-ring-caption {
    fill: var(--text-muted);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.chart-series-legend {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.chart-series-legend-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    color: var(--text-soft);
    font-size: 12px;
}

.chart-series-legend-item strong {
    color: var(--text);
    font-size: 12px;
}

.chart-heatmap {
    overflow-x: auto;
}

.chart-heatmap-grid {
    display: grid;
    gap: 8px;
    align-items: stretch;
    min-width: max-content;
}

.chart-heatmap-corner,
.chart-heatmap-x,
.chart-heatmap-y {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
}

.chart-heatmap-y {
    justify-content: flex-start;
    text-align: left;
}

.chart-heatmap-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 74px;
    padding: 8px;
    border-radius: 16px;
    background:
        linear-gradient(
            145deg,
            rgba(92, 200, 255, calc(0.12 + var(--heat) * 0.24)),
            rgba(255, 138, 76, calc(0.08 + var(--heat) * 0.34))
        );
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.chart-heatmap-cell span {
    display: block;
    line-height: 1.2;
}

.followup-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.followup-chip {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.3;
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

@media (max-width: 720px) {
    .message-chart-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .chart-svg {
        min-width: 560px;
    }

    .chart-svg-radar {
        min-width: 460px;
    }

    .chart-series-grid {
        grid-template-columns: 1fr;
    }
}

.followup-chip:hover {
    background: var(--bg-hover);
    border-color: var(--line-strong);
    transform: translateY(-1px);
}

.composer {
    position: sticky;
    bottom: 0;
    padding: 18px 0 0;
    background:
        linear-gradient(180deg, rgba(33, 33, 33, 0), rgba(33, 33, 33, 0.92) 24%, rgba(33, 33, 33, 1) 100%);
}

.composer-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 140px;
    gap: 12px;
    align-items: end;
    max-width: 920px;
    margin: 0 auto;
    padding: 14px;
    border-radius: 20px;
    background: #2f2f2f;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.composer textarea {
    min-height: 72px;
    max-height: 220px;
    resize: vertical;
    border: none;
    padding: 8px 10px;
    background: transparent;
}

.primary-button,
.ghost-button,
.danger-button {
    border-radius: 12px;
    padding: 12px 16px;
}

.primary-button {
    background: var(--accent);
    color: #171717;
    font-weight: 600;
}

.ghost-button {
    background: var(--bg-soft);
    color: var(--text);
}

.danger-button {
    background: var(--danger-soft);
    color: var(--danger);
}

button:disabled {
    opacity: 0.42;
    cursor: not-allowed;
    transform: none;
}

.logs-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 14px;
    border-radius: 18px;
    background: #171717;
    border: 1px solid var(--line);
}

.logs-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.logs-head h2 {
    font-size: 18px;
}

.logs-feed {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 14px;
}

.log-card {
    padding: 14px;
    border-radius: 14px;
    background: var(--bg);
    border: 1px solid var(--line);
}

.log-card strong {
    display: block;
    margin-top: 6px;
    font-size: 14px;
    line-height: 1.4;
}

.logs-feed pre {
    margin: 10px 0 0;
    padding: 12px;
    border-radius: 12px;
    background: #111111;
    color: #d0d0d0;
    overflow: auto;
    font-size: 12px;
    border: 1px solid var(--line);
}

.settings-stage {
    gap: 16px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(320px, 1fr));
    gap: 16px;
    align-content: start;
    padding-right: 4px;
}

.settings-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    border-radius: 18px;
    background: #171717;
    border: 1px solid var(--line);
}

.settings-card h3 {
    margin: 6px 0 0;
    font-size: 22px;
    line-height: 1.08;
    font-weight: 600;
}

.settings-card .split {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 12px;
}

.settings-card textarea {
    min-height: 240px;
    resize: vertical;
}

.empty-state {
    padding: 18px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--line);
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    min-width: 220px;
    max-width: 420px;
    padding: 14px 16px;
    border-radius: 14px;
    background: #101010;
    color: var(--text);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 1480px) {
    .chat-layout {
        grid-template-columns: minmax(0, 1fr) 296px;
    }
}

@media (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 248px minmax(0, 1fr);
    }

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

    .logs-panel {
        max-height: 320px;
    }
}

@media (max-width: 860px) {
    body {
        overflow: auto;
    }

    .app-shell {
        grid-template-columns: 1fr;
        height: auto;
    }

    .sidebar,
    .main-shell,
    .chat-stage,
    .settings-stage {
        height: auto;
        min-height: auto;
    }

    .main-shell {
        overflow: visible;
    }

    .chat-stage-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .auth-gate {
        align-items: stretch;
        padding: 14px;
    }

    .auth-card {
        padding: 22px;
        border-radius: 22px;
    }

    .auth-step-head h2 {
        font-size: 24px;
    }

    .chat-stage-eyebrow {
        width: 100%;
    }

    .chat-stats {
        width: 100%;
        gap: 8px;
    }

    .chat-stat-chip {
        width: 100%;
        justify-content: space-between;
        border-radius: 14px;
    }

    .composer-shell,
    .settings-grid,
    .settings-card .split,
    .auth-actions-row {
        grid-template-columns: 1fr;
    }

    .auth-actions-row {
        display: grid;
    }
}
