.workspace-ai-trigger {
  flex: none;
  color: var(--accent-text);
  background: var(--accent-wash);
  border-color: color-mix(in srgb, var(--accent-text) 17%, var(--line));
}
.workspace-ai-trigger:hover:not(:disabled), .workspace-ai-trigger[aria-expanded="true"] {
  background: color-mix(in srgb, var(--accent-wash) 80%, var(--accent-text));
}

.workspace-ai {
  --ai-width: 424px;
  --ai-gutter: 14px;
  position: fixed;
  z-index: 12;
  inset: calc(var(--header-h) + 9px) var(--ai-gutter) var(--ai-gutter) auto;
  display: grid;
  grid-template-areas: 'head' 'content' 'composer' 'footer';
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: min(var(--ai-width), calc(100% - var(--ai-gutter) * 2));
  min-height: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 6px 18px #1f232b12, 0 22px 56px #1f232b23;
}
.workspace-ai[hidden] { display: none; }
.ai-head { grid-area: head; display: flex; align-items: center; gap: 11px; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.ai-head-copy { flex: 1; min-width: 0; }
.ai-head-actions { display: flex; flex: none; align-items: center; gap: 4px; }
.ai-head .ai-header-button { min-height: 32px; padding: 4px 7px; gap: 4px; color: var(--accent-text); }
.ai-head [aria-expanded="true"] { background: var(--accent-wash); color: var(--accent-text); }
.ai-head h2 { font-size: 15px; font-weight: 720; }
.ai-head p { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.ai-symbol, .ai-item-icon { display: inline-grid; flex: none; place-items: center; }
.ai-symbol { width: 38px; height: 38px; border-radius: 11px; background: var(--accent-wash); color: var(--accent-text); }
.ai-head .icon-button { flex: none; }
.ai-scroll { grid-area: content; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 17px; }
.ai-context span { margin-inline-end: 4px; font-weight: 700; color: var(--accent-text); }
.ai-history { display: grid; gap: 15px; }
.ai-history h3 { font-size: 18px; font-weight: 730; }
.ai-history-group { display: grid; gap: 5px; min-width: 0; }
.ai-history-group h4 { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: 12px; font-weight: 650; overflow-wrap: anywhere; }
.ai-history-group h4 svg { flex: none; }
.ai-history-group ul { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; }
.ai-history-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 8px;
  width: 100%; padding: 8px 9px; color: var(--ink); border: 0; border-radius: 8px; background: transparent; text-align: start;
}
.ai-history-row > svg { margin-block-start: 2px; color: var(--muted); }
.ai-history-row span { min-width: 0; }
.ai-history-row strong, .ai-history-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-history-row strong { font-size: 13px; font-weight: 600; }
.ai-history-row small { margin-block-start: 2px; color: var(--muted); font-size: 11px; }
.ai-history-row:hover { background: var(--hover); }
.ai-history-row[aria-current="true"] { color: var(--accent-text); background: var(--accent-wash); }
.ai-thread { display: grid; gap: 15px; }
.ai-thread:empty { display: none; }
.ai-message { display: grid; gap: 4px; min-width: 0; justify-items: start; }
.ai-message[data-role="user"] { justify-items: end; }
.ai-author { color: var(--muted); font-size: 11px; font-weight: 650; }
.ai-message p {
  max-width: 100%; padding: 9px 11px; overflow-wrap: anywhere; white-space: pre-wrap;
  color: var(--ink); background: var(--bar); border-radius: 10px; font-size: 13px; line-height: 1.6;
}
.ai-message[data-role="user"] p { max-width: 90%; background: var(--accent-wash); }
.ai-tool { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 11px; }
.ai-tool svg { color: var(--accent-text); }
.ai-welcome { display: grid; gap: 11px; }
.ai-welcome h3, .ai-draft h3 { font-size: 18px; font-weight: 730; letter-spacing: -.02em; }
.ai-scroll > .ai-chips { margin-block-start: 12px; }
.ai-connection { margin-block-end: 13px; color: var(--muted); font-size: 12px; }
.ai-connection summary { width: fit-content; cursor: pointer; color: var(--accent-text); }
.ai-connection form { display: grid; justify-items: stretch; gap: 8px; margin-block-start: 8px; padding: 11px; background: var(--bar); border-radius: 9px; }
.ai-connection form button { justify-self: end; }
.ai-working { padding-block-start: 12px; color: var(--muted); font-size: 12px; }
.ai-draft { display: grid; gap: 11px; min-width: 0; margin-block-start: 15px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.ai-draft-heading { display: grid; gap: 5px; }
.ai-draft-heading p { color: var(--muted); font-size: 12px; line-height: 1.5; }
.ai-draft [data-ai-selection] { margin-inline-end: auto; color: var(--muted); font-size: 12px; }
.ai-composer { grid-area: composer; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; padding: 10px 17px; border-top: 1px solid var(--line); }
.ai-composer textarea, .ai-field :is(input, textarea, select) {
  width: 100%; min-width: 0; margin: 0; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); background: var(--surface); font: inherit;
}
.ai-composer textarea { background: var(--bar); font-size: 13px; line-height: 1.45; }
.workspace-ai textarea { resize: vertical; }
.workspace-ai .ai-composer textarea { resize: none; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chips .button { min-height: 30px; padding: 4px 8px; }
.ai-state { justify-self: start; display: inline-flex; align-items: center; gap: 5px; padding: 3px 7px; border-radius: 6px; color: var(--warning); background: var(--warning-wash); font-size: 11px; font-weight: 650; }
.ai-state i { width: 5px; height: 5px; background: currentColor; border-radius: 50%; }
.ai-space-fields { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bar); }
.ai-field { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.ai-field[hidden] { display: none; }
.ai-field input:disabled { opacity: .5; }
.ai-field :is(input, select) { min-height: 34px; }
.ai-fields-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.ai-items { display: grid; gap: 9px; min-width: 0; }
.ai-item-group { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; }
.ai-item-group h4 { display: flex; gap: 6px; justify-content: space-between; margin: 0; padding: 6px 9px; color: var(--muted); background: var(--bar); font-size: 11px; }
.ai-item-group h4 span { color: var(--accent-text); }
.ai-item { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 8px; padding: 8px 9px; }
.ai-item + .ai-item { border-top: 1px solid var(--line); }
.ai-item > input { width: 15px; height: 15px; margin: 9px 0 0; accent-color: var(--accent-text); }
.ai-item details:not([open]) .ai-item-fields { display: none; }
.ai-item summary { display: flex; align-items: center; min-height: 33px; gap: 8px; list-style: none; cursor: pointer; }
.ai-item summary::-webkit-details-marker { display: none; }
.ai-item-icon { width: 31px; height: 31px; border-radius: 7px; color: var(--accent-text); background: var(--accent-wash); }
.ai-item-icon[data-ai-type="timer"] { color: var(--positive); background: var(--positive-wash); }
.ai-item-icon[data-ai-type="pomodoro"] { color: var(--negative); background: var(--negative-wash); }
.ai-item-icon[data-ai-type="step"] { color: var(--muted); background: var(--bar); }
.ai-item-copy { display: grid; flex: 1; min-width: 0; gap: 2px; }
.ai-item-copy strong, .ai-item-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-item-copy strong { font-size: 13px; font-weight: 680; }
.ai-item-copy small, .ai-item-chevron { color: var(--muted); font-size: 11px; }
.ai-item details[open] .ai-item-chevron { transform: rotate(180deg); }
.ai-item-fields { display: grid; min-width: 0; gap: 8px; padding: 10px 0 2px; margin: 0; border: 0; }
.ai-item:has(> input:not(:checked)) summary { opacity: .55; }
.ai-error { margin-top: 12px; padding: 8px 11px; border-radius: 8px; color: var(--negative); background: var(--negative-wash); font-size: 13px; line-height: 1.5; }
.ai-footer { grid-area: footer; display: grid; gap: 7px; padding: 9px 17px; border-top: 1px solid var(--line); }
.ai-footer-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.ai-footer small { color: var(--muted); font-size: 11px; text-align: right; }

@media (min-width: 1080px) {
  body[data-ai-drawer-open] #app { --signal-panel-allocation: 452px; }
  body[data-ai-drawer-open] #app > .shell { margin-inline-end: var(--signal-panel-allocation); }
}
@media (max-width: 760px) {
  .workspace-ai { --ai-gutter: 8px; border-radius: 12px; }
}
@media (max-width: 670px) {
  .ai-head { gap: 8px; padding-inline: 12px; }
  .ai-symbol { width: 31px; height: 31px; }
}
@media (max-width: 550px) {
  .top-actions .workspace-ai-trigger > span { display: none; }
  .top-actions .workspace-ai-trigger { min-width: 31px; }
}
@media (max-width: 365px) {
  .ai-head .ai-header-button { padding-inline: 5px; }
  .ai-head-actions { gap: 2px; }
  .ai-history-toggle span { display: none; }
}
