html,
body {
    height: 100%;
    min-height: 100%;
    width: 100%;
    overflow: hidden;
    overflow-x: hidden;
}

body {
    font-family: "Inter", sans-serif;
    max-width: 100vw;
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}

#appShell {
    position: fixed;
    inset: 0;
    overflow: hidden;
}

#appSidebar {
    width: 288px;
    min-width: 288px;
    flex-shrink: 0;
    overflow: hidden;
    transition: width 0.24s ease, min-width 0.24s ease, opacity 0.24s ease, transform 0.24s ease;
}

#sidebarToggleBtn,
#sidebarExpandBtn {
    flex-shrink: 0;
}

#sidebarToggleBtn svg,
#sidebarExpandBtn svg {
    display: block;
    width: 20px;
    height: 20px;
}

.panel-scrollbar::-webkit-scrollbar {
    width: 8px;
}

.panel-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.panel-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(82, 82, 91, 0.85);
    border-radius: 999px;
}

#sidebarBackdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(0, 0, 0, 0.56);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease;
}

#messageList {
    min-height: 0;
}

#chatViewport {
    position: relative;
    --scroll-to-bottom-offset: 190px;
}

.scroll-to-bottom-btn {
    position: absolute;
    left: 50%;
    bottom: var(--scroll-to-bottom-offset);
    z-index: 12;
    display: flex;
    height: 46px;
    width: 46px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    background: rgba(34, 35, 39, 0.92);
    color: #e5e7eb;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

.scroll-to-bottom-btn:hover {
    background: rgba(53, 55, 61, 0.98);
}

.scroll-to-bottom-btn.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

#composerWrap {
    width: min(950px, 100%);
}

#composerShell {
    box-sizing: border-box;
    position: relative;
    min-height: 132px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

#composerInner {
    min-height: 98px;
    align-items: stretch;
}

#composerInputWrap {
    display: flex;
    min-height: 0;
}

#userInput {
    height: 100%;
    min-height: 0;
    max-height: 100px;
    padding-top: 0.1rem;
    padding-bottom: 0.1rem;
    font-size: 0.94rem;
    line-height: 1.58rem;
}

#composerActionWrap {
    flex-shrink: 0;
}

#attachmentBtn,
#sendBtn,
#stopBtn {
    height: 46px;
    min-width: 46px;
    padding: 0 1rem;
    line-height: 1;
}

#attachmentBtn,
#sendBtn {
    width: 46px;
    padding: 0;
}

.pending-attachment-list {
    margin-bottom: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    max-width: 100%;
    min-height: 2.4rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    padding: 0.42rem 0.5rem 0.42rem 0.8rem;
    color: #e2e8f0;
}

.attachment-chip.is-compact {
    min-height: 2.15rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.36rem 0.72rem;
}

.attachment-chip-body {
    min-width: 0;
}

.attachment-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 18rem;
    font-size: 0.84rem;
    font-weight: 600;
    color: #f8fafc;
}

.attachment-chip-size {
    margin-top: 0.1rem;
    font-size: 0.73rem;
    color: #94a3b8;
}

.attachment-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 1.7rem;
    width: 1.7rem;
    flex-shrink: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    padding: 0;
    color: #94a3b8;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.attachment-chip-remove:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.attachment-drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(103, 232, 249, 0.45);
    border-radius: inherit;
    background: rgba(18, 23, 30, 0.88);
    backdrop-filter: blur(4px);
    pointer-events: none;
}

.attachment-drop-overlay-text {
    padding: 0.8rem 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: #dff8ff;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

#composerShell.is-dragging-attachment {
    border-color: rgba(103, 232, 249, 0.36);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(103, 232, 249, 0.14);
}

#composerMeta {
    position: relative;
    min-height: 1.5rem;
    justify-content: center;
}

#composerStatus {
    position: absolute;
    left: 0;
    top: 50%;
    opacity: 0;
    transform: translateY(calc(-50% + 4px));
    transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

#composerStatus.is-visible {
    opacity: 1;
    transform: translateY(-50%);
}

#composerStatus[data-tone="streaming"] {
    color: #9dd9e2;
}

#composerStatus[data-tone="error"] {
    color: #fca5a5;
}

#composerStatus[data-tone="stopped"] {
    color: #f7d38b;
}

#composerDisclaimer {
    width: 100%;
    text-align: center;
}

body.is-streaming #composerShell {
    border-color: rgba(103, 232, 249, 0.22);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(103, 232, 249, 0.08);
}

#emptyState {
    display: none;
}

.empty-state-shell {
    margin: 0 auto;
    display: flex;
    width: min(1080px, 100%);
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1rem 0;
    text-align: center;
}

.empty-state-heading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.empty-state-heading-logo {
    display: flex;
    height: 42px;
    width: 42px;
    border-radius: 999px;
    background: #fff;
    padding: 3px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.empty-state-title {
    margin: 0;
    font-size: clamp(2rem, 2.2vw, 2.7rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    color: #fff;
}

.empty-state-subtitle {
    margin: 0;
    max-width: 760px;
    font-size: 0.98rem;
    line-height: 1.8;
    color: #8f98ab;
}

.empty-state-chip-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.empty-state-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.6rem;
    padding: 0.72rem 1.15rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
    color: #d4d9e4;
    font-size: 0.93rem;
    line-height: 1;
    transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.empty-state-chip:hover {
    transform: translateY(-1px);
    border-color: rgba(103, 232, 249, 0.24);
    background: linear-gradient(180deg, rgba(103, 232, 249, 0.1), rgba(255, 255, 255, 0.03));
    color: #f4fbff;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
}

.empty-state-chip:focus-visible {
    outline: none;
    border-color: rgba(103, 232, 249, 0.4);
    box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.12);
}

body.empty-session #chatViewport {
    justify-content: center;
}

body.empty-session #messageList {
    flex: 0 0 auto;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 1.25rem;
}

body.empty-session #emptyState {
    display: block;
}

body.empty-session #mainHeader {
    flex: 0 0 auto;
    justify-content: flex-start;
}

body.empty-session #composerSection {
    border-top-color: transparent;
    padding-top: 0;
    padding-bottom: 3.75rem;
}

body.empty-session #composerWrap {
    width: min(970px, calc(100vw - 2rem));
}

body.empty-session #composerShell {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(47, 47, 52, 0.96), rgba(39, 39, 43, 0.96));
    border-color: rgba(255, 255, 255, 0.08);
    border-radius: 2rem;
    min-height: 132px;
}

body.empty-session #composerShell::before {
    content: "";
    position: absolute;
    top: 0;
    left: 7%;
    width: 86%;
    height: 1px;
    background: linear-gradient(90deg, rgba(34, 211, 238, 0), rgba(34, 211, 238, 0.72), rgba(34, 211, 238, 0));
    box-shadow: 0 0 18px rgba(34, 211, 238, 0.2);
    animation: emptyComposerGlow 3.6s ease-in-out infinite;
    pointer-events: none;
}

body.empty-session #composerInner {
    min-height: 88px;
}

body.empty-session #userInput {
    font-size: 0.98rem;
    line-height: 1.7rem;
}

body.empty-session #composerMeta {
    display: none;
}

@keyframes emptyComposerGlow {
    0%,
    100% {
        opacity: 0.38;
        transform: scaleX(0.97);
    }

    50% {
        opacity: 0.95;
        transform: scaleX(1);
    }
}

.assistant-message {
    position: relative;
}

.assistant-message.is-error,
.assistant-message.is-stopped {
    border-radius: 1.35rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1rem 1.1rem;
    background: rgba(255, 255, 255, 0.025);
}

.assistant-message.is-error {
    border-color: rgba(248, 113, 113, 0.22);
    background: rgba(127, 29, 29, 0.12);
}

.assistant-message.is-stopped {
    border-color: rgba(251, 191, 36, 0.18);
    background: rgba(120, 91, 15, 0.09);
}

.assistant-state {
    margin-bottom: 0.8rem;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #9ca3af;
}

.assistant-message.is-error .assistant-state {
    color: #fca5a5;
}

.assistant-message.is-stopped .assistant-state {
    color: #f7d38b;
}

.assistant-message.is-streaming .assistant-state {
    color: #9dd9e2;
}

.assistant-actions {
    margin-top: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-attachment-row {
    margin-bottom: 0.7rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

.assistant-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2.1rem;
    width: 2.1rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: #d1d5db;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.assistant-icon-btn:hover {
    border-color: rgba(103, 232, 249, 0.28);
    background: rgba(103, 232, 249, 0.08);
    color: #fff;
}

.floating-toast {
    position: fixed;
    left: 50%;
    bottom: 2rem;
    z-index: 60;
    transform: translate(-50%, 12px);
    border-radius: 999px;
    background: rgba(22, 24, 28, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.55rem 0.95rem;
    font-size: 0.8rem;
    color: #f3f4f6;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.floating-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.confirm-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(9, 10, 12, 0.58);
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.confirm-dialog-backdrop.hidden {
    display: none;
}

.confirm-dialog-card {
    width: min(420px, 100%);
    border-radius: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, rgba(37, 37, 42, 0.98), rgba(28, 28, 32, 0.98));
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.confirm-dialog-head {
    padding: 1.25rem 1.25rem 0.9rem;
}

.confirm-dialog-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
}

.confirm-dialog-message {
    margin: 0.7rem 0 0;
    line-height: 1.7;
    font-size: 0.92rem;
    color: #cbd5e1;
}

.confirm-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem 1.2rem;
}

.confirm-dialog-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 5.8rem;
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 0.62rem 1rem;
    font-size: 0.88rem;
    font-weight: 600;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.confirm-dialog-btn.is-secondary {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: #d1d5db;
}

.confirm-dialog-btn.is-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.confirm-dialog-btn.is-danger {
    background: #7f1d1d;
    color: #fff;
}

.confirm-dialog-btn.is-danger:hover {
    background: #991b1b;
}

.streaming-placeholder {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 1.8rem;
}

.streaming-placeholder span {
    height: 0.45rem;
    width: 0.45rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    animation: lscode-ai-pulse 1.15s infinite ease-in-out;
}

.streaming-placeholder span:nth-child(2) {
    animation-delay: 0.16s;
}

.streaming-placeholder span:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes lscode-ai-pulse {
    0%,
    80%,
    100% {
        transform: translateY(0) scale(0.92);
        opacity: 0.36;
    }

    40% {
        transform: translateY(-2px) scale(1);
        opacity: 1;
    }
}

.assistant-markdown {
    color: #f3f4f6;
}

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

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

.assistant-markdown h1,
.assistant-markdown h2,
.assistant-markdown h3,
.assistant-markdown h4 {
    margin: 1.4rem 0 0.8rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: #fff;
}

.assistant-markdown h1 {
    font-size: 1.75rem;
}

.assistant-markdown h2 {
    font-size: 1.4rem;
}

.assistant-markdown h3 {
    font-size: 1.12rem;
}

.assistant-markdown p,
.assistant-markdown ul,
.assistant-markdown ol,
.assistant-markdown blockquote,
.assistant-markdown pre,
.assistant-markdown table,
.assistant-markdown details,
.assistant-markdown hr {
    margin: 0 0 1rem;
}

.assistant-markdown ul,
.assistant-markdown ol {
    padding-left: 1.3rem;
}

.assistant-markdown li + li {
    margin-top: 0.35rem;
}

.assistant-markdown a {
    color: #67e8f9;
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.assistant-markdown strong {
    color: #fff;
    font-weight: 700;
}

.assistant-markdown code {
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.08);
    padding: 0.14rem 0.42rem;
    font-family: "Consolas", "SFMono-Regular", monospace;
    font-size: 0.92em;
    color: #d1fae5;
}

.assistant-markdown pre {
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1rem;
    background: #111214;
    padding: 2.9rem 1.05rem 1rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.assistant-markdown pre code {
    display: block;
    padding: 0;
    background: transparent;
    color: #dbeafe;
    white-space: pre;
}

.assistant-markdown .hljs {
    background: transparent;
    padding: 0;
    color: inherit;
}

.assistant-markdown .fanuc-custom-highlight {
    background: transparent;
    color: #dbeafe;
}

.assistant-markdown .fanuc-custom-highlight .fanuc-token-directive,
.assistant-markdown .fanuc-custom-highlight .fanuc-token-attribute {
    font-weight: 600;
}

.assistant-markdown blockquote {
    border-left: 3px solid rgba(103, 232, 249, 0.48);
    background: rgba(255, 255, 255, 0.03);
    padding: 0.9rem 1rem;
    color: #d1d5db;
}

.assistant-markdown table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.assistant-markdown th,
.assistant-markdown td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.8rem 0.9rem;
    text-align: left;
    vertical-align: top;
}

.assistant-markdown th {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-weight: 600;
}

.assistant-markdown tr:last-child td {
    border-bottom: 0;
}

.assistant-markdown hr {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.assistant-markdown details {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.85rem 1rem;
}

.assistant-markdown summary {
    cursor: pointer;
    color: #fff;
    font-weight: 600;
}

.code-block-shell {
    position: relative;
}

.code-copy-btn {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2rem;
    width: 2rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: #d1d5db;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.code-copy-btn:hover {
    border-color: rgba(103, 232, 249, 0.28);
    background: rgba(103, 232, 249, 0.08);
    color: #fff;
}

@media (min-width: 768px) {
    body.sidebar-collapsed #appSidebar {
        width: 0;
        min-width: 0;
        opacity: 0;
        border-right-color: transparent;
    }

    body.sidebar-collapsed #appSidebar * {
        pointer-events: none;
    }
}

@media (max-width: 767px) {
    html,
    body {
        height: 100%;
        min-height: 100%;
        height: 100svh;
        min-height: 100svh;
        overflow: hidden;
    }

    #appShell {
        position: fixed;
        top: 0;
        right: 0;
        left: 0;
        height: 100%;
        min-height: 100%;
        height: 100svh;
        min-height: 100svh;
        overflow: hidden;
    }

    #appSidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 30;
        height: 100%;
        min-height: 100%;
        height: 100svh;
        min-height: 100svh;
        width: min(84vw, 288px);
        min-width: min(84vw, 288px);
        transform: translateX(-100%);
        opacity: 1;
    }

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

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

    #messageList {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .scroll-to-bottom-btn {
        left: 50%;
        height: 42px;
        width: 42px;
    }

    #composerSection {
        padding-left: 1rem;
        padding-right: 1rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }

    #composerWrap {
        width: 100%;
    }

    #composerShell {
        min-height: 112px;
        padding-left: 0.95rem;
        padding-right: 0.95rem;
        border-radius: 1.45rem;
    }

    #composerInner {
        min-height: 82px;
        gap: 0.7rem;
    }

    #composerMeta {
        min-height: 1.7rem;
    }

    #composerStatus {
        max-width: calc(100% - 8rem);
        font-size: 0.78rem;
    }

    .pending-attachment-list {
        margin-bottom: 0.75rem;
        gap: 0.5rem;
    }

    .attachment-chip {
        padding-left: 0.72rem;
    }

    .attachment-chip-name {
        max-width: 12rem;
    }

    #composerDisclaimer {
        font-size: 0.78rem;
        text-align: center;
    }

    #attachmentBtn,
    #sendBtn,
    #stopBtn {
        height: 42px;
        min-width: 42px;
    }

    #stopBtn {
        padding: 0 0.9rem;
        font-size: 0.78rem;
    }

    .empty-state-shell {
        gap: 0.85rem;
        padding-top: 1rem;
    }

    .empty-state-heading {
        gap: 0.75rem;
    }

    .empty-state-heading-logo {
        height: 34px;
        width: 34px;
        border-radius: 999px;
    }

    body.empty-session #composerSection {
        padding-bottom: calc(1.6rem + env(safe-area-inset-bottom, 0px));
    }

    body.empty-session #composerShell {
        min-height: 108px;
        border-radius: 1.55rem;
    }

    .empty-state-title {
        font-size: 1.85rem;
    }

    .empty-state-subtitle {
        max-width: 100%;
        font-size: 0.88rem;
        line-height: 1.7;
    }

    .empty-state-chip-list {
        gap: 0.55rem;
    }

    .empty-state-chip {
        min-height: 2.35rem;
        padding: 0.66rem 0.95rem;
        font-size: 0.84rem;
    }

    .assistant-markdown h1 {
        font-size: 1.45rem;
    }

    .assistant-markdown h2 {
        font-size: 1.22rem;
    }

    .assistant-markdown p,
    .assistant-markdown li,
    .assistant-markdown blockquote,
    .assistant-markdown th,
    .assistant-markdown td {
        font-size: 0.9rem;
        line-height: 1.58;
    }
}
