/* Keys and splines — on top of calc.css */
main.ky .tabs { grid-template-columns: repeat(3, 1fr); }
main.ky .stage-bar { justify-content: flex-start; gap: 8px; flex-wrap: wrap; }
main.ky .stage-bar .hist { margin-left: auto; }
.ky-types button { white-space: nowrap; }
#view { display: block; width: 100%; height: auto; user-select: none; touch-action: none; }
#view .hit { fill: transparent; stroke: none; }
#view .handle { cursor: grab; }
#view .handle.hx { cursor: ew-resize; }
#view .handle .knob { fill: var(--surface); stroke: var(--sel); stroke-width: 1.8; }
#view .handle:hover .knob, #view .handle:focus .knob { fill: var(--sel); }
#view.dragging .handle { cursor: grabbing; }

/* parts */
.ky-hub { fill: var(--steel-200); stroke: var(--steel-700); stroke-width: 1.1; fill-rule: evenodd; }
.ky-shaft { fill: var(--steel-300); stroke: var(--steel-750); stroke-width: 1.1; fill-rule: evenodd; }
.ky-key { fill: var(--x-b9c0c8, #b9c0c8); stroke: var(--steel-850); stroke-width: 1.1; stroke-linejoin: round; }
.ky-ctr { stroke: var(--steel-550); stroke-width: .8; stroke-dasharray: 10 3 2 3; fill: none; pointer-events: none; }
.ky-hatch { fill: url(#kyHatch); stroke: var(--steel-700); stroke-width: 1.1; }
.ky-band { fill: var(--steel-300); stroke: var(--steel-750); stroke-width: 1.1; }
.ky-hubside { fill: color-mix(in srgb, var(--steel-200) 72%, transparent); stroke: var(--steel-700); stroke-width: 1.1; }
.ky-slot { fill: var(--steel-50); stroke: var(--steel-750); stroke-width: .9; }
.ky-teeth { stroke: var(--steel-650); stroke-width: .7; fill: none; pointer-events: none; }
.ky-strip { fill: none; stroke-linecap: butt; pointer-events: none; }
.ky-shearln { fill: none; stroke-width: 2; stroke-dasharray: 4 3; pointer-events: none; }
.ky-ext { fill: none; stroke: var(--steel-400); stroke-width: .8; }
.ky-dim { fill: none; stroke: var(--steel-550); stroke-width: .9; }
.ky-dimh { fill: var(--steel-550); }
.ky-load line, .ky-load path.sh { stroke: var(--load); stroke-width: 1.8; fill: none; }
.ky-load path.hd { fill: var(--load); stroke: none; }
.ky-load.ky-grey line, .ky-load.ky-grey path.sh { stroke: var(--steel-550); } .ky-load.ky-grey path.hd { fill: var(--steel-550); }
.ky-name { font-size: 12.5px; font-weight: 600; fill: var(--text); }
.ky-role { font-size: 11px; fill: var(--text-3); }
.ky-nm { cursor: text; }
.ky-nm:hover .ky-name, .ky-nm:focus .ky-name { fill: var(--sel); }
.ky-nm:focus { outline: none; }
.ky-vlab { font-size: 11px; fill: var(--text-3); letter-spacing: .02em; }
.ky-hubhatch { fill: url(#kyHatchA); stroke: var(--steel-750); stroke-width: 1.1; fill-rule: evenodd; }
.ky-shafthatch { fill: url(#kyHatchB); stroke: var(--primary-hover); stroke-width: 1.1; fill-rule: evenodd; }
.ky-detring { fill: none; stroke: var(--steel-700); stroke-width: 1.2; pointer-events: none; }
.ky-detA { font-size: 12px; font-weight: 600; fill: var(--text-2); }
.ky-magring { fill: none; stroke: var(--steel-400); stroke-width: 1; stroke-dasharray: 3 2; pointer-events: none; }
.ky-leg { font-size: 11px; fill: var(--text-3); }

/* pills */
#view .pill rect { fill: var(--surface); stroke: var(--steel-300); }
#view .pill text { font-size: 11.5px; font-weight: 500; fill: var(--text-2); font-variant-numeric: tabular-nums; }
#view .pill.dimv rect { stroke: var(--steel-200); }
#view .pill.load rect { stroke: color-mix(in srgb, var(--load) 35%, transparent); } #view .pill.load text { fill: var(--load); font-weight: 600; }
#view .pill.desig rect { stroke: color-mix(in srgb, var(--sel) 45%, transparent); } #view .pill.desig text { fill: var(--x-1e4fbf, #1e4fbf); font-weight: 600; }
#view .pill.desig { cursor: pointer; }
#view .pill.editable { cursor: text; }
#view .pill.editable:hover rect, #view .pill.editable:focus rect { stroke: var(--sel); stroke-width: 1.4; }
#view .pill.editable:focus, #view .pill.desig:focus { outline: none; }

/* editors in the drawing */
.stage { position: relative; }
.ky-edit { position: absolute; transform: translate(-50%, -50%); z-index: 5; display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1.5px solid var(--sel); border-radius: 9px; padding: 2px 8px 2px 4px; box-shadow: 0 6px 18px rgba(20, 22, 28, .14); }
.ky-edit input { width: 82px; border: 0; outline: none; font: inherit; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; padding: 3px 2px; }
.ky-edit-name input { width: 180px; text-align: center; }
.ky-edit span { font-size: 11.5px; color: var(--text-3); }

/* live strip */
.ky-live { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; min-height: 38px; align-items: center; }
.ky-live b { font-weight: 500; color: var(--text-3); margin-right: 5px; }
.ky-live i { font-style: normal; color: var(--text-3); }

/* panel */
.ky-seg { margin-bottom: 6px; }
.ky-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 6px; }
.ky-chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 9px; font-size: 12px; color: var(--text-2); cursor: pointer; font-variant-numeric: tabular-nums; }
.ky-chip:hover { border-color: var(--line-2); }
.ky-chip.on { border-color: var(--text); color: var(--text); font-weight: 500; }
.ky-forms { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-bottom: 6px; }
.ky-form { display: grid; justify-items: center; gap: 2px; padding: 5px 6px 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; font-size: 12px; color: var(--text-2); }
.ky-form:hover { border-color: var(--line-2); }
.ky-form.on { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); color: var(--text); }
.ky-lab { font-size: 12px; color: var(--text-3); margin: 8px 0 4px; }
#panel input.bad { color: var(--bad); }
#panel .num:has(input.bad) input { border-color: var(--bad); }
#panel select { max-width: 100%; }
#panel .f.sel.wide { grid-template-columns: minmax(0, 1fr); }
#panel .f.sel.wide select { width: 100%; }

/* summary */
.ky-say { margin-top: 6px; font-size: 12.5px; color: var(--text-2); line-height: 1.4; max-width: 34ch; }
.ky-des { font-weight: 600; color: var(--x-1e4fbf, #1e4fbf); }
.ky-tag { display: inline-flex; align-items: center; line-height: 1; font-size: 10.5px; color: var(--text-3); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; margin-left: 4px; white-space: nowrap; vertical-align: 1px; }

/* chart and dimensions */
.ky-two { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; }
#cchart .tdrag { cursor: ew-resize; }
#cchart { touch-action: none; user-select: none; }
.ky-dims table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.ky-dims th { font-weight: 500; font-size: 11.5px; color: var(--text-3); text-align: left; padding: 5px 8px 5px 0; border-bottom: 1px solid var(--line); }
.ky-dims td { padding: 5px 8px 5px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.ky-dims td.v { text-align: right; white-space: nowrap; font-weight: 500; }
.ky-dims td.t { color: var(--text-3); white-space: nowrap; text-align: right; }
.ky-dims .ky-desig { font-weight: 600; color: var(--text); margin: 0 0 8px; font-size: 13px; }
.ky-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 2px; }

@media (max-width: 1100px) { .ky-two { grid-template-columns: minmax(0, 1fr); } }
#panel.fade-b { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); }
#panel.fade-t { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px); mask-image: linear-gradient(to bottom, transparent, #000 28px); }
#panel.fade-t.fade-b { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 32px), transparent); }
#checks td.note { white-space: normal; min-width: 200px; line-height: 1.4; }
/* phones: the margins as stacked cards (no sideways scroll) */
@media (max-width: 760px) {
  #checks thead { display: none; }
  #checks, #checks tbody { display: block; width: 100%; }
  #checks tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
  #checks td { display: block; border: 0; padding: 0; text-align: left; white-space: normal; }
  #checks td.chk { grid-column: 1; grid-row: 1; }
  #checks td:nth-child(5) { grid-column: 2; grid-row: 1; align-self: center; }
  #checks td:nth-child(2) { grid-column: 1; grid-row: 2; font-size: 12.5px; }
  #checks td:nth-child(3) { grid-column: 2; grid-row: 2; font-size: 12.5px; text-align: right; }
  #checks td:nth-child(2)::before { content: "actual "; color: var(--text-3); }
  #checks td:nth-child(3)::before { content: "allowed "; color: var(--text-3); }
  #checks td:nth-child(4) { grid-column: 1 / -1; grid-row: 3; font-size: 12px; color: var(--text-3); min-width: 0; }
  .ky-types { width: 100%; }
  .ky-dims td.v, .ky-dims td.t { white-space: normal; }
  .ky-types button { flex: 1 1 0; padding-left: 4px; padding-right: 4px; }
}
@media print { .ky-edit { display: none !important; } }

/* theme-auto:start · generated by scripts/theme/hexmap.py: dark values (the rule of scripts/theme/colour.py) for
   colours that are not tokens, written as var(--x-rrggbb, #rrggbb): light is the fallback, unchanged */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --x-1e4fbf: #749ff5; --x-2f8f9d: #7ac1cd; --x-6e7177: #85827f; --x-8a5cb8: #c09bea; --x-8f98a2: #5f666e;
    --x-b9c0c7: #44494e; --x-b9c0c8: #44494f; --x-cfd5db: #373b3f;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --x-1e4fbf: #749ff5; --x-2f8f9d: #7ac1cd; --x-6e7177: #85827f; --x-8a5cb8: #c09bea; --x-8f98a2: #5f666e;
    --x-b9c0c7: #44494e; --x-b9c0c8: #44494f; --x-cfd5db: #373b3f;
  }
}
/* theme-auto:end */
