.gear-tool { font-family: "Inter", -apple-system, sans-serif; font-size: .87rem; }
.gear-tool fieldset { border: 1px solid #ddd; border-radius: 5px; padding: 1rem; margin: 1rem 0; min-width: 0; }
.gear-tool legend, .gear-tool summary { font-weight: 600; }
.gear-family-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.gear-type { position: relative; display: flex; align-items: center; justify-content: center; min-height: 3rem; padding: .35rem; text-align: center; border: 1px solid #aaa; border-radius: 3px; cursor: pointer; font-size: clamp(.64rem, 2.5vw, .87rem); overflow-wrap: anywhere; }
.gear-type:has(input:checked) { background: #245e89; border-color: #245e89; color: #fff; }
.gear-type:has(input:focus-visible) { outline: 2px solid #245e89; outline-offset: 3px; }
.gear-type:has(input:disabled) { opacity: .5; cursor: wait; }
.gear-tool .gear-type input { position: absolute; width: 1px; height: 1px; padding: 0; margin: 0; clip-path: inset(50%); overflow: hidden; }
.gear-pair-toggle { display: flex; align-items: center; gap: .6rem; margin: 1rem 0; }
.gear-tool .gear-pair-toggle input { width: auto; padding: 0; }
.gear-view-label { display: flex; align-items: center; gap: .6rem; margin: .6rem 0; }
.gear-tool .gear-view-label select { width: auto; }
.gear-view-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0 1.4rem; }
.gear-animate { display: flex; align-items: center; gap: .4rem; }
.gear-tool input, .gear-tool select, .gear-tool textarea { font: inherit; width: 100%; padding: .5rem .6rem; border: 1px solid #aaa; border-radius: 3px; background: #fff; color: #1a1a1a; }
.gear-tool textarea { min-height: 8rem; font-family: "Hack", monospace; font-size: .75rem; resize: vertical; }
.gear-tool input:focus-visible, .gear-tool select:focus-visible, .gear-tool textarea:focus-visible, .gear-tool button:focus-visible, .gear-tool a:focus-visible { outline: 2px solid #245e89; outline-offset: 3px; }
.gear-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem 1rem; }
.gear-input-label { display: flex; flex-direction: column; gap: .25rem; }
.gear-field { display: flex; flex-direction: column; gap: .25rem; }
.gear-field small, .gear-note { color: #555; font-size: .76rem; font-weight: 400; line-height: 1.5; }
.gear-field small { margin-top: .1rem; }
.gear-field-wide { grid-column: 1 / -1; }
.gear-note { margin: .6rem 0; }
.gear-tool details { margin: 1rem 0; }
.gear-tool summary { cursor: pointer; margin-bottom: .8rem; }
.gear-actions { display: flex; gap: .55rem; flex-wrap: wrap; margin: 1.2rem 0; }
.gear-tool button, .gear-button { font: inherit; display: inline-block; background: #eee; border: 1px solid #bbb; color: #222; padding: .55rem .8rem; border-radius: 3px; cursor: pointer; line-height: 1.4; text-decoration: none; }
.gear-button { color: #fff; background: #245e89; border-color: #245e89; }
.gear-tool button:disabled { opacity: .5; cursor: wait; }
.gear-tool [hidden] { display: none !important; }
/* Two lines are kept for the status whatever it says, so that nothing below
   it moves as it changes. */
#gear-status { min-height: 3.2em; margin: .8rem 0; }
#gear-status[data-error="true"] { color: #9c251c; }
.gear-preview { position: relative; height: 360px; border: 1px solid #d9dfe3; border-radius: 5px; background: #f2f5f7; overflow: hidden; }
#gear-canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#gear-canvas:active { cursor: grabbing; }
#gear-preview-note { position: absolute; bottom: .4rem; margin: 0; padding: 0 .6rem; width: 100%; text-align: center; font-size: .7rem; color: #52616d; pointer-events: none; }
.gear-download { display: flex; align-items: center; flex-wrap: wrap; gap: .7rem; margin: .8rem 0 1.5rem; }
#gear-stats { font-size: .75rem; color: #555; }
/* The download stays in place, greyed and without a link, until the build
   of the displayed values arrives; the stats of the last build dim with it. */
.gear-tool .gear-button[aria-disabled="true"] { opacity: .45; cursor: default; }
#gear-stats.gear-stale { opacity: .5; }
@media (max-width: 420px) { .gear-fields { grid-template-columns: minmax(0, 1fr); } .gear-preview { height: 290px; } }

.gear-tool details.gear-illustration { margin: .2rem 0 .4rem; font-size: .72rem; }
.gear-tool .gear-illustration summary { color: #245e89; font-weight: 400; margin: 0; }
.gear-illustration figure { margin: .5rem 0 0; padding: .5rem; border: 1px solid #d9dfe3; border-radius: 4px; }
.gear-illustration img { width: 100%; height: auto; display: block; border-radius: 2px; }
.gear-example-values { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; text-align: center; color: #333; margin-bottom: .3rem; font-variant-numeric: tabular-nums; }
.gear-illustration figcaption { color: #555; font-size: .72rem; line-height: 1.5; margin-top: .4rem; }

.gear-profile-help { min-width: 0; font-size: .78rem; color: #444; line-height: 1.55; padding: .8rem; border: 1px solid #d9dfe3; border-radius: 4px; }
.gear-profile-help p { margin: .5rem 0; }
.gear-profile-choice { display: grid; gap: .3rem; font-weight: 600; }
.gear-profile-help pre { margin: .6rem 0; max-width: 100%; overflow-x: auto; padding: .6rem; border-radius: 3px; background: #f2f5f7; line-height: 1.5; }
.gear-profile-help code { font-size: .72rem; }
.gear-profile-help dt { margin-top: .6rem; font-weight: 600; overflow-wrap: anywhere; }
.gear-profile-help dd { margin: .15rem 0 .6rem; }
.gear-profile-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .7rem 0; }
.gear-profile-family-note { border-left: 2px solid #aebfcb; padding-left: .6rem; }

.gear-tool .gear-invalid { border-color: #9c251c; box-shadow: inset 0 0 0 1px #9c251c; }
.gear-tool .gear-applied { border-color: #2f6b3a; box-shadow: inset 0 0 0 1px #2f6b3a; }
/* Problems lie over the top of the preview, which is out of date while any
   remains, so that nothing on the page moves when they appear. */
.gear-problems { position: absolute; top: .5rem; left: .5rem; right: .5rem; max-height: calc(100% - 2.6rem); overflow: auto; z-index: 1; display: flex; flex-direction: column; gap: .6rem; padding: .6rem .7rem; background: rgba(255, 255, 255, .96); border: 1px solid #d9dfe3; border-radius: 4px; box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.gear-problems[hidden] { display: none; }
.gear-problem { border-left: 3px solid #9c251c; padding: .1rem 0 .1rem .7rem; }
.gear-problem p { margin: 0 0 .35rem; }
.gear-fixes { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.gear-fixes small, .gear-problem small { color: #555; font-size: .76rem; }
.gear-tool .gear-fix { font-size: .88rem; padding: .3rem .65rem; }

/* Wide viewports: the tool leaves the text column for two columns of its
   own, the settings on the left and the output on the right, which stays in
   view while the settings scroll past it. The width leaves 1.5rem each side
   of the viewport, scroll bar included. */
@media (min-width: 1000px) {
  .gear-tool {
    --gear-width: min(76rem, 100vw - 3rem);
    width: var(--gear-width); margin-left: calc(50% - var(--gear-width) / 2);
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 2.5rem; align-items: start;
  }
  .gear-output { position: sticky; top: 1rem; }
  .gear-output #gear-status { margin-top: 0; }
  /* The status, layout choice and download row take about 16rem with the
     sticky offset, so the preview takes the rest of the viewport's height. */
  .gear-output .gear-preview { height: clamp(300px, calc(100vh - 17rem), 760px); }
}


.gear-axial-values { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .25rem .8rem; font-size: .88rem; }
.gear-axial-values dt { font-weight: 600; }
.gear-axial-values dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
#gear-axial-results.gear-stale { opacity: .55; }
