/* Codeharbor workspace. Root rules are scoped to .uwapp-root.uwapp-codeharbor (the body carries the app class too);
   everything else hangs off .ch-app. Themes: auto (follows the site: html[data-theme] / prefers-color-scheme), light,
   dark and high contrast via .ch-app[data-theme]. CSP: no inline styles; positions use CSSOM only. */
.uwapp-root.uwapp-codeharbor { background: #f4f7f8; }

.ch-app {
  --ch-bg: #f4f7f8; --ch-surface: #ffffff; --ch-surface-2: #eaf0f2; --ch-ink: #13252b; --ch-muted: #4a5b62; --ch-line: #cfdade;
  --ch-control: #6b7d84; --ch-accent: #0f766e; --ch-accent-ink: #0b5d57; --ch-on-accent: #ffffff; --ch-focus: #b45309;
  --ch-err: #b00020; --ch-warn: #8a4b00; --ch-ok: #0b6b2c; --ch-sel: rgb(15 118 110 / .22); --ch-cur: #f1f6f7; --ch-match: #fde68a; --ch-match-cur: #f59e0b;
  --ch-ed-bg: #ffffff; --ch-gutter: #5b6b72;
  --t-kw: #8f1d6b; --t-str: #0b6b2c; --t-num: #8a4b00; --t-com: #5a6770; --t-fn: #1f4fa3; --t-type: #0c6870; --t-prop: #6b3fa0; --t-tag: #9b1c1c;
  --t-attr: #8a4b00; --t-punct: #2b3a40; --t-op: #5b2a86; --t-re: #a3271b; --t-bool: #1f4fa3; --t-meta: #5a6770; --t-head: #0f4f9e; --t-link: #0a58a8; --t-var: #8f1d6b;
  color-scheme: light;
  display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; background: var(--ch-bg); color: var(--ch-ink);
  font-size: 15px;
}
.ch-app[data-theme="dark"], :root[data-theme="dark"] .ch-app[data-theme="auto"] {
  --ch-bg: #0b1418; --ch-surface: #12202a; --ch-surface-2: #1b2c36; --ch-ink: #e7eef1; --ch-muted: #b4c3c9; --ch-line: #2c3f4a;
  --ch-control: #87a0a9; --ch-accent: #5eead4; --ch-accent-ink: #99f6e4; --ch-on-accent: #04201d; --ch-focus: #fbbf24;
  --ch-err: #ffb4b4; --ch-warn: #fcd38d; --ch-ok: #9be3a6; --ch-sel: rgb(94 234 212 / .25); --ch-cur: #15242d; --ch-match: #5c4a0b; --ch-match-cur: #8a6a00;
  --ch-ed-bg: #0f1a20; --ch-gutter: #9fb0b7;
  --t-kw: #f4a8db; --t-str: #9be3a6; --t-num: #f7c98f; --t-com: #a3b3ba; --t-fn: #93c8ff; --t-type: #7fdbd1; --t-prop: #cdb8ff; --t-tag: #ffa3a3;
  --t-attr: #f7c98f; --t-punct: #d6dfe3; --t-op: #e3c7ff; --t-re: #ffb3a8; --t-bool: #93c8ff; --t-meta: #a3b3ba; --t-head: #93c8ff; --t-link: #93c8ff; --t-var: #f4a8db;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ch-app[data-theme="auto"] {
    --ch-bg: #0b1418; --ch-surface: #12202a; --ch-surface-2: #1b2c36; --ch-ink: #e7eef1; --ch-muted: #b4c3c9; --ch-line: #2c3f4a;
    --ch-control: #87a0a9; --ch-accent: #5eead4; --ch-accent-ink: #99f6e4; --ch-on-accent: #04201d; --ch-focus: #fbbf24;
    --ch-err: #ffb4b4; --ch-warn: #fcd38d; --ch-ok: #9be3a6; --ch-sel: rgb(94 234 212 / .25); --ch-cur: #15242d; --ch-match: #5c4a0b; --ch-match-cur: #8a6a00;
    --ch-ed-bg: #0f1a20; --ch-gutter: #9fb0b7;
    --t-kw: #f4a8db; --t-str: #9be3a6; --t-num: #f7c98f; --t-com: #a3b3ba; --t-fn: #93c8ff; --t-type: #7fdbd1; --t-prop: #cdb8ff; --t-tag: #ffa3a3;
    --t-attr: #f7c98f; --t-punct: #d6dfe3; --t-op: #e3c7ff; --t-re: #ffb3a8; --t-bool: #93c8ff; --t-meta: #a3b3ba; --t-head: #93c8ff; --t-link: #93c8ff; --t-var: #f4a8db;
    color-scheme: dark;
  }
}
.ch-app[data-theme="hc"] {
  --ch-bg: #000000; --ch-surface: #000000; --ch-surface-2: #1a1a1a; --ch-ink: #ffffff; --ch-muted: #e6e6e6; --ch-line: #ffffff;
  --ch-control: #ffffff; --ch-accent: #ffff00; --ch-accent-ink: #ffff66; --ch-on-accent: #000000; --ch-focus: #00ffff;
  --ch-err: #ff8080; --ch-warn: #ffd166; --ch-ok: #7dff7d; --ch-sel: rgb(0 255 255 / .35); --ch-cur: #101010; --ch-match: #4d4d00; --ch-match-cur: #806600;
  --ch-ed-bg: #000000; --ch-gutter: #ffffff;
  --t-kw: #ff9cff; --t-str: #7dff7d; --t-num: #ffd166; --t-com: #d0d0d0; --t-fn: #7fd7ff; --t-type: #7fffd4; --t-prop: #e0b0ff; --t-tag: #ff9c9c;
  --t-attr: #ffd166; --t-punct: #ffffff; --t-op: #ffffff; --t-re: #ffb3a8; --t-bool: #7fd7ff; --t-meta: #d0d0d0; --t-head: #ffff66; --t-link: #7fd7ff; --t-var: #ff9cff;
  color-scheme: dark;
}

/* Platform element defaults leak into app workspaces: reset at zero specificity. */
:where(.ch-app, .ch-dialog) button { font: inherit; font-size: .88rem; font-weight: 600; padding: 0; border: 0; border-radius: 6px; background: none; color: inherit; cursor: pointer; width: auto; min-height: 0; margin: 0; }
:where(.ch-app, .ch-dialog) button:hover { background: none; }
:where(.ch-app, .ch-dialog) :is(input, select, textarea) { font: inherit; color: var(--ch-ink); background: var(--ch-surface); border: 1px solid var(--ch-control); border-radius: 6px; width: auto; margin: 0; }
:where(.ch-app, .ch-dialog) table { border-collapse: collapse; width: 100%; margin: 0; font-size: .88rem; }
:where(.ch-app, .ch-dialog) :is(th, td) { text-align: start; padding: 4px 8px; border-bottom: 1px solid var(--ch-line); vertical-align: top; }
:where(.ch-app, .ch-dialog) thead th { background: var(--ch-surface-2); color: var(--ch-ink); }
:where(.ch-app, .ch-dialog) kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82em; padding: 1px 6px; border: 1px solid var(--ch-control); border-bottom-width: 2px; border-radius: 5px; background: var(--ch-surface-2); color: var(--ch-ink); white-space: nowrap; }
:where(.ch-app, .ch-dialog) a { color: var(--t-link); }
:where(.ch-app, .ch-dialog) :is(code, pre) { background: var(--ch-surface-2); color: var(--ch-ink); border-radius: 4px; }
:where(.ch-app, .ch-dialog) h2, :where(.ch-app, .ch-dialog) h3 { color: var(--ch-ink); }
:where(.ch-app, .ch-dialog) ul, :where(.ch-app, .ch-dialog) ol { margin: 0; }
.ch-app :focus-visible, .ch-dialog :focus-visible { outline: 3px solid var(--ch-focus); outline-offset: 1px; }
.ch-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; }
.ch-spacer { flex: 1; min-width: 0; }
.ch-hint { color: var(--ch-muted); font-size: .82rem; margin: .3rem 0 .5rem; }
.ch-error { color: var(--ch-err); font-size: .85rem; margin: .2rem 0; min-height: 0; }
.ch-error:empty { display: none; }
.ch-none { color: var(--ch-muted); padding: .4rem .6rem; list-style: none; }

/* buttons */
.ch-btn { display: inline-flex; align-items: center; gap: .3rem; min-height: 32px; padding: .25rem .7rem; border: 1px solid var(--ch-control); border-radius: 7px; background: var(--ch-surface); color: var(--ch-ink); font-size: .85rem; white-space: nowrap; }
.ch-btn:hover:not([disabled]) { background: var(--ch-surface-2); }
.ch-btn[disabled], .ch-icon-btn[disabled] { opacity: .55; cursor: not-allowed; }
.ch-btn-s { min-height: 28px; padding: .1rem .5rem; font-size: .8rem; }
.ch-btn-primary, :is(.ch-app, .ch-dialog) button[type=submit].ch-btn-primary, .ch-btn-run { background: var(--ch-accent); border-color: var(--ch-accent); color: var(--ch-on-accent); }
.ch-btn-primary:hover:not([disabled]), :is(.ch-app, .ch-dialog) button[type=submit].ch-btn-primary:hover:not([disabled]), .ch-btn-run:hover:not([disabled]) { background: var(--ch-accent-ink); border-color: var(--ch-accent-ink); color: var(--ch-on-accent); }
.ch-icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 1px solid transparent; border-radius: 7px; color: var(--ch-ink); flex: none; }
.ch-icon-btn:hover:not([disabled]) { background: var(--ch-surface-2); border-color: var(--ch-line); }

/* toolbar + menus */
.ch-toolbar { display: flex; align-items: center; gap: .3rem; padding: .25rem .5rem; border-bottom: 1px solid var(--ch-line); background: var(--ch-surface); flex-wrap: wrap; min-width: 0; }
.ch-menus { display: flex; flex-wrap: wrap; gap: .1rem; min-width: 0; }
.ch-menu-wrap { position: relative; }
.ch-menu-btn { display: inline-flex; align-items: center; gap: .15rem; min-height: 32px; padding: .2rem .5rem; border-radius: 7px; color: var(--ch-ink); }
.ch-menu-btn:hover, .ch-menu-btn[aria-expanded="true"] { background: var(--ch-surface-2); }
.ch-menu { position: fixed; z-index: 40; min-width: 16rem; max-width: min(26rem, 94vw); max-height: calc(100dvh - 12px); overflow-y: auto; padding: .3rem; background: var(--ch-surface); color: var(--ch-ink); border: 1px solid var(--ch-control); border-radius: 9px; box-shadow: 0 12px 30px rgb(0 0 0 / .28); }
.ch-menu[hidden] { display: none; }
.ch-menu-item { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 1rem; min-height: 30px; padding: .3rem .6rem; border-radius: 6px; text-align: start; font-weight: 500; color: var(--ch-ink); }
.ch-menu-item:hover, .ch-menu-item:focus { background: var(--ch-surface-2); }
.ch-menu-item[aria-disabled="true"] { color: var(--ch-muted); cursor: not-allowed; }
.ch-menu-key { color: var(--ch-muted); font-size: .76rem; font-weight: 600; }
.ch-menu-sep { height: 1px; margin: .3rem .2rem; background: var(--ch-line); }
.ch-ws-chip:empty { display: none; }

/* main grid */
.ch-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(12rem, 17rem) minmax(0, 1fr) minmax(16rem, 38%); }
.ch-app.ch-no-side .ch-main { grid-template-columns: minmax(0, 1fr) minmax(16rem, 38%); }
.ch-app.ch-no-preview .ch-main { grid-template-columns: minmax(12rem, 17rem) minmax(0, 1fr); }
.ch-app.ch-no-side.ch-no-preview .ch-main { grid-template-columns: minmax(0, 1fr); }
.ch-side, .ch-preview, .ch-center { min-width: 0; min-height: 0; }
.ch-side { display: flex; flex-direction: column; border-inline-end: 1px solid var(--ch-line); background: var(--ch-surface); overflow: hidden; }
.ch-side[hidden], .ch-preview[hidden] { display: none; }
.ch-side-tabs { display: flex; gap: .15rem; padding: .3rem; border-bottom: 1px solid var(--ch-line); }
.ch-side-tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: .25rem; min-height: 30px; padding: .15rem .3rem; border-radius: 6px; color: var(--ch-muted); font-size: .8rem; }
.ch-side-tab.ch-on { background: var(--ch-surface-2); color: var(--ch-ink); box-shadow: inset 0 -2px 0 var(--ch-accent); }
.ch-side-body { flex: 1; overflow: auto; padding: .4rem .5rem .8rem; position: relative; }
.ch-side-h { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ch-muted); margin: .4rem .2rem; overflow-wrap: anywhere; }
.ch-side-actions { display: flex; flex-wrap: wrap; gap: .1rem; margin-bottom: .2rem; }

/* tree */
.ch-tree, .ch-tree ul { list-style: none; margin: 0; padding: 0; }
.ch-tree { min-height: 2rem; border-radius: 6px; }
.ch-tree.ch-drop { outline: 2px dashed var(--ch-accent); }
.ch-ti { cursor: pointer; border-radius: 5px; }
.ch-ti:focus-visible { outline-offset: -2px; }
.ch-ti-row { display: flex; align-items: center; gap: .3rem; min-height: 26px; padding: 0 .3rem; border-radius: 5px; font-size: .86rem; }
.ch-ti-row:hover { background: var(--ch-surface-2); }
.ch-ti-sel > .ch-ti-row { background: var(--ch-surface-2); box-shadow: inset 3px 0 0 var(--ch-accent); }
.ch-ti.ch-drop > .ch-ti-row { outline: 2px dashed var(--ch-accent); }
.ch-ti-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-ti-badge { font-size: .68rem; padding: 0 .3rem; border: 1px solid var(--ch-control); border-radius: 4px; color: var(--ch-muted); }
.ch-ti-err, .ch-tab-err { color: var(--ch-err); font-weight: 800; }
.ch-ti-indent[data-level="1"] { width: 0; } .ch-ti-indent[data-level="2"] { width: 12px; } .ch-ti-indent[data-level="3"] { width: 24px; } .ch-ti-indent[data-level="4"] { width: 36px; }
.ch-ti-indent[data-level="5"] { width: 48px; } .ch-ti-indent[data-level="6"] { width: 60px; } .ch-ti-indent[data-level="7"] { width: 72px; } .ch-ti-indent[data-level="8"] { width: 84px; }
.ch-ti-indent[data-level="9"], .ch-ti-indent[data-level="10"], .ch-ti-indent[data-level="11"], .ch-ti-indent[data-level="12"] { width: 96px; }
.ch-ti-indent { flex: none; }

/* editors */
.ch-center { display: flex; flex-direction: column; min-width: 0; }
.ch-editors { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.ch-app.ch-split .ch-editors { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.ch-group { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-inline-start: 1px solid var(--ch-line); }
.ch-group[hidden] { display: none; }
.ch-tabs { border-bottom: 1px solid var(--ch-line); background: var(--ch-surface); overflow-x: auto; position: relative; }
.ch-tablist { display: flex; list-style: none; padding: 0; margin: 0; min-height: 32px; }
.ch-tablist > li { display: flex; align-items: center; border-inline-end: 1px solid var(--ch-line); }
.ch-tab { display: inline-flex; align-items: center; gap: .3rem; min-height: 32px; padding: 0 .3rem 0 .7rem; font-weight: 500; color: var(--ch-muted); white-space: nowrap; border-radius: 0; }
.ch-tab-on { color: var(--ch-ink); background: var(--ch-ed-bg); box-shadow: inset 0 -2px 0 var(--ch-control); }
.ch-tab-focus { box-shadow: inset 0 -3px 0 var(--ch-accent); }
.ch-tab-x { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-inline-end: .2rem; color: var(--ch-muted); }
.ch-tab-x:hover { color: var(--ch-ink); background: var(--ch-surface-2); }
.ch-empty { padding: 2rem 1rem; color: var(--ch-muted); text-align: center; }
.ch-empty[hidden] { display: none; }

.ch-ed { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--ch-ed-bg); }
.ch-ed[hidden] { display: none; }
.ch-ed-body { flex: 1; min-height: 0; display: flex; position: relative; }
.ch-ed-gutter { flex: none; overflow: hidden; position: relative; padding-inline: .3rem .5rem; color: var(--ch-gutter); background: var(--ch-ed-bg); border-inline-end: 1px solid var(--ch-line); font: 13.5px/20px ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; text-align: end; user-select: none; }
.ch-ed-ln { height: 20px; }
.ch-ed-ln-cur { color: var(--ch-ink); font-weight: 700; }
.ch-ed-ln-err { color: var(--ch-err); }
.ch-ed-view { flex: 1; min-width: 0; position: relative; overflow: hidden; direction: ltr; }
.ch-ed-hl, .ch-ed-input { margin: 0; padding: 8px 12px; border: 0; font: 13.5px/20px ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; letter-spacing: 0; tab-size: 4; white-space: pre; overflow-wrap: normal; word-break: normal; font-variant-ligatures: none; }
.ch-ed-hl { position: absolute; top: 0; left: 0; min-width: 100%; max-width: none; overflow: visible; box-sizing: border-box; background: transparent; color: var(--ch-ink); pointer-events: none; border-radius: 0; }
.ch-ed-hl code { display: block; font: inherit; background: none; padding: 0; color: inherit; }
.ch-ed-input { position: absolute; inset: 0; width: 100%; height: 100%; box-sizing: border-box; resize: none; background: transparent; color: transparent; caret-color: var(--ch-ink); outline: none; overflow: auto; border-radius: 0; }
.ch-ed-input::selection { background: var(--ch-sel); color: transparent; }
.ch-ed-input:focus-visible { outline: 2px solid var(--ch-focus); outline-offset: -2px; }
:where(.ch-app) .ch-ed-input { border: 0; background: transparent; color: transparent; }
.ch-ed-wrap .ch-ed-hl, .ch-ed-wrap .ch-ed-input { white-space: pre-wrap; overflow-wrap: anywhere; }
.ch-ed-wrap .ch-ed-ln { height: auto; }
.ch-ed-ro .ch-ed-input { caret-color: var(--ch-muted); }
.ch-line { display: block; min-height: 20px; }
.ch-line-cur { background: var(--ch-cur); }
.ch-t-kw { color: var(--t-kw); } .ch-t-str { color: var(--t-str); } .ch-t-num { color: var(--t-num); } .ch-t-com { color: var(--t-com); font-style: italic; }
.ch-t-fn { color: var(--t-fn); } .ch-t-type { color: var(--t-type); } .ch-t-prop { color: var(--t-prop); } .ch-t-tag { color: var(--t-tag); } .ch-t-attr { color: var(--t-attr); }
.ch-t-punct { color: var(--t-punct); } .ch-t-op { color: var(--t-op); } .ch-t-re { color: var(--t-re); } .ch-t-bool { color: var(--t-bool); } .ch-t-meta { color: var(--t-meta); }
.ch-t-head { color: var(--t-head); font-weight: 700; } .ch-t-strong { font-weight: 700; } .ch-t-em { font-style: italic; } .ch-t-code { color: var(--t-str); }
.ch-t-link { color: var(--t-link); text-decoration: underline; } .ch-t-var { color: var(--t-var); } .ch-t-err { color: var(--ch-err); text-decoration: underline wavy; }
.ch-d-bracket { outline: 1px solid var(--ch-control); border-radius: 2px; background: var(--ch-surface-2); }
.ch-d-match { background: var(--ch-match); border-radius: 2px; }
.ch-d-match-cur { background: var(--ch-match); outline: 2px solid var(--ch-match-cur); border-radius: 2px; }
.ch-d-error { text-decoration: underline wavy var(--ch-err); text-decoration-skip-ink: none; text-underline-offset: 3px; }
.ch-d-warning { text-decoration: underline dotted var(--ch-warn); text-underline-offset: 3px; }

/* find bar */
.ch-find { display: grid; gap: .2rem; padding: .3rem .5rem; border-bottom: 1px solid var(--ch-line); background: var(--ch-surface); }
.ch-find[hidden] { display: none; }
.ch-find-row { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; min-width: 0; }
.ch-find-row[hidden] { display: none; }
.ch-find-label { font-size: .8rem; font-weight: 600; min-width: 4.5rem; }
.ch-find-in { flex: 1 1 9rem; min-width: 6rem; min-height: 30px; padding: .1rem .4rem; font-family: ui-monospace, monospace; font-size: .85rem; }
.ch-find-in[aria-invalid="true"] { border-color: var(--ch-err); box-shadow: inset 0 0 0 1px var(--ch-err); }
.ch-find-opt { min-width: 30px; min-height: 30px; padding: 0 .3rem; border: 1px solid var(--ch-line); font-family: ui-monospace, monospace; font-size: .8rem; color: var(--ch-ink); }
.ch-find-opt[aria-pressed="true"] { background: var(--ch-accent); color: var(--ch-on-accent); border-color: var(--ch-accent); }
.ch-find-count { font-size: .8rem; color: var(--ch-muted); min-width: 5rem; }

/* bottom panel */
.ch-bottom { border-top: 1px solid var(--ch-line); background: var(--ch-surface); display: flex; flex-direction: column; max-height: 38%; min-height: 0; }
.ch-app.ch-no-bottom .ch-bottom { max-height: none; }
.ch-bottom-tabs { display: flex; align-items: center; gap: .2rem; padding: .15rem .4rem; }
.ch-bt { display: inline-flex; align-items: center; gap: .35rem; min-height: 28px; padding: 0 .5rem; border-radius: 6px; color: var(--ch-muted); }
.ch-bt.ch-on { color: var(--ch-ink); box-shadow: inset 0 -2px 0 var(--ch-accent); }
.ch-count { font-size: .72rem; padding: 0 .35rem; border-radius: 9px; background: var(--ch-surface-2); color: var(--ch-ink); }
.ch-bottom-body { overflow: auto; min-height: 6rem; flex: 1; position: relative; }
.ch-bottom-body[hidden] { display: none; }
.ch-problems, .ch-console { list-style: none; margin: 0; padding: .2rem .4rem .6rem; font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.ch-prob { display: flex; flex-wrap: wrap; gap: .2rem .6rem; width: 100%; text-align: start; padding: .15rem .3rem; border-radius: 4px; font: inherit; font-weight: 400; color: var(--ch-ink); }
.ch-prob:hover { background: var(--ch-surface-2); }
.ch-prob-sev { font-weight: 700; }
.ch-prob-error .ch-prob-sev { color: var(--ch-err); } .ch-prob-warning .ch-prob-sev { color: var(--ch-warn); }
.ch-prob-loc { color: var(--ch-muted); }
.ch-log { display: flex; gap: .5rem; padding: .1rem .2rem; border-bottom: 1px solid var(--ch-line); white-space: pre-wrap; overflow-wrap: anywhere; }
.ch-log-lv { flex: none; min-width: 1.2rem; font-weight: 700; color: var(--ch-muted); }
.ch-log-error .ch-log-lv, .ch-log-error .ch-log-text { color: var(--ch-err); }
.ch-log-warn .ch-log-lv, .ch-log-warn .ch-log-text { color: var(--ch-warn); }
.ch-log-system .ch-log-text { color: var(--ch-muted); font-style: italic; }
.ch-log-text { flex: 1; min-width: 0; }
.ch-log-at { flex: none; font: inherit; color: var(--t-link); text-decoration: underline; }

/* preview */
.ch-preview { display: flex; flex-direction: column; border-inline-start: 1px solid var(--ch-line); background: var(--ch-surface); }
.ch-preview-head { display: flex; align-items: center; gap: .3rem; padding: .25rem .5rem; border-bottom: 1px solid var(--ch-line); flex-wrap: wrap; }
.ch-preview-title { font-size: .85rem; margin: 0; }
.ch-preview-file { font-size: .78rem; color: var(--ch-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ch-preview-body { flex: 1; min-height: 12rem; overflow: auto; background: #ffffff; color: #13252b; position: relative; }
.ch-runner { display: block; width: 100%; height: 100%; min-height: 12rem; border: 0; background: #ffffff; }
.ch-preview-empty { margin: 1rem; color: #4a5b62; }
.ch-md { padding: .8rem 1.1rem 2rem; font-size: .95rem; line-height: 1.55; color: #13252b; overflow-wrap: anywhere; }
.ch-md :is(h1, h2, h3, h4) { color: #0d2a33; line-height: 1.25; }
.ch-md a { color: #0a58a8; }
.ch-md pre { background: #f2f6f7; color: #13252b; padding: .6rem .8rem; border-radius: 6px; overflow: auto; max-width: 100%; }
.ch-md code { background: #eef3f5; color: #13252b; padding: 0 .2em; border-radius: 3px; }
.ch-md pre code { background: none; padding: 0; }
.ch-md table { border-collapse: collapse; margin: .6rem 0; }
.ch-md :is(th, td) { border: 1px solid #b8c7cc; padding: .25rem .5rem; }
.ch-md .al-right { text-align: right; } .ch-md .al-center { text-align: center; }
.ch-md blockquote { margin: .6rem 0; padding: .2rem .9rem; border-inline-start: 4px solid #0f766e; color: #33484f; }
.ch-md .task { list-style: none; } .ch-md .md-img-alt { color: #4a5b62; font-style: italic; }
.ch-md .ch-t-kw { color: #8f1d6b; } .ch-md .ch-t-str { color: #0b6b2c; } .ch-md .ch-t-num { color: #8a4b00; } .ch-md .ch-t-com { color: #5a6770; }
.ch-md .ch-t-fn { color: #1f4fa3; } .ch-md .ch-t-tag { color: #9b1c1c; } .ch-md .ch-t-attr { color: #8a4b00; } .ch-md .ch-t-prop { color: #6b3fa0; } .ch-md .ch-t-type { color: #0c6870; } .ch-md .ch-t-bool { color: #1f4fa3; }

/* status bar */
.ch-status { display: flex; align-items: center; gap: .15rem .6rem; flex-wrap: wrap; padding: .1rem .6rem; min-height: 26px; border-top: 1px solid var(--ch-line); background: var(--ch-surface-2); font-size: .78rem; color: var(--ch-ink); }
.ch-status-msg { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; }
.ch-st { white-space: nowrap; }
.ch-st-btn { font-size: .78rem; font-weight: 500; padding: .1rem .3rem; border-radius: 4px; color: var(--ch-ink); }
.ch-st-btn:hover { background: var(--ch-surface); }
.ch-st-run { color: var(--ch-ok); font-weight: 700; }

/* side panels: search, history */
.ch-field { display: grid; gap: .15rem; margin: 0 0 .5rem; min-width: 0; }
.ch-field > label { font-weight: 600; font-size: .82rem; }
.ch-field :is(select, input, textarea) { min-height: 32px; padding: .2rem .45rem; min-width: 0; width: 100%; box-sizing: border-box; }
.ch-check { display: flex; align-items: center; gap: .4rem; margin: .15rem 0; font-size: .85rem; }
.ch-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--ch-accent); flex: none; }
.ch-checks { display: grid; gap: .1rem; margin-bottom: .4rem; }
.ch-dialog-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.ch-s-file h3 { font-size: .8rem; margin: .6rem 0 .2rem; overflow-wrap: anywhere; }
.ch-s-file ul { list-style: none; padding: 0; }
.ch-s-hit { display: flex; gap: .4rem; width: 100%; text-align: start; padding: .1rem .3rem; border-radius: 4px; font: 12px/1.4 ui-monospace, monospace; font-weight: 400; color: var(--ch-ink); }
.ch-s-hit:hover { background: var(--ch-surface-2); }
.ch-s-ln { color: var(--ch-muted); min-width: 2.2rem; text-align: end; flex: none; }
.ch-s-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-changes, .ch-commits { list-style: none; padding: 0; margin: 0 0 .5rem; }
.ch-change, .ch-commit { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .45rem; width: 100%; text-align: start; padding: .2rem .3rem; border-radius: 5px; font-weight: 400; font-size: .84rem; color: var(--ch-ink); }
.ch-change:hover, .ch-commit:hover { background: var(--ch-surface-2); }
.ch-commit-msg-t { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.ch-badge { font-size: .7rem; font-weight: 700; padding: 0 .3rem; border-radius: 4px; border: 1px solid currentColor; }
.ch-badge-added { color: var(--ch-ok); } .ch-badge-removed { color: var(--ch-err); } .ch-badge-modified { color: var(--ch-warn); }
.ch-diffnum { color: var(--ch-muted); font-size: .75rem; }
.ch-commit-msg { resize: vertical; }

/* dialogs */
.ch-dialog { width: min(34rem, calc(100vw - 1.5rem)); max-height: calc(100dvh - 1.5rem); padding: 0; border: 1px solid var(--ch-control); border-radius: 12px; background: var(--ch-surface); color: var(--ch-ink); box-shadow: 0 24px 60px rgb(0 0 0 / .35); }
.ch-dialog-wide { width: min(62rem, calc(100vw - 1.5rem)); }
.ch-dialog::backdrop { background: rgb(5 14 18 / .55); }
.ch-dialog-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1rem .5rem; background: var(--ch-surface); border-bottom: 1px solid var(--ch-line); }
.ch-dialog-head h2 { margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.ch-dialog-lede { margin: .5rem 0 0; padding: 0 1rem; color: var(--ch-muted); font-size: .9rem; }
.ch-dialog-body { padding: .6rem 1rem 1rem; }
.ch-dialog-body h3 { font-size: .95rem; margin: .8rem 0 .3rem; }
.ch-form { display: grid; gap: .1rem; }
.ch-cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .5rem; }
.ch-card { display: grid; gap: .25rem; width: 100%; height: 100%; text-align: start; padding: .6rem .7rem; border: 1px solid var(--ch-line); border-radius: 9px; background: var(--ch-surface); font-weight: 400; color: var(--ch-ink); }
.ch-card span { color: var(--ch-muted); font-size: .84rem; }
.ch-card:hover, .ch-card-on { border-color: var(--ch-accent); box-shadow: inset 0 0 0 1px var(--ch-accent); }
.ch-pal-list { list-style: none; padding: 0; margin: .4rem 0 0; max-height: min(60vh, 26rem); overflow: auto; }
.ch-pal-item { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem .5rem; border-radius: 6px; cursor: pointer; overflow-wrap: anywhere; }
.ch-pal-item.ch-on { background: var(--ch-accent); color: var(--ch-on-accent); }
.ch-pal-item.ch-on kbd { background: var(--ch-surface); color: var(--ch-ink); }
.ch-dialog #ch-pal-in { width: 100%; min-height: 38px; padding: .3rem .5rem; box-sizing: border-box; }
.ch-keys td:first-child { white-space: nowrap; }
.ch-diff-wrap { overflow: auto; max-height: 60vh; position: relative; border: 1px solid var(--ch-line); border-radius: 6px; }
.ch-diff { font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.ch-diff td { border: 0; padding: 0 .4rem; }
.ch-diff-n { color: var(--ch-muted); text-align: end; width: 3rem; user-select: none; }
.ch-diff-k { color: var(--ch-muted); width: 4.5rem; font-size: .9em; }
.ch-diff-t code { background: none; white-space: pre-wrap; overflow-wrap: anywhere; }
.ch-diff-add { background: color-mix(in srgb, var(--ch-ok) 14%, var(--ch-surface)); }
.ch-diff-del { background: color-mix(in srgb, var(--ch-err) 14%, var(--ch-surface)); }
.ch-diff-add mark, .ch-diff-del mark { background: color-mix(in srgb, var(--ch-warn) 30%, var(--ch-surface)); color: inherit; font-weight: 700; }
.ch-diff-gap td { color: var(--ch-muted); text-align: center; }
.ch-diff-h { font-family: ui-monospace, monospace; }
.ch-snaps { list-style: none; padding: 0; }
.ch-snap { border-bottom: 1px solid var(--ch-line); padding: .4rem 0; }
.ch-runner-note { color: var(--ch-muted); }

/* read-only notice from teams.js */
.ch-center > .uwt-readonly { margin: 0; padding: .3rem .6rem; }

/* phones and small tablets */
@media (max-width: 760px) {
  .ch-main { display: flex; flex-direction: column; overflow: auto; }
  .ch-side { border-inline-end: 0; border-bottom: 1px solid var(--ch-line); max-height: 45vh; flex: none; }
  .ch-center { flex: 1 0 22rem; }
  .ch-preview { border-inline-start: 0; border-top: 1px solid var(--ch-line); flex: none; height: 50vh; }
  .ch-app.ch-split .ch-editors { grid-template-columns: minmax(0, 1fr); grid-template-rows: 1fr 1fr; }
  .ch-toolbar .ch-btn-run span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .ch-status { font-size: .74rem; }
}
@media (prefers-reduced-motion: reduce) {
  .ch-app *, .ch-dialog * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
