/*
 * Expert mode: fullscreen workspace + hide chat composer.
 * Server-side on_message gating is the fail-safe if CSS selectors drift.
 */

html.expert-mode-active #message-composer,
html.expert-shell-active #message-composer,
html.expert-mode-active .message-composer,
html.expert-shell-active .message-composer,
html.expert-mode-active #chat-input,
html.expert-shell-active #chat-input,
html.expert-mode-active [data-testid="chat-input"],
html.expert-shell-active [data-testid="chat-input"],
html.expert-mode-active [data-testid="message-composer"],
html.expert-shell-active [data-testid="message-composer"],
html.expert-mode-active form:has(textarea[placeholder*="message" i]),
html.expert-shell-active form:has(textarea[placeholder*="message" i]),
html.expert-mode-active form:has(textarea[placeholder*="nachricht" i]),
html.expert-shell-active form:has(textarea[placeholder*="nachricht" i]),
html.expert-mode-active footer:has(button[type="submit"]),
html.expert-shell-active footer:has(button[type="submit"]),
html.expert-mode-active [class*="waterMark"]:has(textarea),
html.expert-shell-active [class*="waterMark"]:has(textarea) {
  display: none !important;
}

html.expert-mode-active footer:has(textarea),
html.expert-shell-active footer:has(textarea),
html.expert-mode-active [class*="composer"]:has(textarea),
html.expert-shell-active [class*="composer"]:has(textarea) {
  display: none !important;
}

html.expert-mode-active .expert-workspace-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: auto;
  box-sizing: border-box;
  background: hsl(var(--background, 0 0% 7%));
  color: hsl(var(--foreground, 0 0% 98%));
  /* Avoid browser restoring window scroll when Chainlit remounts the element */
  overscroll-behavior: contain;
  overflow-anchor: none;
}

/* Cap growing index UI so mid-job entries do not stretch the page. */
html.expert-mode-active .expert-gesetze-index-entries {
  max-height: min(16rem, 32vh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

html.expert-mode-active .expert-gesetze-index-log {
  max-height: min(12rem, 24vh);
  overflow: auto;
  overscroll-behavior: contain;
}

html.expert-mode-active .expert-gesetze-dropzone {
  border: 2px dashed hsl(var(--border, 0 0% 25%));
  border-radius: 0.5rem;
  padding: 1.25rem 1rem;
  text-align: center;
  color: hsl(var(--muted-foreground, 0 0% 65%));
  background: hsl(var(--muted, 0 0% 18%) / 0.2);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

html.expert-mode-active .expert-gesetze-dropzone:hover,
html.expert-mode-active .expert-gesetze-dropzone[data-dragover="true"] {
  border-color: hsl(var(--primary, 322 80% 46%) / 0.55);
  background: hsl(var(--primary, 322 80% 46%) / 0.08);
}

html.expert-mode-active .expert-gesetze-dropzone:focus-visible {
  outline: 2px solid hsl(var(--primary, 322 80% 46%) / 0.75);
  outline-offset: 2px;
}

html.expert-mode-active {
  overflow: hidden;
}

html.expert-mode-active .expert-overtype-host {
  /* Height is set inline by ExpertWorkspace (default 37vh, user-resizable). */
  min-height: 8rem;
  width: 100%;
}

html.expert-mode-active .expert-overtype-host .overtype-container,
html.expert-mode-active .expert-overtype-host .overtype-wrapper {
  height: 100%;
  min-height: 0;
  width: 100%;
}

html.expert-mode-active .expert-overtype-host .overtype-toolbar {
  flex-wrap: wrap;
  /* Distinct "tools" strip vs editor body (Chainlit dark) */
  background: #2b3344 !important;
  border-bottom: 1px solid #4b5568 !important;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.06);
  padding: 0.4rem 0.5rem !important;
  gap: 0.15rem;
}

html.expert-mode-active .expert-overtype-host .overtype-toolbar-button {
  border-radius: 0.35rem;
}

html.expert-mode-active .expert-overtype-host .overtype-toolbar-separator {
  background: #64748b !important;
  opacity: 0.7;
}

/* Light Chainlit theme: slightly tinted tools bar */
html.light.expert-mode-active .expert-overtype-host .overtype-toolbar,
html.expert-mode-active:not(.dark) .expert-overtype-host .overtype-toolbar {
  background: #e8eef6 !important;
  border-bottom: 1px solid #c5d0de !important;
  box-shadow: none;
}

/*
 * ClarifyPanel active: hide main chat composer until option / free-text / skip.
 * Soft-fail: on_message also rejects while session clarify_lock is set.
 */
html.clarify-lock-active #message-composer,
html.clarify-lock-active .message-composer,
html.clarify-lock-active #chat-input,
html.clarify-lock-active [data-testid="chat-input"],
html.clarify-lock-active [data-testid="message-composer"],
html.clarify-lock-active form:has(textarea[placeholder*="message" i]),
html.clarify-lock-active form:has(textarea[placeholder*="nachricht" i]),
html.clarify-lock-active footer:has(button[type="submit"]),
html.clarify-lock-active [class*="waterMark"]:has(textarea),
html.clarify-lock-active footer:has(textarea),
html.clarify-lock-active [class*="composer"]:has(textarea) {
  display: none !important;
}

/*
 * AppointmentFlow active: hide main chat composer until overlay closes.
 */
html.appointment-lock-active #message-composer,
html.appointment-lock-active .message-composer,
html.appointment-lock-active #chat-input,
html.appointment-lock-active [data-testid="chat-input"],
html.appointment-lock-active [data-testid="message-composer"],
html.appointment-lock-active form:has(textarea[placeholder*="message" i]),
html.appointment-lock-active form:has(textarea[placeholder*="nachricht" i]),
html.appointment-lock-active footer:has(button[type="submit"]),
html.appointment-lock-active [class*="waterMark"]:has(textarea),
html.appointment-lock-active footer:has(textarea),
html.appointment-lock-active [class*="composer"]:has(textarea) {
  display: none !important;
}

/* ClarifyPanel: Chainlit primary highlight for selected choice card */
.clarify-panel .clarify-choice-selected {
  border-color: hsl(var(--primary)) !important;
  background-color: hsl(var(--primary) / 0.18) !important;
  box-shadow: 0 0 0 1px hsl(var(--primary) / 0.55) !important;
}

.clarify-panel .clarify-confirm-btn:not(:disabled) {
  background-color: hsl(var(--primary)) !important;
  color: hsl(var(--primary-foreground)) !important;
  border: 2px solid hsl(var(--primary)) !important;
}

.clarify-panel .clarify-confirm-btn:not(:disabled):hover {
  filter: brightness(1.08);
}

/*
 * Chat answers use ### → h3. Soften heading size so sections read as
 * labels, not page titles (Chainlit default h2/h3 are visually heavy).
 * Scoped out of expert mode (fullscreen workspace).
 */
html:not(.expert-mode-active) .step h1,
html:not(.expert-mode-active) .step h2,
html:not(.expert-mode-active) .step h3,
html:not(.expert-mode-active) [class*="message"] h1,
html:not(.expert-mode-active) [class*="message"] h2,
html:not(.expert-mode-active) [class*="message"] h3,
html:not(.expert-mode-active) .prose h1,
html:not(.expert-mode-active) .prose h2,
html:not(.expert-mode-active) .prose h3 {
  font-size: 1.05rem;
  line-height: 1.35;
  font-weight: 600;
  margin-top: 0.95em;
  margin-bottom: 0.35em;
}

html:not(.expert-mode-active) .step h1,
html:not(.expert-mode-active) [class*="message"] h1,
html:not(.expert-mode-active) .prose h1 {
  font-size: 1.12rem;
}

/* After confirm/skip: static snapshot — no hover motion, no pointer targets */
.clarify-panel.clarify-panel-submitted .clarify-choice {
  cursor: default;
  pointer-events: none;
  transition: none !important;
}

/* Language selector: hide the CustomElement host message; portal lives in the header. */
.step:has(.aul-language-selector-anchor),
[class*="message"]:has(.aul-language-selector-anchor),
.step:has(.aul-appointment-header-anchor),
[class*="message"]:has(.aul-appointment-header-anchor) {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
}

.aul-language-selector-host {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

html.expert-mode-active .aul-language-selector-host,
html.expert-mode-active .aul-language-selector {
  display: none !important;
  pointer-events: none !important;
}

html.expert-mode-active,
html.expert-mode-active .expert-workspace-root,
html.expert-mode-active #expert-workspace,
html.expert-mode-active .expert-overlay {
  direction: ltr;
}

html[dir="rtl"] header {
  direction: rtl;
}

html[dir="rtl"] .aul-language-selector-host {
  margin-inline: 0.15rem;
}

.aul-language-selector {
  position: relative;
  display: flex;
  align-items: center;
}

.aul-language-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 2rem;
  padding: 0 0.65rem;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--foreground, 0 0% 98%));
}

.aul-language-globe {
  flex-shrink: 0;
}

.aul-language-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 80;
  min-width: 0;
  width: max-content;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  border: 1px solid hsl(var(--border, 0 0% 25%));
  border-radius: 0.5rem;
  background: hsl(var(--popover, var(--background, 0 0% 9%)));
  color: hsl(var(--popover-foreground, var(--foreground, 0 0% 98%)));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

html[dir="rtl"] .aul-language-menu {
  right: auto;
  left: 0;
}

.aul-language-option {
  display: flex;
  align-items: center;
  gap: 0.75rem; /* space between flag and language name — tune freely */
  width: 100%;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: inherit;
  text-align: start;
  font-size: 0.875rem;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  white-space: nowrap;
}

.aul-language-flag {
  flex-shrink: 0;
  line-height: 1;
  font-size: 1.1em;
}

.aul-language-option-label,
.aul-language-name {
  line-height: 1;
}

.aul-language-option:hover,
.aul-language-option:focus-visible {
  background: hsl(var(--muted, 0 0% 16%));
  outline: none;
}

.aul-language-option-selected {
  font-weight: 600;
  background: hsl(var(--primary, 322 80% 46%) / 0.15);
}

html.aul-chrome-fading textarea,
html.aul-chrome-fading [data-aul-readme],
html.aul-chrome-fading [data-aul-watermark] {
  opacity: 0.55;
  transition: opacity 160ms ease;
}

#sidebar [data-aul-watermark],
#sidebar [class*="watermark"],
#side-view [class*="watermark"],
[data-testid="element-sidebar"] [data-aul-watermark],
[class*="element-sidebar"] [data-aul-watermark],
[class*="ElementSidebar"] [class*="watermark"] {
  display: none !important;
}

/* ExpertAccessHotkey CustomElement host messages + anchor are never visible. */
.step:has(.aul-expert-hotkey-anchor),
[class*="message"]:has(.aul-expert-hotkey-anchor) {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
}

/*
 * Formatierungshilfe: keep the summary row and content clear of the card
 * border; the disclosure triangle gets breathing room and text is inset.
 */
.expert-formatierungshilfe {
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.expert-formatierungshilfe > summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
  min-height: 2.25rem;
}

.expert-formatierungshilfe > summary::-webkit-details-marker {
  display: none;
}

.expert-formatierungshilfe > summary::before {
  content: "";
  flex-shrink: 0;
  width: 0.65em;
  height: 0.65em;
  margin-right: 0.35rem;
  /* Corner points right when closed, down when open (chevron convention). */
  transform: rotate(-45deg);
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transition: transform 160ms ease;
}

.expert-formatierungshilfe[open] > summary::before {
  transform: rotate(45deg);
}

/*
 * Formatierungshilfe body: explicit list geometry so bullet markers can
 * never hang outside the card border (Tailwind pl-5 is not guaranteed to
 * survive Chainlit's CSS scoping inside CustomElements).
 */
.expert-help-body {
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.expert-help-body ul {
  list-style-position: inside;
  padding-left: 1.1rem;
  margin-left: 0;
}

.expert-help-body ol {
  list-style-position: inside;
  padding-left: 1.4rem;
  margin-left: 0;
}

.expert-help-body li {
  margin-left: 0;
}

.expert-help-body pre {
  margin-left: 0;
}

/*
 * Panel header buttons: subtle themed focus instead of the browser's
 * default white outline (visible when tabbing / shift-tabbing).
 */
.expert-panel > button:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px hsl(var(--primary, 322 80% 46%) / 0.55);
  border-radius: inherit;
}

.expert-panel > button:focus:not(:focus-visible) {
  outline: none;
}

/*
 * Expert panel resize handle: thin strip below each editor card body.
 * Cursor hints the vertical drag; active drag disables transitions so the
 * panel tracks the pointer 1:1.
 */
.expert-panel-resize-handle {
  position: relative;
  height: 10px;
  margin: 2px auto 6px;
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
  border-radius: 4px;
}

.expert-panel-resize-handle::after {
  content: "";
  position: absolute;
  left: 25%;
  right: 25%;
  top: 50%;
  height: 3px;
  transform: translateY(-50%);
  border-radius: 2px;
  background: hsl(var(--muted-foreground, 0 0% 60%) / 0.35);
  transition: background 120ms ease;
}

.expert-panel-resize-handle:hover::after,
.expert-panel-resize-handle[data-dragging="true"]::after {
  background: hsl(var(--primary, 322 80% 46%) / 0.7);
}

html.expert-mode-active .expert-panel-resizing,
html.expert-mode-active .expert-panel-resizing * {
  transition: none !important;
}

/*
 * Answer loading state: spinning gear + cycling stage label, appended
 * slow note after 30 s (element: LoadingIndicator.jsx).
 */
.aul-loading-indicator {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  color: hsl(var(--muted-foreground, 0 0% 60%));
}

.aul-loading-indicator .aul-gear {
  flex-shrink: 0;
  animation: aul-gear-spin 2.4s linear infinite;
}

@keyframes aul-gear-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.aul-loading-indicator .aul-loading-stage {
  font-size: 0.925rem;
}

.aul-loading-indicator .aul-loading-slow {
  font-size: 0.85rem;
  opacity: 0.75;
}

@media (prefers-reduced-motion: reduce) {
  .aul-loading-indicator .aul-gear,
  .aul-loading-indicator .aul-gear * {
    animation: none !important;
  }
}

/*
 * Empty-chat start screen: big brand title + composer pulled to mid-screen.
 * Active while html.aul-start-screen is set by StartHero.jsx (until the first
 * real user/assistant message appears). The language-selector host message
 * otherwise suppresses Chainlit's native #welcome-screen.
 *
 * Composer lives in a sibling column under the message list (not a <footer>),
 * so StartHero tags its parent with .aul-start-composer-wrap for positioning.
 */
.aul-start-hero {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  /* Leave room under the title for the fixed composer */
  padding: 0 1.25rem 9rem;
  pointer-events: none;
  text-align: center;
}

.aul-start-hero[hidden] {
  display: none !important;
}

.aul-start-hero-title {
  margin: 0;
  font-size: clamp(1.85rem, 4.5vw, 2.85rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: hsl(var(--foreground, 0 0% 98%));
}

.aul-start-hero-subtitle-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.aul-start-hero-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.2;
  color: hsl(var(--primary-foreground, 0 0% 98%));
  background: hsl(var(--primary, 322 80% 46%));
}

.aul-start-hero-subtitle {
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 450;
  letter-spacing: 0.02em;
  color: hsl(var(--muted-foreground, 0 0% 65%));
}

html.aul-start-screen .aul-start-composer-wrap {
  position: fixed !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  top: 54% !important;
  transform: translateX(-50%);
  width: min(44rem, calc(100vw - 2rem)) !important;
  max-width: calc(100vw - 2rem);
  z-index: 35;
  margin: 0 !important;
  padding: 0 !important;
}

html.aul-start-screen .aul-start-composer-wrap #message-composer {
  width: 100%;
}

html.expert-mode-active .aul-start-hero,
html.expert-mode-active .aul-start-composer-wrap {
  display: none !important;
}

.step:has(.aul-start-hero-anchor),
[class*="message"]:has(.aul-start-hero-anchor) {
  display: none !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
}

/*
 * Dedicated expert /expert app: shell navigation + workspace in content column.
 * Scoped under html.expert-shell-active so worker /chat is unchanged.
 */
html.expert-shell-active .aul-expert-shell {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  grid-template-columns: 16rem 1fr;
  background: hsl(var(--background, 0 0% 7%));
  color: hsl(var(--foreground, 0 0% 98%));
  box-sizing: border-box;
  overflow: hidden;
}

html.expert-shell-active .aul-expert-shell-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 0.75rem;
  border-right: 1px solid hsl(var(--border, 0 0% 25%));
  background: hsl(var(--background, 0 0% 7%));
}

html.expert-shell-active .aul-expert-nav-btn {
  justify-content: flex-start;
  width: 100%;
}

html.expert-shell-active .aul-expert-nav-logout {
  margin-top: auto;
}

html.expert-shell-active .aul-expert-shell-content {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
  padding: 1.25rem 1.5rem;
}

html.expert-shell-active .aul-expert-pane[hidden] {
  display: block;
  visibility: hidden;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

html.expert-shell-active .aul-expert-pane:not([hidden]) {
  visibility: visible;
  flex: 1;
  min-height: 0;
  height: auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}

html.expert-shell-active .aul-expert-pane-title {
  flex-shrink: 0;
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
}

html.expert-shell-active .aul-expert-pane-lead {
  margin: 0 0 1rem;
  max-width: 42rem;
  color: hsl(var(--muted-foreground, 0 0% 65%));
}

html.expert-shell-active .aul-expert-cases-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

html.expert-shell-active .aul-expert-cases-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

html.expert-shell-active .aul-expert-cases-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: hsl(var(--background, 0 0% 7%));
}

html.expert-shell-active .aul-expert-cases-table th,
html.expert-shell-active .aul-expert-cases-table td {
  border: 1px solid hsl(var(--border, 0 0% 25%));
  padding: 0.5rem 0.65rem;
  text-align: left;
}

html.expert-shell-active .aul-expert-cases-empty {
  color: hsl(var(--muted-foreground, 0 0% 65%));
  font-style: italic;
}

html.expert-shell-active .aul-expert-cases-row {
  cursor: pointer;
}

html.expert-shell-active .aul-expert-cases-row:hover,
html.expert-shell-active .aul-expert-cases-row:focus-visible {
  background: hsl(var(--muted, 0 0% 18%) / 0.45);
  outline: none;
}

html.expert-shell-active .aul-expert-cases-actions-col {
  width: 12rem;
  white-space: nowrap;
}

html.expert-shell-active .aul-expert-case-error {
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid hsl(var(--destructive, 0 72% 51%) / 0.45);
  border-radius: 0.375rem;
  color: hsl(var(--destructive, 0 72% 51%));
  background: hsl(var(--destructive, 0 72% 51%) / 0.08);
}

html.expert-shell-active .aul-expert-cases-empty {
  flex: 1;
  min-height: 0;
}

html.expert-shell-active .aul-expert-case-detail {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

html.expert-shell-active .aul-expert-case-detail-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

html.expert-shell-active .aul-expert-case-detail-toolbar {
  margin-bottom: 1rem;
}

html.expert-shell-active .aul-expert-case-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.45rem 1rem;
  margin: 0 0 0.85rem;
}

html.expert-shell-active .aul-expert-case-field dt {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground, 0 0% 65%));
}

html.expert-shell-active .aul-expert-case-field dd {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
}

html.expert-shell-active .aul-expert-case-section-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

html.expert-shell-active .aul-expert-case-proposed {
  margin: 0 0 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 0.4rem;
  border: 1px solid hsl(var(--border, 0 0% 25%));
  background: hsl(var(--muted, 0 0% 18%) / 0.35);
}

html.expert-shell-active .aul-expert-case-proposed-heading {
  margin: 0 0 0.25rem;
  font-size: 0.9rem;
  font-weight: 600;
}

html.expert-shell-active .aul-expert-case-proposed pre {
  margin: 0;
  padding: 0.75rem;
  border-radius: 0.375rem;
  border: 1px solid hsl(var(--border, 0 0% 25%));
  font-size: 0.8rem;
  overflow-x: auto;
}

html.expert-shell-active .aul-expert-case-proposed-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.35rem 0 0;
}

html.expert-shell-active .aul-expert-case-proposed-row {
  display: grid;
  grid-template-columns: minmax(7rem, 11rem) 1fr;
  gap: 0.75rem;
  align-items: start;
}

html.expert-shell-active .aul-expert-case-proposed-row dt {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground, 0 0% 65%));
}

html.expert-shell-active .aul-expert-case-proposed-row dd {
  margin: 0;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

html.expert-shell-active .aul-expert-case-notes {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  line-height: 1.45;
  min-height: 4.5rem;
  max-height: 16rem;
  overflow-y: auto;
}

html.expert-shell-active .aul-expert-case-propose-form {
  margin: 1.25rem 0;
  padding: 1rem;
  border: 1px solid hsl(var(--border, 0 0% 25%));
  border-radius: 0.5rem;
}

html.expert-shell-active .aul-expert-case-propose-hint {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground, 0 0% 65%));
}

html.expert-shell-active .aul-expert-case-propose-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

html.expert-shell-active .aul-expert-case-propose-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
}

html.expert-shell-active .aul-expert-case-propose-label input,
html.expert-shell-active .aul-expert-case-propose-label textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.4rem 0.55rem;
  border: 1px solid hsl(var(--border, 0 0% 25%));
  border-radius: 0.375rem;
  background: hsl(var(--background, 0 0% 9%));
  color: inherit;
  font: inherit;
}

html.expert-shell-active .aul-expert-propose-calendar {
  margin: 0.75rem 0 1rem;
  padding: 0.85rem;
  border: 1px solid hsl(var(--border, 0 0% 25%));
  border-radius: 0.75rem;
  background: hsl(var(--background, 0 0% 9%));
  color: hsl(var(--foreground, 0 0% 96%));
}

html.expert-shell-active .aul-expert-propose-calendar-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: hsl(var(--foreground, 0 0% 96%));
}

html.expert-shell-active .aul-expert-propose-month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.35rem 0 0.5rem;
}

html.expert-shell-active .aul-expert-propose-month-title {
  font-weight: 700;
  text-align: center;
  color: hsl(var(--foreground, 0 0% 96%));
}

html.expert-shell-active .aul-expert-propose-month-nav-btn {
  min-width: 2rem;
  min-height: 2rem;
  border: 1px solid hsl(var(--border, 0 0% 25%));
  border-radius: 0.4rem;
  background: hsl(var(--background, 0 0% 9%));
  color: hsl(var(--foreground, 0 0% 96%));
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

html.expert-shell-active .aul-expert-propose-month-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

html.expert-shell-active .aul-expert-propose-month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.25rem;
  margin: 0.25rem 0 0.75rem;
}

html.expert-shell-active .aul-expert-propose-weekday {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: hsl(var(--foreground, 0 0% 96%));
}

html.expert-shell-active .aul-expert-propose-month-pad {
  min-height: 2rem;
}

html.expert-shell-active .aul-expert-propose-month-day {
  min-height: 2rem;
  border: 1px solid transparent;
  border-radius: 0.4rem;
  background: transparent;
  color: hsl(var(--foreground, 0 0% 96%));
  cursor: pointer;
  font: inherit;
}

html.expert-shell-active .aul-expert-propose-month-day.is-selected {
  border-color: hsl(var(--primary, 322 80% 46%));
  background: transparent;
}

html.expert-shell-active .aul-expert-propose-month-day.is-disabled,
html.expert-shell-active .aul-expert-propose-month-day.is-weekend {
  opacity: 0.35;
  cursor: not-allowed;
}

html.expert-shell-active .aul-expert-propose-periods {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

html.expert-shell-active .aul-expert-propose-slot {
  border: 1px solid hsl(var(--border, 0 0% 25%));
  border-radius: 0.45rem;
  padding: 0.4rem 0.65rem;
  background: hsl(var(--background, 0 0% 9%));
  color: hsl(var(--foreground, 0 0% 96%));
  cursor: pointer;
  font: inherit;
}

html.expert-shell-active .aul-expert-propose-slot.is-selected {
  border-color: hsl(var(--primary, 322 80% 46%));
  background: hsl(var(--primary, 322 80% 46%) / 0.18);
}

html.expert-shell-active .aul-expert-case-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

html.expert-shell-active .aul-expert-case-action-bar {
  position: sticky;
  bottom: 0;
  z-index: 6;
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin: 0.75rem 0 0;
  padding: 0.75rem 0 0.15rem;
  border-top: 1px solid hsl(var(--border, 0 0% 25%));
  background: hsl(var(--background, 0 0% 7%));
}

html.expert-shell-active .aul-expert-case-close-confirm {
  font-weight: 600;
}

html.expert-shell-active .aul-expert-case-collapsible {
  margin-top: 1rem;
  border: 1px solid hsl(var(--border, 0 0% 25%));
  border-radius: 0.5rem;
  overflow: hidden;
}

html.expert-shell-active .aul-expert-case-collapsible-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  background: hsl(var(--card, var(--background, 0 0% 9%)));
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

html.expert-shell-active .aul-expert-case-collapsible-toggle:hover {
  background: hsl(var(--muted, 0 0% 18%) / 0.35);
}

html.expert-shell-active .aul-expert-case-collapsible-body {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid hsl(var(--border, 0 0% 25%));
}

html.expert-shell-active .aul-expert-case-transcript {
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

html.expert-shell-active .aul-expert-transcript-turn {
  list-style: none;
  padding: 0.65rem 0.85rem;
  border: 1px solid hsl(var(--border, 0 0% 25%));
  border-radius: 0.5rem;
  background: hsl(var(--muted, 0 0% 18%) / 0.2);
}

html.expert-shell-active .aul-expert-transcript-role {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: hsl(var(--muted-foreground, 0 0% 65%));
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

html.expert-shell-active .aul-expert-transcript-body {
  font-size: 0.9rem;
  line-height: 1.45;
  overflow: visible;
}

html.expert-shell-active .aul-expert-transcript-worker-lang {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid hsl(var(--border, 0 0% 25%));
}

html.expert-shell-active .aul-expert-md-heading {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
}

html.expert-shell-active .aul-expert-md-heading:first-child {
  margin-top: 0;
}

html.expert-shell-active .aul-expert-md-p {
  margin: 0 0 0.5rem;
  white-space: pre-wrap;
  word-break: break-word;
}

html.expert-shell-active .aul-expert-md-p:last-child,
html.expert-shell-active .aul-expert-md-plain {
  margin-bottom: 0;
}

html.expert-shell-active .aul-expert-md-list {
  margin: 0 0 0.5rem;
  padding-left: 1.2rem;
  list-style: disc;
}

html.expert-shell-active ol.aul-expert-md-list {
  list-style: decimal;
}

html.expert-shell-active .aul-expert-md-list li + li {
  margin-top: 0.25rem;
}

html.expert-shell-active .aul-expert-case-transcript li + li {
  margin-top: 0;
}

html.expert-shell-active .aul-expert-case-transcript-empty {
  margin: 0;
  color: hsl(var(--muted-foreground, 0 0% 65%));
  font-style: italic;
}

html.expert-shell-active .aul-expert-debug-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

html.expert-shell-active .aul-expert-debug-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem;
}

html.expert-shell-active .aul-expert-debug-card {
  border: 1px solid hsl(var(--border, 0 0% 25%));
  border-radius: 0.5rem;
  padding: 0.85rem 1rem;
  background: hsl(var(--card, var(--background, 0 0% 9%)));
}

html.expert-shell-active .aul-expert-debug-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
}

html.expert-shell-active .aul-expert-debug-card p {
  margin: 0;
  font-size: 0.85rem;
  color: hsl(var(--muted-foreground, 0 0% 65%));
}

html.expert-shell-active.aul-debug-hidden #pane-debug {
  visibility: hidden;
  pointer-events: none;
}

html.expert-shell-active .expert-workspace-root {
  position: fixed;
  inset: 0 0 0 16rem;
  z-index: 111;
  /* Fill the shell content column like Fälle (not a narrow max-w-5xl column). */
  max-width: none;
  width: auto;
  margin: 0;
  box-sizing: border-box;
  /* Same side inset as .aul-expert-shell-content */
  padding: 1.25rem 1.5rem !important;
  overflow-x: hidden;
  overflow-y: auto;
  min-width: 0;
}

/* Long OverType lines must not widen FAQ past Kontakt / Gesetze. */
html.expert-shell-active .expert-panel {
  min-width: 0;
  max-width: 100%;
}

html.expert-shell-active .expert-overtype-host {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
}

html.expert-shell-active .expert-overtype-host .overtype-container,
html.expert-shell-active .expert-overtype-host .overtype-wrapper {
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

html.expert-shell-active.aul-pane-cases .expert-workspace-root,
html.expert-shell-active.aul-pane-debug .expert-workspace-root {
  visibility: hidden;
  pointer-events: none;
}

html.expert-shell-active .expert-workspace-close {
  display: none !important;
}

html.expert-shell-active .expert-workspace-root > header > div:first-child > h1 {
  display: none;
}

html.expert-shell-active [data-testid="new-chat-button"],
html.expert-shell-active button[aria-label*="New chat" i],
html.expert-shell-active button[aria-label*="Neuer Chat" i],
html.expert-shell-active [class*="history"] button[aria-label*="history" i] {
  display: none !important;
}

.step:has(.aul-expert-shell),
[class*="message"]:has(.aul-expert-shell) {
  margin: 0 !important;
  padding: 0 !important;
}


.aul-appointment-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.25rem;
  padding: 0 0.85rem;
  border: 0;
  border-radius: 0.5rem;
  background: hsl(var(--primary, 322 80% 46%));
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--primary-foreground, 0 0% 98%));
}

.aul-appointment-header-btn:focus-visible,
.aul-appointment-back:focus-visible,
.aul-appointment-segment-btn:focus-visible,
.aul-appointment-month-nav-btn:focus-visible,
.aul-appointment-month-day:focus-visible,
.aul-appointment-slot:focus-visible,
button[data-aul-action="appointment"]:focus-visible,
[role="button"][data-aul-action="appointment"]:focus-visible {
  outline: 2px solid hsl(var(--primary, 322 80% 46%));
  outline-offset: 2px;
}

.aul-appointment-header-icon {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

button[data-aul-action="appointment"],
[role="button"][data-aul-action="appointment"] {
  font-weight: 700;
  color: hsl(var(--primary, 322 80% 46%));
  border: 1px solid hsl(var(--primary, 322 80% 46%) / 0.55);
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  background: hsl(var(--primary, 322 80% 46%) / 0.12);
}

.aul-appointment-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem 1rem 2rem;
  overflow-y: auto;
  background: hsl(var(--background) / 0.72);
  backdrop-filter: blur(4px);
}

.aul-appointment-card {
  width: min(100%, 40rem);
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  border: 1px solid hsl(var(--border));
  border-radius: 0.75rem;
  background: hsl(var(--card));
  padding: 1.25rem 1.5rem 1.5rem;
  box-shadow: 0 12px 40px hsl(var(--foreground) / 0.12);
}

.aul-appointment-back {
  display: inline-flex;
  margin-bottom: 0.75rem;
  border: 0;
  background: transparent;
  color: hsl(var(--primary));
  cursor: pointer;
  font-size: 0.875rem;
  text-decoration: underline;
}

.aul-appointment-title {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.aul-appointment-method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.aul-appointment-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
}

.aul-appointment-field input,
.aul-appointment-field select,
.aul-appointment-field textarea {
  width: 100%;
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  padding: 0.5rem 0.65rem;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}

.aul-appointment-field-invalid {
  /* Border-only invalid; keep labels/legends at foreground color. */
}

.aul-appointment-field-invalid input,
.aul-appointment-field-invalid select,
.aul-appointment-field-invalid textarea {
  border-color: hsl(var(--destructive, 0 72% 38%));
  box-shadow: 0 0 0 1px hsl(var(--destructive, 0 72% 38%) / 0.45);
}

.aul-appointment-calendar.aul-appointment-field-invalid {
  border: 1px solid hsl(var(--destructive, 0 72% 38%));
  border-radius: 0.75rem;
  padding: 0.75rem;
}

.aul-appointment-segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  padding: 0.2rem;
  border-radius: 0.65rem;
  background: hsl(var(--muted) / 0.35);
}

.aul-appointment-segment-btn {
  border: 0;
  border-radius: 0.5rem;
  padding: 0.45rem 0.5rem;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  color: inherit;
}

.aul-appointment-segment-btn.is-active {
  background: hsl(var(--primary, 322 80% 46%));
  color: hsl(var(--primary-foreground, 0 0% 98%));
}

.aul-appointment-segment-btn.is-invalid {
  border: 1px solid hsl(var(--destructive, 0 72% 38%));
  box-shadow: 0 0 0 1px hsl(var(--destructive, 0 72% 38%) / 0.45);
  color: hsl(var(--destructive, 0 72% 38%));
}

.aul-appointment-segment-btn.is-active.is-invalid {
  background: hsl(var(--destructive, 0 72% 38%));
  color: hsl(var(--primary-foreground, 0 0% 98%));
}

.aul-appointment-month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.35rem 0 0.5rem;
}

.aul-appointment-month-title {
  font-weight: 700;
  text-align: center;
  color: hsl(var(--foreground, 0 0% 96%));
}

.aul-appointment-month-nav-btn {
  min-width: 2rem;
  min-height: 2rem;
  border: 1px solid hsl(var(--border));
  border-radius: 0.4rem;
  background: hsl(var(--background));
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.aul-appointment-month-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.aul-appointment-month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.25rem;
  margin: 0.25rem 0 0.75rem;
}

.aul-appointment-weekday {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: hsl(var(--foreground, 0 0% 96%));
}

.aul-appointment-month-pad {
  min-height: 2.1rem;
}

.aul-appointment-month-day {
  min-height: 2.1rem;
  border: 1px solid transparent;
  border-radius: 0.4rem;
  background: hsl(var(--background));
  color: hsl(var(--foreground, 0 0% 96%));
  cursor: pointer;
  font-size: 0.85rem;
}

.aul-appointment-month-day.is-disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.aul-appointment-month-day.is-weekend {
  opacity: 0.28;
  background: hsl(var(--muted) / 0.35);
  cursor: not-allowed;
}

.aul-appointment-month-day.is-selected {
  border-color: hsl(var(--primary, 322 80% 46%));
  background: transparent;
  font-weight: 700;
  color: hsl(var(--foreground, 0 0% 96%));
}

.aul-appointment-calendar-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.aul-appointment-periods {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.aul-appointment-slot {
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  padding: 0.45rem 0.5rem;
  background: hsl(var(--background));
  color: hsl(var(--foreground, 0 0% 96%));
  cursor: pointer;
  font-size: 0.8rem;
  text-align: left;
}

.aul-appointment-slot-selected {
  border-color: hsl(var(--primary));
  background: transparent;
  color: hsl(var(--foreground, 0 0% 96%));
}

.aul-appointment-slot-taken {
  opacity: 0.45;
  cursor: not-allowed;
}

.aul-appointment-error {
  margin: 0.9rem 0 0;
  color: hsl(var(--destructive, 0 72% 38%));
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.35;
}

.aul-appointment-primary {
  margin-top: 0.5rem;
}

.aul-appointment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.aul-appointment-recap-list {
  margin: 0;
}

.aul-appointment-recap-row {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.75rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid hsl(var(--border) / 0.6);
}

.aul-appointment-recap-row dt {
  margin: 0;
  font-weight: 600;
}

.aul-appointment-recap-row dd {
  margin: 0;
}

.aul-appointment-recap-access {
  padding: 0.65rem 0.75rem;
  margin: 0.35rem 0 0.75rem;
  border: 1px solid hsl(var(--primary, 322 80% 46%) / 0.45);
  border-radius: 0.5rem;
  background: hsl(var(--primary, 322 80% 46%) / 0.12);
}

.aul-appointment-recap-access dt,
.aul-appointment-recap-access dd {
  font-size: 1.05rem;
  font-weight: 700;
}

.aul-appointment-recap-proposed {
  margin: 0.85rem 0 0;
  padding: 0.65rem 0.75rem 0.25rem;
  border: 1px solid hsl(var(--border) / 0.8);
  border-radius: 0.5rem;
}

.aul-appointment-recap-proposed .aul-appointment-hint {
  margin: 0 0 0.5rem;
}

.aul-appointment-phones {
  margin: 0 0 1rem;
  padding-left: 1.1rem;
}

.aul-appointment-lookup-entry {
  margin-top: 1rem;
}

