:root {
  --teal: #13535A;
  --cream: #FEF7EC;
  --orange: #DC704B;
  --green: #87956F;
  --blue: #87A9B6;
  --text: #1F3F43;
  --white: #FFFDF9;
  --border: #D9D6CB;
  --muted: #6D7776;
  --shadow: 0 16px 40px rgba(19, 83, 90, .09);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  color: var(--text);
  background: var(--cream);
  min-height: 100vh;
}

button,
textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 5vw;
  border-bottom: 1px solid rgba(19, 83, 90, .1);
  background: rgba(254, 247, 236, .95);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-logo { width: 46px; height: 46px; object-fit: contain; flex: 0 0 auto; }
.brand-copy { line-height: 1.1; min-width: 0; }
.brand-copy strong { display: block; color: var(--teal); font-size: 14px; }
.brand-copy small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }

.prototype-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--teal);
  background: #E8EFEA;
  border: 1px solid rgba(19, 83, 90, .12);
  padding: 7px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

.main { width: min(1160px, 90vw); margin: 0 auto; flex: 1; padding: 48px 0 72px; }
.screen { display: none; animation: fade .28s ease; }
.screen.active { display: block; }

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

h1,
h2,
h3 { color: var(--teal); margin-top: 0; }
h1 { font: 700 clamp(36px, 5vw, 60px)/1.08 Lora, serif; letter-spacing: -.02em; }
h2 { font: 600 clamp(28px, 3.2vw, 40px)/1.15 Lora, serif; }
h3 { font: 600 18px/1.3 Inter, sans-serif; }
p { line-height: 1.65; }
.lead { font-size: 19px; max-width: 760px; color: #435A5D; }
.eyebrow { color: var(--orange); font-weight: 700; text-transform: uppercase; letter-spacing: .11em; font-size: 12px; margin-bottom: 16px; }

.hero { display: grid; grid-template-columns: 1.2fr .8fr; gap: 56px; align-items: center; min-height: 62vh; }
.hero-card { background: var(--white); border: 1px solid rgba(19, 83, 90, .12); border-radius: 28px; padding: 30px; box-shadow: var(--shadow); }
.loop { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 22px; }
.loop span { background: #EFF2EA; border-radius: 12px; padding: 16px 10px; text-align: center; font-weight: 600; color: var(--teal); font-size: 13px; }
.hero-pills { margin-top: 24px; border-top: 1px solid rgba(19, 83, 90, .1); padding-top: 20px; }

.btn { border: 0; border-radius: 12px; padding: 13px 20px; font-weight: 600; transition: .18s ease; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary { background: var(--orange); color: white; box-shadow: 0 8px 18px rgba(220, 112, 75, .2); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(.98); }
.btn-secondary { background: transparent; color: var(--teal); border: 1px solid rgba(19, 83, 90, .24); }
.btn-secondary:hover:not(:disabled) { background: rgba(19, 83, 90, .05); }
.btn-ghost { background: transparent; color: var(--muted); padding-left: 0; }
.btn-hint { background: #EEF3EF; color: var(--teal); border: 1px solid rgba(19, 83, 90, .12); }
.btn-hint:hover:not(:disabled) { border-color: var(--green); background: #E7EEE5; }
.btn-light { background: white; color: var(--teal); }
.btn-outline-light { background: transparent; color: white; border: 1px solid rgba(255, 255, 255, .45); }
.btn.full { width: 100%; margin-top: 18px; }
.btn:disabled { opacity: .55; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.centered-actions { justify-content: center; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 28px; }
.case-card { background: var(--white); border: 1px solid rgba(19, 83, 90, .13); border-radius: var(--radius); padding: 24px; min-height: 270px; display: flex; flex-direction: column; box-shadow: 0 8px 22px rgba(19, 83, 90, .05); }
.case-card.disabled { opacity: .58; box-shadow: none; }
.case-card p { font-size: 14px; color: #5F6C6D; }
.case-card .btn { margin-top: auto; width: 100%; }

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 18px; }
.pill { font-size: 12px; font-weight: 600; color: var(--teal); background: #EEF3EF; padding: 7px 10px; border-radius: 999px; }
.pill.orange { color: #9C452D; background: #FBE9E1; }
.pill.blue { background: #E9F0F3; }
.pill.green { background: #EBF0E5; }

.brief-grid { display: grid; grid-template-columns: .9fr 1.1fr; gap: 28px; margin-top: 26px; }
.panel { background: var(--white); border: 1px solid rgba(19, 83, 90, .12); border-radius: var(--radius); padding: 26px; box-shadow: 0 8px 22px rgba(19, 83, 90, .05); }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.fact { background: #F7F1E7; border-radius: 12px; padding: 14px; }
.fact b { display: block; color: var(--teal); font-size: 12px; margin-bottom: 5px; }
.case-skills { margin-top: 18px; }
.notice { margin-top: 20px; background: #EAF1F2; border-left: 4px solid var(--blue); padding: 15px 16px; border-radius: 10px; font-size: 13px; line-height: 1.5; }
.compact-notice { margin-top: 18px; }

.sim-shell { display: grid; grid-template-columns: 280px 1fr; gap: 22px; align-items: start; }
.sidebar { position: sticky; top: 94px; }
.sidebar-panel { box-shadow: none; }
.sidebar-eyebrow { margin-bottom: 8px; }
.sidebar-panel h3 { margin-bottom: 8px; }
.sidebar-copy { font-size: 13px; color: var(--muted); margin-top: 0; }

.session-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.session-stats div { background: #F7F1E7; border-radius: 12px; padding: 12px; }
.session-stats span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.session-stats b { color: var(--teal); font-size: 19px; }

.chat-card { background: var(--white); border: 1px solid rgba(19, 83, 90, .12); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.chat-head { padding: 18px 22px; border-bottom: 1px solid rgba(19, 83, 90, .1); display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.client-id { display: flex; align-items: center; gap: 12px; }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: #E4EBDD; color: var(--teal); display: grid; place-items: center; font-weight: 700; flex: 0 0 auto; }
.client-id small { display: block; color: var(--muted); margin-top: 3px; }
.chat-body { padding: 24px; min-height: 390px; max-height: 520px; overflow: auto; background: linear-gradient(180deg, #FFFDF9 0%, #FFFCF7 100%); }
.message { display: flex; margin-bottom: 14px; }
.message.client { justify-content: flex-start; }
.message.therapist { justify-content: flex-end; }
.msg { max-width: 78%; padding: 13px 15px; border-radius: 16px; line-height: 1.55; font-size: 14px; white-space: pre-wrap; }
.message.client .msg { background: #F0F4ED; border-bottom-left-radius: 4px; }
.message.therapist .msg { background: #F8E8DF; border-bottom-right-radius: 4px; }

.composer { border-top: 1px solid rgba(19, 83, 90, .1); padding: 18px 22px 20px; background: #FFFDF9; }
.composer textarea { width: 100%; resize: vertical; min-height: 92px; max-height: 220px; border: 1px solid rgba(19, 83, 90, .2); border-radius: 14px; padding: 14px 15px; color: var(--text); background: white; outline: none; line-height: 1.5; }
.composer textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(135, 169, 182, .13); }
.composer textarea:disabled { background: #F7F5EF; }
.composer-foot { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-top: 12px; }
.composer-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.keyboard-hint { font-size: 11px; color: var(--muted); }

.typing,
.hint-loading { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; }
.typing { padding: 0 24px 14px; }
.hint-loading { margin-top: 12px; padding: 12px 14px; background: #F7F2E9; border-radius: 12px; }
.typing span,
.hint-loading span,
.analysis-loader span { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: bounce 1.1s infinite ease-in-out; }
.typing span:nth-child(2),
.hint-loading span:nth-child(2),
.analysis-loader span:nth-child(2) { animation-delay: .12s; }
.typing span:nth-child(3),
.hint-loading span:nth-child(3),
.analysis-loader span:nth-child(3) { animation-delay: .24s; }
.typing em,
.hint-loading em { margin-left: 4px; font-style: normal; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(.7); opacity: .45; }
  40% { transform: scale(1); opacity: 1; }
}

.hint-panel { margin-top: 12px; border: 1px solid rgba(135, 149, 111, .3); background: #F5F5EA; border-radius: 14px; padding: 15px; }
.hint-panel-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.hint-panel-head strong { display: block; color: var(--teal); font-size: 14px; margin-top: 3px; }
.hint-kicker { text-transform: uppercase; letter-spacing: .08em; color: #6A7958; font-size: 10px; font-weight: 700; }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; padding: 0 2px; }
.hint-content { margin-top: 12px; font-size: 14px; line-height: 1.55; }
.hint-content p { margin: 0; }
.hint-example { border-left: 3px solid var(--green); padding-left: 12px; font-style: italic; color: #415552; }
.hint-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 14px; }
.hint-actions .btn { padding: 9px 13px; font-size: 12px; }

.center { text-align: center; max-width: 740px; margin: 9vh auto 0; }
.big-check { width: 72px; height: 72px; border-radius: 50%; background: #EAF0E4; color: var(--green); display: grid; place-items: center; font-size: 34px; margin: 0 auto 22px; }
.big-check.processing { font-size: 22px; letter-spacing: 3px; }
.centered-lead { margin-left: auto; margin-right: auto; }
.analysis-loader { display: flex; justify-content: center; gap: 7px; margin-top: 26px; }
.analysis-loader span { width: 9px; height: 9px; }
.error-box { margin: 24px auto 0; max-width: 620px; background: #FBE9E1; border: 1px solid rgba(220, 112, 75, .25); color: #874330; padding: 15px; border-radius: 12px; line-height: 1.5; font-size: 14px; text-align: left; }

.feedback-layout { display: grid; grid-template-columns: .88fr 1.12fr; gap: 22px; margin-top: 25px; }
.score-card,
.feedback-card { background: var(--white); border: 1px solid rgba(19, 83, 90, .12); border-radius: var(--radius); padding: 22px; }
.feedback-card { margin-bottom: 16px; }
.feedback-card h3 { margin-bottom: 12px; }
.metric { margin-bottom: 18px; }
.metric:last-child { margin-bottom: 0; }
.metric-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 7px; }
.metric-name { font-size: 13px; font-weight: 600; color: var(--text); }
.level { font-size: 11px; padding: 5px 8px; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.level.strong { background: #E8EFE2; color: #596947; }
.level.developing { background: #E8F0F2; color: #52727A; }
.level.attention { background: #F8E8DF; color: #9C4B35; }
.metric-bar { height: 7px; background: #EEEADF; border-radius: 999px; overflow: hidden; }
.metric-bar span { display: block; height: 100%; border-radius: 999px; background: var(--green); }
.metric-explanation { font-size: 12px; color: var(--muted); margin: 7px 0 0; line-height: 1.45; }
.feedback-item { margin-bottom: 15px; }
.feedback-item:last-child { margin-bottom: 0; }
.feedback-item strong { color: var(--teal); font-size: 14px; }
.feedback-item p { margin: 5px 0 0; font-size: 13px; color: #536466; }
.evidence { background: #F7F2E9; border-radius: 12px; padding: 13px 15px; margin: 9px 0; font-size: 13px; line-height: 1.5; }
.evidence b { color: var(--teal); }
.evidence .quote { display: block; margin-bottom: 6px; font-style: italic; color: #435A5D; }
.hint-feedback-card { border-left: 4px solid var(--green); }
.hint-feedback-card p { margin-bottom: 0; color: #536466; font-size: 14px; }

.ethics-summary { display: flex; gap: 18px; align-items: center; background: var(--white); border: 1px solid rgba(19, 83, 90, .12); border-radius: var(--radius); padding: 24px; margin: 24px 0; }
.ethics-summary h3 { margin-bottom: 5px; }
.ethics-summary p { margin: 0; color: var(--muted); }
.status-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 25px; background: #EEF2E9; color: var(--green); flex: 0 0 auto; }
.status-icon.attention { background: #F8E8DF; color: var(--orange); }
.status-icon.critical { background: #F9E2E2; color: #9A3A3A; }
.flag-card { background: var(--white); border: 1px solid rgba(19, 83, 90, .12); border-left: 5px solid var(--orange); border-radius: 14px; padding: 18px; margin: 12px 0; }
.flag-card h3 { margin-bottom: 7px; }
.flag-card p { font-size: 14px; margin: 0; color: #536466; }

.reflection-box { background: var(--teal); color: white; border-radius: 24px; padding: 34px; margin-top: 26px; }
.reflection-box h2,
.reflection-box h3 { color: white; }
.reflection-box p { color: #EAF2F2; }
.reflection-subtitle { margin-top: 26px; }
.retry-focus { font-size: 18px; }
.footer-note { font-size: 12px; color: var(--muted); margin-top: 30px; line-height: 1.5; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (min-width: 901px) {
  #simulation { margin-top: -18px; }
  #simulation .sidebar-panel { padding: 22px; }
  #simulation .chat-head { padding: 14px 18px; }
  #simulation .avatar { width: 38px; height: 38px; }
  #simulation .chat-body {
    height: clamp(270px, calc(100vh - 430px), 390px);
    min-height: 270px;
    max-height: 390px;
    padding: 18px 20px;
  }
  #simulation .message { margin-bottom: 11px; }
  #simulation .msg { padding: 11px 14px; line-height: 1.48; }
  #simulation .composer { padding: 14px 18px 16px; }
  #simulation .composer textarea {
    min-height: 72px;
    max-height: 150px;
    padding: 11px 14px;
  }
  #simulation .composer-foot { margin-top: 9px; }
  #simulation .typing { padding: 0 20px 10px; }
}

@media (max-width: 900px) {
  .hero,
  .brief-grid,
  .feedback-layout,
  .sim-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .grid { grid-template-columns: 1fr; }
  .hero { gap: 26px; }
  .loop { grid-template-columns: repeat(2, 1fr); }
  .main { padding-top: 30px; }
  .topbar { padding-left: 4vw; padding-right: 4vw; }
}

@media (max-width: 560px) {
  .main { width: min(92vw, 1160px); }
  h1 { font-size: 38px; }
  .brand-copy small { display: none; }
  .brand-logo { width: 40px; height: 40px; }
  .facts { grid-template-columns: 1fr; }
  .msg { max-width: 92%; }
  .chat-body { padding: 18px; min-height: 340px; }
  .composer { padding: 16px 18px 18px; }
  .composer-foot { align-items: stretch; flex-direction: column; }
  .composer-tools { justify-content: space-between; }
  .composer-foot > .btn-primary { width: 100%; }
  .keyboard-hint { display: none; }
  .prototype-tag { font-size: 10px; }
  .panel,
  .case-card,
  .feedback-card,
  .score-card { padding: 20px; }
  .session-stats { grid-template-columns: 1fr 1fr; }
}