/* Display components shared by render (read-only, in chat) and applications.

   Spacing is the container's, and there is one rule for it: a container hands
   its children a gap and insets its own content, both from --ui-gap and
   --ui-pad. A component never carries an outer margin of its own, and a
   component that paints a surface (a box with a border or a fill, a section, a
   clickable outside a dense context) always insets its content, so a panel
   cannot be painted flush. Density is a closed set chosen by the container and
   inherited by everything inside it: tight, normal, roomy. */
:root { --ui-gap: 16px; --ui-pad: 20px; }
.ui-density--tight { --ui-gap: 8px; --ui-pad: 12px; }
.ui-density--normal { --ui-gap: 16px; --ui-pad: 20px; }
.ui-density--roomy { --ui-gap: 24px; --ui-pad: 28px; }
.ui-stack { display: flex; min-width: 0; gap: var(--ui-gap); }
.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 > *, .ui-section > * { min-width: 0; max-width: 100%; }
.ui-grid { display: grid; min-width: 0; gap: var(--ui-gap); 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); }
/* A box that paints is a panel, and a panel insets its content: the gutter
   cannot be forgotten by leaving padding out. */
.ui-box--panel { padding: var(--ui-pad); }
/* A section is a column of blocks, so two children never run together into one
   line of text; its own head is the one pair that sits close. */
.ui-section { display: flex; flex-direction: column; gap: var(--ui-gap); padding: var(--ui-pad); background: var(--panel); }
.ui-section-head { display: flex; flex-direction: column; gap: 6px; }
.ui-section-head > h2 { margin: 0; }
.ui-section-head > .ui-help { margin: 0; }
.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; }
/* A clickable outside a dense context is a card: it paints a panel and insets
   its content. Inside a table cell or a list item the cell or the row is
   already the container, so it adds neither a gutter nor a fill and signals by
   hover instead — the case that used to double a cell's padding. */
.ui-clickable { min-width: 0; padding: var(--ui-pad); border-radius: var(--radius-lg); background: var(--panel); cursor: pointer; transition: background .15s; }
.ui-table td .ui-clickable, .ui-list > li .ui-clickable { padding: 0; background: none; }
/* A card inside a panel steps up to --raised with the ring, the way every other
   nested surface in the kit does: --panel on --panel reads as plain text. */
:is(.ui-section, .ui-box--panel) .ui-clickable { background: var(--raised); box-shadow: var(--ring); }
:is(.ui-section, .ui-box--panel) .ui-clickable:hover:not([aria-disabled=true]) { background: var(--sunken); }
.ui-table td .ui-clickable:hover:not([aria-disabled=true]), .ui-list > li .ui-clickable:hover:not([aria-disabled=true]) { background: var(--hover); border-radius: var(--radius-sm); }
.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; }
/* A heading and the sentence under it are one block: they sit 6px apart however
   far the surrounding children are spaced. */
.ui-heading-block { min-width: 0; }
.ui-heading-block > .ui-help { margin: 4px 0 0; }
.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, and the floor is only half the rule: `break-word` keeps a
   number whole, because a column's minimum stays its longest unbreakable word.
   `anywhere` is what broke it — it shrinks that minimum to one character, so the
   floor decided the layout and digits split mid-number ("$1,28 / 0.44"). Digits
   line up across rows because they are tabular. */
.ui-table th, .ui-table td { min-width: 100px; font-variant-numeric: tabular-nums; }
.ui-table th:first-child, .ui-table td:first-child { min-width: 180px; }
.ui-table td { vertical-align: middle; overflow-wrap: break-word; white-space: normal; }
/* A caption is an annotation on the data, not a title for it, so it is
   metadata: 13px --muted in the table's own 12px/16px cell rhythm rather than
   a heading's weight and an indent of its own. It starts where the first
   column's text starts -- the same gutter the cells carry, which is flush
   inside a panel -- and it wraps inside the table's width, anywhere, so a long
   word can never widen the table it annotates. It paints nothing: no fill, no
   rule, no border. */
.ui-table caption { padding: 12px 16px 0; color: var(--muted); font-size: 13px; font-weight: 400; line-height: 1.6; overflow-wrap: anywhere; 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; }
}
/* A phone is a denser page: the same rule, one step tighter. */
@media (max-width: 700px) { :root { --ui-gap: 12px; --ui-pad: 16px; } .ui-grid { grid-template-columns: minmax(0, 1fr); } }
@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); }
/* A table inside a panel aligns to the panel's gutter on both sides, so the
   first column is not flush on one edge and 16px short on the other. */
.ui-section .ui-table tr > :first-child { padding-left: 0; }
.ui-section .ui-table tr > :last-child { padding-right: 0; }
/* A caption lines up with that first column's text, not with the panel's
   gutter, so it follows the same rule: flush on both sides inside a panel. */
.ui-section .ui-table caption { padding-right: 0; padding-left: 0; }
.ui-section .ui-section { background: var(--raised); box-shadow: var(--ring); }
