/* =========================================================================
   EASTA — design system
   Warm, editorial, Claude-inspired: cream surfaces, terracotta accent,
   a serif display face paired with a clean sans body face.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;1,9..144,500&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --color-bg: #F6F1E8;
    --color-bg-soft: #F1EADC;
    --color-surface: #FFFFFF;
    --color-sidebar: #F1EADC;
    --color-border: #E4DBC9;
    --color-border-strong: #D8CBAF;

    --color-text: #2A2622;
    --color-text-muted: #6F6558;
    --color-text-faint: #9A907F;

    --color-accent: #C4693E;
    --color-accent-hover: #AD5731;
    --color-accent-soft: #F1DCC5;
    --color-accent-soft-strong: #E7C6A2;

    --color-danger: #B3402F;
    --color-danger-soft: #F6DDD7;
    --color-success: #4C7A55;

    --color-user-bubble: #EFE6D3;
    --color-assistant-bubble: #FFFFFF;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(42, 38, 34, 0.06);
    --shadow-md: 0 6px 20px rgba(42, 38, 34, 0.08);
    --shadow-lg: 0 16px 40px rgba(42, 38, 34, 0.14);

    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
        Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo,
        Consolas, monospace;

    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--color-accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 500;
    line-height: 1.15;
    margin: 0;
}

button {
    font-family: var(--font-body);
}

::selection {
    background: var(--color-accent-soft);
}

/* --- shared brand mark ------------------------------------------------- */

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: linear-gradient(155deg, #D98255 0%, #B85632 100%);
    color: #FFF9F0;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 19px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-row .brand-name {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--color-text);
}

/* --- buttons ------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease,
        color 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--color-accent);
    color: #FFF8F0;
}

.btn-primary:hover {
    background: var(--color-accent-hover);
    text-decoration: none;
}

.btn-secondary {
    background: transparent;
    color: var(--color-text);
    border-color: var(--color-border-strong);
}

.btn-secondary:hover {
    background: var(--color-bg-soft);
    text-decoration: none;
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    border-color: transparent;
    padding: 8px 14px;
}

.btn-ghost:hover {
    background: var(--color-bg-soft);
    color: var(--color-text);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* =========================================================================
   LANDING PAGE
   ========================================================================= */

.landing-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1120px;
    margin: 0 auto;
    padding: 22px 24px;
}

.landing-nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.landing-hero {
    max-width: 860px;
    margin: 0 auto;
    padding: 64px 24px 40px;
    text-align: center;
}

.landing-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    background: var(--color-accent-soft);
    color: var(--color-accent-hover);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    margin-bottom: 24px;
}

.landing-hero h1 {
    font-size: clamp(36px, 6vw, 58px);
    letter-spacing: -0.01em;
    margin-bottom: 20px;
}

.landing-hero h1 em {
    font-style: italic;
    color: var(--color-accent);
}

.landing-hero p.lede {
    font-size: 19px;
    line-height: 1.6;
    color: var(--color-text-muted);
    max-width: 620px;
    margin: 0 auto 32px;
}

.landing-hero-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

.landing-hero-actions .btn {
    padding: 13px 26px;
    font-size: 16px;
}

.landing-preview {
    max-width: 900px;
    margin: 48px auto 0;
    padding: 0 24px;
}

.landing-preview-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 22px;
}

.landing-preview-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 18px;
}

.landing-preview-bar span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-border-strong);
}

.landing-preview-row {
    display: flex;
    gap: 12px;
    margin-bottom: 14px;
    align-items: flex-start;
}

.landing-preview-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-accent-soft);
    flex-shrink: 0;
}

.landing-preview-avatar.assistant {
    background: linear-gradient(155deg, #D98255 0%, #B85632 100%);
}

.landing-preview-bubble {
    background: var(--color-bg-soft);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--color-text);
    max-width: 90%;
}

.landing-preview-row.user .landing-preview-bubble {
    background: var(--color-user-bubble);
}

.landing-features {
    max-width: 1080px;
    margin: 96px auto 0;
    padding: 0 24px;
}

.landing-section-heading {
    text-align: center;
    max-width: 620px;
    margin: 0 auto 44px;
}

.landing-section-heading h2 {
    font-size: clamp(28px, 4vw, 38px);
    margin-bottom: 14px;
}

.landing-section-heading p {
    color: var(--color-text-muted);
    font-size: 16px;
    line-height: 1.6;
}

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

.feature-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 26px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.feature-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.feature-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: var(--color-accent-soft);
    color: var(--color-accent-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 16px;
}

.feature-card h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.feature-card p {
    color: var(--color-text-muted);
    font-size: 14.5px;
    line-height: 1.6;
    margin: 0;
}

.landing-cta {
    max-width: 760px;
    margin: 96px auto 80px;
    padding: 48px 40px;
    text-align: center;
    border-radius: var(--radius-lg);
    background: linear-gradient(155deg, #2A2622 0%, #40342A 100%);
    color: #F6F1E8;
}

.landing-cta h2 {
    color: #FFF8F0;
    font-size: clamp(24px, 3.4vw, 32px);
    margin-bottom: 14px;
}

.landing-cta p {
    color: #D9CFC0;
    margin-bottom: 26px;
}

.landing-footer {
    text-align: center;
    padding: 32px 24px 48px;
    color: var(--color-text-faint);
    font-size: 13.5px;
}

/* =========================================================================
   AUTH (login / register)
   ========================================================================= */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 15%, #FBE9D6 0%, transparent 45%),
        radial-gradient(circle at 85% 85%, #F0DEC7 0%, transparent 50%),
        var(--color-bg);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 36px 32px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.login-brand h1 {
    font-size: 21px;
    margin: 0 0 2px;
}

.login-brand p {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 13.5px;
}

.login-heading {
    margin-bottom: 20px;
}

.login-heading h2 {
    font-size: 24px;
    margin-bottom: 6px;
}

.login-heading p {
    color: var(--color-text-muted);
    font-size: 14.5px;
    margin: 0;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
}

.login-field input {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-strong);
    background: var(--color-bg);
    font-size: 15px;
    color: var(--color-text);
    font-family: var(--font-body);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-field input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.login-button {
    margin-top: 4px;
    width: 100%;
    padding: 13px;
    border-radius: var(--radius-pill);
    border: none;
    background: var(--color-accent);
    color: #FFF8F0;
    font-size: 15.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.login-button:hover {
    background: var(--color-accent-hover);
}

.login-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-switch {
    text-align: center;
    margin-top: 22px;
    font-size: 14px;
    color: var(--color-text-muted);
}

.login-switch a {
    font-weight: 600;
}

.error-message {
    font-size: 13.5px;
    color: var(--color-danger);
}

.login-error:empty {
    display: none;
}

/* =========================================================================
   CHAT APP
   ========================================================================= */

.chat-page {
    height: 100vh;
    overflow: hidden;
    background: var(--color-bg);
}

.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- sidebar --- */

.sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    border-right: 1px solid var(--color-border);
    background: var(--color-sidebar);
    transition: width 0.2s ease, padding 0.2s ease;
}

.sidebar.sidebar-hidden {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
    border-right: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 6px 18px;
}

.sidebar-close {
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: none;
    padding: 4px;
    border-radius: var(--radius-sm);
}

.sidebar-close:hover {
    background: var(--color-bg);
}

.new-chat-button {
    width: 100%;
    margin-bottom: 18px;
    padding: 11px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.new-chat-button:hover {
    background: var(--color-accent-soft);
    border-color: var(--color-accent-soft-strong);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin: 0 -4px;
    padding: 0 4px;
}

.conversation-link {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

.conversation-link:hover {
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
}

.conversation-link.active {
    background: var(--color-accent-soft);
    color: var(--color-accent-hover);
    font-weight: 600;
}

.sidebar-language {
    padding: 10px 6px 2px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-language label {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-faint);
}

.sidebar-language select {
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 13.5px;
    cursor: pointer;
}

.sidebar-language select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.sidebar-footer {
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-footer-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--color-text-muted);
    text-decoration: none;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: var(--font-body);
}

.sidebar-footer-link:hover {
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
}

/* --- main chat panel --- */

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--color-bg);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.sidebar-toggle {
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 15px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--color-bg-soft);
}

.chat-header h1 {
    font-size: 16.5px;
    font-weight: 600;
    font-family: var(--font-body);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header #current-user {
    margin: 1px 0 0;
    font-size: 12.5px;
    color: var(--color-text-faint);
}

.logout-link {
    border: 1px solid var(--color-border-strong);
    background: transparent;
    color: var(--color-text-muted);
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
}

.logout-link:hover {
    background: var(--color-surface);
    color: var(--color-text);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.canvas-toggle-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
}

.canvas-toggle-button:hover {
    background: var(--color-bg-soft);
}

.canvas-toggle-button[aria-pressed="true"] {
    background: var(--color-accent-soft);
    border-color: var(--color-accent-soft-strong);
    color: var(--color-accent-hover);
}

/* The [hidden] attribute alone loses to any author-stylesheet `display`
 * rule (including these buttons' own `display: inline-flex`/`flex`),
 * so controls that get shown/hidden via el.hidden need an explicit
 * override — otherwise "hidden" elements stay visible. */
.canvas-toggle-button[hidden],
.composer-toggle-button[hidden],
.composer-icon-button[hidden] {
    display: none;
}

/* --- messages --- */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 28px 20px 8px;
}

.empty-chat {
    max-width: 640px;
    margin: 8vh auto 0;
    text-align: center;
}

.empty-chat h2 {
    font-size: 28px;
    margin-bottom: 10px;
}

.empty-chat p {
    color: var(--color-text-muted);
    font-size: 15px;
}

.message-row {
    max-width: 760px;
    margin: 0 auto 22px;
    display: flex;
}

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

.message-row.assistant-row {
    justify-content: flex-start;
}

.message-group {
    max-width: 92%;
    position: relative;
}

.message {
    padding: 13px 17px;
    border-radius: var(--radius-md);
    font-size: 15px;
    line-height: 1.65;
    word-wrap: break-word;
}

.user-message {
    background: var(--color-user-bubble);
    color: var(--color-text);
    border-bottom-right-radius: 4px;
}

.assistant-message {
    background: var(--color-assistant-bubble);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    border-bottom-left-radius: 4px;
}

.assistant-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.assistant-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    color: var(--color-text-faint);
    padding-left: 4px;
}

.assistant-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-accent);
    animation: pulse-dot 1.1s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.1); }
}

.tool-use-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    background: var(--color-accent-soft);
    color: var(--color-accent-hover);
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 2px;
}

.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    background: var(--color-bg-soft);
    border: 1px solid var(--color-border-strong);
    font-size: 12.5px;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.source-list {
    margin-top: 4px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--color-bg-soft);
    border: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.source-list-heading {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-faint);
    margin-bottom: 2px;
}

.source-list-item {
    font-size: 13px;
    color: var(--color-text-muted);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-list-item:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

/* markdown content inside assistant bubbles */

.assistant-message p {
    margin: 0 0 10px;
}

.assistant-message p:last-child {
    margin-bottom: 0;
}

.assistant-message ul,
.assistant-message ol {
    margin: 0 0 10px;
    padding-left: 22px;
}

.assistant-message li {
    margin-bottom: 4px;
}

.assistant-message h1,
.assistant-message h2,
.assistant-message h3 {
    font-family: var(--font-body);
    font-weight: 700;
    margin: 16px 0 8px;
}

.assistant-message h1:first-child,
.assistant-message h2:first-child,
.assistant-message h3:first-child {
    margin-top: 0;
}

.assistant-message a {
    text-decoration: underline;
}

.assistant-message blockquote {
    margin: 0 0 10px;
    padding: 4px 14px;
    border-left: 3px solid var(--color-accent-soft-strong);
    color: var(--color-text-muted);
}

.assistant-message code {
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--color-bg-soft);
    padding: 2px 6px;
    border-radius: 5px;
}

.assistant-message pre {
    position: relative;
    margin: 0 0 12px;
    padding: 16px;
    padding-top: 38px;
    border-radius: var(--radius-md);
    background: #2A2622;
    overflow-x: auto;
}

.assistant-message pre code {
    background: none;
    padding: 0;
    color: #F1EADC;
    font-size: 13px;
    line-height: 1.6;
}

.code-block-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: #B7ACA0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.copy-code-button {
    background: transparent;
    border: none;
    color: #D9CFC0;
    font-size: 11.5px;
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 5px;
}

.copy-code-button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.assistant-message table {
    border-collapse: collapse;
    width: 100%;
    margin: 0 0 12px;
    font-size: 14px;
}

.assistant-message th,
.assistant-message td {
    border: 1px solid var(--color-border);
    padding: 8px 10px;
    text-align: left;
}

.assistant-message th {
    background: var(--color-bg-soft);
}

/* message hover actions (edit / regenerate / copy) */

.message-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.12s ease;
}

.message-row:hover .message-actions {
    opacity: 1;
}

.message-row.user-row .message-actions {
    justify-content: flex-end;
}

.message-action-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: none;
    background: transparent;
    color: var(--color-text-faint);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 9px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-body);
}

.message-action-button:hover {
    background: var(--color-bg-soft);
    color: var(--color-text);
}

.edit-textarea {
    width: 100%;
    min-width: 360px;
    max-width: 70vw;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-accent);
    background: var(--color-surface);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    resize: vertical;
    box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

/* --- composer --- */

.chat-composer {
    padding: 12px 20px 20px;
}

.message-form {
    max-width: 760px;
    margin: 0 auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 10px 10px 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.attachment-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.attachment-row:empty {
    display: none;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: var(--radius-pill);
    background: var(--color-bg-soft);
    border: 1px solid var(--color-border-strong);
    font-size: 12.5px;
    color: var(--color-text);
}

.attachment-chip button {
    border: none;
    background: transparent;
    color: var(--color-text-faint);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}

.attachment-chip-loading {
    color: var(--color-text-muted);
}

.attachment-chip-image {
    padding: 4px;
    gap: 6px;
}

.attachment-chip-image img {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

.message-image-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.message-image {
    max-width: 220px;
    max-height: 220px;
    width: auto;
    height: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    object-fit: cover;
}

.user-message:empty {
    display: none;
}

.composer-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.message-form textarea {
    flex: 1;
    resize: none;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    color: var(--color-text);
    padding: 8px 0;
    max-height: 160px;
}

.message-form textarea::placeholder {
    color: var(--color-text-faint);
}

.composer-icon-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    flex-shrink: 0;
    font-size: 16px;
}

.composer-icon-button:hover {
    background: var(--color-bg-soft);
    color: var(--color-text);
}

.composer-icon-button.recording {
    background: var(--color-danger-soft);
    color: var(--color-danger);
    animation: pulse-recording 1.1s ease-in-out infinite;
}

@keyframes pulse-recording {
    0%, 100% { box-shadow: 0 0 0 0 rgba(179, 64, 47, 0.35); }
    50% { box-shadow: 0 0 0 6px rgba(179, 64, 47, 0); }
}

.message-action-button.speaking {
    background: var(--color-accent-soft);
    color: var(--color-accent-hover);
}

.composer-toggle-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 12px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--color-border-strong);
    background: transparent;
    color: var(--color-text-muted);
    font-family: var(--font-body);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease,
        color 0.15s ease;
}

.composer-toggle-button:hover {
    background: var(--color-bg-soft);
    color: var(--color-text);
}

.composer-toggle-button[aria-pressed="true"] {
    background: var(--color-accent-soft);
    border-color: var(--color-accent-soft-strong);
    color: var(--color-accent-hover);
}

#send-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--color-accent);
    color: #FFF8F0;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 15px;
    transition: background 0.15s ease, transform 0.1s ease;
}

#send-button:hover {
    background: var(--color-accent-hover);
}

#send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.composer-hint {
    text-align: center;
    font-size: 11.5px;
    color: var(--color-text-faint);
    margin: 8px 0 0;
}

/* --- canvas / design panel ------------------------------------------------ */

.canvas-panel {
    width: 440px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--color-border);
    background: var(--color-surface);
}

.canvas-panel[hidden] {
    display: none;
}

.canvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.canvas-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.canvas-header-info h2 {
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-body);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.canvas-kind-badge {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    background: var(--color-accent-soft);
    color: var(--color-accent-hover);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.canvas-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.canvas-action-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-text);
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    font-family: var(--font-body);
}

.canvas-action-button:hover {
    background: var(--color-bg-soft);
    text-decoration: none;
}

.canvas-close-button {
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.canvas-close-button:hover {
    background: var(--color-bg-soft);
}

.canvas-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px;
}

.canvas-body .assistant-message {
    border: none;
    padding: 0;
}

.canvas-body pre {
    margin: 0;
    padding: 16px;
    border-radius: var(--radius-md);
    background: #2A2622;
    overflow-x: auto;
}

.canvas-body pre code {
    background: none;
    padding: 0;
    color: #F1EADC;
    font-size: 13px;
    line-height: 1.6;
    font-family: var(--font-mono);
}

.canvas-body img {
    max-width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    display: block;
}

.canvas-empty {
    color: var(--color-text-faint);
    font-size: 14px;
    text-align: center;
    margin-top: 20%;
}

/* =========================================================================
   USAGE / COST DASHBOARD
   ========================================================================= */

.usage-page {
    min-height: 100vh;
    background: var(--color-bg);
}

.usage-shell {
    max-width: 980px;
    margin: 0 auto;
    padding: 28px 24px 64px;
}

.usage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}

.usage-header h1 {
    font-size: 26px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
    font-size: 12.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-faint);
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 26px;
}

.usage-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.usage-panel h2 {
    font-size: 16px;
    margin-bottom: 16px;
}

.chart-wrap {
    height: 220px;
    position: relative;
}

.model-bar-row {
    display: grid;
    grid-template-columns: 160px 1fr 90px;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 13.5px;
}

.model-bar-row .model-name {
    color: var(--color-text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-bar-track {
    height: 8px;
    border-radius: var(--radius-pill);
    background: var(--color-bg-soft);
    overflow: hidden;
}

.model-bar-fill {
    height: 100%;
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, #D98255, #B85632);
}

.model-bar-cost {
    text-align: right;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

.usage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

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

.usage-table th {
    color: var(--color-text-faint);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11.5px;
    letter-spacing: 0.03em;
}

.usage-empty {
    color: var(--color-text-muted);
    font-size: 14px;
    padding: 12px 0;
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */

@media (max-width: 900px) {
    .feature-grid {
        grid-template-columns: 1fr;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 700px) {
    .sidebar {
        position: fixed;
        z-index: 20;
        top: 0;
        bottom: 0;
        left: 0;
        box-shadow: var(--shadow-lg);
    }

    .sidebar-close {
        display: inline-flex;
    }

    .chat-header {
        padding: 14px 16px;
    }

    .chat-messages {
        padding: 20px 14px 8px;
    }

    .chat-composer {
        padding: 10px 12px 16px;
    }

    .edit-textarea {
        min-width: 0;
        max-width: 100%;
    }

    .landing-hero {
        padding: 44px 20px 28px;
    }

    .model-bar-row {
        grid-template-columns: 100px 1fr 70px;
        font-size: 12.5px;
    }

    .canvas-panel {
        position: fixed;
        z-index: 20;
        top: 0;
        bottom: 0;
        right: 0;
        width: 100%;
        box-shadow: var(--shadow-lg);
        border-left: none;
    }
}
