@import url("./buttons.css");

/* Shared application shell: the sidebar, header and layout used by every application page
   (chat, Converter para Excel and future apps). Load after foundations.css and before the
   application's own stylesheet. Spec: docs/design/DESIGN_SYSTEM.md#application-shell. */
/* Aliases used by these rules; the sidebar redefines them for its ink surface. */
:root { --secondary: var(--ink-muted); --muted: var(--ink-muted); --border: var(--line); --edge: var(--line-strong); --focus: var(--ink); }
.app { font: var(--text-16)/1.65 var(--font-sans); color: var(--ink); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
button, textarea, input { font: inherit; }
button { border: 1px solid transparent; border-radius: var(--radius-md); padding: 8px 15px; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:where(button, a, summary, [tabindex]):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: var(--ink); text-underline-offset: 3px; text-decoration: underline; }
.icon { display: block; width: 18px; height: 18px; flex-shrink: 0; }
[data-icon] { display: inline-flex; align-items: center; flex-shrink: 0; }
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.sidebar { display: flex; flex-direction: column; gap: 4px; min-height: 0; padding: 16px; border-right: 0; background: var(--ink); color: var(--paper); font-size: var(--text-13); --secondary: var(--gray-400); --muted: var(--gray-400); --border: var(--gray-800); --focus: var(--paper); overflow-y: auto; }
.brand-wordmark { display: block; width: auto; height: 24px; }
.brand-symbol { display: none; width: auto; height: 28px; }
.brand-row { display: flex; align-items: center; gap: 10px; padding: 0 4px; margin-bottom: 12px; }
.brand { display: flex; flex-shrink: 0; gap: 10px; align-items: center; color: inherit; text-decoration: none; font-weight: var(--weight-semibold); font-size: var(--text-17); min-width: 0; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; min-height: 30px; padding: 5px; border: 0; background: transparent; color: var(--muted); border-radius: var(--radius-md); }
#sidebar-toggle { margin-left: auto; }
.icon-button:hover { background: var(--surface-sunken); color: var(--ink); }
.new-chat { display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--edge); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); margin: 12px 0 6px; padding: 9px 14px; min-height: 46px; font-size: var(--text-14); box-shadow: 0 1px 2px rgb(20 20 19 / .04); }
.new-chat:hover:not(:disabled) { border-color: var(--ink); background: var(--paper); }
.new-chat:active:not(:disabled) { box-shadow: inset 0 2px 3px rgb(20 20 19 / .1); }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; overflow-y: auto; }
.brand-row, .sidebar > .new-chat, .account { flex-shrink: 0; }
.nav-caption { font-size: var(--text-12); color: var(--muted); padding: 14px 12px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 12px; text-align: left; background: transparent; color: var(--secondary); border-radius: var(--radius-md); font-size: var(--text-14); }
.nav-item .sidebar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover:not(:disabled) { background: var(--surface-sunken); }
.nav-item.selected { background: var(--surface); border: .5px solid var(--line); color: var(--ink); }
#current-chat .sidebar-label { color: var(--ink); }
.account { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 14px 4px 0; border-top: .5px solid var(--border); font-size: var(--text-13); }
.account-avatar { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; background: var(--ink); color: var(--on-ink); font-size: var(--text-11); font-weight: var(--weight-semibold); }
.account-info { display: flex; flex-direction: column; min-width: 0; }
.organization { color: var(--muted); font-size: var(--text-12); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-settings { margin-left: auto; color: var(--secondary); }
.account-info { overflow-wrap: anywhere; }
#account-error { color: var(--danger); font-size: var(--text-12); }
#account-control { flex-shrink: 0; min-height: 44px; padding: 8px; background: transparent; }
.account-icon { display: none; }
.main-panel { grid-column: 2; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface); }
.column { width: min(760px, calc(100% - 48px - var(--thread-gutter, 0px))); margin-inline: auto; }
.topbar { height: 52px; flex-shrink: 0; border-bottom: .5px solid var(--border); color: var(--ink); font-size: var(--text-16); }
.header-content { width: calc(100% - 48px); height: 100%; display: flex; align-items: center; justify-content: flex-start; gap: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
[hidden] { display: none !important; }
.app.sidebar-collapsed { grid-template-columns: 56px minmax(0, 1fr); }
.sidebar-collapsed .sidebar { padding: 16px 8px; align-items: center; }
.sidebar-collapsed .sidebar-label { display: none; }
.sidebar-collapsed .brand-row { flex-direction: column; padding: 0; gap: 8px; }
.sidebar-collapsed #sidebar-toggle { margin: 0; }
.sidebar-collapsed .new-chat, .sidebar-collapsed .nav-item { padding: 8px; width: 40px; justify-content: center; }
.sidebar-collapsed .account { padding-inline: 0; }
.sidebar-collapsed #account-control { width: 40px; display: flex; justify-content: center; }
.sidebar-collapsed .account-icon { display: inline-flex; }
.sidebar-collapsed .brand-wordmark { display: none; }
.sidebar-collapsed .brand-symbol { display: block; }
#mobile-menu, .sidebar-backdrop { display: none; }
@media (max-width: 960px) {
  .app, .app.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); }
  .main-panel { grid-column: 1; }
  .sidebar { display: none; }
  .sidebar-expanded .sidebar { display: flex; position: fixed; inset: 0 auto 0 0; width: min(248px, calc(100% - 48px)); z-index: 5; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 4; border: 0; border-radius: 0; background: rgb(20 20 19 / .3); }
  #mobile-menu { display: inline-flex; min-width: 40px; min-height: 40px; }
  .topbar { height: 56px; }
  .header-content { width: calc(100% - 24px); gap: 8px; }
}
:is(#reset-dialog, #delete-dialog) { width: min(460px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 24px; border: 1px solid var(--edge); border-radius: var(--radius-xl); color: var(--ink); }
:is(#reset-dialog, #delete-dialog)::backdrop { background: rgb(20 20 19 / .3); }
:is(#reset-dialog, #delete-dialog) h2 { font-size: var(--text-20); line-height: 1.4; margin: 0 0 12px; }
:is(#reset-dialog, #delete-dialog) p { margin: 0 0 20px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#saved-history { min-width: 0; }
#history-list { display: flex; flex-direction: column; gap: 4px; }
.history-row { display: flex; align-items: center; min-width: 0; border-radius: var(--radius-md); }
.history-row.selected { background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.history-open { flex: 1; min-width: 0; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; text-align: left; background: transparent; padding: 9px 8px; font-size: var(--text-13); color: var(--ink); }
.history-delete { flex: 0 0 auto; padding: 8px; background: transparent; color: var(--muted); }
.history-row:hover { background: var(--surface-sunken); }
#history-status { font-size: var(--text-12); color: var(--secondary); padding: 0 8px; }
#history-more, #history-retry { background: transparent; font-size: var(--text-12); color: var(--focus); }
#delete-title { overflow-wrap: anywhere; font-weight: var(--weight-semibold); }
/* Ink navigation follows the supplied Chat-Empty/Chat-Active boards. */
.sidebar .new-chat { justify-content: center; min-height: 36px; margin: 0 0 12px; padding: 6px 10px; border-color: var(--gray-400); background: transparent; color: var(--paper); box-shadow: none; font-size: var(--text-13); }
.sidebar .new-chat .icon { width: 14px; height: 14px; }
.sidebar .new-chat:hover:not(:disabled), .sidebar .icon-button:hover, .sidebar .nav-item:hover:not(:disabled), .sidebar .history-row:hover { background: var(--gray-800); color: var(--paper); }
.sidebar .nav-item.selected, .sidebar .history-row.selected { background: var(--gray-800); border-color: transparent; box-shadow: none; }
.sidebar .nav-item, .sidebar #current-chat .sidebar-label, .sidebar .history-open, .sidebar #account-control { color: var(--paper); }
.sidebar .nav-caption { margin: 0; font-size: var(--text-12); font-weight: var(--weight-semibold); text-transform: uppercase; padding: var(--space-2) var(--space-3) var(--space-1); }
.sidebar-nav:not(:has(#current-chat:not([hidden]), #saved-history:not([hidden]) .history-row)) > .nav-caption { display: none; }
.sidebar .nav-item { font-size: var(--text-13); min-height: 38px; border-radius: var(--radius-md); }
.sidebar .account { padding-top: 16px; }
.sidebar #account-control { font-size: var(--text-12); }
.sidebar #history-more, .sidebar #history-retry { color: var(--paper); }
.guest-reminder { margin-top: auto; margin-bottom: 14px; padding: 12px; border-radius: var(--radius-lg); background: var(--gray-800); font-size: var(--text-12); line-height: 17px; color: var(--paper); }
.guest-reminder strong { display: block; font-size: var(--text-13); }
.guest-reminder p { color: var(--on-ink-muted); margin: 4px 0 10px; }
.guest-reminder button { width: 100%; min-height: 36px; font-size: var(--text-13); background: var(--paper); color: var(--ink); border-color: var(--paper); }
.guest-reminder button:hover:not(:disabled) { background: var(--surface); }
.guest-reminder:not([hidden]) + .account { margin-top: 0; }
.guest-reminder { flex-shrink: 0; }
.sidebar-collapsed .guest-reminder + .account { margin-top: auto; }
.account-info { flex: 1; }
#account-open { flex-shrink: 0; padding: 8px 4px; min-height: 44px; font-size: var(--text-12); background: transparent; color: var(--paper); }
.sidebar-collapsed .account { flex-direction: column; gap: 2px; }
.sidebar-collapsed #account-open { width: 40px; }

/* Application links (src/shared/applications.ts) sit between Nova conversa and Recentes. */
.app-links { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; margin: 0 0 8px; }
a.new-chat, .app-link { text-decoration: none; }
@media (max-width: 600px) {
  .column { width: calc(100% - 24px - var(--thread-gutter, 0px)); }
  .sidebar-collapsed .account { flex-direction: row; }
}
/* Generic main area for application pages: header title and one scrolling content area. */
.topbar-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

/* Activity panel and run status shared by task applications (Revisar CBS, the converters).
   Opt in with class="with-activity-panel" on <body>; script: src/shared/activity-panel.ts. */
.with-activity-panel .run-status { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-12); font-variant-numeric: tabular-nums; }
.with-activity-panel .run-dot { display: none; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.with-activity-panel .run-status.is-running .run-dot { display: inline-block; animation: activity-pulse 1.6s infinite; }
.with-activity-panel .elapsed { color: var(--ink-muted); }
.with-activity-panel .elapsed:not(:empty)::before { content: "· "; }
@keyframes activity-pulse { 50% { opacity: .3; } }
/* Painel de Atividades steps, in chat and the task applications (src/shared/activity-steps.ts):
   one row per step with its status in words, the running step pulsing, a finished step's duration. */
:is(.conversation-panel, .activity-details) .step { display: grid; gap: 2px; margin-top: var(--space-2); padding-left: var(--space-3); border-left: 1px solid var(--line-strong); color: var(--ink); }
:is(.conversation-panel, .activity-details) .step-title { display: flex; align-items: baseline; gap: var(--space-2); margin: 0; font-size: var(--text-12); font-weight: var(--weight-medium); }
:is(.conversation-panel, .activity-details) .step-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
:is(.conversation-panel, .activity-details) .step-duration { flex-shrink: 0; color: var(--ink-muted); font-weight: var(--weight-regular); font-variant-numeric: tabular-nums; white-space: nowrap; }
:is(.conversation-panel, .activity-details) .step-state { margin: 0; color: var(--ink-muted); font-size: var(--text-11); line-height: 1.5; }
:is(.conversation-panel, .activity-details) .step[data-status="running"] .step-state::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--ink); vertical-align: middle; animation: activity-pulse 1.6s infinite; }
:is(.conversation-panel, .activity-details) .step[data-status="unsuccessful"] .step-state { color: var(--warn); }
:is(.conversation-panel, .activity-details) .step[data-status="failed"] { border-left-color: var(--danger); }
:is(.conversation-panel, .activity-details) .step[data-status="failed"] :is(.step-state, .step-title) { color: var(--danger); }
:is(.conversation-panel, .activity-details) :is(.step-context, .step-progress, .step-detail) { margin: 0; color: var(--ink-muted); font-size: var(--text-11); line-height: 1.5; overflow-wrap: anywhere; }
:is(.conversation-panel, .activity-details) .step-context { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
:is(.conversation-panel, .activity-details) .step-progress { color: var(--ink); font-variant-numeric: tabular-nums; }
:is(.conversation-panel, .activity-details) .step-sources { margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--line); }
:is(.conversation-panel, .activity-details) .step-sources-title { margin: 0; color: var(--ink-muted); font: var(--weight-semibold) var(--text-11)/1.5 var(--font-sans); letter-spacing: .06em; text-transform: uppercase; }
:is(.conversation-panel, .activity-details) .step-sources ul { display: grid; gap: var(--space-2); margin: var(--space-2) 0 0; padding: 0; list-style: none; }
:is(.conversation-panel, .activity-details) .step-sources a { color: var(--ink); font-size: var(--text-12); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .with-activity-panel .run-status.is-running .run-dot { animation: none; } }
.with-activity-panel .app.panel-open { grid-template-columns: 248px minmax(0, 1fr) 320px; }
.with-activity-panel .app.sidebar-collapsed.panel-open { grid-template-columns: 56px minmax(0, 1fr) 320px; }
.panel-toggle { margin-left: auto; flex-shrink: 0; }
.with-activity-panel .conversation-panel { grid-column: 3; display: flex; flex-direction: column; min-width: 0; min-height: 0; border-left: 1px solid var(--line); background: var(--paper); color: var(--ink); font-size: var(--text-12); }
.with-activity-panel .conversation-panel-header { display: flex; align-items: center; flex-shrink: 0; gap: var(--space-2); min-height: 52px; padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4); border-bottom: 1px solid var(--line); }
.with-activity-panel .conversation-panel-header h2 { flex: 1; margin: 0; font: var(--weight-medium) var(--text-13)/1.5 var(--font-sans); }
.with-activity-panel .conversation-panel-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.with-activity-panel .panel-section { padding: var(--space-5) var(--space-4); border-bottom: 1px solid var(--line); }
.with-activity-panel .panel-section h3 { margin: 0 0 var(--space-3); color: var(--ink-muted); font: var(--weight-semibold) var(--text-11)/1.5 var(--font-sans); letter-spacing: .06em; text-transform: uppercase; }
.with-activity-panel .panel-section p { margin: 0; overflow-wrap: anywhere; color: var(--ink-muted); }
.with-activity-panel #panel-file { font-size: var(--text-12); font-variant-numeric: tabular-nums; }
.with-activity-panel .activity { margin: 0 0 var(--space-5); }
.with-activity-panel .activity > summary { font-weight: var(--weight-medium); }
.with-activity-panel .activity summary { cursor: pointer; overflow-wrap: anywhere; }
@media (max-width: 960px) {
 .with-activity-panel .app.panel-open, .with-activity-panel .app.sidebar-collapsed.panel-open { grid-template-columns: minmax(0, 1fr); }
 .with-activity-panel .conversation-panel { position: fixed; inset: 0; z-index: 6; border-left: 0; }
 .with-activity-panel .conversation-panel-header { min-height: 56px; }
 .with-activity-panel .conversation-panel-scroll { padding-bottom: env(safe-area-inset-bottom); }
}
@media (max-width: 600px) {
 .with-activity-panel :is(.panel-toggle, .conversation-panel .icon-button) { min-height: 44px; min-width: 44px; }
 .with-activity-panel .activity summary { min-height: 44px; }
}

/* Task applications (Revisar CBS, Converter notas fiscais, Converter SPED): shared text,
   buttons, status pills, view tabs and tables. Opt in with class="task-app" on the work
   area and its dialogs. Spec: docs/design/DESIGN_SYSTEM.md#components. */
.task-app p { margin: 0; }
.task-app h1 { margin: 0; font-size: var(--text-32); line-height: 1.2; letter-spacing: -.02em; }
.task-app h2 { margin: 0; font-size: var(--text-20); line-height: 1.4; }
.task-app h3 { margin: 0; font-size: var(--text-17); line-height: 1.4; }
.task-app .muted { color: var(--ink-muted); }
.task-app .eyebrow { margin: 0; color: var(--ink-muted); font: var(--weight-semibold) var(--text-11)/1.45 var(--font-sans); letter-spacing: .06em; text-transform: uppercase; }
.task-app .actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.task-app .visually-hidden, .task-app .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
/* Text actions explicitly use .button; variants are shared through buttons.css. */
.task-app :is(a, button, input, textarea, summary, [tabindex="0"]):focus-visible, .task-app .button:has(input:focus-visible) { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
/* Status pills: a word always accompanies the colour. */
.task-app .status-pill { display: inline-flex; align-items: center; padding: 0 var(--space-2); border: 1px solid transparent; border-radius: var(--radius-pill); font: var(--weight-semibold) var(--text-11)/20px var(--font-sans); white-space: nowrap; }
.task-app .status-pill.ok { background: var(--ok-soft); color: var(--ok); }
.task-app .status-pill.warn { background: var(--warn-soft); color: var(--warn); }
.task-app .status-pill.outline { border-color: var(--line-strong); color: var(--ink); }
/* View tabs: a paper track with the selected view in ink. */
.task-app .view-tabs { display: flex; gap: var(--space-1); padding: var(--space-1); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--paper); }
.task-app .view-tabs button { border-color: transparent; background: transparent; }
.task-app .view-tabs button[aria-selected="true"], .task-app .view-tabs button[aria-selected="true"]:hover { background: var(--ink); color: var(--on-ink); }

/* Task page structure (D45), one implementation for Revisar CBS and the converters. The work
   area (class="task-app task-page") fits the window: a file bar after upload, page messages,
   a body holding either the centred entry or the work view (a heading block over an
   inset framed table) and a footer with the notice and the main actions. */
.task-page { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; overflow-y: auto; color: var(--ink); font: var(--weight-regular) var(--text-14)/1.6 var(--font-sans); overflow-wrap: anywhere; }
.main-panel:has(> .task-page) { background: var(--surface); }
.task-page [data-icon] .icon { width: 18px; height: 18px; }
.task-page .filename { font-size: var(--text-13); font-variant-numeric: tabular-nums; }
.task-page .file-bar { flex-shrink: 0; display: flex; align-items: center; gap: var(--space-4); padding: var(--space-2) var(--space-5); border-bottom: 1px solid var(--line); background: var(--surface); }
.task-page .file-identity { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.task-page .file-identity > div { min-width: 0; }
.task-page .file-identity :is(.filename, .file-context) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-page .file-context, .task-page .file-state { font-size: var(--text-12); }
.task-page .file-actions { display: flex; align-items: center; gap: var(--space-2) var(--space-3); margin-left: auto; flex-shrink: 0; }
.task-page .task-messages { flex-shrink: 0; }
.task-page .task-messages p:not([hidden]):not(:empty) { padding: var(--space-3) var(--space-5); font-size: var(--text-13); }
.task-page .page-error { max-height: calc(var(--space-8) * 2); overflow: auto; background: var(--danger-soft); color: var(--danger); }
.task-page .page-status { color: var(--ink-muted); }
.task-page .task-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* Entry: the outcome, the upload card, what comes back and how long it takes. */
.task-page .entry { flex: 1; min-height: 0; overflow-y: auto; display: flex; padding: var(--space-6) var(--space-5); }
.task-page .entry-content { width: min(100%, 600px); margin: auto; display: grid; gap: var(--space-5); }
.task-page .intro { display: grid; gap: var(--space-2); }
.task-page .lead { max-width: 640px; color: var(--ink-muted); font-size: var(--text-16); }
/* The whole card chooses files; hovering or dragging over it draws the ink drop outline. */
.task-page .upload { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); padding: var(--space-5); border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); text-align: center; }
.task-page .upload:has(input:not(:disabled)) { cursor: pointer; }
.task-page .upload:hover:has(input:not(:disabled)), .task-page .upload.is-dragging { padding: calc(var(--space-5) - 1px); border: 2px dashed var(--ink); background: var(--paper); }
.task-page .upload-icon .icon { width: 24px; height: 24px; }
.task-page .upload .when-dragging { display: none; }
.task-page .upload.is-dragging .when-idle { display: none; }
.task-page .upload.is-dragging span.when-dragging { display: inline; }
.task-page .upload.is-dragging .upload-icon.when-dragging { display: block; }
.task-page .upload.is-dragging .file-picker { visibility: hidden; }
.task-page .upload-format { font-size: var(--text-13); }
.task-page .upload-note { font-size: var(--text-12); }
.task-page .entry-error { width: 100%; padding: var(--space-3); border-radius: var(--radius-md); background: var(--danger-soft); color: var(--danger); font-size: var(--text-13); text-align: left; }
.task-page .entry-error .filename { font-size: var(--text-12); }
.task-page .entry-error .filename:empty { display: none; }
.task-page progress { width: 100%; height: 4px; appearance: none; border: 0; border-radius: var(--radius-sm); background: var(--line); overflow: hidden; }
.task-page progress::-webkit-progress-bar { background: var(--line); }
.task-page progress::-webkit-progress-value { background: var(--ink); }
.task-page progress::-moz-progress-bar { background: var(--ink); }
.task-page .upload-status { color: var(--ink-muted); font-size: var(--text-12); }
.task-page .upload-status:empty { display: none; }
.task-page .deliverable { display: grid; gap: var(--space-2); }
.task-page .deliverable > .muted { font-size: var(--text-12); }
.task-page .deliverable-compact { display: none; font-size: var(--text-13); }
.task-page .deliverable-columns { display: grid; grid-template-columns: 1fr 1.15fr 1.15fr; margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.task-page .deliverable-columns li { padding: var(--space-2) var(--space-3); background: var(--surface-sunken); color: var(--ink-muted); font-size: var(--text-12); line-height: 1.4; }
.task-page .deliverable-columns li + li { border-left: 1px solid var(--line-strong); }
.task-page .deliverable-columns strong { display: block; color: var(--ink); font-weight: var(--weight-medium); }

/* Work view: a heading block (state, title, counts, view tabs, lead, current operation and the
   optional-input callout) over a framed table that shrinks to its rows and scrolls within the available area. */
.task-page .task-heading { flex-shrink: 0; display: grid; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--line); }
.task-page .heading-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-3); }
.task-page .heading-title { display: grid; gap: var(--space-1); min-width: 0; }
.task-page .result-counts { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.task-page .result-counts:not(:has(> :not([hidden]))) { display: none; }
.task-page .result-line { font-size: var(--text-13); }
.task-page .result-line:empty { display: none; }
.task-page .heading-row .view-tabs { margin-left: auto; }
.task-page .option-callout { display: flex; align-items: center; gap: var(--space-4); justify-self: start; max-width: 560px; padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--paper); }
.task-page .option-callout > div { min-width: 0; }
.task-page .callout-title { font-size: var(--text-13); font-weight: var(--weight-semibold); }
.task-page .callout-preview { font-size: var(--text-12); }
.task-page .option-callout button { flex-shrink: 0; }
.task-page .task-footer { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--line); }
.task-page .footer-notices { min-width: 0; font-size: var(--text-12); }
.task-page .task-footer .actions { justify-content: flex-end; flex-shrink: 0; }

/* Dialogs of task pages stay inside the window; their bodies scroll. */
.task-dialog { width: min(720px, calc(100% - var(--space-6))); max-height: calc(100dvh - var(--space-6)); overflow-y: auto; padding: var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow-card); color: var(--ink); background: var(--surface); font: var(--text-14)/1.6 var(--font-sans); overflow-wrap: anywhere; }
.task-dialog::backdrop { background: rgb(20 20 19 / .3); }
.task-dialog .dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); }
.task-dialog label { display: block; margin-bottom: var(--space-2); font-size: var(--text-13); font-weight: var(--weight-semibold); }
.task-dialog textarea { width: 100%; padding: var(--space-2) var(--space-3); resize: vertical; border: 1px solid var(--line-strong); border-radius: var(--radius-md); font: inherit; color: var(--ink); background: var(--surface); }
.task-dialog textarea::placeholder { color: var(--ink-muted); opacity: 1; }
.task-dialog .dialog-help { margin: var(--space-3) 0 var(--space-5); font-size: var(--text-12); }
.task-dialog .actions { justify-content: flex-end; }

@media (max-width: 720px) {
  .task-page .file-bar { flex-wrap: wrap; padding-inline: var(--space-3); }
  .task-page .file-identity [data-icon] { display: none; }
  .task-page .file-actions { width: 100%; justify-content: flex-end; margin-left: 0; }
  .task-page .file-actions .run-status { margin-right: auto; white-space: nowrap; }
  .task-page .run-status .quiet { display: none; }
  .task-page .drop-word { display: none; }
  .task-page .deliverable-columns { grid-template-columns: minmax(0, 1fr); }
  .task-page .deliverable-columns li + li { border-left: 0; border-top: 1px solid var(--line); }
  .task-page .task-heading { padding: var(--space-3); }
  .task-page .heading-row .view-tabs { width: 100%; margin-left: 0; }
  .task-page .heading-row .view-tabs button { flex: 1; }
  .task-page .task-footer { flex-wrap: wrap; padding-inline: var(--space-3); }
  .task-page .task-footer .actions { margin-left: auto; }
}
@media (max-width: 600px) {
  .task-page .entry { padding: var(--space-5) var(--space-3); }
  .task-page .entry-content { gap: var(--space-4); }
  .task-page h1 { font-size: var(--text-28); }
  .task-page .file-picker { width: 100%; }
  .task-page .option-callout { flex-wrap: wrap; }
  .task-page .deliverable-columns { display: none; }
  .task-page .deliverable-compact { display: block; }
  .task-dialog textarea { font-size: var(--text-16); }
  .task-dialog .dialog-heading { flex-wrap: wrap; }
}
@media (max-height: 600px) {
  .task-page .task-heading { gap: var(--space-2); padding-block: var(--space-2); }
  .task-page .entry { padding-block: var(--space-4); }
}

/* Ruled data tables (D41), shared with chat answers: a --line rule around every cell, a sunken
   head row at the cells' size. Answer tables fit their content; .dense tool tables fill the area. */
:is(.data-table, .answer .content table) :is(th, td) { padding: var(--space-2) var(--space-3); border: 1px solid var(--line); vertical-align: top; }
:is(.data-table, .answer .content table) th { text-align: left; }
:is(.data-table, .answer .content table) thead th { background: var(--surface-sunken); }
.data-table { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.data-table.dense { width: 100%; font-size: var(--text-13); line-height: 1.45; }
.data-table .num { text-align: right; }
/* Task tables share a ruled frame inside the page gutter; long tables scroll within it. */
.task-page .table-frame { flex: 0 1 auto; min-height: 0; margin: var(--space-4) var(--space-5) var(--space-5); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.data-table.framed { border-collapse: separate; border-spacing: 0; }
.task-page .data-table.framed :is(th, td) { border-width: 0 1px 1px 0; }
.task-page .data-table.framed thead th { position: sticky; top: 0; z-index: 1; border-bottom: 0; box-shadow: inset 0 -1px 0 var(--line); }
.data-table.framed :is(th, td):last-child { border-right: 0; }
.data-table.framed tbody tr:last-child > * { border-bottom: 0; }
@media (max-width: 720px) { .task-page .table-frame { margin-inline: var(--space-3); } }
.task-app .table-scroll { max-width: 100%; overflow: auto; }
@media (max-width: 600px) {
  :is(.data-table, .answer .content table) :is(th, td) { padding: var(--space-2); }
}

.panel-toggle.is-running::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: var(--space-2); border-radius: 50%; background: currentColor; animation: activity-pulse 1.6s infinite; }
@media (prefers-reduced-motion: reduce) { .panel-toggle.is-running::before { animation: none; } }

/* Answer/table copy controls shared by Chat and task answers. */
.copy-control { position: relative; width: var(--space-6); height: var(--space-6); color: var(--ink); }
@media (max-width: 600px) {
  .copy-control { min-width: 44px; min-height: 44px; }
}
.copy-answer { margin-top: var(--space-3); }

.content .table-actions { display: flex; margin: var(--space-2) 0 var(--space-4); }
