/* Sizewise workspace. Root rules are scoped to .uwapp-root.uwapp-sizewise (the body carries the app class too).
   Light and dark tokens follow html[data-theme] / prefers-color-scheme. No animations. */
.uwapp-root.uwapp-sizewise {
  --sw-bg: #f6f3f8; --sw-surface: #ffffff; --sw-surface-2: #f0e9f3; --sw-ink: #1f1a24; --sw-muted: #57506a; --sw-paper: #ffffff;
  --sw-line: #ddd3e3; --sw-control: #776e89; --sw-accent: #a21caf; --sw-accent-ink: #86198f; --sw-on-accent: #ffffff;
  --sw-warn: #9a3412; --sw-focus: #b45309; --sw-lived: #475569; --sw-future: #94a3b8;
  background: var(--sw-bg); color: var(--sw-ink); color-scheme: light;
}
:root[data-theme="dark"] .uwapp-root.uwapp-sizewise {
  --sw-bg: #15111a; --sw-surface: #1f1a26; --sw-surface-2: #2a2333; --sw-ink: #f1ecf5; --sw-muted: #c3b8cf; --sw-paper: #1f1a26;
  --sw-line: #3b3346; --sw-control: #9a8fae; --sw-accent: #f0abfc; --sw-accent-ink: #f5c2fd; --sw-on-accent: #2a0a2f;
  --sw-warn: #fdba74; --sw-focus: #fbbf24; --sw-lived: #a5b4c8; --sw-future: #5b6474;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .uwapp-root.uwapp-sizewise {
    --sw-bg: #15111a; --sw-surface: #1f1a26; --sw-surface-2: #2a2333; --sw-ink: #f1ecf5; --sw-muted: #c3b8cf; --sw-paper: #1f1a26;
    --sw-line: #3b3346; --sw-control: #9a8fae; --sw-accent: #f0abfc; --sw-accent-ink: #f5c2fd; --sw-on-accent: #2a0a2f;
    --sw-warn: #fdba74; --sw-focus: #fbbf24; --sw-lived: #a5b4c8; --sw-future: #5b6474;
    color-scheme: dark;
  }
}

/* Platform element defaults (buttons, tables, code) leak into app workspaces: reset them at zero specificity. */
:where(.sw-app) button { font: inherit; font-size: .9rem; font-weight: 600; padding: 0; border: 0; border-radius: 8px; background: none; color: inherit; cursor: pointer; width: auto; min-height: 0; }
:where(.sw-app) button:hover { background: none; }
:where(.sw-app) :is(input, select, textarea) { font: inherit; color: var(--sw-ink); background: var(--sw-surface); border: 1px solid var(--sw-control); border-radius: 8px; }
:where(.sw-app) table { border-collapse: collapse; width: 100%; margin: 0; font-size: .92rem; }
:where(.sw-app) :is(th, td) { text-align: start; padding: 6px 8px; border-bottom: 1px solid var(--sw-line); }
:where(.sw-app) thead th { background: var(--sw-surface-2); color: var(--sw-ink); }
:where(.sw-app) kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; padding: 1px 6px; border: 1px solid var(--sw-control); border-bottom-width: 2px; border-radius: 5px; background: var(--sw-surface-2); color: var(--sw-ink); white-space: nowrap; }
:where(.sw-app) a { color: var(--sw-accent-ink); }

.sw-tab, .sw-menu-btn, .sw-menu-item, .sw-icon-btn, .sw-title, .sw-obj, .sw-link-btn, .sw-card { background: transparent; color: var(--sw-ink); }
.sw-app { display: flex; flex-direction: column; flex: 1; min-height: 0; background: var(--sw-bg); color: var(--sw-ink); }
.sw-app :focus-visible { outline: 3px solid var(--sw-focus); outline-offset: 2px; }
.sw-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.sw-spacer { flex: 1; }
.sw-hint { color: var(--sw-muted); font-size: .85rem; margin: .2rem 0 .5rem; }
.sw-warn { color: var(--sw-warn); font-weight: 600; font-size: .9rem; }
.sw-note { font-size: .88rem; color: var(--sw-muted); background: var(--sw-surface-2); border-radius: 8px; padding: .55rem .75rem; }
.sw-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; }
.sw-wide { width: 100%; box-sizing: border-box; }

/* ---------- buttons */
.sw-btn { display: inline-flex; align-items: center; gap: .35rem; min-height: 34px; padding: .35rem .75rem; border: 1px solid var(--sw-control); border-radius: 8px; background: var(--sw-surface); color: var(--sw-ink); font-size: .88rem; }
.sw-btn:hover:not([disabled]) { background: var(--sw-surface-2); }
.sw-btn[disabled], .sw-icon-btn[disabled] { opacity: .5; cursor: not-allowed; }
.sw-btn-primary, :is(.sw-app, .sw-dialog) button[type=submit].sw-btn-primary { background: var(--sw-accent); border-color: var(--sw-accent); color: var(--sw-on-accent); }
.sw-btn-primary:hover:not([disabled]), :is(.sw-app, .sw-dialog) button[type=submit].sw-btn-primary:hover:not([disabled]) { background: var(--sw-accent-ink); border-color: var(--sw-accent-ink); color: var(--sw-on-accent); }
.sw-icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 1px solid transparent; border-radius: 8px; color: var(--sw-ink); }
.sw-icon-btn:hover:not([disabled]) { background: var(--sw-surface-2); border-color: var(--sw-line); }
.sw-mute[aria-pressed="true"] { background: var(--sw-surface-2); border-color: var(--sw-warn); color: var(--sw-warn); }

/* ---------- toolbar */
.sw-toolbar { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .5rem .9rem; background: var(--sw-surface); border-bottom: 1px solid var(--sw-line); }
.sw-tb-group { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; min-width: 0; }
.sw-menus { gap: .15rem; }
.sw-menu-wrap { position: relative; }
.sw-menu-btn { display: inline-flex; align-items: center; gap: .2rem; min-height: 34px; padding: .3rem .6rem; border-radius: 8px; color: var(--sw-ink); }
.sw-menu-btn:hover, .sw-menu-btn[aria-expanded="true"] { background: var(--sw-surface-2); }
.sw-menu { position: absolute; z-index: 30; inset-inline-start: 0; top: calc(100% + 4px); min-width: 15rem; max-width: min(22rem, 92vw); padding: .3rem; background: var(--sw-surface); border: 1px solid var(--sw-control); border-radius: 10px; box-shadow: 0 12px 30px rgb(0 0 0 / .22); }
.sw-menu[hidden] { display: none; }
.sw-menu-item { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 1rem; min-height: 32px; padding: .35rem .6rem; border-radius: 6px; text-align: start; font-weight: 500; color: var(--sw-ink); }
.sw-menu-item:hover, .sw-menu-item:focus { background: var(--sw-surface-2); }
.sw-menu-item[aria-disabled="true"] { color: var(--sw-muted); cursor: not-allowed; }
.sw-menu-key { color: var(--sw-muted); font-size: .78rem; font-weight: 600; }
.sw-menu-sep { height: 1px; margin: .3rem .2rem; background: var(--sw-line); }
/* ---------- dialogs */
.sw-dialog { width: min(32rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); padding: 0; border: 1px solid var(--sw-control); border-radius: 14px; background: var(--sw-surface); color: var(--sw-ink); box-shadow: 0 24px 60px rgb(0 0 0 / .35); }
.sw-dialog-wide { width: min(46rem, calc(100vw - 2rem)); }
.sw-dialog::backdrop { background: rgb(12 10 30 / .55); }
.sw-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1rem .4rem; }
.sw-dialog-head h2 { margin: 0; font-size: 1.15rem; }
.sw-dialog-lede { margin: 0; padding: 0 1rem; color: var(--sw-muted); font-size: .9rem; }
.sw-dialog-body { padding: .6rem 1rem 1rem; }
.sw-dialog-body > label { display: block; font-weight: 600; font-size: .85rem; margin: .3rem 0 .2rem; }
.sw-dialog-body :is(input[type=text], textarea) { padding: .4rem .55rem; }
.sw-dialog-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .8rem; }
.sw-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .6rem; }
.sw-card { display: flex; flex-direction: column; gap: .35rem; padding: .7rem .8rem; border: 1px solid var(--sw-line); border-radius: 12px; background: var(--sw-surface); text-align: start; }
.sw-card:hover { border-color: var(--sw-accent); }
.sw-card span { color: var(--sw-muted); font-weight: 400; font-size: .86rem; }
.sw-recent { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.sw-recent li { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.sw-link-btn { color: var(--sw-accent-ink); text-decoration: underline; }
.sw-muted { color: var(--sw-muted); font-size: .85rem; }

/* ---------- title + tabs */
.sw-title { font-size: 1rem; font-weight: 700; padding: .3rem .5rem; border-radius: 8px; max-width: 24rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-title:hover { background: var(--sw-surface-2); }
.sw-tabs { flex: none; display: flex; gap: .2rem; padding: .3rem .7rem 0; overflow-x: auto; background: var(--sw-surface); border-bottom: 1px solid var(--sw-line); }
.sw-tab { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .75rem; border-radius: 8px 8px 0 0; white-space: nowrap; color: var(--sw-muted); border-bottom: 3px solid transparent; min-height: 40px; }
.sw-tab[aria-selected="true"] { color: var(--sw-ink); border-bottom-color: var(--sw-accent); background: var(--sw-surface-2); }
.sw-tab:hover { color: var(--sw-ink); }
.sw-tab-key { display: inline-grid; place-items: center; width: 1.2rem; height: 1.2rem; border-radius: 4px; font-size: .72rem; border: 1px solid var(--sw-line); color: var(--sw-muted); }


/* ---------- layout */
.sw-main { position: relative; flex: 1; min-height: 0; min-width: 0; overflow-y: auto; }
.sw-main:focus { outline: none; }
.sw-view { display: grid; grid-template-columns: minmax(17rem, 21rem) minmax(0, 1fr); min-height: 100%; }
.sw-controls { padding: .8rem .9rem; border-inline-end: 1px solid var(--sw-line); background: var(--sw-surface); min-width: 0; }
.sw-stage { padding: .9rem 1rem 1.2rem; min-width: 0; }
.sw-field { display: grid; gap: .2rem; margin: 0 0 .6rem; min-width: 0; }
.sw-field label { font-weight: 600; font-size: .85rem; }
.sw-field :is(select, input, textarea) { min-height: 36px; padding: .25rem .5rem; min-width: 0; width: 100%; box-sizing: border-box; }
.sw-field input[type=range] { padding: 0; border: 0; background: none; accent-color: var(--sw-accent); }
.sw-row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .6rem; }
.sw-btn-small { white-space: nowrap; min-height: 30px; padding: .2rem .55rem; font-size: .82rem; margin-bottom: .6rem; }
.sw-check { display: flex; align-items: flex-start; gap: .5rem; margin: .2rem 0 .5rem; font-size: .9rem; }
.sw-check input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--sw-accent); }
.sw-section { background: var(--sw-surface); border: 1px solid var(--sw-line); border-radius: 14px; padding: .8rem .9rem; min-width: 0; margin-bottom: .9rem; }
.sw-controls .sw-section { border: 0; padding: 0; margin-bottom: 1rem; }
.sw-section > h2 { margin: 0 0 .6rem; font-size: 1.05rem; }
.sw-table-wrap { overflow-x: auto; max-width: 100%; }
.sw-table-wrap table { min-width: 28rem; }
.sw-table-wrap tbody th { font-weight: 600; }
.sw-table-wrap td { font-variant-numeric: tabular-nums; }
.sw-empty { color: var(--sw-muted); font-size: 1rem; padding: 2rem 0; }
.sw-figure { margin: .6rem 0 1rem; }
.sw-svg { width: 100%; height: auto; display: block; border-radius: 10px; border: 1px solid var(--sw-line); }
.sw-figure-light .sw-svg { background: #ffffff; }
.sw-figure-grid .sw-svg { max-width: 44rem; }
.sw-figure figcaption { margin-top: .35rem; }
.sw-results { list-style: none; margin: 0 0 .6rem; padding: 0; max-height: 15rem; overflow-y: auto; border: 1px solid var(--sw-line); border-radius: 10px; }
.sw-results li { border-bottom: 1px solid var(--sw-line); }
.sw-results li:last-child { border-bottom: 0; }
.sw-results > li.sw-muted { padding: .5rem .6rem; }
.sw-pick { display: flex; width: 100%; align-items: center; gap: .45rem; padding: .4rem .6rem; text-align: start; font-weight: 500; color: var(--sw-ink); background: transparent; min-height: 36px; }
.sw-pick:hover { background: var(--sw-surface-2); }
.sw-pick-name { flex: 1; min-width: 0; }
.sw-inline-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 .5rem; align-items: start; }
.sw-inline-form .sw-btn { grid-column: 1 / -1; justify-self: start; }
.sw-list { margin: 0 0 .6rem; padding-inline-start: 1.4rem; display: grid; gap: .15rem; }
.sw-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .1rem .4rem; }
.sw-list-name { flex: 1 1 8rem; min-width: 0; overflow-wrap: anywhere; }
.sw-list-btns { display: inline-flex; gap: 0; }
.sw-icon-btn.sw-small { width: 30px; height: 30px; }
.sw-zoombar { display: flex; flex-wrap: wrap; align-items: end; gap: .3rem .5rem; }
.sw-zoombar .sw-field { flex: 1 1 14rem; margin: 0; }
.sw-hero-number { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .7rem; margin: 0 0 .8rem; font-size: 1.05rem; }
.sw-hero-value { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; color: var(--sw-accent-ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sw-big-ratio { font-size: 1.05rem; font-weight: 600; }
.sw-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .3rem 1rem; margin: 0 0 1rem; font-size: .93rem; }
.sw-facts dt { color: var(--sw-muted); }
.sw-facts dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.sw-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 0 .7rem; }
.sw-chip { padding: .25rem .6rem; min-height: 30px; border: 1px solid var(--sw-control); border-radius: 999px; color: var(--sw-ink); font-weight: 500; font-size: .85rem; background: var(--sw-surface); }
.sw-chip:hover { background: var(--sw-surface-2); }
.sw-digits pre { white-space: pre-wrap; word-break: break-all; font-size: .85rem; max-height: 12rem; overflow: auto; background: var(--sw-surface-2); color: var(--sw-ink); padding: .6rem; border-radius: 8px; }
.sw-digits summary { cursor: pointer; font-weight: 600; margin-bottom: .4rem; }
.sw-counter-box { display: grid; justify-items: start; gap: .3rem; padding: 1rem 1.1rem; margin-bottom: 1rem; border: 1px solid var(--sw-line); border-radius: 14px; background: var(--sw-surface); }
.sw-counter-label { margin: 0; font-weight: 600; }
.sw-counter { font-size: clamp(1.8rem, 5vw, 3rem); font-weight: 800; font-variant-numeric: tabular-nums; color: var(--sw-accent-ink); overflow-wrap: anywhere; }
.sw-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; }
.sw-inline-form .sw-hint { margin-bottom: 0; }

/* ---------- status bar */
.sw-status { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem; padding: .35rem .9rem; border-top: 1px solid var(--sw-line); background: var(--sw-surface); font-size: .82rem; color: var(--sw-muted); }
.sw-status-text { color: var(--sw-ink); font-weight: 600; }

.uwapp-root.uwapp-sizewise [hidden], .sw-dialog [hidden] { display: none !important; }

@media (forced-colors: active) {
  .sw-tab[aria-selected="true"] { border-bottom-color: Highlight; }
}
@media (max-width: 900px) {
  .sw-view { grid-template-columns: 1fr; }
  .sw-controls { border-inline-end: 0; border-bottom: 1px solid var(--sw-line); }
}
@media (max-width: 640px) {
  .sw-title { max-width: 12rem; }
  .sw-inline-form { grid-template-columns: 1fr; }
  .sw-stage { padding: .7rem .6rem 1rem; }
}
@media print {
  .sw-toolbar, .sw-tabs, .sw-controls, .sw-status, .sw-zoombar { display: none; }
  .sw-view { display: block; }
}
.sw-legend { display: flex; flex-wrap: wrap; gap: .15rem 1.2rem; margin: .2rem 0 .4rem; padding: 0; list-style: none; font-size: .88rem; }
.sw-hero-label { flex-basis: 100%; font-weight: 600; color: var(--sw-muted); font-size: .95rem; }
