:root {
  --bg: #eef3f4;
  --surface: #ffffff;
  --surface-2: #edf6f5;
  --text: #0c2830;
  --muted: #5e7278;
  --border: #d5e1e3;
  --teal: #087b83;
  --teal-dark: #035d63;
  --blue: #1f5f9f;
  --amber: #c57915;
  --red: #bb3b3b;
  --green: #15845d;
  --shadow: 0 18px 50px rgba(12, 40, 48, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  overflow-x: hidden;
}

button {
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

#app {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.topbar > div:first-child,
.patient-card,
.scenario,
.rationale {
  min-width: 0;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  max-width: 100%;
}

.progress-strip {
  margin: -6px 0 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfdfd;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.section-label {
  margin: 0 0 6px;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3,
p,
li,
a,
span,
strong,
button {
  overflow-wrap: anywhere;
}

h1 {
  margin-bottom: 0;
  font-size: 42px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 300px) minmax(420px, 1fr) minmax(300px, 360px);
  gap: 18px;
  align-items: start;
}

.patient-card,
.scenario,
.rationale {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.patient-card,
.rationale {
  padding: 20px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin-bottom: 16px;
  border: 1px solid #b7d8d8;
  border-radius: 8px;
  background: linear-gradient(180deg, #f7ffff, #dff1f1);
  color: var(--teal-dark);
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0;
}

.patient-card h2,
.rationale h2 {
  margin-bottom: 16px;
  font-size: 20px;
}

.observation,
.time-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfd;
}

.observation {
  margin-bottom: 12px;
}

.observation span,
.time-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.observation p {
  margin: 8px 0 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.time-box {
  margin: 12px 0 20px;
}

.time-box strong {
  display: inline-block;
  margin-top: 8px;
  font-size: 20px;
}

.chart {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.chart h3,
.evidence-box h3,
.log h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.chart ul,
.evidence-box ul,
.log ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chart li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.chart-info {
  color: var(--muted);
}

.chart-step {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdfd;
  padding: 10px 12px;
}

.chart-time {
  display: block;
  margin-bottom: 6px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
}

.chart-action {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.chart-appearance {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.chart-appearance::before {
  content: "Состояние: ";
  color: var(--teal-dark);
  font-weight: 800;
}

.evidence-box li,
.log li {
  min-width: 0;
}

.scenario {
  padding: 26px;
}

.stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.stepper span {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #f9fbfb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.stepper span.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.stepper span.done {
  border-color: #b9ded0;
  background: #e8f6f1;
  color: var(--green);
}

.scene-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.scene-head span {
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 900;
}

#consequenceTag {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfdfd;
  color: var(--muted);
}

.scenario h2 {
  margin-bottom: 14px;
  font-size: 36px;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.patient-reaction {
  border-left: 4px solid var(--teal);
  background: var(--surface-2);
  padding: 14px 16px;
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

.outcome-panel {
  margin-top: 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f7fcfb;
  padding: 18px 20px;
}

.outcome-panel h3 {
  margin: 0 0 10px;
  font-size: 20px;
}

.outcome-panel p {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  line-height: 1.55;
}

.scenario h3 {
  margin: 26px 0 16px;
  font-size: 20px;
}

.choice-grid {
  display: grid;
  gap: 12px;
}

.choice-card {
  width: 100%;
  min-height: 78px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdfd;
  color: var(--text);
  padding: 18px;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.choice-card span {
  display: block;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.choice-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.choice-card:hover {
  border-color: var(--teal);
  box-shadow: 0 10px 24px rgba(8, 123, 131, 0.15);
  transform: translateY(-2px);
}

.ghost-button,
.primary-button {
  max-width: 100%;
  min-height: 42px;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 850;
  line-height: 1.2;
  white-space: normal;
}

.ghost-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.primary-button {
  border: 0;
  background: var(--teal);
  color: #fff;
}

.wide {
  width: min(320px, 100%);
}

.patient-card,
.scenario,
.rationale,
.choice-card,
.log li,
.evidence-box li {
  max-width: 100%;
}

.rationale {
  position: sticky;
  top: 16px;
}

.rationale p {
  color: var(--muted);
  line-height: 1.5;
}

.evidence-box {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}

.evidence-box li {
  padding-left: 12px;
  border-left: 3px solid var(--teal);
}

.evidence-box a {
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.evidence-box p {
  margin: 6px 0 0;
  font-size: 13px;
}

.log {
  padding-top: 16px;
}

.log li {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfd;
}

.log strong {
  display: block;
  font-size: 13px;
  line-height: 1.35;
}

.log span {
  display: block;
  margin-top: 6px;
  color: var(--teal-dark);
  font-size: 13px;
  line-height: 1.35;
}

.log em {
  display: block;
  margin-top: 8px;
  border-left: 3px solid var(--amber);
  padding-left: 10px;
  color: var(--text);
  font-size: 12px;
  font-style: normal;
  line-height: 1.4;
}

.log p {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.4;
}

@media (max-width: 1280px) {
  .layout {
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  }

  .rationale {
    position: static;
    grid-column: 1 / -1;
  }

  .scenario h2 {
    font-size: 32px;
  }
}

@media (max-width: 920px) {
  #app {
    padding: 20px;
  }

  h1 {
    font-size: 34px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .patient-card {
    display: grid;
    grid-template-columns: 110px 1fr;
    column-gap: 20px;
  }

  .patient-card h2,
  .patient-card .observation,
  .patient-card .time-box,
  .patient-card .chart {
    grid-column: 2;
  }

  .avatar {
    grid-row: 1 / span 4;
  }

  .scenario {
    padding: 22px;
  }

  .rationale {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  #app {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
    width: 100%;
  }

  .top-actions button {
    width: 100%;
  }

  .patient-card,
  .scenario,
  .rationale {
    padding: 18px;
  }

  .patient-card {
    display: block;
  }

  h1 {
    font-size: 30px;
    line-height: 1.12;
  }

  .scenario h2 {
    font-size: 28px;
    line-height: 1.14;
  }

  .scenario h3 {
    font-size: 18px;
  }

  .scene-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .stepper {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .choice-card {
    padding: 16px;
  }

  .choice-card span {
    font-size: 16px;
  }
}

@media (max-width: 420px) {
  #app {
    padding: 12px;
  }

  h1 {
    font-size: 26px;
  }

  .section-label,
  .progress-strip {
    font-size: 12px;
  }

  .patient-card,
  .scenario,
  .rationale {
    padding: 14px;
  }

  .avatar {
    width: 74px;
    height: 74px;
    font-size: 24px;
  }

  .scenario h2 {
    font-size: 24px;
  }

  .stepper {
    grid-template-columns: 1fr;
  }

  .stepper span,
  #consequenceTag {
    padding: 7px 8px;
  }

  .patient-reaction {
    padding: 12px;
    font-size: 15px;
  }

  .outcome-panel {
    padding: 14px;
  }

  .outcome-panel p {
    font-size: 15px;
  }

  .choice-card {
    min-height: 68px;
    padding: 14px;
  }

  .ghost-button,
  .primary-button {
    width: 100%;
  }
}
