.chat-hero-copy h2 {
    margin: 0 0 10px;
    font-size: 26px;
    font-weight: 700;
    color: var(--color-secondary);
}

.chat-hero-copy p {
    margin: 0;
    font-size: 16px;
    color: var(--color-text-muted);
    max-width: 460px;
    line-height: 1.6;
}

.chat-hero-meta {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
    font-size: 13px;
    color: var(--color-text-muted);
    text-align: right;
}

.chat-workspace {
    width: 100%;
    flex: 1;
    min-height: 0;
    align-items: stretch;
    grid-template-rows: minmax(0, 1fr);
}

.chat-primary {
    --chat-input-offset: 0px;
    flex: 1;
    min-height: 0;
}

.chat-warning {
    padding: 12px 16px;
    background: rgba(249, 115, 22, 0.12);
    color: var(--color-primary-strong);
    border-radius: var(--radius-md);
    border: 1px dashed rgba(249, 115, 22, 0.4);
    max-width: 320px;
}

.chat-toast-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-toast {
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
    background: var(--color-surface);
    color: var(--color-secondary);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-toast-exit {
    opacity: 0;
    transform: translateY(-6px);
}

.chat-toast.info {
    border-color: rgba(249, 115, 22, 0.25);
    background: var(--color-primary-soft);
    color: var(--color-primary-strong);
}

.chat-toast.success {
    border-color: rgba(21, 128, 61, 0.25);
    background: rgba(21, 128, 61, 0.12);
    color: #166534;
}

.chat-toast.error {
    border-color: rgba(220, 38, 38, 0.25);
    background: rgba(220, 38, 38, 0.12);
    color: #b91c1c;
}

.chat-quick-start {
    gap: 18px;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.chat-quick-start.is-dismissed {
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
}

.quick-start-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
}

.quick-start-title {
    font-weight: 600;
    color: var(--color-secondary);
    font-size: 16px;
}

.quick-start-tip {
    font-size: 13px;
    color: var(--color-text-muted);
}

.quick-prompt-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.prompt-chip {
    border: 1px solid rgba(249, 115, 22, 0.35);
    background: var(--color-primary-soft);
    color: var(--color-primary-strong);
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: box-shadow 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.prompt-chip:hover {
    background: rgba(249, 115, 22, 0.2);
    box-shadow: 0 10px 20px rgba(249, 115, 22, 0.18);
    transform: translateY(-1px);
}

.prompt-chip:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.chat-panel {
    gap: 20px;
    padding: 0;
}

.chat-panel--primary {
    flex: 1;
    min-height: 0;
}

.chat-history {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 20px 18px calc(20px + var(--chat-input-offset));
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    background: var(--color-surface-muted);
    border-radius: var(--radius-md);
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.chat-message {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.chat-message.user {
    flex-direction: row-reverse;
}

.chat-message-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.chat-message.user .chat-message-body {
    align-items: flex-end;
    text-align: right;
}

.chat-message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.chat-message.user .chat-message-meta {
    justify-content: flex-end;
}

.chat-turn {
    letter-spacing: 0.06em;
    font-weight: 600;
    color: var(--color-secondary);
}

.chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-muted);
    color: var(--color-secondary);
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.chat-message.assistant .chat-avatar {
    background: rgba(249, 115, 22, 0.18);
    color: var(--color-primary-strong);
}

.chat-message.user .chat-avatar {
    background: rgba(15, 23, 42, 0.08);
    color: var(--color-secondary);
}

.chat-bubble {
    padding: 18px 22px;
    border-radius: var(--radius-md);
    font-size: 15px;
    line-height: 1.6;
    background: var(--color-surface-muted);
    color: var(--color-secondary);
    border: 1px solid var(--color-border);
    max-width: min(620px, 100%);
}

.chat-bubble--markdown h1,
.chat-bubble--markdown h2,
.chat-bubble--markdown h3,
.chat-bubble--markdown h4 {
    margin: 0 0 0.6em;
    font-weight: 700;
    color: var(--color-secondary);
}

.chat-bubble--markdown h1 {
    font-size: 1.45em;
}

.chat-bubble--markdown h2 {
    font-size: 1.3em;
}

.chat-bubble--markdown h3 {
    font-size: 1.18em;
}

.chat-bubble--markdown h4 {
    font-size: 1.08em;
}

.chat-bubble--markdown p {
    margin: 0 0 0.8em;
}

.chat-bubble--markdown ul,
.chat-bubble--markdown ol {
    margin: 0 0 0.85em;
    padding-left: 1.4em;
}

.chat-bubble--markdown li + li {
    margin-top: 0.35em;
}

.chat-bubble--markdown pre {
    margin: 0 0 0.85em;
    padding: 14px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.06);
    border: 1px solid var(--color-border);
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, SFMono, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.92em;
}

.chat-bubble--markdown code {
    font-family: ui-monospace, SFMono-Regular, SFMono, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.92em;
    background: rgba(15, 23, 42, 0.08);
    border-radius: 6px;
    padding: 0.1em 0.45em;
}

.chat-bubble--markdown blockquote {
    margin: 0 0 0.85em;
    padding-left: 1.1em;
    border-left: 3px solid rgba(249, 115, 22, 0.4);
    color: var(--color-text-muted);
}

.chat-bubble--markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 0.85em;
    font-size: 0.95em;
}

.chat-bubble--markdown table th,
.chat-bubble--markdown table td {
    border: 1px solid var(--color-border);
    padding: 8px 10px;
    text-align: left;
}

.chat-bubble--markdown table th {
    background: rgba(249, 115, 22, 0.08);
    font-weight: 600;
}

.chat-bubble--markdown > *:last-child {
    margin-bottom: 0;
}

.chat-message.assistant .chat-bubble {
    background: #fff;
    border-left: 3px solid var(--color-primary);
}

.chat-message--loading .chat-bubble {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--color-text-muted);
    font-style: italic;
    flex-wrap: wrap;
}

.chat-message--loading .chat-turn {
    color: var(--color-text-muted);
}

.chat-loading-dots {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.chat-loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary);
    opacity: 0.25;
    animation: chat-loading-bounce 1.1s infinite ease-in-out;
}

.chat-loading-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.chat-delay-notice {
    display: none;
    width: 100%;
    font-size: 12px;
    font-style: normal;
    color: var(--color-text-muted);
    opacity: 0.85;
    margin-top: 6px;
}

.chat-delay-notice.is-visible {
    display: block;
}

.chat-loading-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes chat-loading-bounce {
    0%, 80%, 100% {
        transform: scale(0.65);
        opacity: 0.25;
    }
    40% {
        transform: scale(1);
        opacity: 0.85;
    }
}

.chat-message.user .chat-bubble {
    background: var(--color-primary);
    color: #fff;
    border: none;
    box-shadow: 0 12px 20px rgba(249, 115, 22, 0.25);
}

.chat-empty {
    font-size: 15px;
    color: var(--color-text-muted);
    border-radius: var(--radius-md);
    padding: 24px;
    background: var(--color-surface-muted);
    border: 1px dashed rgba(249, 115, 22, 0.35);
    text-align: center;
}

.chat-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "label label"
        "input actions";
    gap: 10px 12px;
    align-items: stretch;
}

.chat-form--floating {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    width: min(100% - 32px, 1096px);
    padding: 12px 16px 14px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: var(--radius-md);
    border: 1px solid rgba(15, 23, 42, 0.12);
    box-shadow: 0 24px 42px rgba(15, 23, 42, 0.18);
    backdrop-filter: blur(12px);
    z-index: 920;
}

.chat-form label {
    grid-area: label;
    font-size: 13px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    font-weight: 600;
}

.chat-form textarea {
    grid-area: input;
    min-height: 84px;
    max-height: 180px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    line-height: 1.5;
}

.chat-form-actions {
    grid-area: actions;
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 8px;
}

.chat-back {
    font-weight: 600;
    color: var(--color-secondary);
    text-decoration: none;
    border-bottom: 1px solid rgba(15, 23, 42, 0.2);
    padding-bottom: 2px;
}

.chat-back:hover {
    border-bottom-color: rgba(15, 23, 42, 0.45);
    text-decoration: none;
}

.chat-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding-left: 18px;
    padding-right: 18px;
    min-width: 120px;
    position: relative;
    transition: background 0.2s ease, opacity 0.2s ease;
}

.chat-send__icon {
    font-size: 18px;
}

.chat-send__spinner {
    display: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
}

.chat-send[data-loading="true"] .chat-send__spinner {
    display: inline-flex;
    animation: chat-send-spin 0.7s linear infinite;
}

.chat-send[data-loading="true"] .chat-send__icon {
    display: none;
}

.chat-send[data-loading="true"] .chat-send__label {
    opacity: 0.65;
}

@keyframes chat-send-spin {
    0% {
        transform: scale(1) rotate(0deg);
    }
    100% {
        transform: scale(1) rotate(360deg);
    }
}

.chat-summary {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 32px;
}

.chat-summary-link {
    font-weight: 600;
    font-size: 14px;
    color: var(--color-secondary);
    text-decoration: none;
    border-bottom: 1px solid rgba(15, 23, 42, 0.2);
    align-self: flex-start;
    padding-bottom: 2px;
}

.chat-summary-link:hover {
    border-bottom-color: rgba(15, 23, 42, 0.45);
    text-decoration: none;
}

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

    .chat-summary {
        position: static;
    }
}

@media (max-width: 768px) {
    .chat-primary {
        gap: 20px;
    }

    .chat-hero-card {
        flex-direction: column;
        align-items: flex-start;
        padding: 24px;
    }

    .chat-hero-meta {
        align-items: flex-start;
    }

    .quick-prompt-chips {
        gap: 10px;
    }

    .prompt-chip {
        width: 100%;
        text-align: center;
    }

    .chat-panel {
        padding: 0;
    }

    .chat-history {
        height: auto;
        min-height: 0;
    }

    .chat-form--floating {
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + var(--keyboard-offset));
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        box-shadow: 0 -12px 24px rgba(15, 23, 42, 0.08);
    }

    body.is-keyboard-open .chat-form--floating {
        bottom: calc(env(safe-area-inset-bottom) + var(--keyboard-offset));
    }

    .planner-chat-drawer.is-open .chat-form--floating {
        bottom: calc(12px + env(safe-area-inset-bottom));
    }

    body.is-keyboard-open .planner-chat-drawer.is-open .chat-form--floating {
        bottom: calc(env(safe-area-inset-bottom) + var(--keyboard-offset));
    }

    .chat-form {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "input actions";
        gap: 10px;
    }

    .chat-form label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .chat-form textarea {
        min-height: 44px;
        max-height: 120px;
        padding: 10px 14px;
        border-radius: 14px;
        resize: none;
    }

    .chat-form-actions {
        align-items: center;
    }

    .chat-send {
        width: 44px;
        height: 44px;
        min-width: 0;
        padding: 0;
        border-radius: 12px;
    }

    .chat-send__label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .chat-send__icon {
        font-size: 20px;
    }

    .chat-send__spinner {
        width: 16px;
        height: 16px;
    }

    .chat-summary-link {
        align-self: stretch;
        text-align: center;
        padding: 10px 0;
    }
}
