.tr-ui { font: var(--tr-font-md)/var(--tr-line-height) var(--tr-font); color: var(--tr-text); }
.tr-ui *, .tr-ui *::before, .tr-ui *::after { box-sizing: border-box; }
.tr-ui [hidden] { display: none !important; }
.tr-ui :focus-visible { outline: 2px solid var(--tr-focus); outline-offset: 3px; }
:where(.tr-ui) button, :where(.tr-ui) input, :where(.tr-ui) textarea { font: inherit; }
.tr-ui a:not(.tr-btn) { color: inherit; text-underline-offset: 3px; }
.tr-ui h1, .tr-ui h2, .tr-ui h3, .tr-ui p { margin: 0; }
.tr-ui h1, .tr-ui h2 { font-size: var(--tr-font-lg); font-weight: 600; }
.tr-ui h3 { font-size: var(--tr-font-md); font-weight: 600; }
.tr-muted { color: var(--tr-muted); }
.tr-caption { font-size: var(--tr-font-sm); color: var(--tr-label); }
.tr-numeric { font-variant-numeric: tabular-nums; }
.tr-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--tr-space-2);
  min-height: var(--tr-control-height); padding: var(--tr-space-1) var(--tr-space-3);
  border: 1px solid var(--tr-border); border-radius: var(--tr-radius-sm);
  background: var(--tr-control); color: var(--tr-control-text); cursor: pointer;
  white-space: nowrap; text-decoration: none; font-size:var(--tr-font-sm); font-weight:565; line-height:1.36;
  transition: background var(--tr-motion-fast), opacity var(--tr-motion-fast);
}
.tr-btn:hover { background: var(--tr-hover); }
.tr-btn:active { background: var(--tr-selected); }
.tr-btn--primary { background: var(--tr-accent); color: var(--tr-on-accent); border-color: transparent; }
.tr-btn--primary:hover, .tr-btn--primary:active { background: var(--tr-accent-hover); }
.tr-btn--ghost { background: transparent; border-color: transparent; }
.tr-btn--danger { color: var(--tr-danger); }
.tr-btn--icon { width: var(--tr-control-height); padding: var(--tr-space-2); }
.tr-btn:disabled, .tr-btn[aria-disabled='true'], .tr-ui input:disabled { opacity: var(--tr-disabled); cursor: not-allowed; }
.tr-btn[aria-busy='true'] { cursor: progress; }
.tr-icon { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.tr-field { display: grid; gap: var(--tr-space-2); min-width: 0; }
.tr-field > label { color: var(--tr-label); }
.tr-input {
  width: 100%; min-width: 0; min-height: var(--tr-control-height); padding: var(--tr-space-2) var(--tr-space-3);
  border: 1px solid var(--tr-field-border); border-radius: 9px;
  background: var(--tr-field); color: var(--tr-text);
}
textarea.tr-input { resize: vertical; min-height: 100px; }
.tr-input[aria-invalid='true'] { border-color: var(--tr-danger); }
.tr-input:read-only { background: var(--tr-subtle); }
.tr-check { display: inline-flex; align-items: center; gap: var(--tr-space-2); cursor: pointer; }
.tr-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--tr-accent); }
.tr-switch input {
  appearance: none; width: 38px; height: 23px; border: 1px solid var(--tr-field-border);
  border-radius: var(--tr-radius-pill); background: var(--tr-hover); position: relative; cursor: pointer;
}
.tr-switch input::before {
  content: ''; position: absolute; width: 17px; height: 17px; top: 2px; left: 2px;
  border-radius: var(--tr-radius-pill); background: var(--tr-switch-thumb); box-shadow:var(--tr-switch-shadow); transition: transform var(--tr-motion-fast);
}
.tr-switch input:checked { background: var(--tr-switch-on); border-color: var(--tr-switch-on); }
.tr-switch input:checked::before { transform: translateX(15px); background: var(--tr-switch-thumb); }
.tr-segment { display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 2px; background: var(--tr-subtle); border-radius: var(--tr-radius-sm); }
.tr-segment .tr-btn { background: transparent; border-color: transparent; min-height: 29px; }
.tr-segment .tr-btn[aria-checked='true'] { background: var(--tr-control); box-shadow: 0 1px 3px var(--tr-border); }
.tr-tabs { position:relative; display: flex; gap: 16px; overflow-x:auto; border-bottom: 1px solid var(--tr-border); }
.tr-tabs .tr-btn { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; padding:10px 5px; min-height:39px; color:var(--tr-muted); font-weight:490; }
.tr-tabs .tr-btn[aria-selected='true'] { color:var(--tr-text); font-weight:590; border-bottom-color:var(--tr-text); }
.tr-tabs[data-animated] .tr-btn[aria-selected='true'] { border-bottom-color:transparent; }
.tr-tab-indicator { position:absolute; bottom:0; left:0; height:2px; background:var(--tr-text); pointer-events:none; transition:width var(--tr-motion-tabs), transform var(--tr-motion-tabs); }
.tr-message { padding: var(--tr-space-3); border: 1px solid var(--tr-border); border-radius: var(--tr-radius-sm); overflow-wrap: anywhere; }
.tr-message--error { color: var(--tr-danger); border-color: var(--tr-danger); }
.tr-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (forced-colors: active) {
  .tr-switch input { appearance: auto; }
  .tr-switch input::before { display: none; }
  .tr-segment [aria-checked='true'], .tr-tabs [aria-selected='true'] { outline: 2px solid Highlight; }
}

.tr-btn--primary { font-weight:600; }
.tr-btn--primary:hover { opacity:.88; }
.tr-btn--compact { min-height:28px; padding:6px 10px; font-size:var(--tr-font-sm); border-radius:7px; }
.tr-btn--tertiary { background:var(--tr-soft); border-color:transparent; }
.tr-toolbar .tr-btn { min-height:35px; height:35px; border-radius:8px; padding:7px 13px; }
.tr-toolbar .tr-btn--icon { padding:7px; width:35px; }
.tr-field > label { font-size:var(--tr-font-sm); font-weight:550; }
.tr-input { min-height:36px; padding:8px 10px; font-size:var(--tr-font-sm); }
.tr-input-wrap { display:flex; align-items:center; border:1px solid var(--tr-field-border); border-radius:9px; background:var(--tr-field); padding-inline:12px; gap:8px; }
.tr-input-wrap .tr-input { border:0; background:transparent; padding-inline:0; }
.tr-input-wrap:focus-within { outline:2px solid var(--tr-focus); outline-offset:2px; }
.tr-split { display:inline-flex; }
.tr-split > :first-child { border-radius:10px 0 0 10px; }
.tr-split > :last-child { border-radius:0 10px 10px 0; border-left:1px solid var(--tr-border); }
.tr-badge { display:inline-flex; padding:5px 9px; border-radius:100px; background:var(--tr-soft); color:var(--tr-muted); font-size:calc(11px + var(--tr-font-step)); white-space:nowrap; }
.tr-badge[data-tone='success'] { color:var(--tr-success); background:color-mix(in srgb,var(--tr-success) 9%,transparent); }
.tr-badge[data-tone='error'] { color:var(--tr-danger); }
.tr-progress { height:2px; overflow:hidden; background:var(--tr-soft); position:relative; }
.tr-progress::after { content:''; position:absolute; height:2px; width:35%; background:var(--tr-text); animation:tr-progress 1.1s infinite ease-in-out; }
@keyframes tr-progress { from { transform:translateX(-100%); } to { transform:translateX(390%); } }
@media(prefers-reduced-motion:reduce) { .tr-progress::after { animation:none; width:100%; opacity:.4; } }
:root[data-motion='off'] .tr-progress::after { animation:none; width:100%; opacity:.4; }

.tr-textarea { width:100%; min-width:0; min-height:94px; resize:vertical; padding:11px 12px; border:1px solid var(--tr-field-border); border-radius:9px; background:var(--tr-field); color:var(--tr-text); font-size:var(--tr-font-sm); }
.tr-switch { display:inline-flex; align-items:center; gap:9px; cursor:pointer; font-size:var(--tr-font-sm); }
.tr-switch input { flex:none; margin:0; transition:background 150ms; }
.tr-btn { padding:7px 12px; color:var(--tr-text); }
.tr-btn--primary { padding:7px 12px; color:var(--tr-on-accent); border-color:var(--tr-accent); }
.tr-btn--compact { min-height:29px; padding:5px 8px; border-radius:10px; font-size:calc(11px + var(--tr-font-step)); }
.tr-btn--icon { padding:8px; }

.tr-btn--danger { color:var(--tr-danger); }
.tr-btn--icon { width:34px; min-width:34px; padding:6px; }
