 :root {
     --ground: #0b0b0b;
     --surface: #131313;
     --sunken: #080808;
     --ink: #ededea;
     --ink2: #b8b8b2;
     --muted: #86867f;
     --line: #262625;
     --line-soft: #1d1d1c;
     --accent: #ff3b3b;
     --ok: #54c58a;
     --warn: #e0a63a;
     --crit: #ff5a5a;
     --r-sm: 4px;
     --r-md: 6px;
     --sans: 'Archivo', system-ui, sans-serif;
     --mono: 'JetBrains Mono', ui-monospace, monospace;
     --display: 'Doto', var(--mono);
     --brand: 'Open Sans', 'Segoe UI', sans-serif;
     /* skeuomorphic bevels */
     --bevel-hi: rgba(255, 255, 255, .07);
     --bevel-lo: rgba(0, 0, 0, .65);
 }

 *,
 *::before,
 *::after {
     box-sizing: border-box;
     margin: 0;
     padding: 0;
 }

 /* squircle corners everywhere. Browsers without corner-shape keep plain rounded corners. */
 @supports (corner-shape: squircle) {
     :root {
         --r-sm: 7px;
         --r-md: 11px;
     }

     *,
     *::before,
     *::after {
         corner-shape: squircle;
     }

     .app {
         border-radius: 18px !important;
     }

     .dot {
         corner-shape: round;
     }
 }

 body {
     min-height: 100vh;
     background: var(--ground);
     color: var(--ink);
     font: 14px/1.5 var(--sans);
     display: grid;
     place-items: center;
     align-content: center;
     grid-template-columns: minmax(0, 1fr);
     gap: 18px;
     padding: 32px 16px;
     -webkit-font-smoothing: antialiased;
 }

 #bg-canvas {
     position: fixed;
     inset: 0;
     width: 100%;
     height: 100%;
     z-index: 0;
     pointer-events: none;
 }

 /* ── Shell ── */
 .app {
     position: relative;
     z-index: 1;
     width: min(980px, 100%);
     background: linear-gradient(180deg, color-mix(in srgb, #1a1a19 92%, transparent), color-mix(in srgb, #0f0f0f 92%, transparent));
     border: 1px solid #2e2e2c;
     border-top-color: #3a3a37;
     border-bottom-color: #050505;
     border-radius: 10px;
     backdrop-filter: blur(6px);
     box-shadow:
         inset 0 1px 0 var(--bevel-hi),
         inset 0 -1px 0 var(--bevel-lo),
         0 0 0 1px #000,
         0 2px 0 #050505,
         0 30px 80px rgba(0, 0, 0, .7);
     display: grid;
     grid-template-columns: minmax(0, 1fr) 280px;
     grid-template-rows: auto 1fr auto;
     grid-template-areas:
         "head  side"
         "main  side"
         "log   side";
     gap: 20px;
     padding: 24px;
 }

 .eyebrow {
     font: 500 11px/1 var(--mono);
     letter-spacing: .12em;
     text-transform: uppercase;
     color: var(--muted);
 }

 header {
     grid-area: head;
     display: flex;
     flex-direction: column;
     gap: 8px;
     align-self: start;
 }

 header h1 {
     font: 300 26px/1.25 var(--brand);
     letter-spacing: .14em;
     color: var(--ink);
     text-shadow: 0 1px 0 #000, 0 -1px 0 rgba(255, 255, 255, .04);
 }

 header h1 .br {
     color: var(--accent);
 }

 header h1 .amp {
     color: var(--muted);
 }

 /* recessed well: dark inner shadow, light lower lip */
 .panel {
     background: linear-gradient(180deg, #060606, var(--sunken) 30%, #0c0c0c);
     border: 1px solid #000;
     border-radius: var(--r-md);
     box-shadow:
         inset 0 2px 6px rgba(0, 0, 0, .8),
         inset 0 0 0 1px rgba(255, 255, 255, .02),
         0 1px 0 var(--bevel-hi);
 }

 /* ── Buttons & inputs ── */
 button,
 input {
     font: inherit;
     color: inherit;
 }

 .btn {
     background: linear-gradient(180deg, #2a2a28, #181817);
     border: 1px solid #000;
     border-radius: var(--r-sm);
     padding: 7px 14px;
     cursor: pointer;
     font-weight: 500;
     font-size: 13px;
     box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), inset 0 -1px 0 rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .6);
     text-shadow: 0 -1px 0 #000;
     transition: filter .15s, box-shadow .1s, transform .1s;
 }

 .btn:hover {
     filter: brightness(1.15);
 }

 .btn:active {
     transform: translateY(1px);
     box-shadow: inset 0 2px 4px rgba(0, 0, 0, .7);
 }

 .btn.primary {
     background: linear-gradient(180deg, #ff5c5c, #d92020 55%, #b51818);
     border-color: #5a0a0a;
     color: #fff;
     font-weight: 600;
     letter-spacing: .04em;
     text-shadow: 0 -1px 0 rgba(0, 0, 0, .45);
     box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), inset 0 -2px 0 rgba(0, 0, 0, .25), 0 2px 0 #3a0606, 0 6px 18px rgba(255, 59, 59, .25);
 }

 .btn.primary:active {
     transform: translateY(2px);
     box-shadow: inset 0 2px 5px rgba(0, 0, 0, .45), 0 0 0 #3a0606;
 }

 .input {
     width: 100%;
     background: linear-gradient(180deg, #050505, #0e0e0e);
     border: 1px solid #000;
     border-radius: var(--r-sm);
     box-shadow: inset 0 1px 3px rgba(0, 0, 0, .9), 0 1px 0 var(--bevel-hi);
     padding: 8px 10px;
     font-size: 13px;
     outline: none;
 }

 .input::placeholder {
     color: var(--muted);
 }

 .input:focus {
     border-color: var(--accent);
     box-shadow: inset 0 1px 3px rgba(0, 0, 0, .9), 0 0 0 2px rgba(255, 59, 59, .18);
 }

 /* ── Footer ── */
 .foot {
     position: relative;
     z-index: 1;
     text-align: center;
     font: 300 11px/1.6 var(--brand);
     letter-spacing: .3em;
     color: white;
 }

 .foot b {
     font-weight: 400;
     color: var(--ink2);
 }

 .foot .tag {
     display: block;
     font-size: 10px;
     opacity: .6;
 }

 /* ── API key panel ── */
 .api {
     padding: 14px;
     display: flex;
     flex-direction: column;
     gap: 10px;
 }

 .api-head {
     display: flex;
     justify-content: space-between;
     align-items: center;
 }

 .seg {
     display: grid;
     grid-template-columns: repeat(3, 1fr);
     background: #050505;
     border: 1px solid #000;
     border-radius: var(--r-sm);
     padding: 3px;
     gap: 3px;
     box-shadow: inset 0 2px 4px rgba(0, 0, 0, .9), 0 1px 0 var(--bevel-hi);
 }

 .seg button {
     border: 0;
     background: transparent;
     border-radius: 3px;
     padding: 6px 4px;
     cursor: pointer;
     font: 500 11px/1.2 var(--mono);
     color: var(--muted);
 }

 .seg button[aria-pressed="true"] {
     background: linear-gradient(180deg, #2c2c2a, #1a1a19);
     color: var(--ink);
     box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), inset 0 -2px 0 var(--accent), 0 1px 2px rgba(0, 0, 0, .8);
 }

 .api-view {
     display: none;
     flex-direction: column;
     gap: 8px;
 }

 .api-view.active {
     display: flex;
 }

 .key-list {
     list-style: none;
     display: flex;
     flex-direction: column;
     gap: 6px;
 }

 .key-list li {
     display: flex;
     justify-content: space-between;
     align-items: center;
     gap: 6px;
     padding: 6px 4px 6px 10px;
     border: 1px solid var(--line-soft);
     border-radius: var(--r-sm);
     font-size: 13px;
     cursor: pointer;
     background: linear-gradient(180deg, rgba(255, 255, 255, .025), transparent);
 }

 .key-list li:hover {
     border-color: var(--line);
 }

 .key-list li.on {
     border-color: var(--accent);
     box-shadow: inset 3px 0 0 var(--accent);
 }

 .key-list .info {
     min-width: 0;
     display: flex;
     flex-direction: column;
 }

 .key-list .info b {
     font-weight: 500;
     overflow: hidden;
     text-overflow: ellipsis;
     white-space: nowrap;
 }

 .key-list code {
     font: 11px var(--mono);
     color: var(--muted);
     overflow: hidden;
     text-overflow: ellipsis;
     white-space: nowrap;
 }

 .key-list .del {
     flex-shrink: 0;
     background: none;
     border: 0;
     border-radius: var(--r-sm);
     color: var(--muted);
     cursor: pointer;
     padding: 4px 8px;
     font: 15px/1 var(--sans);
 }

 .key-list .del:hover {
     color: var(--crit);
 }

 .key-list .del.confirm {
     font: 500 11px/1 var(--mono);
     color: #fff;
     background: linear-gradient(180deg, #ff5c5c, #b51818);
     box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3);
     padding: 6px 8px;
 }

 .api-active {
     font: 11px var(--mono);
     color: var(--muted);
     max-width: 60%;
     overflow: hidden;
     text-overflow: ellipsis;
     white-space: nowrap;
 }

 .api-active.on {
     color: var(--ok);
 }

 .api-msg {
     font-size: 12px;
     color: var(--crit);
 }

 .api-msg:empty {
     display: none;
 }

 .input.bad {
     border-color: var(--crit);
 }

 .hint {
     font-size: 12px;
     color: var(--muted);
 }

 select.input {
     appearance: none;
     cursor: pointer;
     font-family: var(--mono);
     font-size: 12px;
     background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%), linear-gradient(180deg, #050505, #0e0e0e);
     background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%, 0 0;
     background-size: 5px 5px, 5px 5px, 100% 100%;
     background-repeat: no-repeat;
 }

 select.input option {
     background: #111;
     color: var(--ink);
 }

 /* ── Main area ── */
 main {
     grid-area: main;
     min-height: 340px;
     display: flex;
 }

 .view {
     display: none;
     flex: 1;
 }

 .view.active {
     display: flex;
 }

 .drop {
     flex: 1;
     flex-direction: column;
     align-items: center;
     justify-content: center;
     gap: 10px;
     border: 1px dashed #3a3a37;
     border-radius: var(--r-md);
     background: linear-gradient(180deg, #050505, var(--sunken) 30%, #0d0d0d);
     box-shadow: inset 0 3px 10px rgba(0, 0, 0, .85), 0 1px 0 var(--bevel-hi);
     cursor: pointer;
     text-align: center;
     transition: border-color .15s, background .15s;
 }

 .drop.active {
     display: flex;
 }

 .drop:hover {
     border-color: var(--accent);
     background: color-mix(in srgb, var(--accent) 4%, var(--sunken));
 }

 .drop .icon {
     font: 900 40px/1 var(--display);
     color: var(--accent);
 }

 .drop strong {
     font-size: 16px;
 }

 .drop u {
     text-decoration-color: var(--accent);
     text-underline-offset: 3px;
 }

 .fields {
     gap: 14px;
     align-items: stretch;
     flex-direction: column;
 }

 .fields.active {
     display: flex;
 }

 .fields-top {
     display: flex;
     justify-content: space-between;
     align-items: center;
 }

 .fields-top .file {
     font: 12px var(--mono);
     color: var(--ink2);
 }

 .fields-top .file b {
     color: var(--ok);
     font-weight: 500;
 }

 .columns {
     flex: 1;
     display: grid;
     grid-template-columns: 1fr 1fr;
     gap: 14px;
 }

 .col {
     display: flex;
     flex-direction: column;
     overflow: hidden;
 }

 .col h2 {
     font: 600 13px/1 var(--sans);
     padding: 12px 14px;
     border-bottom: 1px solid var(--line);
     display: flex;
     justify-content: space-between;
 }

 .col h2 small {
     font: 11px var(--mono);
     color: var(--muted);
 }

 .col ul {
     list-style: none;
     padding: 8px;
     display: flex;
     flex-direction: column;
     gap: 4px;
     flex: 1;
 }

 .col li {
     padding: 8px 10px;
     border-radius: var(--r-sm);
     font: 13px var(--mono);
     cursor: pointer;
     border: 1px solid transparent;
 }

 .col li:hover {
     background: var(--surface);
 }

 .col li.sel {
     border-color: var(--accent);
     background: var(--surface);
 }

 /* ── Log ── */
 .log {
     grid-area: log;
     padding: 6px 14px 12px;
     display: flex;
     flex-direction: column;
     gap: 6px;
 }

 .log-head {
     display: flex;
     justify-content: space-between;
     align-items: center;
 }

 .log-head .btn {
     padding: 3px 10px;
     font-size: 12px;
 }

 .status {
     display: flex;
     align-items: center;
     gap: 8px;
     font: 11px var(--mono);
     color: var(--ink2);
 }

 /* LED */
 .dot {
     width: 10px;
     height: 10px;
     border-radius: 50%;
     background: radial-gradient(circle at 35% 30%, #c9ffe0, var(--ok) 45%, #1f6b44);
     box-shadow: 0 0 0 2px #000, 0 0 0 3px rgba(255, 255, 255, .06), 0 0 10px var(--ok);
 }

 .log pre {
     font: 12px/1.7 var(--mono);
     color: var(--ink2);
     max-height: 110px;
     overflow: auto;
     white-space: pre-wrap;
     overflow-wrap: anywhere;
 }

 .log pre .ok {
     color: var(--ok);
 }

 .log pre .warn {
     color: var(--warn);
 }

 .log pre .t {
     color: var(--muted);
 }

 /* ── Side ── */
 .side {
     grid-area: side;
     display: flex;
     flex-direction: column;
     justify-content: space-between;
     gap: 20px;
 }

 .side .btn.primary {
     padding: 12px;
     font-size: 14px;
 }

 .btn:disabled {
     opacity: .45;
     cursor: default;
     filter: none;
     transform: none;
 }

 .viewer th.hit {
     color: var(--accent);
 }

 .viewer td.hit {
     color: var(--ink);
 }

 .viewer td.changed {
     color: var(--ok);
 }

 /* ── Field tools (Fix / Daten) next to each selected field ── */
 .col li {
     display: flex;
     align-items: center;
     gap: 6px;
 }

 .col li .name {
     flex: 1;
     min-width: 0;
     overflow: hidden;
     text-overflow: ellipsis;
     white-space: nowrap;
 }

 #list-sel li {
     padding: 4px 4px 4px 10px;
 }

 .tool {
     padding: 2px 8px;
     font: 500 11px/1.6 var(--mono);
     flex-shrink: 0;
 }

 #list-av .tool {
     display: none;
 }

 .tool.on {
     color: var(--ok);
     box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), inset 0 -2px 0 var(--ok), 0 1px 2px rgba(0, 0, 0, .6);
 }

 .tool[aria-expanded="true"] {
     filter: brightness(1.3);
 }

 /* ── Available headers (filter, drag) → TTN slots ── */
 .col ul {
     max-height: 300px;
     overflow: auto;
 }

 .col-tools {
     padding: 8px 8px 0;
 }

 .col-tools .input {
     padding: 6px 9px;
     font: 12px var(--mono);
 }

 #list-av li {
     cursor: grab;
 }

 #list-av li.dragging {
     opacity: .4;
 }

 #list-av li.none {
     cursor: default;
     color: var(--muted);
     font-style: italic;
 }

 #list-av li.none:hover {
     background: none;
 }

 .badge {
     flex-shrink: 0;
     font: 10px/1.5 var(--mono);
     color: var(--ok);
     border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent);
     border-radius: 3px;
     padding: 0 5px;
 }

 .col li.slot {
     display: block;
     padding: 7px 6px 7px 10px;
     cursor: default;
     border: 1px dashed #30302e;
     background: rgba(255, 255, 255, .012);
 }

 .col li.slot:hover {
     background: rgba(255, 255, 255, .025);
 }

 .slot-top {
     display: flex;
     justify-content: space-between;
     gap: 8px;
     margin-bottom: 5px;
     font: 500 10px/1 var(--mono);
     letter-spacing: .1em;
     text-transform: uppercase;
     color: var(--muted);
 }

 .slot-top .req {
     color: var(--accent);
 }

 .slot-body {
     display: flex;
     align-items: center;
     gap: 6px;
     min-height: 24px;
 }

 .slot:not(.filled) .name {
     color: #4b4b48;
     font-style: italic;
 }

 /* ausgegraut */
 .slot.filled {
     border-style: solid;
     border-color: #2a2a28;
 }

 .slot.fixed {
     border-style: solid;
     border-color: transparent;
     background: none;
 }

 .slot.fixed .name {
     color: var(--ink2);
     font-style: normal;
 }

 #list-sel.dropping .slot:not(.fixed):not(.filled) {
     border-color: rgba(255, 59, 59, .45);
 }

 .col li.slot.over {
     border-color: var(--accent);
     border-style: solid;
     background: rgba(255, 59, 59, .07);
 }

 .slot .x {
     background: none;
     border: 0;
     color: var(--muted);
     cursor: pointer;
     padding: 0 6px;
     font-size: 15px;
     line-height: 1;
 }

 .slot .x:hover {
     color: var(--crit);
 }

 /* TTN command preview */
 .ttn {
     padding: 10px 14px 12px;
     display: flex;
     flex-direction: column;
     gap: 6px;
 }

 .ttn-head {
     display: flex;
     justify-content: space-between;
     align-items: center;
     gap: 10px;
 }

 .ttn-ready {
     font: 12px var(--mono);
     color: var(--muted);
 }

 .ttn-ready b {
     color: var(--ok);
     font-weight: 500;
 }

 .ttn-cmd {
     font: 12px/1.6 var(--mono);
     color: var(--muted);
     white-space: pre-wrap;
     overflow-wrap: anywhere;
 }

 .ttn-cmd .kw {
     color: var(--accent);
 }

 .ttn-cmd .v {
     color: var(--ink);
 }

 .ttn-cmd .ph {
     color: #55554f;
     font-style: italic;
 }

 /* LED states */
 .dot.busy {
     background: radial-gradient(circle at 35% 30%, #fff1c9, var(--warn) 45%, #7a5600);
     box-shadow: 0 0 0 2px #000, 0 0 0 3px rgba(255, 255, 255, .06), 0 0 10px var(--warn);
 }

 .dot.err {
     background: radial-gradient(circle at 35% 30%, #ffd0d0, var(--crit) 45%, #7a1010);
     box-shadow: 0 0 0 2px #000, 0 0 0 3px rgba(255, 255, 255, .06), 0 0 10px var(--crit);
 }

 .sheet .preview b {
     color: var(--ink);
     font-weight: 500;
 }

 .sheet .row .grow {
     flex: 1;
 }

 /* while a window (Daten, CSV ansehen, …) is open the blurred page behind it does not scroll */
 html {
     scrollbar-gutter: stable;
 }

 html:has(dialog[open]) {
     overflow: hidden;
 }

 .tiles,
 .table-wrap {
     overscroll-behavior: contain;
     min-height: 0;
 }

 /* fix menu (popover under the Fix box) */
 .menu {
     position: fixed;
     z-index: 20;
     min-width: 250px;
     max-width: calc(100vw - 16px);
     padding: 6px;
     display: none;
     flex-direction: column;
     gap: 2px;
     background: linear-gradient(180deg, #1d1d1c, #121212);
     border: 1px solid #000;
     border-radius: var(--r-md);
     box-shadow: inset 0 1px 0 var(--bevel-hi), 0 0 0 1px #2e2e2c, 0 18px 40px rgba(0, 0, 0, .75);
 }

 .menu.open {
     display: flex;
 }

 .menu .grp {
     font: 500 10px/1 var(--mono);
     letter-spacing: .12em;
     text-transform: uppercase;
     color: var(--muted);
     padding: 8px 8px 4px;
 }

 .menu .item {
     display: flex;
     align-items: center;
     gap: 6px;
 }

 .menu .item>button:first-child {
     flex: 1;
     text-align: left;
     background: none;
     border: 0;
     border-radius: var(--r-sm);
     padding: 6px 8px;
     cursor: pointer;
     font-size: 13px;
     color: var(--ink);
 }

 .menu .item>button:first-child small {
     display: block;
     font: 11px var(--mono);
     color: var(--muted);
 }

 .menu .item>button:first-child:hover {
     background: var(--surface);
 }

 .menu .item .x {
     background: none;
     border: 0;
     color: var(--muted);
     cursor: pointer;
     padding: 4px 8px;
     font-size: 14px;
 }

 .menu .item .x:hover {
     color: var(--crit);
 }

 .menu hr {
     border: 0;
     border-top: 1px solid #000;
     box-shadow: 0 1px 0 var(--bevel-hi);
     margin: 4px 2px;
 }

 /* fix-script editor */
 .sheet {
     margin: auto;
     width: min(560px, calc(100vw - 32px));
     color: var(--ink);
     background: linear-gradient(180deg, #1a1a19, #0f0f0f);
     border: 1px solid #2e2e2c;
     border-top-color: #3a3a37;
     border-radius: 14px;
     box-shadow: inset 0 1px 0 var(--bevel-hi), 0 0 0 1px #000, 0 30px 80px rgba(0, 0, 0, .8);
     padding: 16px;
     flex-direction: column;
     gap: 10px;
 }

 .sheet[open] {
     display: flex;
 }

 .sheet::backdrop {
     background: rgba(0, 0, 0, .45);
     backdrop-filter: blur(8px);
 }

 .sheet h3 {
     font: 300 16px/1.2 var(--brand);
     letter-spacing: .1em;
 }

 .sheet textarea.input {
     font: 12px/1.6 var(--mono);
     min-height: 110px;
     resize: vertical;
 }

 .sheet .sig {
     font: 12px var(--mono);
     color: var(--muted);
 }

 .sheet .sig b {
     color: var(--accent);
     font-weight: 500;
 }

 .sheet .preview {
     font: 12px/1.7 var(--mono);
     color: var(--ink2);
     padding: 8px 10px;
     min-height: 40px;
     white-space: pre-wrap;
     overflow-wrap: anywhere;
 }

 .sheet .preview .err {
     color: var(--crit);
 }

 .sheet .preview .ok {
     color: var(--ok);
 }

 .sheet .row {
     display: flex;
     justify-content: flex-end;
     gap: 8px;
 }

 /* data overlay: blurred page, small glass tiles float in front */
 .peek {
     margin: auto;
     width: min(900px, calc(100vw - 32px));
     max-height: calc(100vh - 48px);
     background: none;
     border: 0;
     padding: 0;
     color: var(--ink);
     flex-direction: column;
     gap: 12px;
     overflow: hidden;
 }

 .peek[open] {
     display: flex;
 }

 .peek::backdrop {
     background: rgba(5, 5, 5, .5);
     backdrop-filter: blur(10px) saturate(120%);
 }

 .glass {
     background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .025));
     backdrop-filter: blur(14px);
     -webkit-backdrop-filter: blur(14px);
     border: 1px solid rgba(255, 255, 255, .08);
     border-bottom-color: rgba(0, 0, 0, .6);
     border-radius: var(--r-md);
     box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 8px 24px rgba(0, 0, 0, .45);
 }

 .peek-head {
     display: flex;
     align-items: center;
     justify-content: space-between;
     gap: 10px;
     padding: 8px 8px 8px 14px;
     flex-wrap: wrap;
 }

 .peek-head .title {
     font: 300 15px/1.3 var(--brand);
     letter-spacing: .1em;
 }

 .peek-head .title .br {
     color: var(--accent);
 }

 .peek-head .meta {
     font: 12px var(--mono);
     color: var(--ink2);
 }

 .peek-head .actions {
     display: flex;
     gap: 8px;
     align-items: center;
 }

 .peek-head .input {
     width: 160px;
     padding: 5px 9px;
 }

 .peek-head .btn {
     padding: 4px 11px;
     font-size: 12px;
 }

 .tiles {
     display: flex;
     flex-wrap: wrap;
     gap: 8px;
     overflow: auto;
     padding: 2px;
 }

 .tile {
     padding: 6px 10px;
     font: 12px/1.4 var(--mono);
     max-width: 100%;
     overflow-wrap: anywhere;
     animation: tileIn .25s both;
 }

 .tile small {
     color: var(--muted);
     margin-right: 6px;
 }

 .tile.empty {
     color: var(--muted);
     font-style: italic;
 }

 .tile.changed {
     border-color: color-mix(in srgb, var(--ok) 55%, transparent);
     color: var(--ok);
 }

 .tile.changed s {
     color: var(--muted);
     margin-right: 6px;
 }

 /* edit mode: tiles become inputs */
 .peek-head .btn[aria-pressed="true"] {
     color: var(--ink);
     box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), inset 0 -2px 0 var(--accent), 0 1px 2px rgba(0, 0, 0, .6);
 }

 .tile.edit {
     display: flex;
     align-items: center;
     gap: 4px;
     padding: 3px 3px 3px 10px;
 }

 .tile.edit input {
     width: calc(var(--len, 6) * 1ch + 14px);
     min-width: 7ch;
     max-width: 100%;
     background: rgba(0, 0, 0, .4);
     color: inherit;
     font: inherit;
     outline: none;
     border: 1px solid #000;
     border-radius: var(--r-sm);
     padding: 3px 6px;
     box-shadow: inset 0 1px 3px rgba(0, 0, 0, .8), 0 1px 0 var(--bevel-hi);
 }

 .tile.edit input::placeholder {
     color: var(--muted);
     font-style: italic;
 }

 .tile.edit input:focus {
     border-color: var(--accent);
     box-shadow: inset 0 1px 3px rgba(0, 0, 0, .8), 0 0 0 2px rgba(255, 59, 59, .18);
 }

 .tile .del {
     background: none;
     border: 0;
     color: var(--muted);
     cursor: pointer;
     padding: 0 6px;
     font-size: 15px;
     line-height: 1;
 }

 .tile .del:hover {
     color: var(--crit);
 }

 .tile .del:disabled {
     visibility: hidden;
 }

 @keyframes tileIn {
     from {
         opacity: 0;
         transform: translateY(6px) scale(.97);
     }
 }

 /* ── CSV viewer ── */
 .fields-top .actions {
     display: flex;
     gap: 8px;
 }

 .viewer {
     margin: auto;
     width: min(920px, calc(100vw - 32px));
     max-height: calc(100vh - 48px);
     color: var(--ink);
     background: linear-gradient(180deg, #1a1a19, #0f0f0f);
     border: 1px solid #2e2e2c;
     border-top-color: #3a3a37;
     border-radius: 14px;
     box-shadow: inset 0 1px 0 var(--bevel-hi), 0 0 0 1px #000, 0 30px 80px rgba(0, 0, 0, .8);
     padding: 14px;
     flex-direction: column;
     gap: 10px;
 }

 .viewer[open] {
     display: flex;
 }

 .viewer::backdrop {
     background: rgba(0, 0, 0, .6);
     backdrop-filter: blur(2px);
 }

 .viewer-head {
     display: flex;
     justify-content: space-between;
     align-items: center;
     gap: 12px;
 }

 .viewer-head .file {
     font: 12px var(--mono);
     color: var(--ink2);
     overflow: hidden;
     text-overflow: ellipsis;
     white-space: nowrap;
 }

 .viewer-head .file b {
     color: var(--ok);
     font-weight: 500;
 }

 .viewer-head .actions {
     display: flex;
     gap: 8px;
     flex-shrink: 0;
 }

 .viewer-head .input {
     width: 180px;
     padding: 5px 9px;
 }

 .viewer-head .btn {
     padding: 4px 11px;
     font-size: 12px;
 }

 .table-wrap {
     overflow: auto;
     min-height: 120px;
 }

 .viewer table {
     border-collapse: collapse;
     width: 100%;
     font: 12px/1.5 var(--mono);
 }

 .viewer th,
 .viewer td {
     padding: 5px 10px;
     text-align: left;
     white-space: nowrap;
     border-bottom: 1px solid var(--line-soft);
 }

 .viewer th {
     position: sticky;
     top: 0;
     background: #101010;
     color: var(--ink);
     font-weight: 500;
     border-bottom-color: var(--line);
 }

 .viewer td {
     color: var(--ink2);
 }

 .viewer td.n,
 .viewer th.n {
     color: var(--muted);
     text-align: right;
     width: 1%;
 }

 .viewer tbody tr:hover td {
     background: var(--surface);
 }

 .viewer .empty {
     padding: 24px;
     text-align: center;
     color: var(--muted);
 }

 @media (max-width: 760px) {
     .viewer-head {
         flex-wrap: wrap;
     }

     .viewer-head .input {
         width: 100%;
     }

     .app {
         grid-template-columns: minmax(0, 1fr);
         grid-template-areas: "head" "api" "main" "log" "go";
         padding: 16px;
     }

     .side {
         display: contents;
     }

     .api {
         grid-area: api;
     }

     .side>.btn.primary {
         grid-area: go;
     }

     header h1 {
         font-size: 20px;
         letter-spacing: .08em;
     }

     .seg button {
         min-width: 0;
         overflow: hidden;
         text-overflow: ellipsis;
     }

     .foot {
         letter-spacing: .15em;
     }

     .columns {
         grid-template-columns: 1fr;
     }
 }
/* ── Application ID (top right) ── */
.side-top {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.appid {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.appid .input {
    font-family: var(--mono);
    font-size: 12px;
}

.appid .hint:empty {
    display: none;
}

.appid .hint {
    color: var(--crit);
}

@media (max-width: 760px) {
    .side-top {
        display: contents;
    }

    .appid {
        grid-area: appid;
    }

    .app {
        grid-template-areas: "head" "appid" "api" "main" "log" "go";
    }
}
