/* Workspace layout: a fixed navigation rail and a full-width canvas library. */
:root {
    --home-background: #f7f8fa;
    --home-dot: rgba(35, 43, 53, .09);
    --home-text: #29313b;
    --home-heading: #1c232c;
    --home-muted: #6e7783;
    --home-line: #e2e5e9;
    --home-line-strong: #c0c7ce;
    --home-panel-solid: #fff;
    --home-soft: #f0f2f5;
    --home-primary: #283c36;
    --home-primary-text: #fff;
    --home-accent: #488776;
    --home-danger: #bd303d;
    --home-shadow: 0 14px 36px rgba(29, 37, 48, .06);
    --workspace-sidebar: #eef1f4;
    --workspace-sidebar-text: #5a6572;
    --workspace-sidebar-heading: #242d37;
    --workspace-sidebar-muted: #737f8c;
    --workspace-sidebar-edge: #d9dfe5;
    --workspace-sidebar-hover: #e4e8ec;
    --workspace-sidebar-active: #dce6e1;
    --workspace-sidebar-selected: #294c3d;
    --workspace-wallet: #ffffff;
    --workspace-wallet-accent: #2f6a53;
    --workspace-avatar: #d9e7df;
    --workspace-avatar-ink: #355e4b;
}

html.theme-dark,
body.theme-dark {
    --home-background: #111214;
    --home-dot: rgba(255, 255, 255, .055);
    --home-text: #dce0e6;
    --home-heading: #f1f2f5;
    --home-muted: #969da8;
    --home-line: #2d3036;
    --home-line-strong: #515762;
    --home-panel-solid: #1b1d21;
    --home-soft: #25282e;
    --home-primary: #b7dace;
    --home-primary-text: #182a23;
    --home-accent: #a2d3bf;
    --home-danger: #ff8591;
    --home-shadow: 0 14px 36px rgba(0, 0, 0, .18);
    --workspace-sidebar: #191b1e;
    --workspace-sidebar-text: #afb4be;
    --workspace-sidebar-heading: #f3f5f7;
    --workspace-sidebar-muted: #929ca9;
    --workspace-sidebar-edge: #2b2f35;
    --workspace-sidebar-hover: #25282c;
    --workspace-sidebar-active: #30343a;
    --workspace-sidebar-selected: #f1f5f3;
    --workspace-wallet: #22262b;
    --workspace-wallet-accent: #b5ddc9;
    --workspace-avatar: #31473e;
    --workspace-avatar-ink: #c1e0ce;
}

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

body {
    color: var(--home-text);
    background: var(--home-background);
    font-size: 13px;
    line-height: 1.5;
}

html.theme-dark body,
body.theme-dark { background: var(--home-background); }
body::before { display: none; }
[hidden] { display: none !important; }

button,
a,
input { -webkit-tap-highlight-color: transparent; }
button { font-weight: 500; }
button:disabled { opacity: .5; cursor: wait; }

svg[data-lucide] {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    stroke-width: 1.7;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--home-accent);
    outline-offset: 3px;
}

.home-shell {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-width: 0;
}

.workspace-sidebar {
    display: flex;
    flex-direction: column;
    gap: 34px;
    min-width: 0;
    min-height: 0;
    padding: 24px 12px 18px;
    overflow-y: auto;
    color: var(--workspace-sidebar-text);
    background: var(--workspace-sidebar);
    border-right: 1px solid var(--workspace-sidebar-edge);
    scrollbar-color: var(--workspace-sidebar-edge) transparent;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

.workspace-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    flex: 0 0 auto;
    width: 100%;
    padding: 0 9px;
    border: 0;
    color: var(--workspace-sidebar-heading);
    background: transparent;
    text-align: left;
    border-radius: 8px;
}

.home-brand-dot {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: url('/static/images/app-icon.png') center / contain no-repeat;
}

.workspace-brand-copy { display: grid; gap: 2px; min-width: 0; }
.workspace-brand-copy strong { font-size: 15px; font-weight: 650; overflow-wrap: anywhere; }
.workspace-brand-copy small { font-size: 10px; color: var(--workspace-sidebar-muted); letter-spacing: .06em; }
.workspace-nav { display: grid; gap: 8px; }

.workspace-nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: inherit;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    transition: color .16s ease, background-color .16s ease;
}

.workspace-nav-item:hover { color: var(--workspace-sidebar-heading); background: var(--workspace-sidebar-hover); }
.workspace-nav-item.is-active { color: var(--workspace-sidebar-selected); background: var(--workspace-sidebar-active); }

.workspace-account {
    display: grid;
    gap: 14px;
    min-width: 0;
    margin-top: auto;
    padding: 18px 2px 0;
    border-top: 1px solid var(--workspace-sidebar-edge);
    color: var(--workspace-sidebar-text);
}
.workspace-account button { border: 0; background: transparent; color: inherit; text-align: left; }
.workspace-account-profile { display: flex; align-items: center; gap: 10px; min-width: 0; width: 100%; padding: 4px; border-radius: 9px; }
.workspace-account-profile:hover { background: var(--workspace-sidebar-hover); }
.workspace-account-avatar { display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 36px; border: 1px solid color-mix(in srgb, var(--workspace-wallet-accent) 20%, transparent); border-radius: 11px; background: var(--workspace-avatar); color: var(--workspace-avatar-ink); font-size: 15px; font-weight: 600; }
.workspace-account-avatar svg { width: 18px; height: 18px; }
.workspace-account-copy { display: grid; gap: 3px; flex: 1; min-width: 0; }
.workspace-account-copy strong { overflow: hidden; color: var(--workspace-sidebar-heading); font-size: 12px; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.workspace-account-copy > span { overflow: hidden; color: var(--workspace-sidebar-muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.workspace-account[data-connected="true"] #workspaceAccountTier { color: var(--workspace-wallet-accent); }
.workspace-account[data-connected="true"] #workspaceAccountTier[data-tier="monthly"] { color: light-dark(#3e6c9b, #a6c9ef); }
.workspace-account[data-connected="true"] #workspaceAccountTier[data-tier="quarterly"] { color: light-dark(#765494, #cfb5e9); }
.workspace-account[data-connected="true"] #workspaceAccountTier[data-tier="yearly"] { color: light-dark(#89652c, #e8c687); }
.workspace-account[data-connected="true"] #workspaceAccountTier[data-tier="permanent"] { color: light-dark(#826343, #d9b58e); }
.workspace-account-arrow { width: 13px !important; height: 13px !important; color: var(--workspace-sidebar-muted); }
.workspace-wallet { position: relative; min-width: 0; padding: 12px; border: 1px solid var(--workspace-sidebar-edge); border-radius: 12px; background: var(--workspace-wallet); box-shadow: 0 2px 4px rgba(0,0,0,.02); }
.workspace-wallet-balance { display: grid; gap: 8px; min-width: 0; width: 100%; padding: 0; }
.workspace-wallet-caption { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; min-height: 20px; max-width: calc(100% - 46px); color: var(--workspace-sidebar-muted); font-size: 10px; }
#workspacePointsValue { display: block; overflow: hidden; color: var(--workspace-sidebar-heading); font-size: 21px; font-weight: 600; line-height: 1.3; letter-spacing: -.04em; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.workspace-sync-indicator { color: light-dark(#986224, #edbe7a); font-size: 9px; }
.workspace-account .workspace-recharge { position: absolute; top: 10px; right: 9px; display: inline-flex; align-items: center; justify-content: center; gap: 3px; min-height: 23px; padding: 3px 6px; border: 1px solid color-mix(in srgb, var(--workspace-wallet-accent) 20%, transparent); border-radius: 7px; background: color-mix(in srgb, var(--workspace-wallet-accent) 9%, transparent); color: var(--workspace-wallet-accent); font-size: 10px; }
.workspace-wallet.has-long-balance #workspacePointsValue { font-size: 15px; white-space: normal; overflow-wrap: anywhere; }
.workspace-recharge svg { width: 12px; height: 12px; }
.workspace-account .workspace-recharge:hover { background: color-mix(in srgb, var(--workspace-wallet-accent) 17%, transparent); }
.workspace-account-ledger { display: flex; align-items: center; gap: 8px; width: 100%; padding: 4px 6px; border-radius: 6px; font-size: 10px; }
.workspace-account-ledger:hover { background: var(--workspace-sidebar-hover); color: var(--workspace-sidebar-heading); }
.workspace-account-ledger svg { width: 13px; height: 13px; }
.workspace-account-ledger span { flex: 1; }
.workspace-tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; min-width: 0; padding-top: 10px; border-top: 1px solid var(--workspace-sidebar-edge); }
.workspace-account .workspace-tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; min-width: 0; min-height: 54px; padding: 8px 2px; border-radius: 8px; color: var(--workspace-sidebar-muted); font-size: 10px; line-height: 1.4; white-space: nowrap; }
.workspace-account .workspace-tool:hover { color: var(--workspace-sidebar-heading); background: var(--workspace-sidebar-hover); }
.workspace-tool svg { width: 17px; height: 17px; }

.workspace-main {
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: 0 clamp(24px, 3.2vw, 64px) 48px;
    background-color: var(--home-background);
    background-image: radial-gradient(var(--home-dot) .75px, transparent .75px);
    background-size: 20px 20px;
    scrollbar-color: var(--home-line-strong) transparent;
    scroll-behavior: smooth;
}

.workspace-main:is(.is-conversation, .is-tool) { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 0; background-image: none; }
.workspace-main:is(.is-conversation, .is-tool) .workspace-toolbar { flex-shrink: 0; }
.workspace-conversation { flex: 1 1 0; min-width: 0; min-height: 0; margin: 0 calc(-1 * clamp(24px, 3.2vw, 64px)); }
.workspace-conversation iframe { display: block; width: 100%; height: 100%; border: 0; background: transparent; }
.workspace-conversation[hidden], .home-history-panel[hidden] { display: none; }

.workspace-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 68px;
    gap: 16px;
}
.workspace-breadcrumb { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--home-muted); }
.workspace-breadcrumb span:last-child { color: var(--home-text); }
.workspace-breadcrumb span[aria-hidden] { opacity: .5; }

.home-icon-button {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--home-line);
    border-radius: 9px;
    background: var(--home-panel-solid);
    color: var(--home-muted);
    transition: background-color .16s ease, color .16s ease, border-color .16s ease;
}
.home-icon-button:hover { background: var(--home-soft); color: var(--home-heading); border-color: var(--home-line-strong); }

.home-history-panel {
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 20px 0 0;
    border: 0;
    background: transparent;
}
.home-section-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; width: 100%; margin-bottom: 26px; }
.home-section-copy { display: grid; gap: 7px; min-width: 0; }
.home-section-copy h1 { color: var(--home-heading); font-size: 26px; font-weight: 600; line-height: 1.3; letter-spacing: -.025em; }
.home-section-copy p { margin: 0; font-size: 12px; color: var(--home-muted); }

.home-primary-button,
.home-secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    gap: 7px;
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid var(--home-line);
    border-radius: 8px;
    color: var(--home-text);
    background: var(--home-panel-solid);
    font-size: 12px;
    white-space: nowrap;
    transition: background-color .16s ease, border-color .16s ease;
}
.home-secondary-button:hover { background: var(--home-soft); border-color: var(--home-line-strong); }
.home-primary-button { color: var(--home-primary-text); background: var(--home-primary); border-color: transparent; }
.home-primary-button:hover { filter: brightness(1.1); }
.home-secondary-button svg,
.home-primary-button svg { width: 14px; height: 14px; }

.home-canvas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 208px);
    grid-auto-rows: auto;
    justify-content: start;
    align-items: stretch;
    gap: 18px;
    width: 100%;
    min-width: 0;
}

.home-canvas-card {
    position: relative;
    width: 100%;
    min-width: 0;
    min-height: 186px;
    padding: 9px;
    border: 1px solid var(--home-line);
    border-radius: 12px;
    background: var(--home-panel-solid);
    color: var(--home-text);
    text-align: left;
    cursor: pointer;
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.home-canvas-card:hover { border-color: var(--home-line-strong); box-shadow: var(--home-shadow); transform: translateY(-2px); }
.home-canvas-card:focus-within { border-color: var(--home-line-strong); }
.home-canvas-preview { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 7px; background: var(--home-soft); }
.home-preview-images { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 2px; }
.home-preview-images[data-count="1"] { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.home-preview-images[data-count="2"] { grid-template-rows: 1fr; }
.home-preview-images[data-count="3"] .home-preview-tile:first-child { grid-row: span 2; }
.home-preview-tile { min-width: 0; min-height: 0; overflow: hidden; background: var(--home-soft); }
.home-preview-tile img { width: 100%; height: 100%; display: block; object-fit: cover; }
.home-preview-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 12px; color: var(--home-muted); font-size: 10px; }
.home-preview-fallback svg { width: 22px; height: 22px; opacity: .65; }
.home-preview-fallback p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; font-size: 10px; line-height: 1.5; }
.home-canvas-preview.has-media .home-preview-fallback { display: none; }

.home-canvas-info { display: flex; flex-direction: column; gap: 5px; padding: 10px 2px 1px; }
.home-canvas-meta { color: var(--home-muted); font-size: 10px; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-canvas-title-row { display: flex; align-items: center; gap: 5px; min-width: 0; }
.home-canvas-title-row strong { flex: 1; min-width: 0; overflow: hidden; color: var(--home-heading); font-size: 12px; line-height: 1.6; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.home-canvas-actions,
.home-inline-title-actions { display: flex; flex: 0 0 auto; gap: 1px; }
.home-canvas-actions button,
.home-inline-title-actions button { display: grid; place-items: center; width: 24px; height: 26px; padding: 0; border: 0; border-radius: 5px; color: var(--home-muted); background: transparent; }
.home-canvas-actions svg,
.home-inline-title-actions svg { width: 13px; height: 13px; }
.home-canvas-actions button:hover,
.home-inline-title-actions button:hover { color: var(--home-heading); background: var(--home-soft); }
.home-canvas-actions .danger:hover { color: var(--home-danger); background: color-mix(in srgb, var(--home-danger) 10%, transparent); }
.home-inline-title-input { flex: 1; min-width: 0; width: 100%; height: 27px; padding: 3px 5px; border: 1px solid var(--home-accent); border-radius: 5px; color: var(--home-heading); background: var(--home-panel-solid); font-size: 12px; }
.home-inline-title-input:focus-visible { outline: 2px solid var(--home-accent); outline-offset: 1px; }

.home-canvas-create { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; min-height: 186px; border-style: dashed; background: color-mix(in srgb, var(--home-panel-solid) 55%, transparent); text-align: center; }
.home-canvas-create > svg { width: 26px; height: 26px; margin-bottom: 7px; color: var(--home-muted); stroke-width: 1.4; }
.home-canvas-create strong { color: var(--home-heading); font-size: 12px; font-weight: 500; }
.home-canvas-create span { font-size: 10px; color: var(--home-muted); }
.home-canvas-create:hover { border-color: var(--home-accent); background: var(--home-panel-solid); }

.home-empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; margin: 46px 0 0; padding: 25px 12px; color: var(--home-muted); text-align: center; }
.home-empty-state > svg { width: 26px; height: 26px; margin-bottom: 4px; opacity: .65; }
.home-empty-state strong { color: var(--home-text); font-size: 13px; font-weight: 500; }
.home-empty-state span { font-size: 12px; }

.home-create-dialog { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; color: var(--home-text); background: rgba(9, 12, 16, .45); backdrop-filter: blur(6px); }
.home-create-card { display: grid; gap: 24px; width: min(420px, 100%); max-height: 100%; overflow: auto; padding: 24px; border: 1px solid var(--home-line); border-radius: 16px; background: var(--home-panel-solid); box-shadow: 0 24px 80px rgba(0, 0, 0, .22); }
.home-create-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.home-create-head strong { color: var(--home-heading); font-size: 18px; font-weight: 600; }
.home-create-head .home-icon-button { border: 0; background: transparent; }
.home-create-field { display: grid; gap: 9px; color: var(--home-muted); font-size: 12px; }
.home-create-field input { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid var(--home-line-strong); border-radius: 8px; background: var(--home-background); color: var(--home-heading); font-size: 13px; }
.home-create-field input:focus { border-color: var(--home-accent); outline: 2px solid color-mix(in srgb, var(--home-accent) 22%, transparent); }
.home-create-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.home-toast { position: fixed; left: 50%; bottom: 26px; z-index: 120; width: max-content; max-width: calc(100% - 32px); padding: 11px 16px; border: 1px solid var(--home-line-strong); border-radius: 10px; transform: translateX(-50%); background: var(--home-panel-solid); color: var(--home-text); box-shadow: var(--home-shadow); font-size: 13px; }
.spin { animation: home-spin .85s linear infinite; }
@keyframes home-spin { to { transform: rotate(360deg); } }

@media (max-width: 1080px) {
    .workspace-conversation { margin-right: -24px; margin-left: -24px; }
    .home-shell { grid-template-columns: 184px minmax(0, 1fr); }
    .workspace-main { padding-right: 24px; padding-left: 24px; }
    .home-canvas-grid { grid-template-columns: repeat(auto-fill, 196px); gap: 16px; }
}

@media (max-width: 680px) {
    .workspace-conversation { margin-right: -18px; margin-left: -18px; }
    .home-shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
    .workspace-sidebar { padding: 12px 16px; gap: 14px; border-right: 0; border-bottom: 1px solid var(--workspace-sidebar-edge); }
    .workspace-brand { width: max-content; max-width: 100%; padding: 0; }
    .home-brand-dot { width: 28px; height: 28px; flex-basis: 28px; }
    .workspace-brand-copy { display: flex; align-items: baseline; gap: 8px; }
    .workspace-brand-copy strong { font-size: 14px; }
    .workspace-brand-copy small { font-size: 10px; }
    .workspace-nav { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
    .workspace-nav-item { width: auto; min-height: 36px; padding: 8px 11px; font-size: 12px; }
    .workspace-account { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px; width: 100%; margin: 0; padding: 12px 0 0; }
    .workspace-account-profile { gap: 7px; padding: 0; }
    .workspace-account-avatar { width: 28px; height: 31px; flex-basis: 28px; border-radius: 9px; }
    .workspace-account-copy strong { font-size: 11px; }
    .workspace-account-arrow { display: none; }
    .workspace-wallet { grid-column: 2; grid-row: 1 / span 2; padding: 9px; }
    #workspacePointsValue { font-size: 18px; }
    .workspace-wallet.has-long-balance #workspacePointsValue { font-size: 13px; }
    .workspace-account .workspace-recharge { top: 8px; right: 8px; }
    .workspace-account-ledger { width: max-content; grid-column: 1; grid-row: 2; padding: 0; }
    .workspace-account-ledger svg:last-child { display: none; }
    .workspace-tools { grid-column: 1 / -1; padding-top: 8px; }
    .workspace-account .workspace-tool { flex-direction: row; gap: 6px; min-height: 34px; padding: 7px 4px; }
    .workspace-tool svg { width: 15px; height: 15px; }
    .workspace-main { padding: 0 18px 32px; }
    .workspace-toolbar { min-height: 54px; }
    .home-history-panel { padding-top: 10px; }
    .home-section-head { gap: 12px; margin-bottom: 20px; }
    .home-section-copy h1 { font-size: 23px; }
    .home-canvas-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .home-canvas-card { min-height: 162px; padding: 7px; border-radius: 10px; }
    .home-canvas-create { min-height: 162px; }
    .home-canvas-meta { font-size: 9px; }
    .home-canvas-title-row strong { font-size: 11px; }
    .home-canvas-actions button { width: 22px; }
    .home-create-card { padding: 20px; }
}

@media (max-width: 350px) {
    .workspace-conversation { margin-right: -12px; margin-left: -12px; }
    .workspace-main { padding-right: 12px; padding-left: 12px; }
    .home-canvas-grid { grid-template-columns: minmax(0, 1fr); }
    .home-canvas-card { max-width: 230px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (forced-colors: active) {
    .workspace-sidebar { background: Canvas; color: CanvasText; border-color: CanvasText; }
    .workspace-brand,
    .workspace-brand-copy small,
    .workspace-account,
    .workspace-account-copy strong,
    .workspace-account-copy > span,
    .workspace-wallet-caption,
    #workspacePointsValue { color: CanvasText; }
    .workspace-nav-item.is-active { color: HighlightText; background: Highlight; forced-color-adjust: none; }
    .workspace-wallet,
    .workspace-account button { background: Canvas; color: CanvasText; border-color: CanvasText; }
    .home-canvas-card,
    .home-create-card { border: 1px solid CanvasText; }
    .home-primary-button { background: ButtonFace; color: ButtonText; border: 1px solid ButtonText; }
    .workspace-main { background-image: none; }
}
