/* Small refinements to the original AI settings. Existing segmented controls stay intact. */
#page-settings:has(#set-ai.detail-mode) #setFab { display: none; }
.ai-settings-sheet {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 18px 44px -32px rgba(25, 35, 60, .15);
}
.ai-settings-sheet > .ai-detail-section {
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.ai-settings-sheet > .ai-detail-section + .ai-detail-section {
  border-top: 1px solid var(--border);
}
.ai-settings-sheet > .ai-detail-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin: 0;
  padding: 18px 24px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
}
.ai-settings-sheet > .ai-detail-foot .tpl-detail-foot-hint { text-align: right; }
/* Same white surface and lower blue accent as the existing Marps settings tabs. */
.ai-settings-sheet .ai-traits { gap: var(--ds-space-2); }
.ai-settings-sheet .ai-trait {
  height: var(--ds-control);
  padding-inline: var(--ds-space-3) var(--ds-space-4);
  gap: var(--ds-space-2);
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius-control);
  background: var(--ds-surface);
  color: var(--ds-ink-secondary);
  font-family: var(--ds-font);
  font-size: var(--ds-text-body);
  font-weight: 500;
  letter-spacing: 0;
  box-shadow: 0 1px 2px rgba(35, 25, 54, .025);
  backdrop-filter: none;
  transform: none;
  transition: border-color var(--ds-duration-fast), color var(--ds-duration-fast), box-shadow var(--ds-duration-fast);
}
.ai-trait-mark {
  width: var(--ds-icon-sm);
  height: var(--ds-icon-sm);
  flex: 0 0 var(--ds-icon-sm);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ai-settings-sheet .ai-trait:hover:not(.lim) {
  color: var(--ds-accent-strong);
  border-color: rgba(var(--ds-accent-rgb), .25);
  background: var(--ds-surface);
  box-shadow: 0 2px 6px rgba(44, 31, 69, .05);
  transform: none;
}
.ai-settings-sheet .ai-trait.on,
.ai-settings-sheet .ai-trait.on:hover {
  color: var(--ds-accent-strong);
  background: var(--ds-surface);
  border-color: rgba(var(--ds-accent-rgb), .18);
  box-shadow: 0 2px 6px rgba(44, 31, 69, .05), inset 0 -2px 0 rgba(var(--ds-accent-rgb), .5);
}
.ai-settings-sheet .ai-trait:focus-visible { outline: 2px solid var(--ds-accent); outline-offset: 2px; }
.ai-settings-sheet .ai-trait.lim { opacity: .48; cursor: not-allowed; box-shadow: none; }
.ai-settings-sheet .ai-trait.lim:hover { color: var(--ds-ink-secondary); background: var(--ds-surface); border-color: var(--ds-line); }
@media (prefers-reduced-motion: reduce) {
  .ai-settings-sheet .ai-trait { transition: none; }
}
.ai-settings-sheet .ai-greetings { gap: 20px; margin-bottom: 20px; }
.ai-settings-sheet .ai-greet-row { grid-template-columns: minmax(0, 1fr) 32px; column-gap: 8px; row-gap: 8px; }
.ai-settings-sheet .ai-greet-input { width: 100%; min-width: 0; }
.ai-greet-tools, .ai-greet-example, .ai-greet-feedback { grid-column: 1 / -1; }
.ai-greet-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.ai-greet-tools-label { color: var(--t3); font-size: 12px; margin-right: 2px; }
.ai-greet-token {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg2);
  color: var(--t2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
}
.ai-greet-token > span { color: var(--a); font-size: 16px; line-height: 1; }
.ai-greet-token:hover { color: var(--a); border-color: var(--a3); background: var(--accent-soft); }
.ai-greet-token:focus-visible, .ai-settings-sheet .ai-greet-rm:focus-visible {
  outline: 2px solid var(--a);
  outline-offset: 2px;
}
.ai-greet-example { color: var(--t2); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.ai-greet-example > span:first-child { color: var(--t3); }
.ai-greet-feedback { color: var(--red); font-size: 12px; }
.ai-greet-feedback:empty { display: none; }
.ai-settings-sheet .ai-topics { gap: 0; }
.ai-settings-sheet .ai-topic { padding: 18px 0; }
.ai-settings-sheet .ai-topic:first-child { padding-top: 0; }
.ai-settings-sheet .ai-topic:last-child { padding-bottom: 0; }
.ai-settings-sheet .ai-topic.on { background: transparent; }
.ai-settings-sheet .ai-topic-head { align-items: flex-start; padding: 0 0 10px; }
.ai-topic-label { flex: 1; min-width: 0; }
.ai-topic-label .ai-topic-name { display: block; margin-bottom: 4px; }
.ai-topic-hint { display: block; font-size: 12px; color: var(--t3); line-height: 1.5; }
.ai-settings-sheet .ai-topic-state { flex-shrink: 0; margin-top: 3px; font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none; }
.ai-settings-sheet .ai-topic-txt {
  display: block;
  min-height: 80px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg2);
  line-height: 1.6;
}
.ai-settings-sheet .ai-topic-txt:focus {
  border-color: var(--a);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--bg2);
}
@media (max-width: 600px) {
  .ai-settings-sheet .ai-trait { height: var(--ds-control-lg); }
  .ai-settings-sheet > .ai-detail-section { padding: 20px 16px; }
  .ai-greet-token { min-height: 36px; }
  .ai-settings-sheet .ai-topic-head { flex-wrap: wrap; gap: 6px; }
  .ai-topic-label { flex-basis: 100%; }
  .ai-settings-sheet .ai-topic-state { margin: 0; }
  .ai-settings-sheet .ai-topic-txt { min-height: 112px; }
  .ai-settings-sheet > .ai-detail-foot {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 16px;
  }
  .ai-settings-sheet > .ai-detail-foot .tpl-detail-foot-hint { order: 2; text-align: center; }
  .ai-settings-sheet > .ai-detail-foot .tpl-save-btn { width: 100%; }
}
