@layer features {
.ai-titlebar, .ai-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.ai-titlebar { justify-content: flex-start; flex-wrap: wrap; margin-bottom: 0; padding: clamp(16px, 2vw, 24px); border: 1px solid var(--border); border-radius: var(--lumi-radius-md); background: var(--card); box-shadow: var(--lumi-shadow-sm); }
.ai-titlebar > div:first-child { min-width: min(100%, 280px); margin-right: auto; }
.ai-titlebar h1, .ai-section-heading h2 { margin: 0; }
.ai-titlebar p, .ai-section-heading p { margin: 4px 0 0; color: var(--ink-soft); }
.ai-runtime-badge { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--lumi-radius-pill); background: var(--surface-2); font-weight: 700; }
.ai-runtime-badge span { width: 9px; height: 9px; border-radius: 50%; background: #d73a49; }
.ai-runtime-badge.ready span { background: #2ea043; }
.ai-tabs { position: sticky; top: 8px; z-index: 4; display: flex; gap: 4px; overflow-x: auto; padding: 6px; background: color-mix(in srgb, var(--surface-2) 94%, transparent); border: 1px solid var(--border); border-radius: var(--lumi-radius-md); box-shadow: var(--lumi-shadow-sm); backdrop-filter: blur(14px); }
.ai-tabs a { padding: 7px 10px; border-radius: 5px; color: var(--ink-soft); text-decoration: none; font-weight: 700; white-space: nowrap; }
.ai-tabs a:hover { background: var(--surface-2); color: var(--ink); }
.ai-band { padding: clamp(16px, 2vw, 24px); border: 1px solid var(--border); border-radius: var(--lumi-radius-md); background: color-mix(in srgb, var(--card) 97%, transparent); box-shadow: var(--lumi-shadow-sm); scroll-margin-top: 72px; }
.ai-section-heading { align-items: flex-start; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.ai-section-heading h2 { display: flex; align-items: center; gap: 10px; }
.ai-section-heading h2::before { content: ""; width: 4px; height: 1.2em; flex: 0 0 auto; border-radius: 99px; background: var(--sea); }
.ai-stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-top: 16px; overflow: hidden; border: 1px solid var(--border); border-radius: 7px; background: var(--border); }
.ai-stat-grid div { min-width: 0; padding: 14px; background: var(--card); }
.ai-stat-grid span { display: block; color: var(--ink-soft); font-size: 12px; }
.ai-stat-grid strong { display: block; margin-top: 4px; overflow-wrap: anywhere; }
.ai-stat-grid.compact div { padding: 10px 12px; }
.ai-model-list { display: grid; gap: 8px; margin-top: 14px; }
.ai-model-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 12px; border: 1px solid var(--border); border-radius: var(--lumi-radius-sm); background: var(--surface-2); }
.ai-model-main span { display: block; margin-top: 3px; color: var(--ink-soft); font-size: 12px; overflow-wrap: anywhere; }
.ai-tag { padding: 4px 7px; border: 1px solid var(--border); border-radius: 5px; color: var(--ink-soft); font-size: 12px; }
.ai-tag.installed { border-color: #2ea043; color: #2ea043; }
.ai-tag.warning { border-color: var(--sun); color: var(--sun); }
.ai-inline-form, .ai-inline-form label, .ai-actions { display: flex; align-items: center; gap: 8px; }
.ai-runtime-grid { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr); gap: 16px; margin-top: 16px; }
.ai-runtime-grid > div { min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: var(--lumi-radius-sm); background: var(--surface-2); }
.ai-diagnostic { display: grid; grid-template-columns: minmax(8rem, auto) minmax(0, 1fr); gap: 8px 16px; }
.ai-diagnostic span { color: var(--ink-soft); }
.ai-diagnostic strong { overflow-wrap: anywhere; }
.ai-download-status { margin-top: 12px; padding: 9px; border: 1px solid var(--border); border-radius: 6px; }
.ai-gpu-control { min-width: 0; }
.ai-gpu-label, .ai-gpu-scale, .ai-gpu-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ai-gpu-slider { --gpu-actual: 0%; --gpu-max: 0%; position: relative; width: 100%; height: 28px; display: flex; align-items: center; }
.ai-gpu-slider::before { content: ""; position: absolute; left: 0; right: 0; height: 8px; border-radius: 4px; background: linear-gradient(to right, var(--sea) 0 var(--gpu-actual), var(--surface-2) var(--gpu-actual) var(--gpu-max), color-mix(in srgb, var(--ink-soft) 28%, var(--surface-2)) var(--gpu-max) 100%); pointer-events: none; }
.ai-gpu-slider input[type="range"] { position: relative; z-index: 1; width: 100%; height: 28px; margin: 0; background: transparent; accent-color: var(--sea); cursor: pointer; }
.ai-gpu-slider input[type="range"]:disabled { cursor: not-allowed; opacity: .7; }
.ai-gpu-scale { color: var(--ink-soft); font-size: 12px; }
.ai-gpu-summary { justify-content: flex-start; flex-wrap: wrap; margin-top: 10px; }
.ai-gpu-summary span { padding-right: 14px; border-right: 1px solid var(--border); }
.ai-gpu-summary span:last-child { border-right: 0; }
.ai-cleanup-form { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; margin-top: 16px; }
.ai-cleanup-form label { display: flex; align-items: center; gap: 6px; }
.ai-table-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.ai-table-actions form { margin: 0; }
.ai-assistant-diagnostic { display: block; padding: 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); }
.ai-diagnostic-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; }
.ai-condition-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-top: 12px; border: 1px solid var(--border); background: var(--border); }
.ai-condition-grid div { display: flex; justify-content: space-between; gap: 10px; min-width: 0; padding: 8px 10px; background: var(--card); }
.ai-condition-grid span { color: var(--ink-soft); overflow-wrap: anywhere; text-transform: capitalize; }
.ai-condition-grid .pass { color: #2ea043; }
.ai-condition-grid .fail { color: var(--rose); }
.ai-settings-groups { display: grid; gap: 10px; margin-top: 16px; }
.ai-settings-group { border: 1px solid var(--border); border-radius: 7px; background: var(--card); }
.ai-settings-group > summary { padding: 12px 14px; cursor: pointer; font-weight: 700; }
.ai-settings-group > summary:hover { background: var(--surface-2); }
.ai-settings-group[open] > summary { border-bottom: 1px solid var(--border); }
.ai-settings-group > .ai-form, .ai-settings-group > .ai-limit-grid, .ai-settings-group > .table-wrap { padding: 14px; margin-top: 0; }
.ai-panel-render-diagnostic { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.ai-panel-render-diagnostic span { min-width: 0; color: var(--ink-soft); }
.ai-panel-render-diagnostic strong { display: block; color: var(--ink); overflow-wrap: anywhere; }
.ai-identity-preview, .ai-hard-scope { padding: 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); }
.ai-identity-preview span { display: block; margin-top: 4px; color: var(--ink-soft); }
.ai-hard-scope ul { margin: 8px 0 0; padding-left: 20px; }
.ai-limit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--border); }
.ai-limit-grid > div { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; min-width: 0; padding: 10px; background: var(--card); }
.ai-limit-grid label { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); }
.ai-limit-grid input { width: 88px; }
.ai-log-tools { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.ai-log-tools input { flex: 1; min-width: 180px; }
.ai-log-viewer { max-height: 65vh; overflow: auto; padding: 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-form { margin-top: 16px; }
.ai-access-form { display: grid; grid-template-columns: minmax(260px, 420px) 170px 220px; align-items: end; gap: 12px; max-width: 920px; margin-top: 16px; }
.ai-access-form .field { min-width: 0; }
.ai-user-picker { position: relative; grid-column: span 2; }
.ai-fieldset { display: flex; flex-wrap: wrap; gap: 10px 20px; margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: 7px; }
.ai-fieldset legend { padding: 0 5px; font-weight: 700; }
.ai-fieldset label { display: flex; align-items: center; gap: 6px; }
.ai-test-output { max-height: 420px; overflow: auto; margin-top: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-work-filters { margin: 14px 0 10px; }
.ai-work-summary-row { cursor: pointer; }
.ai-work-summary-row:hover > td,
.ai-work-summary-row:focus-within > td { background: var(--surface-2); }
.ai-work-summary-row.is-open > td { border-bottom-color: transparent; }
.ai-work-expand-button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.ai-work-expand-icon { flex: 0 0 auto; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 120ms ease; }
.ai-work-summary-row.is-open .ai-work-expand-icon { transform: rotate(45deg); }
.ai-work-detail-row > td { padding: 0; background: var(--surface-2); }
.ai-work-detail-content { display: grid; gap: 12px; padding: 14px; border-bottom: 1px solid var(--border); }
.ai-work-prompt { padding: 0; }
.ai-work-prompt pre,
.ai-work-events td pre { max-width: 520px; max-height: 220px; overflow: auto; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-work-flags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ai-remediation { margin: 14px 0; padding-left: 24px; }
.ai-raw-diagnostic pre { max-height: 420px; overflow: auto; padding: 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-tools-modal { z-index: 110; }
.ai-tool-readme-modal { z-index: 120; }
.ai-tool-settings-modal { z-index: 125; }
.ai-tools-dialog { width: min(1180px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
.ai-tools-dialog .modal-header p { margin: 4px 0 0; color: var(--ink-soft); }
.ai-tools-source { margin: 10px 0; color: var(--ink-soft); font-size: 12px; overflow-wrap: anywhere; }
.ai-tools-source.error { color: var(--rose); }
.ai-tool-diagnostics { margin: 10px 0; padding: 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); }
.ai-tool-diagnostic-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 10px 0; }
.ai-tool-diagnostic-controls label { display: grid; gap: 4px; font-weight: 800; }
.ai-tool-diagnostic-results { display: grid; gap: 6px; margin: 8px 0; }
.ai-tool-diagnostic-row { padding: 8px; border-left: 3px solid var(--border); background: var(--card); font-size: 12px; }
.ai-tool-diagnostic-row.exposed { border-left-color: var(--sea); }
.ai-tool-diagnostic-row.hidden { border-left-color: var(--rose); }
.ai-tool-diagnostics pre { max-height: 280px; overflow: auto; white-space: pre-wrap; }
.ai-tools-list { display: grid; gap: 9px; }
.ai-tool-row { border: 1px solid var(--border); border-radius: 7px; background: var(--card); }
.ai-tool-summary { display: grid; grid-template-columns: minmax(170px, 1fr) minmax(280px, 1.5fr) minmax(130px, .7fr) auto; align-items: center; gap: 12px; padding: 11px; }
.ai-tool-identity span { display: block; margin-top: 3px; color: var(--ink-soft); font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; }
.ai-tool-versions, .ai-tool-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ai-tool-version, .ai-tool-scope { color: var(--ink-soft); font-size: 12px; }
.ai-tool-actions { justify-content: flex-end; }
.ai-tool-actions form { margin: 0; }
.ai-tool-actions .button.update { border-color: var(--sun); color: var(--sun); font-weight: 800; }
.ai-tool-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; border-top: 1px solid var(--border); background: var(--border); }
.ai-tool-details[hidden] { display: none; }
.ai-tool-details > div { min-width: 0; padding: 9px 11px; background: var(--surface-2); }
.ai-tool-details strong, .ai-tool-details span { display: block; overflow-wrap: anywhere; }
.ai-tool-details strong { margin-bottom: 3px; font-size: 12px; }
.ai-tool-details span { color: var(--ink-soft); font-size: 12px; }
.ai-tool-readme-dialog { width: min(900px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
.ai-tool-readme { min-height: 160px; line-height: 1.55; }
.ai-tool-readme pre { max-height: 420px; padding: 12px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-3); white-space: pre; }
.ai-tool-readme code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.ai-tool-readme a { color: var(--sea); font-weight: 700; }
.ai-tool-settings-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
.ai-tool-settings-dialog .modal-header p { margin: 4px 0 0; color: var(--ink-soft); }
.ai-tool-settings-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ai-tool-setting { display: grid; gap: 6px; min-width: 0; }
.ai-tool-setting.wide { grid-column: 1 / -1; }
.ai-tool-setting label { font-weight: 800; }
.ai-tool-setting .hint { margin: 0; }
.ai-tool-setting textarea { min-height: 90px; resize: vertical; }
.ai-tool-setting .check-grid { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.ai-tool-setting .check-grid label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
@media (max-width: 800px) {
  .ai-titlebar, .ai-section-heading { align-items: flex-start; flex-direction: column; }
  .ai-stat-grid { grid-template-columns: 1fr 1fr; }
  .ai-model-row { grid-template-columns: 1fr auto; }
  .ai-inline-form { grid-column: 1 / -1; }
  .ai-runtime-grid { grid-template-columns: 1fr; }
  .ai-condition-grid { grid-template-columns: 1fr; }
  .ai-limit-grid { grid-template-columns: 1fr; }
  .ai-limit-grid > div { grid-template-columns: 1fr; }
  .ai-panel-render-diagnostic { grid-template-columns: 1fr; }
  .ai-access-form { grid-template-columns: 1fr; max-width: none; }
  .ai-user-picker { grid-column: auto; }
  .ai-tool-summary { grid-template-columns: 1fr; }
  .ai-tool-actions { justify-content: flex-start; }
  .ai-tool-details { grid-template-columns: 1fr; }
  .ai-tool-settings-fields { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .ai-titlebar > .button,
  .ai-titlebar > a.button { flex: 1 1 auto; }
  .ai-stat-grid { grid-template-columns: 1fr; }
  .ai-model-row { grid-template-columns: 1fr; }
  .ai-inline-form { flex-wrap: wrap; }
  .ai-diagnostic { grid-template-columns: 1fr; }
}

.ai-stat-grid span,
.ai-model-main span,
.ai-tag,
.ai-gpu-scale,
.ai-tools-source,
.ai-tool-diagnostic-row,
.ai-tool-version,
.ai-tool-scope,
.ai-tool-details strong,
.ai-tool-details span { font-size: var(--lumi-font-size-sm); }
}
