.workspace { width: 100%; height: 100%; display: grid; grid-template-rows: 62px minmax(0, 1fr); background: var(--canvas); }
.device-phone .workspace { grid-template-rows: 84px minmax(0, 1fr); }
.app-header { z-index: 20; padding: 13px 14px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; border-bottom: 1px solid var(--border); background: rgb(255 255 255 / 96%); }
.device-phone .app-header { padding-top: 31px; }
.header-brand { display: flex; align-items: center; justify-self: start; }
.header-brand img { width: auto; height: 22px; display: block; }
.page-stack, .page { min-width: 0; min-height: 0; height: 100%; }
.page { display: none; overflow: hidden; }
.page.is-active { display: block; }
.ask-page.is-active { display: grid; }
.ask-scroll, .page-content, .message-scroll { overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.ask-scroll { padding: 24px 16px 40px; }
.prompt-workspace, .content-block { width: min(820px, 100%); margin: 0 auto; }
.prompt-heading { margin: 0 0 18px; }
.prompt-heading h1 { margin: 0 0 8px; color: var(--ink); font-size: clamp(20px, 3vw, 28px); line-height: 1.35; letter-spacing: -.02em; }
.prompt-heading h1:last-child { margin-bottom: 0; }
.content-block { margin-top: 28px; }
.compact-section { padding-bottom: 16px; }
.section-heading { margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading h2 { margin: 0; font-size: 15px; }
.section-heading span { color: var(--muted); font-size: 11px; }

.list-page.is-active, .generic-page.is-active { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.page-header, .chat-header { min-height: 70px; padding: 14px 18px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.page-header .mobile-menu { display: none; }
.page-header > div, .chat-header > div { min-width: 0; flex: 1; }
.page-header h1, .chat-header h1 { overflow: hidden; margin: 0; font-size: 20px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.chat-header p { overflow: hidden; margin: 4px 0 0; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.page-content { padding: 16px; }
.master-layout { display: grid; }
.list-column { min-width: 0; }
.empty-panel { display: none; }
.list-group-title { margin: 18px 3px 7px; color: var(--muted); font-size: 11px; font-weight: 700; }

.chat-page.is-active { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.chat-layout { min-width: 0; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.message-scroll { padding: 20px 14px 30px; }
.user-message, .assistant-answer { width: min(760px, 100%); margin-right: auto; margin-left: auto; }
.user-message { width: fit-content; max-width: min(620px, 88%); margin-right: max(0px, calc((100% - 760px) / 2)); padding: 10px 13px; border-radius: 13px 13px 3px 13px; color: #fff; background: var(--primary); font-size: 13px; line-height: 1.55; }
.assistant-answer { margin-top: 18px; }
.inspector { display: none; min-width: 0; overflow: auto; border-left: 1px solid var(--border); background: var(--surface); }
.inspector.is-open { position: absolute; z-index: 40; inset: 62px 0 0; display: block; padding: 18px; }
.inspector > header { display: flex; align-items: center; justify-content: space-between; }
.inspector h2 { margin: 0; font-size: 18px; }
.inspector h3 { margin: 24px 0 8px; font-size: 13px; }
.inspector ol { margin: 18px 0 0; padding: 0; display: grid; gap: 16px; list-style: none; }
.inspector li { display: flex; gap: 10px; }
.inspector li b { width: 24px; height: 24px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: var(--primary); background: var(--primary-soft); font-size: 11px; }
.inspector li strong, .inspector li small { display: block; }
.inspector li strong { font-size: 12px; }
.inspector li small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.source-item { width: 100%; padding: 11px 0; display: block; text-align: left; border-bottom: 1px solid var(--border); }
.source-item strong, .source-item small { display: block; }
.source-item strong { font-size: 12px; }
.source-item small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.scrim { position: absolute; z-index: 60; inset: 0; background: rgb(15 23 42 / 38%); }
.feature-drawer { position: absolute; z-index: 70; inset: 0 auto 0 0; width: min(330px, 88%); display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; background: var(--surface); box-shadow: var(--shadow); animation: drawer-in .2s ease-out; }
@keyframes drawer-in { from { transform: translateX(-20px); opacity: .7; } }
.feature-drawer > header { padding: 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.feature-drawer .drawer-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.feature-drawer .drawer-brand img { width: auto; height: 22px; display: block; }
.feature-drawer .drawer-brand small { display: block; color: var(--muted); font-size: 10px; }
.drawer-new-chat { min-height: 42px; margin: 12px; padding: 0 11px; display: flex; align-items: center; gap: 8px; border-radius: 8px; color: var(--primary); background: var(--primary-soft); font-size: 12px; font-weight: 700; }
.drawer-new-chat .icon { width: 17px; }
.feature-drawer nav { padding: 0 10px 14px; overflow: auto; }
.drawer-primary { padding-bottom: 10px; }
.drawer-item { width: 100%; min-height: 44px; padding: 7px 8px; display: flex; align-items: center; gap: 10px; border-radius: 8px; text-align: left; }
.drawer-item:hover, .drawer-item.is-active { background: var(--primary-soft); }
.drawer-menu-icon { width: 28px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; color: var(--text); }
.drawer-menu-icon .icon { width: 19px; height: 19px; stroke-width: 1.5; }
.drawer-item > span:not(.drawer-menu-icon) { min-width: 0; flex: 1; }
.drawer-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-item strong { font-size: 12px; }
.drawer-item > em { padding: 2px 5px; border-radius: 4px; color: var(--muted); background: var(--surface-subtle); font-size: 8px; font-style: normal; }
.drawer-notice { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--primary); }
.drawer-parent { width: 100%; min-height: 44px; padding: 7px 8px; display: flex; align-items: center; gap: 10px; border-radius: 8px; text-align: left; }
.drawer-parent:hover { background: var(--surface-subtle); }
.drawer-parent strong { flex: 1; font-size: 12px; }
.drawer-parent > span:last-child { color: var(--muted); font-size: 16px; }
.drawer-submenu { margin: 0 0 4px 22px; padding-left: 15px; display: grid; border-left: 1px solid var(--border); }
.drawer-subitem { min-height: 34px; padding: 5px 8px; display: flex; align-items: center; gap: 7px; border-radius: 7px; text-align: left; font-size: 11px; }
.drawer-subitem:hover { background: var(--surface-subtle); }
.drawer-subitem span { flex: 1; }
.drawer-subitem em { padding: 2px 5px; border-radius: 4px; color: var(--muted); background: var(--canvas); font-size: 8px; font-style: normal; }
.drawer-workspaces { padding: 10px 0; border-top: 1px solid var(--border); }
.drawer-workspaces > header { min-height: 30px; padding: 0 8px; display: flex; align-items: center; justify-content: space-between; }
.drawer-workspaces > header strong { font-size: 11px; }
.drawer-workspaces > header small { color: var(--muted); font-size: 8px; }
.drawer-workspaces > button { width: 100%; min-height: 48px; padding: 7px 8px; display: flex; align-items: center; gap: 9px; border-radius: 8px; text-align: left; }
.drawer-workspaces > button:hover { background: var(--primary-soft); }
.drawer-workspaces .drawer-menu-icon { color: var(--primary); }
.drawer-workspaces > button > span:not(.drawer-menu-icon) { min-width: 0; flex: 1; }
.drawer-workspaces strong, .drawer-workspaces small { display: block; }
.drawer-workspaces strong { font-size: 11px; }
.drawer-workspaces small { margin-top: 2px; color: var(--muted); font-size: 8px; }
.drawer-workspaces > button > b { color: var(--muted); font-size: 14px; }
.drawer-history { padding-top: 11px; border-top: 1px solid var(--border); }
.drawer-history > header { min-height: 34px; padding: 0 8px; display: flex; align-items: center; justify-content: space-between; }
.drawer-history > header strong { font-size: 11px; }
.drawer-history > header span { display: flex; align-items: center; gap: 7px; }
.drawer-history > header button { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); font-size: 10px; }
.drawer-history > header button:hover { background: var(--surface-subtle); }
.drawer-history > header .icon { width: 15px; }
.drawer-history-search { height: 36px; margin: 5px 6px 9px; }
.drawer-history-group > small { display: block; margin: 10px 8px 4px; color: var(--muted); font-size: 9px; }
.drawer-history-group > button { width: 100%; min-height: 48px; padding: 7px 8px; display: flex; align-items: center; gap: 8px; border-radius: 8px; text-align: left; }
.drawer-history-group > button:hover { background: var(--surface-subtle); }
.drawer-history-group button > span { min-width: 0; flex: 1; }
.drawer-history-group strong, .drawer-history-group em { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-history-group strong { font-size: 10px; }
.drawer-history-group em { margin-top: 3px; color: var(--muted); font-size: 8px; font-style: normal; }
.drawer-history-group time { color: var(--muted); font-size: 8px; }
.history-status { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--border-strong); }
.history-status.is-complete, .history-status.is-unread { background: var(--success); }
.history-status.is-running { width: 11px; height: 11px; border: 2px solid #bfdbfe; border-top-color: var(--primary); background: transparent; animation: spin .8s linear infinite; }
.history-status.is-hil { background: var(--warning); }
.drawer-history-empty { padding: 16px 8px; color: var(--muted); text-align: center; font-size: 10px; }
.feature-drawer > footer { padding: 10px 12px max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.feature-drawer > footer button { width: 100%; display: flex; align-items: center; gap: 9px; text-align: left; }
.feature-drawer > footer button > span:nth-child(2) { flex: 1; }
.feature-drawer > footer strong, .feature-drawer > footer small { display: block; }
.feature-drawer > footer strong { font-size: 12px; }
.feature-drawer > footer small { color: var(--muted); font-size: 9px; }

.sheet, .dialog { position: absolute; z-index: 75; background: var(--surface); box-shadow: var(--shadow); }
.sheet { right: 0; bottom: 0; left: 0; max-height: 82%; padding: 18px 16px max(18px, env(safe-area-inset-bottom)); overflow: auto; border-radius: 18px 18px 0 0; animation: sheet-in .2s ease-out; }
@keyframes sheet-in { from { transform: translateY(18px); opacity: .6; } }
.sheet > header, .dialog > header { margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet > header.sheet-close-only { margin-bottom: 4px; justify-content: flex-end; }
.sheet h2, .dialog h2 { margin: 0; font-size: 20px; }
.sheet-note { margin: 0 0 12px; padding: 10px; border-radius: 8px; color: var(--text); background: var(--surface-subtle); font-size: 11px; line-height: 1.5; }
.sheet > .primary-button { width: 100%; margin-top: 14px; }
.dialog { top: 50%; left: 50%; width: min(340px, calc(100% - 32px)); padding: 20px; transform: translate(-50%, -50%); border-radius: var(--radius); }
.dialog > p { color: var(--text); font-size: 12px; line-height: 1.6; }
.dialog > div:last-child { margin-top: 18px; display: flex; justify-content: flex-end; gap: 8px; }
.chart-dialog { width: min(700px, calc(100% - 32px)); }
.chart-dialog > p { margin-bottom: 0; }
