.speed-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 310px);
  align-items: start;
  gap: 18px;
}

.speed-panel,
.speed-summary,
.speed-reference {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.speed-panel { padding: 14px; }
.speed-summary.speed-reference { margin: 0; padding: 6px 20px 16px; }
.speed-reference { margin-top: 18px; padding: 6px 22px; }

.speed-panel-heading,
.speed-submit-row,
.speed-actions,
.speed-slot-results {
  display: flex;
  align-items: center;
}

.speed-panel-heading { justify-content: space-between; gap: 14px; }
.speed-panel h2 { margin: 0; color: #194f3b; font-size: 1.08rem; }
.speed-actions { flex-wrap: wrap; justify-content: flex-end; gap: 7px; }

.speed-button,
.preset-button,
.speed-slot-remove,
.speed-base-choice { min-height: 44px; }

.speed-button {
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: .875rem;
  font-weight: 700;
}

.speed-button:hover { transform: translateY(-1px); }
.speed-button:disabled { cursor: not-allowed; opacity: .48; transform: none; }
.speed-button:focus-visible,
.speed-slot input:focus-visible,
.speed-slot select:focus-visible,
.speed-slot-remove:focus-visible,
.preset-button:focus-visible,
.speed-reference summary:focus-visible {
  outline: 3px solid rgba(63, 155, 112, .24);
  outline-offset: 2px;
}
.speed-button-primary { color: #fff; background: #236b50; box-shadow: 0 7px 18px rgba(35, 107, 80, .18); }
.speed-button-secondary { color: #236b50; background: #edf7f0; border-color: #c8dccf; }
.speed-button-quiet { color: #657b71; background: #fff; border-color: #d7e5dc; }

.speed-guidance,
.speed-reference p,
.speed-footer { color: #63786f; font-size: .8125rem; line-height: 1.45; }
.speed-guidance { margin: 4px 0; padding: 3px 9px; background: #f4f9f5; border-radius: 9px; }

.speed-verdict {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 28px;
  margin: 0 0 4px;
  padding: 3px 9px;
  border-radius: 10px;
}
.speed-verdict strong { flex: 0 0 auto; color: #194f3b; font-size: .875rem; }
.speed-verdict span { color: #687c73; font-size: .8125rem; line-height: 1.35; }
.speed-verdict.is-safe { background: #e9f6ed; border: 1px solid #c5e1cf; }
.speed-verdict.is-risk { background: #fff5ea; border: 1px solid #ecd3b5; }
.speed-verdict.is-error { background: #fff0f0; border: 1px solid #e6c1c1; }

.speed-team { display: grid; gap: 4px; }
.speed-slot {
  display: grid;
  grid-template-columns: 108px minmax(112px, .8fr) minmax(112px, .75fr) minmax(220px, 1.5fr) 48px;
  align-items: center;
  gap: 3px 8px;
  min-width: 0;
  padding: 4px 9px;
  background: #fbfdfb;
  border: 1px solid #dbe9df;
  border-radius: 12px;
}
.speed-slot.has-error { border-color: #dca7a7; background: #fffafa; }
.speed-slot-identity { min-width: 0; }
.speed-slot-title strong { display: block; color: #244f3d; font-size: .88rem; }
.speed-base-choice {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #5e756a;
  font-size: .8125rem;
  cursor: pointer;
}
.speed-base-choice input { accent-color: #2f805d; }
.speed-slot-remove {
  align-self: center;
  padding: 0 6px;
  color: #8a625f;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: .875rem;
  white-space: nowrap;
}
.speed-slot-remove:hover { background: #f8ecea; }

.speed-field { display: grid; gap: 3px; min-width: 0; color: #5b7067; font-size: .8125rem; font-weight: 700; }
.speed-field input,
.speed-field select {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 9px;
  color: #173d2e;
  background: #fff;
  border: 1px solid #c8dccf;
  border-radius: 9px;
  font-size: .875rem;
}
.speed-field input[aria-invalid="true"] { border-color: #bd6767; }
.speed-field-error { color: #ad4141; font-size: .8125rem; font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.speed-field-error:empty { display: none; }

.speed-slot-results { align-items: stretch; gap: 6px; min-width: 0; }
.speed-result {
  min-width: 0;
  min-height: 58px;
  flex: 1 1 0;
  padding: 6px 8px;
  background: #edf7f0;
  border-radius: 8px;
}
.speed-result span { display: block; color: #71877e; font-size: .8125rem; }
.speed-result strong { display: block; margin-top: 2px; overflow-wrap: anywhere; color: #174d38; font-size: .875rem; line-height: 1.25; font-variant-numeric: tabular-nums; }

.speed-slot-gap {
  grid-column: 1 / -1;
  min-width: 0;
  padding: 1px 7px;
  color: #287354;
  background: #edf7f0;
  border-radius: 7px;
  font-size: .8125rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.speed-slot-gap.is-risk { color: #a44f35; background: #fff1e4; }
.speed-slot-gap:empty { display: none; }
.speed-slot-gap strong { font-variant-numeric: tabular-nums; }

.speed-submit-row { justify-content: space-between; gap: 15px; margin-top: 6px; }
.speed-count { color: #71877e; font-size: .8125rem; }
.speed-status { min-height: 1.25em; margin: 3px 0 0; color: #287354; font-size: .8125rem; line-height: 1.35; }
.speed-status.is-error { color: #ad4141; }

.speed-reference summary { display: flex; align-items: center; min-height: 44px; padding: 8px 0; color: #275a45; cursor: pointer; font-size: .88rem; font-weight: 800; }
.speed-reference details[open] summary { padding-bottom: 5px; }
.speed-presets p { margin-bottom: 9px; }
.preset-list { display: grid; gap: 6px; padding-bottom: 3px; }
.preset-button {
  width: 100%;
  padding: 0 10px;
  color: #356750;
  background: #f0f7f2;
  border: 1px solid #cedfd3;
  border-radius: 9px;
  font-size: .8125rem;
  text-align: left;
}
.preset-button[aria-pressed="true"] { color: #fff; background: #3f8967; border-color: #3f8967; }
.preset-current { margin: 8px 0 0; overflow-wrap: anywhere; }
.model-copy { padding-bottom: 8px; }
.speed-footer { width: min(1240px, calc(100% - 40px)); margin: 16px auto; text-align: center; }

@media (max-width: 1100px) {
  .speed-layout { grid-template-columns: 1fr; }
  .speed-summary { position: static; }
  .preset-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1101px) and (max-width: 1220px) {
  .speed-slot {
    grid-template-columns: 108px minmax(112px, 1fr) minmax(112px, 1fr) 48px;
  }
  .speed-slot-identity { grid-column: 1; grid-row: 1; }
  .speed-slot > .speed-field { grid-row: 1; }
  .speed-slot-remove { grid-column: 4; grid-row: 1; }
  .speed-slot-results { grid-column: 1 / -1; grid-row: 2; }
  .speed-slot-gap { grid-row: 3; }
}

@media (max-width: 720px) {
  .speed-panel-heading { align-items: flex-start; flex-direction: column; }
  .speed-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .speed-actions .speed-button:last-child { grid-column: 1 / -1; }
  .speed-slot {
    grid-template-columns: minmax(0, 1fr) 52px;
    gap: 7px;
    padding: 10px;
  }
  .speed-slot-identity,
  .speed-field,
  .speed-slot-results,
  .speed-slot-gap { grid-column: 1 / -1; }
  .speed-slot-remove { grid-column: 2; grid-row: 1; }
  .speed-slot-identity { grid-column: 1; grid-row: 1; }
  .speed-slot-results { flex-direction: row; }
  .speed-submit-row { align-items: stretch; flex-direction: column; }
  .speed-submit-row .speed-button { width: 100%; }
  .preset-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 390px) {
  .speed-panel { padding: 12px; }
  .speed-summary.speed-reference,
  .speed-reference { padding-left: 14px; padding-right: 14px; }
  .speed-button { padding-right: 9px; padding-left: 9px; }
  .speed-verdict { align-items: flex-start; flex-direction: column; gap: 2px; }
  .speed-slot-results { flex-direction: column; }
  .preset-list { grid-template-columns: 1fr; }
}
