/* Jackfield workspace. Root rules are scoped to .uwapp-root.uwapp-jackfield (the body carries the app class too).
   Light and dark tokens follow html[data-theme] / prefers-color-scheme (DESIGN_SYSTEM.md §9). No animations. */
.uwapp-root.uwapp-jackfield {
  --jf-bg: var(--canvas); --jf-surface: var(--surface); --jf-surface-2: var(--surface-2); --jf-ink: var(--ink); --jf-muted: var(--muted);
  --jf-line: var(--line); --jf-control: var(--control); --jf-accent: var(--primary); --jf-accent-ink: var(--primary-text); --jf-on-accent: var(--on-accent);
  --jf-focus: var(--focus-color); --jf-danger: var(--danger); --jf-warn: #9a3412; --jf-ok: #166534;
  --jf-panel: #f4efe9; --jf-panel-edge: #d6c8b8; --jf-socket: #1f2937; --jf-socket-ring: #6b7280; --jf-scope-bg: #0f172a;
  --jf-in: #1d4ed8; --jf-out: #9a3412;
  background: var(--jf-bg); color: var(--jf-ink); color-scheme: light; font-family: var(--font-sans);
}
:root[data-theme="dark"] .uwapp-root.uwapp-jackfield {
  --jf-bg: var(--d-canvas); --jf-surface: var(--d-surface); --jf-surface-2: var(--d-surface-2); --jf-ink: var(--d-ink); --jf-muted: var(--d-muted);
  --jf-line: var(--d-line); --jf-control: var(--d-control); --jf-accent: var(--d-primary); --jf-accent-ink: var(--d-focus); --jf-on-accent: var(--d-on-accent);
  --jf-focus: var(--d-focus); --jf-danger: var(--d-danger); --jf-warn: #fdba74; --jf-ok: #86efac;
  --jf-panel: #26221f; --jf-panel-edge: #4b4239; --jf-socket: #0b0f14; --jf-socket-ring: #9ca3af; --jf-scope-bg: #020617;
  --jf-in: #93c5fd; --jf-out: #fdba74;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .uwapp-root.uwapp-jackfield {
    --jf-bg: var(--d-canvas); --jf-surface: var(--d-surface); --jf-surface-2: var(--d-surface-2); --jf-ink: var(--d-ink); --jf-muted: var(--d-muted);
    --jf-line: var(--d-line); --jf-control: var(--d-control); --jf-accent: var(--d-primary); --jf-accent-ink: var(--d-focus); --jf-on-accent: var(--d-on-accent);
    --jf-focus: var(--d-focus); --jf-danger: var(--d-danger); --jf-warn: #fdba74; --jf-ok: #86efac;
    --jf-panel: #26221f; --jf-panel-edge: #4b4239; --jf-socket: #0b0f14; --jf-socket-ring: #9ca3af; --jf-scope-bg: #020617;
    --jf-in: #93c5fd; --jf-out: #fdba74;
    color-scheme: dark;
  }
}

/* platform element defaults leak into app workspaces: reset them at zero specificity */
:where(.jf-app, .jf-dialog) 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(.jf-app, .jf-dialog) button:hover { background: none; }
:where(.jf-app, .jf-dialog) :is(input, select, textarea) { font: inherit; color: var(--jf-ink); background: var(--jf-surface); border: 1px solid var(--jf-control); border-radius: 8px; }
:where(.jf-app, .jf-dialog) table { border-collapse: collapse; width: 100%; margin: 0; font-size: .9rem; }
:where(.jf-app, .jf-dialog) :is(th, td) { text-align: start; padding: 6px 8px; border-bottom: 1px solid var(--jf-line); vertical-align: middle; }
:where(.jf-app, .jf-dialog) thead th { background: var(--jf-surface-2); color: var(--jf-ink); }
:where(.jf-app, .jf-dialog) kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; padding: 1px 6px; border: 1px solid var(--jf-control); border-bottom-width: 2px; border-radius: 5px; background: var(--jf-surface-2); color: var(--jf-ink); white-space: nowrap; }
:where(.jf-app, .jf-dialog) :is(h2, h3) { color: var(--jf-ink); }
.uwapp-root.uwapp-jackfield [hidden] { display: none !important; }

.jf-app { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; background: var(--jf-bg); color: var(--jf-ink); }
.jf-app :focus-visible, .jf-dialog :focus-visible { outline: 3px solid var(--jf-focus); outline-offset: 2px; }
.jf-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; }
.jf-hint, .jf-muted { color: var(--jf-muted); font-size: .85rem; margin: .3rem 0; }
.jf-error { color: var(--jf-danger); font-weight: 600; font-size: .88rem; margin: .3rem 0; }
.jf-empty { color: var(--jf-muted); padding: 1rem; margin: 0; }
.jf-wide { width: 100%; box-sizing: border-box; padding: .4rem .55rem; }

/* bar */
.jf-bar { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; padding: .45rem .7rem; background: var(--jf-surface); border-bottom: 1px solid var(--jf-line); }
.jf-bar-group { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; min-width: 0; }
.jf-bar-audio { flex: 1 1 auto; }
.jf-name { font-weight: 700; padding: 0 .3rem; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jf-btn, .jf-menu-btn { display: inline-flex; align-items: center; gap: .35rem; padding: .38rem .65rem !important; border: 1px solid var(--jf-control) !important; border-radius: 8px; background: var(--jf-surface) !important; color: var(--jf-ink); min-height: 36px !important; }
.jf-btn:hover, .jf-menu-btn:hover { background: var(--jf-surface-2) !important; }
.jf-btn-primary { background: var(--jf-accent) !important; color: var(--jf-on-accent) !important; border-color: var(--jf-accent) !important; }
.jf-btn-small { min-height: 30px !important; padding: .2rem .5rem !important; font-size: .82rem !important; }
.jf-btn:disabled, .jf-icon-btn:disabled { opacity: .5; cursor: default; }
.jf-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; color: var(--jf-ink); }
.jf-icon-btn:hover { background: var(--jf-surface-2) !important; }
.jf-audio-btn[aria-pressed="false"] { background: var(--jf-accent) !important; color: var(--jf-on-accent) !important; border-color: var(--jf-accent) !important; }
.jf-badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .8rem; font-weight: 700; padding: .15rem .5rem; border-radius: 999px; border: 1px solid currentColor; }
.jf-badge-off { color: var(--jf-muted); }
.jf-badge-on { color: var(--jf-ok); }
.jf-meter { position: relative; display: inline-block; width: 90px; height: 10px; border-radius: 5px; background: var(--jf-surface-2); border: 1px solid var(--jf-line); overflow: hidden; }
.jf-meter-fill { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; background: linear-gradient(90deg, #16a34a, #ca8a04 75%, #dc2626); }
.jf-meter-text, .jf-cpu { font-size: .82rem; font-variant-numeric: tabular-nums; color: var(--jf-muted); min-width: 4.5em; }
.jf-chip { font-size: .78rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; background: var(--jf-warn); color: var(--jf-bg); }
.jf-status { flex: none; margin: 0; padding: .3rem .8rem; font-size: .88rem; min-height: 1.4em; background: var(--jf-surface-2); border-bottom: 1px solid var(--jf-line); }

/* menus */
.jf-menu-wrap { position: relative; }
.jf-menu { position: absolute; z-index: 30; inset-inline-start: 0; top: calc(100% + 4px); min-width: 15rem; padding: .3rem; background: var(--jf-surface); border: 1px solid var(--jf-line); border-radius: 10px; box-shadow: var(--shadow-2); overflow-y: auto; }
.jf-menu-end .jf-menu { inset-inline-start: auto; inset-inline-end: 0; }
.jf-menu-item { display: flex !important; width: 100% !important; justify-content: space-between; gap: 1rem; padding: .45rem .6rem !important; border-radius: 6px; text-align: start; font-weight: 500 !important; }
.jf-menu-item:hover, .jf-menu-item:focus { background: var(--jf-surface-2) !important; }
.jf-menu-item[aria-disabled="true"] { opacity: .5; cursor: default; }
.jf-menu-key { color: var(--jf-muted); font-size: .8rem; }
.jf-menu-sep { height: 1px; background: var(--jf-line); margin: .25rem 0; }
.jf-menu-head { font-size: .75rem; font-weight: 700; color: var(--jf-muted); padding: .3rem .6rem; }

/* rack */
.jf-rack-wrap { position: relative; flex: none; min-height: 260px; overflow-x: auto; overflow-y: hidden; background: var(--jf-surface-2); }
.jf-rack { position: relative; display: flex; flex-direction: column; gap: .7rem; padding: .7rem; min-width: min-content; }
.jf-rack:focus { outline: none; }
.jf-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-start; padding: .45rem; border-radius: 10px; background: repeating-linear-gradient(90deg, transparent 0 46px, rgb(0 0 0 / .04) 46px 48px), var(--jf-bg); border: 1px solid var(--jf-line); }
.jf-cables { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
.jf-cable { fill: none; stroke-width: 4.5; stroke-linecap: round; opacity: .9; }
.jf-cable-shadow { fill: none; stroke: rgb(0 0 0 / .45); stroke-width: 7; stroke-linecap: round; }
.jf-cable-temp { stroke-dasharray: 6 5; }

.jf-mod { position: relative; background: var(--jf-panel); border: 1px solid var(--jf-panel-edge); border-radius: 8px; padding: .45rem .5rem .55rem; box-shadow: inset 0 2px 0 rgb(255 255 255 / .35); }
.jf-w1 { width: 150px; } .jf-w2 { width: 210px; } .jf-w3 { width: 260px; } .jf-w4 { width: 340px; }
.jf-mod-head { display: flex; align-items: center; justify-content: space-between; gap: .3rem; border-bottom: 2px solid var(--jf-out); margin-bottom: .35rem; }
.jf-mod-title { font-size: .95rem; margin: 0; padding: .15rem 0; overflow-wrap: anywhere; }
.jf-mod-type { font-weight: 500; color: var(--jf-muted); font-size: .8rem; }
.jf-mod-menu .jf-icon-btn { width: 30px; height: 30px; flex: none; }
.jf-mod-head .jf-menu { min-width: 13rem; }
.jf-jacks { display: flex; flex-wrap: wrap; gap: .25rem; margin: .2rem 0; padding: .25rem; border-radius: 6px; }
.jf-jacks-in { background: rgb(29 78 216 / .07); }
.jf-jacks-out { background: rgb(154 52 18 / .09); }
.jf-jack { display: inline-flex !important; flex-direction: column; align-items: center; gap: 2px; min-width: 44px; min-height: 44px !important; padding: 2px 3px !important; border-radius: 6px; touch-action: none; }
.jf-jack:hover { background: var(--jf-surface) !important; }
.jf-socket { width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle, var(--jf-socket) 0 38%, #9ca3af 40% 55%, var(--jf-socket-ring) 57%); border: 2px solid var(--jf-socket-ring); }
.jf-jack-in .jf-socket { border-color: var(--jf-in); }
.jf-jack-out .jf-socket { border-color: var(--jf-out); border-radius: 4px; }
.jf-jack-used .jf-socket { box-shadow: 0 0 0 2px var(--jf-panel), 0 0 0 4px currentColor; }
.jf-jack-pending { background: var(--jf-accent) !important; color: var(--jf-on-accent); }
.jf-jack-label { font-size: .72rem; font-weight: 600; line-height: 1.1; max-width: 70px; text-align: center; }
.jf-params { display: grid; grid-template-columns: minmax(0, 1fr); gap: .3rem; margin-top: .3rem; }
.jf-param { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; font-size: .8rem; }
.jf-param label { font-weight: 600; }
.jf-param-ctl { display: flex; align-items: center; gap: .3rem; min-width: 0; }
.jf-range { flex: 1 1 auto; min-width: 0; accent-color: var(--jf-out); height: 24px; }
.jf-num { width: 5.2em; padding: .15rem .25rem; font-size: .8rem; }
.jf-select { padding: .2rem .3rem; font-size: .82rem; }
.jf-seq .jf-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .3rem; }
.jf-step-col { display: grid; gap: 2px; padding: .2rem; border: 1px solid var(--jf-panel-edge); border-radius: 6px; }
.jf-step .jf-param-ctl { flex-direction: column; align-items: stretch; }
.jf-step .jf-num { width: 100%; box-sizing: border-box; }
.jf-step-col input[type=checkbox], .jf-app input[type=checkbox] { width: 24px; height: 24px; margin: 0; accent-color: var(--jf-accent, currentColor); }
.jf-check { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 600; }
.jf-scope { display: block; width: 100%; height: auto; border-radius: 6px; margin: .3rem 0; background: var(--jf-scope-bg); }

/* keys */
.jf-keys { flex: none; display: flex; align-items: center; gap: .6rem; padding: .4rem .7rem; background: var(--jf-surface); border-top: 1px solid var(--jf-line); overflow-x: auto; }
.jf-oct { display: flex; align-items: center; gap: .2rem; flex: none; }
.jf-oct-label { font-size: .85rem; font-weight: 600; min-width: 5.5em; text-align: center; }
.jf-piano { position: relative; display: flex; height: 70px; direction: ltr; flex: none; }
.jf-key { position: relative; touch-action: none; }
.jf-key-white { width: 48px; height: 70px !important; background: #fff !important; border: 1px solid #6b7280 !important; border-radius: 0 0 5px 5px; z-index: 1; }
.jf-key-black { width: 24px; height: 44px !important; margin-inline: -12px; background: #111827 !important; border: 1px solid #000 !important; border-radius: 0 0 4px 4px; z-index: 2; }
.jf-key-on.jf-key-white { background: #fdba74 !important; }
.jf-key-on.jf-key-black { background: #c2410c !important; }

/* details */
.jf-details { flex: none; background: var(--jf-surface); border-top: 1px solid var(--jf-line); }
.jf-tabs { display: flex; flex-wrap: wrap; gap: .2rem; padding: .3rem .6rem 0; border-bottom: 1px solid var(--jf-line); background: var(--jf-surface); }
.jf-tab { padding: .45rem .8rem !important; border-radius: 8px 8px 0 0; color: var(--jf-ink); border-bottom: 3px solid transparent !important; }
.jf-tab[aria-selected="true"] { border-bottom-color: var(--jf-out) !important; }
.jf-panel { padding: .5rem .8rem .8rem; }
.jf-notes-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; }
.jf-notes-grid label { display: block; font-weight: 600; font-size: .88rem; margin: .3rem 0 .15rem; }
.jf-facts { display: grid; grid-template-columns: auto auto; gap: .2rem .8rem; margin: .3rem 0; font-size: .88rem; justify-content: start; align-content: start; }
.jf-facts dt { font-weight: 600; }
.jf-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.jf-verdict { display: flex; align-items: center; gap: .4rem; font-weight: 700; margin: .3rem 0; }
.jf-v-ok { color: var(--jf-ok); } .jf-v-warnings { color: var(--jf-warn); } .jf-v-errors { color: var(--jf-danger); }
.jf-issues { margin: .3rem 0; padding-inline-start: 1.2rem; font-size: .9rem; }
.jf-issues li { margin: .25rem 0; }
.jf-link-btn { color: var(--jf-accent-ink) !important; text-decoration: underline; margin-inline-start: .4rem; font-weight: 600; }
.jf-table-wrap { position: relative; overflow-x: auto; }
.jf-table caption { text-align: start; font-weight: 700; padding: .3rem 0; }
.jf-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-inline-end: .35rem; vertical-align: middle; border: 1px solid #0006; }
.jf-col-yellow { background: #eab308; } .jf-col-red { background: #dc2626; } .jf-col-blue { background: #2563eb; } .jf-col-green { background: #16a34a; }
.jf-col-orange { background: #ea580c; } .jf-col-purple { background: #9333ea; } .jf-col-white { background: #e5e7eb; } .jf-col-cyan { background: #06b6d4; }

/* dialogs */
.jf-dialog { max-width: min(560px, calc(100vw - 2rem)); width: 100%; border: 1px solid var(--jf-line); border-radius: 12px; padding: 0; background: var(--jf-surface); color: var(--jf-ink); box-shadow: var(--shadow-3); }
.jf-dialog-wide { max-width: min(820px, calc(100vw - 2rem)); }
.jf-dialog::backdrop { background: rgb(0 0 0 / .45); }
.jf-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem .9rem; border-bottom: 1px solid var(--jf-line); }
.jf-dialog-head h2 { margin: 0; font-size: 1.1rem; }
.jf-dialog-lede { margin: .5rem .9rem 0; color: var(--jf-muted); font-size: .9rem; }
.jf-dialog-body { padding: .7rem .9rem .9rem; max-height: 70vh; overflow: auto; }
.jf-dialog-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }
.jf-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: .3rem; }
.jf-form label { font-weight: 600; font-size: .88rem; margin-top: .3rem; }
.jf-form :is(input, select) { padding: .35rem .5rem; }
.jf-add-list { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .4rem; }
.jf-add-btn { display: grid !important; gap: .15rem; width: 100% !important; text-align: start; padding: .5rem .6rem !important; border: 1px solid var(--jf-line) !important; border-radius: 8px; background: var(--jf-bg) !important; }
.jf-add-btn:hover { border-color: var(--jf-out) !important; }
.jf-add-btn span { font-weight: 400; font-size: .82rem; color: var(--jf-muted); }
.jf-recent { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }
.jf-recent li { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.jf-dialog-table { margin-top: .3rem; }

@media (max-width: 720px) {
  .jf-bar { gap: .3rem; padding: .35rem .5rem; }
  .jf-name { display: none; }
  .jf-meter { width: 56px; }
  .jf-notes-grid { grid-template-columns: minmax(0, 1fr); }
  .jf-w3, .jf-w4 { width: min(340px, calc(100vw - 3.2rem)); }
  .jf-details { max-height: none; }
}
@media (max-width: 420px) {
  .jf-w1, .jf-w2 { width: calc(50vw - 2rem); }
  .jf-w3, .jf-w4 { width: calc(100vw - 3.2rem); }
  .jf-cpu { display: none; }
}
