/* Display components shared by render (read-only, in chat) and applications. */
.ui-stack { display: flex; min-width: 0; }
.ui-stack--vertical { flex-direction: column; }
.ui-stack--horizontal { flex-direction: row; }
.ui-stack--nowrap { max-width: 100%; overflow-x: auto; }
.ui-stack--nowrap > * { flex-shrink: 0; }
.ui-stack > *, .ui-grid > *, .ui-button-group > * { min-width: 0; max-width: 100%; }
.ui-grid { display: grid; min-width: 0; grid-template-columns: repeat(var(--ui-columns), minmax(0, 1fr)); }
.ui-box, .ui-section { min-width: 0; border-radius: var(--radius-lg); }
.ui-bordered { box-shadow: var(--ring); }
.ui-surface { background: var(--panel); }
.ui-section { padding: 20px 22px; background: var(--panel); }
.ui-section > h2 { margin: 0 0 12px; }
.ui-section > .ui-help { margin: -6px 0 16px; }
.ui-divider { width: 100%; margin: 6px 0; border: 0; border-top: 1px solid var(--line); }
.ui-tabs { min-width: 0; max-width: 100%; }
.ui-tab-list { display: inline-flex; gap: 2px; max-width: 100%; padding: 3px; overflow-x: auto; border-radius: 12px; background: var(--sunken); }
.ui-tab { flex-shrink: 0; padding: 5px 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; font-size: 13.5px; font-weight: 500; }
.ui-tab:hover { color: var(--foreground); }
.ui-tab[aria-selected=true] { background: var(--raised); box-shadow: var(--shadow-sm); color: var(--foreground); }
.ui-tab-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; padding-top: 16px; }
.ui-tab-panel[hidden] { display: none; }
.ui-tab-panel > * { min-width: 0; max-width: 100%; }
.ui-button-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ui-button { align-self: flex-start; }
.ui-button, .ui-menu summary { max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
.ui-button.danger { background: #e5484d; box-shadow: none; color: #fff; }
.ui-button.danger:hover:not(:disabled) { background: #dc3e42; }
.ui-clickable { min-width: 0; padding: 16px; border-radius: var(--radius-lg); background: var(--panel); cursor: pointer; transition: background .15s; }
.ui-clickable:hover:not([aria-disabled=true]) { background: var(--panel-hover); }
.ui-clickable[aria-disabled=true] { cursor: default; }
.ui-link { display: inline-flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.ui-menu { position: relative; align-self: flex-start; min-width: 0; max-width: 100%; }
.ui-menu summary { list-style: none; cursor: pointer; }
.ui-menu summary::-webkit-details-marker { display: none; }
.ui-menu-items { position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; min-width: 190px; max-width: min(320px, 80vw); padding: 4px; border-radius: 12px; background: var(--raised); box-shadow: var(--shadow-md); }
.ui-menu-items .button { display: flex; width: 100%; justify-content: flex-start; min-height: 34px; background: none; box-shadow: none; text-align: left; white-space: normal; }
.ui-menu-items .button:hover:not(:disabled) { background: var(--hover); }
/* A badge is one line: it never breaks its own text, and a row it sits in
   wraps it whole (a horizontal stack wraps by default) rather than squeezing it. */
.ui-badge { display: inline-flex; align-items: center; align-self: flex-start; flex-shrink: 0; height: 22px; padding: 5px 10px; border-radius: 99px; background: var(--sunken); color: var(--foreground); font-size: 12px; font-weight: 500; line-height: 1; text-align: center; white-space: nowrap; }
.ui-badge--blue { background: color-mix(in srgb, #3e63dd 14%, var(--raised)); }
.ui-badge--green { background: color-mix(in srgb, #30a46c 16%, var(--raised)); }
.ui-badge--yellow { background: color-mix(in srgb, #f5d90a 26%, var(--raised)); }
.ui-badge--orange { background: color-mix(in srgb, #f76b15 18%, var(--raised)); }
.ui-badge--red { background: color-mix(in srgb, #e5484d 16%, var(--raised)); }
.ui-banner { padding: 14px 16px; border-radius: var(--radius); background: var(--panel); overflow-wrap: anywhere; }
.ui-banner p { margin: 0; white-space: pre-wrap; }
.ui-banner strong { display: block; margin-bottom: 3px; }
.ui-banner--success { background: color-mix(in srgb, #30a46c 12%, var(--raised)); }
.ui-banner--warning { background: color-mix(in srgb, #f5d90a 20%, var(--raised)); }
.ui-banner--danger { background: color-mix(in srgb, #e5484d 12%, var(--raised)); }
.ui-spinner-label { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; }
.ui-spinner { width: 16px; height: 16px; border: 2px solid var(--line-strong); border-top-color: var(--foreground); border-radius: 50%; animation: ui-spin .8s linear infinite; }
@keyframes ui-spin { to { transform: rotate(360deg); } }
.ui-field { min-width: 0; }
.ui-field > .label { display: block; }
.ui-field .input { width: 100%; max-width: 100%; }
.ui-field input[type=checkbox], .ui-field input[type=radio] { width: 16px; height: 16px; flex-shrink: 0; accent-color: var(--primary); }
.ui-field textarea { resize: vertical; line-height: 1.6; }
.ui-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.ui-choice { display: flex; align-items: center; gap: 9px; padding: 4px 0; cursor: pointer; font-size: 14px; overflow-wrap: anywhere; }
.ui-help { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.ui-drop-zone { padding: 22px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg); background: var(--panel); }
.ui-drop-label { display: block; margin-bottom: 12px; font-size: 14px; font-weight: 500; cursor: pointer; }
.ui-drop-zone input { width: 100%; min-width: 0; font-size: 13px; }
.ui-dragover { border-color: var(--foreground); background: var(--hover); }
.ui-upload-list { padding-left: 18px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.ui-upload-list:empty { display: none; }
/* The table scrolls sideways inside this container, never the page: a wide
   table is clipped here and reachable by scrolling, not laid out badly. */
.ui-table-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
/* Columns keep a floor so a table reads as a grid instead of collapsing into a
   word-per-line column; the table then scrolls inside .table-card rather than
   pushing the page wider than the screen. */
.ui-table th, .ui-table td { min-width: 100px; }
.ui-table th:first-child, .ui-table td:first-child { min-width: 180px; }
.ui-table td { vertical-align: middle; overflow-wrap: anywhere; white-space: normal; }
.ui-table caption { padding: 14px 16px 4px; font-weight: 600; text-align: left; }
.ui-list { margin: 0; padding-left: 22px; }
.ui-list > li + li { margin-top: 6px; }
.ui-icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ui-icon--small { width: 15px; height: 15px; }
.ui-icon--large { width: 26px; height: 26px; }
.ui-heading { margin: 0; font-weight: 600; letter-spacing: -.015em; line-height: 1.3; overflow-wrap: anywhere; }
h1.ui-heading { font-size: 26px; } h2.ui-heading { font-size: 21px; } h3.ui-heading { font-size: 18px; } h4.ui-heading { font-size: 16px; } h5.ui-heading { font-size: 14.5px; } h6.ui-heading { font-size: 13px; }
.ui-copy { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.ui-tone--muted { color: var(--muted); } .ui-tone--success { color: #218358; } .ui-tone--danger { color: #dc3e42; }
.ui-weight--normal { font-weight: 400; } .ui-weight--medium { font-weight: 500; } .ui-weight--bold { font-weight: 650; }
.ui-image { display: block; align-self: flex-start; min-width: 0; max-width: 100%; }
.ui-image img { display: block; max-width: 100%; height: auto; border-radius: var(--radius); cursor: zoom-in; }
.ui-image img[hidden], .ui-image-fallback[hidden] { display: none; }
.ui-image-fallback { color: var(--muted); }
#application-error { white-space: pre-wrap; overflow-wrap: anywhere; }
#application-ui { min-width: 0; line-height: 1.6; }
#application-ui[aria-busy=true] { opacity: .65; }
#application-ui [inert] { opacity: .5; }
@media (max-width: 800px) {
  .ui-menu-items { position: static; min-width: 0; max-width: 100%; margin-top: 6px; }
}
@media (max-width: 700px) { .ui-grid { grid-template-columns: minmax(0, 1fr); } .ui-section { padding: 16px; } }
@media (prefers-reduced-motion: reduce) { .ui-spinner { animation: none; } }
/* A panel inside a panel flattens: depth only reads at one level. */
.ui-section .table-card, .ui-clickable .table-card, .ui-bordered .table-card { border-radius: 0; background: transparent; box-shadow: none; }
:is(.ui-section, .ui-clickable, .ui-surface) :is(.ui-badge--gray, .ui-banner--info) { background: var(--raised); }
.ui-section .ui-table th:first-child, .ui-section .ui-table td:first-child { padding-left: 0; }
.ui-section .ui-section { background: var(--raised); box-shadow: var(--ring); }
