.ksct-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 22px;
}

.ksct-heading > div > span {
  font-size: 11px;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--teal);
}

.ksct-heading h1 {
  font-size: 25px;
  color: var(--ink);
  margin: 5px 0 4px;
}

.ksct-heading p {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
}

.ksct-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.ksct-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  min-width: 0;
  box-shadow: var(--shadow);
}

.ksct-panel h2 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--teal-dark);
  margin-bottom: 10px;
}

.ksct-panel > p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.65;
  margin: 6px 0 16px;
}

.ksct-parameters > h3 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-top: 1px solid var(--line-soft);
  padding-top: 18px;
  margin-top: 20px;
}

.ksct-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 14px 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.ksct-field > span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  line-height: 1.5;
}

.ksct-field b {
  color: #1d4ed8;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ksct-field select,
.ksct-field input,
.ksct-field textarea {
  width: 100%;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  color: var(--ink);
  font-size: 13px;
  min-width: 0;
}

.ksct-field select:focus,
.ksct-field input:focus,
.ksct-field textarea:focus {
  background: #ffffff;
  border-color: var(--teal);
  box-shadow: var(--ring);
}

.ksct-field input[type=range] {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  accent-color: #2563eb;
  cursor: pointer;
  height: 6px;
  margin: 6px 0;
}

.ksct-range small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

.ksct-help {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.65;
  font-weight: 400;
  margin-top: 10px;
}

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

.ksct-main {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.ksct-chart-panel {
  position: relative;
  padding: 20px 22px 18px;
}

.ksct-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 14px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.ksct-chart-header > span {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 5px 11px;
  white-space: nowrap;
}

.ksct-tabs {
  display: flex;
  padding: 4px;
  border-radius: 10px;
  background: #f1f5f9;
  gap: 4px;
}

.ksct-tabs button {
  background: transparent;
  border: 0;
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--muted);
  box-shadow: none;
}

.ksct-tabs button.active {
  color: var(--ink);
  font-weight: 650;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.ksct-legend {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-top: 8px;
}

.ksct-legend > div {
  position: relative;
  padding-left: 18px;
  font-size: 11.5px;
}

.ksct-legend i {
  position: absolute;
  left: 0;
  top: 2px;
  width: 9px;
  height: 15px;
  border-radius: 3px;
}

.ksct-legend strong {
  font-size: 12.5px;
  line-height: 1.45;
  font-weight: 650;
  color: var(--ink);
}

.ksct-legend small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  margin-top: 3px;
}

.ksct-legend > div:nth-child(2) small {
  color: #2563eb;
  font-weight: 600;
}

.ksct-legend > div:nth-child(3) small {
  color: #059669;
  font-weight: 600;
}

.ksct-readout {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  background: #ffffff;
  border-radius: 10px;
  padding: 10px 4px 4px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

.ksct-readout > b {
  color: var(--ink);
}

.ksct-plans {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.ksct-plan {
  padding: 16px;
  background: #f5f8ff;
  border: 1px solid #dbeafe;
  border-radius: 14px;
}

.ksct-plan.b {
  background: #f2fbf7;
  border-color: #cdeee1;
}

.ksct-plan h3 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #1d4ed8;
}

.ksct-plan.b h3 {
  color: #047857;
}

.ksct-plan .ksct-field {
  margin: 12px 0 0;
}

.ksct-plan .ksct-two {
  gap: 9px;
}

.ksct-plan .ksct-field > span {
  font-size: 11.5px;
}

.ksct-plan select {
  background: #ffffff;
}

.ksct-efficacy {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: #2563eb;
  margin-top: 14px;
  font-weight: 650;
}

.ksct-plan.b .ksct-efficacy {
  color: #059669;
}

.ksct-outcomes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.ksct-outcomes > div {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 14px;
}

.ksct-outcomes span,
.ksct-outcomes small {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
}

.ksct-outcomes b {
  display: block;
  font-size: 24px;
  font-weight: 700;
  margin: 8px 0;
  font-variant-numeric: tabular-nums;
}

.ksct-info {
  background: #eff6ff;
  border: 1px solid #dbeafe;
  padding: 12px 14px;
  border-radius: 11px;
  color: #1e40af;
  font-size: 12.5px;
  line-height: 1.55;
}

.ksct-info small {
  font-size: 11px;
  line-height: 1.55;
}

.ksct-check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink-soft);
  margin: 14px 0;
  cursor: pointer;
}

.ksct-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
  flex: none;
}

.ksct-source {
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--muted);
}

.ksct-source a {
  color: var(--teal);
  text-decoration: underline;
}

.ksct-error {
  font-size: 13px;
  color: #b91c1c;
}

.ksct-empty {
  display: grid;
  place-items: center;
  min-height: 260px;
  background: var(--surface-soft);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 24px;
}

.ksct-history {
  margin-top: 22px;
}

.ksct-record {
  white-space: pre-wrap;
  font-size: 11px;
  max-height: 400px;
  overflow: auto;
}

.ksct-panel details {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 14px 0;
}

.ksct-panel summary {
  cursor: pointer;
  font-weight: 600;
}

#ksct-chart svg {
  width: 100%;
  display: block;
}

#ksct-chart circle[role=button] {
  cursor: pointer;
}

#ksct-chart circle[role=button]:focus {
  stroke: #0f172a;
  stroke-width: 4;
  outline: none;
}

.ksct-evidence {
  font-size: 13px;
  line-height: 1.8;
  color: var(--ink-soft);
}

.ksct-evidence ol {
  padding-left: 18px;
  margin: 8px 0;
}

.ksct-evidence li {
  margin: 6px 0;
}

.ksct-evidence a {
  color: var(--teal);
  text-decoration: none;
}

.ksct-evidence a:hover {
  text-decoration: underline;
}

.ksct-evidence details p {
  line-height: 1.75;
}

.ksct-chart-panel #ksct-tooltip {
  position: absolute;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(8px);
  border-radius: 9px;
  padding: 9px 12px;
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.24);
  pointer-events: none;
  z-index: 4;
  font-size: 12.5px;
  max-width: calc(100% - 16px);
  line-height: 1.55;
}

.ksct-chart-panel #ksct-tooltip b,
.ksct-chart-panel #ksct-tooltip span {
  display: block;
}

.ksct-chart-panel #ksct-tooltip i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

#ksct-chart [data-arm] {
  cursor: pointer;
  outline: none;
}

#ksct-chart [data-arm]:focus circle:last-child {
  stroke: #0f172a;
  stroke-width: 3;
}

#ksct-chart [data-arm]:hover circle:last-child {
  r: 7;
}

.ksct-field:has([name=se]) b {
  color: #e11d48;
}

.ksct-field input[name=se] {
  accent-color: #e11d48;
}

.ksct-field:has([name=outdoor]) b {
  color: #059669;
}

.ksct-field input[name=outdoor] {
  accent-color: #059669;
}

.ksct-field:has([name=near]) b {
  color: #6d28d9;
}

.ksct-field input[name=near] {
  accent-color: #6d28d9;
}

.ksct-demographics {
  gap: 10px;
}

.ksct-demographics .ksct-field {
  margin: 6px 0;
}

.ksct-demographics select {
  padding-left: 8px;
  padding-right: 4px;
  font-size: 12px;
}

.ksct-patient-change {
  display: block;
  margin-bottom: 16px;
}

.ksct-patient-change .actions {
  margin-top: 12px;
  flex-wrap: wrap;
}

@media (max-width: 1150px) {
  .ksct-layout {
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 14px;
  }
  .ksct-panel {
    padding: 18px;
  }
  .ksct-plans {
    grid-template-columns: 1fr;
  }
  .ksct-chart-header {
    flex-wrap: wrap;
  }
  .ksct-legend {
    gap: 10px;
  }
  .ksct-outcomes {
    gap: 8px;
  }
  .ksct-outcomes > div {
    padding: 10px;
  }
  .ksct-outcomes b {
    font-size: 20px;
  }
}

@media (max-width: 800px) {
  .ksct-layout {
    grid-template-columns: 1fr;
  }
  .ksct-heading h1 {
    font-size: 22px;
  }
  .ksct-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .ksct-parameters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
  }
  .ksct-parameters > h2,
  .ksct-parameters > h3,
  .ksct-parameters > p,
  .ksct-parameters > .ksct-help,
  #ksct-ratio {
    grid-column: 1 / -1;
  }
  .ksct-demographics {
    grid-column: 1 / -1;
  }
  .ksct-plans {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 500px) {
  .ksct-parameters,
  .ksct-plans,
  .ksct-two {
    grid-template-columns: 1fr;
  }
  .ksct-demographics {
    grid-template-columns: 1fr 1fr;
  }
  .ksct-outcomes b {
    font-size: 18px;
  }
  .ksct-tabs button {
    font-size: 11px;
  }
  .ksct-legend {
    grid-template-columns: 1fr;
  }
  .ksct-legend small {
    margin-top: 2px;
  }
  .ksct-chart-panel {
    padding: 15px 10px;
  }
}

@media print {
  body:has(.ksct-layout) #sidebar,
  body:has(.ksct-layout) #topbar,
  .ksct-heading > button,
  .ksct-history,
  .ksct-panel .form-actions,
  .ksct-check {
    display: none !important;
  }
  body:has(.ksct-layout) .workspace {
    margin: 0;
  }
  .ksct-layout {
    grid-template-columns: 240px minmax(0, 1fr);
  }
  .ksct-panel {
    break-inside: avoid;
    box-shadow: none;
  }
  .ksct-source {
    color: #555;
  }
  .ksct-panel details {
    display: none;
  }
}
