.tool-page { max-width: none !important; }
.tool-page__header { max-width: 820px; margin-bottom: 28px; }
.tool-page__header .lead { max-width: 720px; }
.tool-workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.tool-workbench__pane { min-width: 0; }
.tool-workbench__stack { display: grid; gap: 16px; }
.tool-controls, .tool-results-card { margin-top: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: 0 8px 24px rgba(15,23,42,.04); }
.tool-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.tool-controls .form-label { margin-bottom: 4px; }
.tool-controls .form-check { margin: 0; }
.tool-controls--stacked { align-items: stretch; }
.tool-controls--stacked > .row { width: calc(100% + 1.5rem); }
.tool-controls__grow { flex: 1 1 180px; }
.tool-controls__group { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.tool-alert { margin-top: 12px; margin-bottom: 0; }
.tool-editor { overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: 0 8px 24px rgba(15,23,42,.05); }
.tool-editor__header, .tool-editor__footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tool-editor__header { min-height: 48px; padding: 8px 12px 8px 16px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 92%, var(--cloud)); }
.tool-editor__title { min-width: 0; display: flex; align-items: center; gap: 9px; font-weight: 700; }
.tool-editor__title > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-editor__badge { padding: 3px 7px; border-radius: 5px; background: #eff6ff; color: #1d4ed8; font-size: 11px; line-height: 1.2; letter-spacing: .045em; }
.tool-editor__actions { display: flex; gap: 4px; }
.tool-editor__action { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.tool-editor__action:hover { background: var(--cloud); color: var(--blue); }
.tool-editor__action.is-success { color: #059669; }
.tool-editor__surface { min-height: 360px; }
.tool-editor__surface .cm-editor { height: 360px; font-size: 14px; }
.tool-editor__surface .cm-scroller { overflow: auto; font-family: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace; line-height: 1.6; }
.tool-editor__surface .cm-content { padding: 12px 0; }
.tool-editor__surface .cm-gutterElement { padding-inline: 10px 8px; }
.tool-editor__surface .cm-focused { outline: 3px solid var(--focus); outline-offset: -3px; }
.tool-editor__footer { min-height: 34px; padding: 6px 12px; border-top: 1px solid var(--border); color: var(--muted); font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.tool-editor__source:not([hidden]) { min-height: 360px; font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; }
.tool-editor--compact .tool-editor__surface, .tool-editor--compact .tool-editor__surface .cm-editor { min-height: 220px; height: 220px; }
.tool-editor--short .tool-editor__surface, .tool-editor--short .tool-editor__surface .cm-editor { min-height: 156px; height: 156px; }
.tool-editor--jwt-source .tool-editor__surface, .tool-editor--jwt-source .tool-editor__surface .cm-editor { min-height: 328px; height: 328px; }
.tool-editor--jwt-result .tool-editor__surface, .tool-editor--jwt-result .tool-editor__surface .cm-editor { min-height: 130px; height: 130px; }
.tool-empty { min-height: 360px; display: grid; place-items: center; padding: 32px; border: 1px dashed var(--border); border-radius: 10px; background: var(--surface); color: var(--muted); text-align: center; }
.tool-results-card { margin-top: 0; min-height: 360px; }
.tool-results-card__title { margin-bottom: 16px; font-size: 18px; font-weight: 700; }
.tool-metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tool-metric { padding: 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--cloud); }
.tool-metric strong { display: block; font-size: 30px; line-height: 1.1; color: var(--blue); }
.tool-metric span { color: var(--muted); }
body.dark-theme .tool-editor__badge { background: #172554; color: #7dd3fc; }
body.dark-theme .tool-editor__action:hover { background: #1e293b; }

@media (max-width: 980px) {
  .tool-workbench { grid-template-columns: 1fr; }
  .tool-editor__surface, .tool-editor__surface .cm-editor { min-height: 300px; height: 300px; }
  .tool-editor--compact .tool-editor__surface, .tool-editor--compact .tool-editor__surface .cm-editor { min-height: 220px; height: 220px; }
  .tool-editor--short .tool-editor__surface, .tool-editor--short .tool-editor__surface .cm-editor { min-height: 150px; height: 150px; }
  .tool-editor--jwt-source .tool-editor__surface, .tool-editor--jwt-source .tool-editor__surface .cm-editor { min-height: 230px; height: 230px; }
  .tool-editor--jwt-result .tool-editor__surface, .tool-editor--jwt-result .tool-editor__surface .cm-editor { min-height: 180px; height: 180px; }
}

@media (max-width: 640px) {
  .tool-page__header { margin-bottom: 22px; }
  .tool-controls { align-items: stretch; }
  .tool-controls > .btn, .tool-controls > .form-select, .tool-controls__grow { width: 100% !important; }
  .tool-controls__group { width: 100%; }
  .tool-editor__header { padding-left: 12px; }
  .tool-editor__badge { display: none; }
  .tool-editor__footer { align-items: flex-start; flex-direction: column; gap: 1px; }
  .tool-metric-grid { grid-template-columns: 1fr 1fr; }
}
