:root {
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #1e293b;
  background: #f5f7fa;
  font-synthesis: none;
  --border: #e2e8f0;
  --muted: #64748b;
  --blue: #2563eb;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, section:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.workspace { display: grid; grid-template-columns: 23rem minmax(0, 1fr); gap: .75rem; height: 100dvh; padding: .75rem; transition: grid-template-columns .2s; }
.sidebar, .chat-panel { min-height: 0; border: 1px solid var(--border); border-radius: 1.35rem; background: white; box-shadow: 0 10px 24px #0f172a0d; }
.sidebar { display: flex; flex-direction: column; padding: 1rem; overflow: hidden; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: 1.5rem; }
.brand { display: flex; gap: .65rem; align-items: center; color: #0f172a; text-decoration: none; letter-spacing: .04em; }
.brand img { width: 2.4rem; height: 2.4rem; object-fit: contain; }
.icon-button { width: 2rem; height: 2rem; flex-shrink: 0; display: grid; place-items: center; border: 1px solid var(--border); border-radius: .5rem; background: white; color: var(--muted); }
.icon-button:hover { color: var(--blue); background: #eff6ff; }
.new-conversation { display: flex; align-items: center; justify-content: center; gap: .65rem; padding: .75rem; border-radius: .65rem; background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; font-size: .9rem; font-weight: 600; white-space: nowrap; }
.new-conversation > span:first-child { font-size: 1.25rem; line-height: 1; }
.search-wrap { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--border); border-radius: .6rem; margin-top: 1.2rem; padding: .5rem .7rem; color: var(--muted); }
.search-wrap input { width: 100%; min-width: 0; border: 0; padding: .15rem; color: inherit; background: transparent; font-size: .85rem; }
.section-title { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 1.5rem 0 .65rem; }
.conversation-list { flex: 1; min-height: 0; overflow-y: auto; }
.history-item { width: 100%; border: 1px solid transparent; background: transparent; border-radius: .65rem; text-align: left; padding: .75rem; margin: .1rem 0; color: #334155; }
.history-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; font-weight: 500; }
.history-item time { display: block; margin-top: .3rem; color: var(--muted); font-size: .72rem; }
.history-item:hover, .history-item.active { background: #eff6ff; color: #1e40af; }
.history-item.active { border-color: #dbeafe; }
.empty-history { padding: 1.5rem .5rem; font-size: .85rem; color: var(--muted); text-align: center; line-height: 1.6; }
.sidebar-footer { padding: 1rem 0 0; margin-top: .75rem; border-top: 1px solid var(--border); font-size: .75rem; color: var(--muted); display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
.status-dot { width: .4rem; height: .4rem; background: #22a06b; border-radius: 50%; flex-shrink: 0; }
.chat-panel { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); }
.header-title-group { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.heading { min-width: 0; }
.eyebrow { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 .15rem; }
h1 { font-size: 1rem; line-height: 1.4; margin: 0; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.agent-badge { flex-shrink: 0; padding: .45rem .7rem; border: 1px solid var(--border); border-radius: .65rem; font-size: .75rem; font-weight: 600; }
.agent-badge span { color: var(--muted); font-weight: 400; }
.header-actions { display: flex; gap: .75rem; align-items: center; }
.chat-language { width: 9.5rem; max-width: 100%; padding: .4rem; border: 1px solid var(--border); border-radius: .55rem; background: white; color: #334155; font: inherit; font-size: .78rem; }
.configuration-link { color: var(--blue); font-size: .8rem; }
.mobile-menu { display: none; }
.notice { margin: .75rem 1rem 0; padding: .8rem 1rem; background: #fffbeb; border: 1px solid #fde68a; border-radius: .65rem; color: #92400e; font-size: .85rem; line-height: 1.5; }
.chat-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-body.empty { justify-content: center; overflow-y: auto; }
.welcome { text-align: center; padding: 2rem 1.5rem .75rem; max-width: 52rem; width: 100%; margin: 0 auto; }
.maria-logo { width: 5rem; height: 5rem; object-fit: contain; }
.welcome h2 { font-size: 1.5rem; margin: .75rem 0 .5rem; font-weight: 600; }
.welcome p { color: var(--muted); line-height: 1.7; max-width: 36rem; margin: 0 auto 1.6rem; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; }
.suggestion { border: 1px solid var(--border); border-radius: .85rem; padding: .7rem .9rem; background: white; color: #475569; font-size: .84rem; text-align: left; transition: background .2s; }
.suggestion:hover { border-color: #93c5fd; background: #eff6ff; color: #1d4ed8; }
.composer-area { flex-shrink: 0; width: 100%; max-width: 54rem; margin: 0 auto; padding: .3rem 1.5rem .7rem; }
.empty .composer-area { padding-top: .5rem; }
.composer { border: 1px solid var(--border); border-radius: 1.25rem; box-shadow: 0 8px 30px #0f172a14; background: white; padding: .9rem 1rem .65rem; }
.composer:focus-within { border-color: #94a3b8; box-shadow: 0 10px 30px #0f172a1a; }
textarea { display: block; width: 100%; min-height: 3.5rem; max-height: 9rem; resize: vertical; border: 0; background: transparent; color: #1e293b; line-height: 1.55; font-size: .95rem; }
textarea:focus-visible { outline-offset: 2px; border-radius: .25rem; }
textarea::placeholder { color: #94a3b8; }
.composer-footer { display: flex; align-items: center; gap: 1rem; justify-content: space-between; border-top: 1px dashed var(--border); padding-top: .45rem; }
.composer-footer > span { color: var(--muted); font-size: .68rem; }
.send-button { border: 0; width: 2.2rem; height: 2.2rem; background: var(--blue); color: white; border-radius: .7rem; font-size: 1.4rem; }
.stop-button { border: 1px solid #bfdbfe; border-radius: .65rem; background: #eff6ff; color: #1d4ed8; padding: .5rem .7rem; font-size: .8rem; }
.disclaimer { color: var(--muted); text-align: center; font-size: .7rem; margin: .75rem 0 .2rem; }
.turn-status { color: #1d4ed8; min-height: 1.1rem; margin: .2rem 0 .45rem; font-size: .78rem; }
.turn-status:not(:empty)::before { content: ''; display: inline-block; width: .45rem; height: .45rem; margin-right: .5rem; border-radius: 50%; background: currentColor; animation: activity-pulse 1.5s ease-in-out infinite; }
@keyframes activity-pulse { 50% { opacity: .3; } }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 1.5rem max(1.5rem, calc((100% - 50rem) / 2)); scroll-behavior: smooth; }
.message { display: flex; gap: .8rem; margin-bottom: 1.7rem; min-width: 0; }
.message.user { justify-content: flex-end; }
.message-avatar { width: 2rem; height: 2rem; flex-shrink: 0; object-fit: contain; }
.message-body { min-width: 0; max-width: 100%; }
.message.assistant .message-body { flex: 1; }
.message.user .message-body { max-width: 85%; background: #eff6ff; border: 1px solid #dbeafe; border-radius: 1rem 1rem .25rem 1rem; padding: .8rem 1rem; }
.message-name { font-size: .8rem; font-weight: 600; color: #334155; margin: .25rem 0 .5rem; }
.message-text { font-size: .95rem; line-height: 1.8; overflow-wrap: anywhere; color: #334155; }
.message-text p { margin: 0 0 .9rem; white-space: pre-wrap; }
.message-text > :first-child { margin-top: 0; }
.message-text > :last-child, .message-text li > :last-child, .message-text blockquote > :last-child { margin-bottom: 0; }
.message-text h2, .message-text h3, .message-text h4, .message-text h5, .message-text h6 { color: #0f172a; line-height: 1.4; font-weight: 650; margin: 1.5rem 0 .65rem; }
.message-text h2 { font-size: 1.3rem; }
.message-text h3 { font-size: 1.15rem; }
.message-text h4 { font-size: 1.05rem; }
.message-text h5, .message-text h6 { font-size: .95rem; }
.message-text strong { color: #1e293b; font-weight: 650; }
.message-text ul, .message-text ol { padding-left: 1.6rem; margin: .4rem 0 1rem; }
.message-text li { padding-left: .2rem; margin: .35rem 0; }
.message-text li::marker { color: #64748b; }
.message-text li > p { margin-bottom: .35rem; }
.message-text li > ul, .message-text li > ol { margin-top: .3rem; margin-bottom: .5rem; }
.message-text blockquote { margin: 1rem 0; padding: .7rem 1rem; border-left: 3px solid #93c5fd; border-radius: 0 .5rem .5rem 0; background: #f8fafc; color: #475569; }
.message-text hr { border: 0; border-top: 1px solid var(--border); margin: 1.4rem 0; }
.message-text a { color: #1d4ed8; text-underline-offset: .2em; text-decoration-thickness: 1px; }
.message-text a:hover { color: #1e40af; }
.message-text code { font-family: Consolas, 'SFMono-Regular', monospace; background: #f1f5f9; padding: .15rem .35rem; border-radius: .3rem; font-size: .86em; }
.message-text pre { max-width: 100%; overflow-x: auto; margin: 1rem 0; padding: 1rem; border: 1px solid var(--border); border-radius: .7rem; background: #f8fafc; line-height: 1.65; white-space: pre; overflow-wrap: normal; tab-size: 4; }
.message-text pre code { padding: 0; border-radius: 0; background: transparent; font-size: .85rem; }
.markdown-table { max-width: 100%; overflow-x: auto; margin: 1rem 0; border: 1px solid var(--border); border-radius: .7rem; }
.message-text table { width: 100%; border-collapse: collapse; font-size: .88rem; line-height: 1.6; }
.message-text th, .message-text td { min-width: 8rem; padding: .65rem .85rem; vertical-align: top; border-bottom: 1px solid var(--border); }
.message-text th { background: #f1f5f9; font-weight: 600; color: #1e293b; }
.message-text tbody tr:nth-child(even) { background: #f8fafc; }
.message-text tbody tr:last-child td { border-bottom: 0; }
.message-text .align-left { text-align: left; }
.message-text .align-center { text-align: center; }
.message-text .align-right { text-align: right; }
.message-text [tabindex]:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.message-meta { font-size: .7rem; color: var(--muted); margin-top: .6rem; display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.copy-button { border: 0; color: var(--muted); background: transparent; padding: .2rem 0; font-size: .72rem; }
.copy-button:hover { color: var(--blue); }
.message.interrupted .message-status { color: #92400e; }
.message.running .message-status { color: #1d4ed8; }
.message.running .message-status::before { content: ''; display: inline-block; width: .45rem; height: .45rem; margin-right: .5rem; border-radius: 50%; background: currentColor; animation: activity-pulse 1.5s ease-in-out infinite; }
.provider-block { margin: .5rem 0 1rem; min-width: 0; }
.provider-author { color: var(--muted); font-size: .7rem; margin: 0 0 .4rem; }
.provider-content details { border: 1px solid var(--border); border-radius: .5rem; padding: .5rem .7rem; font-size: .78rem; }
.provider-content summary { cursor: pointer; overflow-wrap: anywhere; }
.provider-content pre { overflow: auto; max-height: 20rem; background: #f8fafc; padding: .6rem; font-size: .75rem; }
.provider-content summary:focus-visible, .provider-content pre:focus-visible { outline: 2px solid var(--blue); }
.provider-visibility, .provider-limit { color: var(--muted); font-size: .74rem; line-height: 1.5; }
.provider-raw { margin: .6rem 0; color: var(--muted); font-size: .75rem; }
.provider-raw summary { cursor: pointer; }
.provider-raw pre { max-height: 22rem; overflow: auto; padding: .6rem; background: #f8fafc; color: #334155; }
.trace-toggle { border: 1px solid #bfdbfe; border-radius: .55rem; background: #eff6ff; color: #1d4ed8; padding: .4rem .65rem; font-size: .8rem; }
.trace-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #fff; border: 1px solid var(--border); border-radius: 1.35rem; overflow: hidden; }
.trace-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1rem .5rem; }
.trace-header h2 { margin: 0; font-size: 1rem; }
.trace-description { margin: 0; padding: .3rem 1rem .75rem; color: var(--muted); font-size: .74rem; line-height: 1.6; }
.trace-controls { padding: 0 1rem; border-bottom: 1px solid var(--border); }
.trace-controls label { display: flex; flex-direction: column; gap: .3rem; min-width: 0; font-size: .72rem; color: var(--muted); }
.trace-controls select { min-width: 0; width: 100%; background: #fff; color: #334155; border: 1px solid var(--border); border-radius: .45rem; padding: .4rem; font: inherit; }
.trace-controls select:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.trace-filters { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: .6rem 0; }
.trace-toolbar { display: flex; align-items: center; gap: .6rem; justify-content: space-between; }
.trace-toolbar p { color: #475569; font-size: .7rem; }
.trace-toolbar button { flex-shrink: 0; }
.trace-limited { color: #92400e; font-size: .72rem; line-height: 1.5; }
.trace-limited:empty { display: none; }
.trace-controls > label + label { margin-top: .6rem; }
.trace-live-status { color: #1d4ed8; font-size: .74rem; line-height: 1.6; white-space: pre-line; margin: .3rem 0 .65rem; }
.trace-live-status:empty { display: none; }
.trace-updates { margin-top: .6rem; border-top: 1px solid var(--border); }
.trace-updates ol { max-height: 17rem; overflow: auto; margin: .2rem 0; padding: .3rem .3rem .3rem 1.6rem; }
.trace-updates li { padding: .3rem 0; border-bottom: 1px solid var(--border); }
.trace-empty { padding: 1rem; color: var(--muted); font-size: .8rem; line-height: 1.6; }
.trace-events { flex: 1; min-height: 0; overflow: auto; padding: .8rem; }
.trace-card { margin-bottom: .65rem; border: 1px solid var(--border); border-radius: .6rem; background: #fff; overflow-wrap: anywhere; }
.trace-card summary { cursor: pointer; padding: .65rem; font-size: .76rem; }
.trace-card summary:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.trace-card-heading { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .35rem; max-width: 100%; }
.trace-card-heading strong { font-weight: 600; }
.trace-card-meta { display: block; color: var(--muted); font-size: .68rem; margin-top: .4rem; }
.trace-status { color: #475569; background: #f1f5f9; padding: .12rem .35rem; border-radius: .3rem; font-size: .65rem; }
.trace-status.running { color: #1d4ed8; background: #eff6ff; }
.trace-status.running::before { content: ''; display: inline-block; width: .35rem; height: .35rem; border-radius: 50%; background: currentColor; margin-right: .3rem; animation: activity-pulse 1.5s ease-in-out infinite; }
.trace-status.completed { color: #166534; background: #f0fdf4; }
.trace-status.failed { color: #991b1b; background: #fef2f2; }
.trace-status.cancelled, .trace-status.interrupted { color: #92400e; background: #fffbeb; }
.trace-card-body { border-top: 1px solid var(--border); padding: .6rem; font-size: .72rem; }
.trace-card-body h4 { margin: .5rem 0; font-size: .72rem; }
.trace-card-body p { margin: .35rem 0; }
.trace-card pre { max-height: 22rem; overflow: auto; white-space: pre; padding: .7rem; margin: .4rem 0; border-radius: .4rem; background: #f8fafc; font-size: .7rem; line-height: 1.6; }
.trace-card pre:focus-visible { outline: 2px solid var(--blue); }
.trace-depth-1 { margin-left: .35rem; border-left: 2px solid #bfdbfe; }
.trace-depth-2 { margin-left: .7rem; border-left: 2px solid #93c5fd; }
.trace-depth-3 { margin-left: 1.05rem; border-left: 2px solid #60a5fa; }
.trace-depth-4 { margin-left: 1.4rem; border-left: 2px solid #3b82f6; }
.trace-backdrop { position: fixed; inset: 0; background: #0f172a66; z-index: 19; border: 0; }
@media (min-width: 1280px) {
  .workspace.trace-open { grid-template-columns: 17rem minmax(0, 1fr) minmax(21rem, 27vw); }
  .workspace.trace-open.collapsed { grid-template-columns: 4.5rem minmax(0, 1fr) minmax(21rem, 27vw); }
  .trace-open .agent-badge { display: none; }
}
@media (max-width: 1279px) {
  .trace-panel { position: fixed; inset: .65rem .65rem .65rem auto; width: min(29rem, calc(100vw - 1.3rem)); z-index: 20; box-shadow: 0 12px 40px #0f172a33; }
}
.workspace.collapsed { grid-template-columns: 4.5rem minmax(0, 1fr); }
.collapsed .sidebar { padding: .75rem .4rem; align-items: center; }
.collapsed .sidebar-header { flex-direction: column; margin-bottom: .7rem; }
.collapsed .brand strong, .collapsed .sidebar-copy, .collapsed .search-wrap, .collapsed .conversation-list { display: none; }
.collapsed .sidebar-footer { margin-top: auto; padding-bottom: .5rem; }
.collapsed .new-conversation { padding: .65rem; }
.backdrop { position: fixed; inset: 0; background: #0f172a66; z-index: 9; border: 0; }
@media (max-width: 991px) {
  .workspace, .workspace.collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .mobile-menu { display: grid; }
  .workspace.menu-open .sidebar { position: fixed; display: flex; inset: .75rem auto .75rem .75rem; width: min(23rem, calc(100vw - 2rem)); z-index: 10; }
}
@media (max-width: 576px) {
  .workspace { padding: .4rem; }
  .chat-header { padding: .8rem; gap: .5rem; }
  .agent-badge { display: none; }
  .header-actions { gap: .45rem; }
  .chat-language { width: 7.5rem; font-size: .7rem; }
  .agent-badge span { display: none; }
  .welcome { padding: 1.2rem 1rem .5rem; }
  .maria-logo { width: 3.5rem; height: 3.5rem; }
  .welcome p { font-size: .9rem; margin-bottom: 1rem; }
  .suggestions { gap: .4rem; }
  .suggestion { font-size: .78rem; padding: .55rem .65rem; }
  .composer-area { padding-left: .8rem; padding-right: .8rem; }
  .messages { padding: 1rem; }
  .message { gap: .5rem; }
  .composer-footer > span { font-size: .6rem; }
}
@media (prefers-reduced-motion: reduce) {
  .message.running .message-status::before { animation: none !important; }
  .trace-status.running::before { animation: none !important; }
  .turn-status::before { animation: none !important; }
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
