@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Roboto+Mono:wght@400;500;600&display=swap');

:root {
  --ink: #1d2925;
  --muted: #69736e;
  --line: #dce1dc;
  --surface: #ffffff;
  --canvas: #f3f5f1;
  --green: #126b50;
  --green-dark: #0b523d;
  --green-soft: #e7f2ed;
  --lime: #d7ea67;
  --amber: #a85d00;
  --amber-soft: #fff5df;
  --red: #b33a35;
  --red-soft: #fff0ef;
  --shadow: 0 10px 32px rgba(31, 48, 41, .07);
  --radius: 14px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--canvas); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: 'Manrope', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(18, 107, 80, .25); outline-offset: 2px; }

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

.topbar {
  min-height: 72px;
  padding: 10px 24px;
  display: grid;
  grid-template-columns: 1fr minmax(240px, 360px) auto;
  align-items: center;
  gap: 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; width: fit-content; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 36px; border-radius: 8px; background: var(--ink); color: white; font: 700 12px/1 'Roboto Mono', monospace; letter-spacing: .08em; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 1px; }

.header-progress { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; }
.progress-copy { display: flex; gap: 7px; align-items: baseline; color: var(--muted); font-size: 12px; white-space: nowrap; }
.progress-copy strong { color: var(--ink); }
.progress-track { height: 7px; overflow: hidden; border-radius: 20px; background: #e7eae6; }
.progress-track span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--green); transition: width .35s ease; }

.icon-button, .help-button, .text-button { border: 0; background: none; cursor: pointer; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; font-size: 22px; line-height: 1; }
.icon-button:hover { background: var(--canvas); }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.reference-button { min-height: 38px; padding: 0 13px; border: 1px solid var(--green); border-radius: 9px; color: var(--green); background: white; font-size: 11px; font-weight: 800; cursor: pointer; }
.reference-button span { margin-right: 5px; font: 700 11px 'Roboto Mono', monospace; }
.reference-button:hover { color: white; background: var(--green); }

.trainer-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 236px 300px minmax(480px, 1fr); }
.task-sidebar, .element-library { min-height: calc(100vh - 113px); background: var(--surface); border-right: 1px solid var(--line); }
.task-sidebar { padding: 25px 14px 22px; }
.element-library { padding: 25px 18px; background: #fafbf9; }
.panel-heading { padding: 0 8px 16px; }
.panel-heading.compact { padding: 0 2px 15px; }
.eyebrow { display: block; margin-bottom: 6px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.panel-heading h2, .builder-header h2 { margin: 0; font-size: 17px; letter-spacing: -.025em; }
.panel-heading p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.task-list { display: flex; flex-direction: column; gap: 3px; }
.task-item { width: 100%; border: 0; border-radius: 9px; padding: 9px 8px; display: grid; grid-template-columns: 28px 1fr 16px; gap: 8px; align-items: center; text-align: left; background: transparent; cursor: pointer; }
.task-item:hover { background: #f3f5f2; }
.task-item.active { background: var(--green-soft); color: var(--green-dark); }
.task-index { width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-size: 10px; font-weight: 700; color: var(--muted); background: white; }
.task-item.active .task-index { border-color: var(--green); color: white; background: var(--green); }
.task-item.completed .task-index { border-color: var(--green); color: var(--green); background: #edf7f2; }
.task-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 600; }
.task-item.response-task .task-name {
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.task-status { color: var(--green); font-size: 13px; font-weight: 800; }
.task-divider { margin: 12px 8px 6px; color: #929a96; font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }

.category-tabs { display: flex; gap: 4px; overflow-x: auto; padding: 2px 1px 10px; scrollbar-width: thin; }
.category-tab { flex: 0 0 auto; border: 1px solid var(--line); background: white; border-radius: 7px; padding: 7px 9px; font-size: 10px; font-weight: 700; cursor: pointer; }
.category-tab.active { border-color: var(--green); background: var(--green); color: white; }
.element-options { display: flex; flex-direction: column; gap: 9px; padding-top: 4px; }
.option-card { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; text-align: left; color: #293530; background: white; cursor: grab; transition: border-color .15s, transform .15s, box-shadow .15s; }
.option-card:hover { border-color: #8aa599; box-shadow: 0 4px 12px rgba(31, 48, 41, .06); transform: translateY(-1px); }
.option-card:active { cursor: grabbing; }
.option-card.used { opacity: .48; }
.option-label { display: block; margin-bottom: 3px; color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.option-value { font: 500 11px/1.45 'Roboto Mono', monospace; overflow-wrap: anywhere; }
.library-tip { margin-top: 8px; padding: 12px; color: var(--muted); background: #f0f2ee; border-radius: 9px; font-size: 11px; line-height: 1.55; }

.workspace { min-width: 0; padding: 25px clamp(22px, 3vw, 48px) 28px; background: var(--canvas); }
.challenge-card { max-width: 900px; margin: 0 auto 14px; display: grid; grid-template-columns: 54px 1fr auto; gap: 16px; align-items: start; }
.challenge-number { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; color: white; background: var(--ink); font: 600 15px 'Roboto Mono', monospace; }
.challenge-card h1 { margin: 0; font-size: clamp(22px, 2.2vw, 30px); line-height: 1.16; letter-spacing: -.04em; }
.challenge-card p { max-width: 680px; margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.source-link { margin-top: 9px; padding: 5px 9px; border: 1px solid #a8c8ba; border-radius: 7px; color: var(--green-dark); background: var(--green-soft); font-size: 10px; font-weight: 700; cursor: pointer; }
.source-link:hover { border-color: var(--green); }
.help-button { margin-top: 17px; padding: 7px 0; color: var(--green); font-size: 11px; font-weight: 700; white-space: nowrap; }
.help-button:hover { text-decoration: underline; }
.theory-note { max-width: 900px; margin: 0 auto 14px; padding: 12px 15px; border-left: 3px solid var(--lime); color: #4f5a55; background: #fbfce8; font-size: 12px; line-height: 1.55; }

.builder-card { max-width: 900px; min-height: 305px; margin: 0 auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.builder-header { padding: 16px 20px 12px; display: flex; justify-content: space-between; align-items: end; border-bottom: 1px solid var(--line); }
.text-button { padding: 5px; color: var(--muted); font-size: 11px; }
.text-button:hover { color: var(--red); }
.http-builder { padding: 18px 20px 22px; font-family: 'Roboto Mono', monospace; font-size: 12px; }

.request-line { display: grid; grid-template-columns: minmax(104px, .24fr) 1fr; gap: 10px; }
.slot-group { margin-top: 14px; }
.slot-caption { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--muted); font: 700 9px 'Manrope', sans-serif; letter-spacing: .1em; text-transform: uppercase; }
.slot-caption::after { content: ''; height: 1px; flex: 1; background: #e8ebe7; }
.drop-slot { min-height: 42px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding: 7px 9px; border: 1px dashed #bfc7c2; border-radius: 8px; background: #fafbf9; transition: .15s; }
.drop-slot.drag-over { border-color: var(--green); background: var(--green-soft); }
.drop-slot.wrong { border-color: var(--red); background: var(--red-soft); animation: nudge .25s ease; }
.drop-slot.correct-field { border-color: #8ab8a5; background: #f6fbf8; }
.slot-placeholder { color: #a0a7a3; font: 400 10px 'Manrope', sans-serif; }
.placed-token { max-width: 100%; padding: 6px 8px; display: inline-flex; align-items: center; gap: 8px; border: 1px solid #b8ccc3; border-radius: 6px; color: var(--green-dark); background: var(--green-soft); font-size: 11px; overflow-wrap: anywhere; }
.placed-token button { flex: 0 0 auto; padding: 0; border: 0; color: #718079; background: transparent; cursor: pointer; font-size: 14px; line-height: 1; }
.body-slot { min-height: 94px; align-items: flex-start; }
.body-slot .placed-token { width: 100%; white-space: pre-wrap; line-height: 1.55; }
.status-slot { max-width: 290px; }
.protocol-label { margin-bottom: 9px; color: #8a938e; font-size: 11px; }

.result-area { max-width: 900px; margin: 14px auto 0; }
.feedback { min-height: 60px; padding: 12px 14px; display: flex; gap: 11px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; background: white; }
.feedback-icon { flex: 0 0 24px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; font: 700 12px 'Roboto Mono', monospace; background: #edf0ed; }
.feedback strong { display: block; font-size: 12px; }
.feedback p { margin: 3px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.feedback.success { border-color: #9fc7b6; background: #f0f8f4; }
.feedback.success .feedback-icon { color: white; background: var(--green); }
.feedback.error { border-color: #efb5b2; background: var(--red-soft); }
.feedback.error .feedback-icon { color: white; background: var(--red); }
.feedback.hint { border-color: #edcb8d; background: var(--amber-soft); }
.feedback.hint .feedback-icon { color: white; background: var(--amber); }
.action-row { margin-top: 11px; display: flex; justify-content: flex-end; gap: 9px; }
.primary-button, .secondary-button, .danger-button { min-height: 40px; padding: 0 18px; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; }
.primary-button { border: 1px solid var(--green); color: white; background: var(--green); }
.primary-button:hover { background: var(--green-dark); }
.primary-button.next { background: var(--ink); border-color: var(--ink); }
.secondary-button { border: 1px solid var(--line); background: white; }
.secondary-button:hover { border-color: #9ba69f; }
.danger-button { border: 1px solid var(--red); color: white; background: var(--red); }

footer { min-height: 41px; padding: 9px 24px; display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--line); color: var(--muted); background: white; font-size: 10px; text-align: center; }
footer a { color: var(--green); font-weight: 700; text-decoration: none; }
footer a:hover { text-decoration: underline; }

.mobile-tabs { display: none; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(18, 29, 25, .45); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(390px, 100%); padding: 26px; border-radius: 16px; background: white; box-shadow: 0 24px 80px rgba(0,0,0,.2); text-align: center; }
.modal-symbol { margin: 0 auto 12px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--red); background: var(--red-soft); font-size: 24px; }
.modal h2 { margin: 0; font-size: 20px; }
.modal p { margin: 9px 0 20px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.modal-actions { display: flex; justify-content: center; gap: 8px; }

.reference-backdrop { align-items: stretch; padding: 22px; }
.api-reference { width: min(1040px, 100%); height: 100%; margin: 0 auto; display: flex; flex-direction: column; overflow: hidden; border-radius: 17px; background: var(--canvas); box-shadow: 0 24px 80px rgba(0,0,0,.24); text-align: left; }
.reference-header { flex: 0 0 auto; padding: 20px 24px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; color: white; background: var(--ink); }
.reference-header .eyebrow { color: var(--lime); }
.reference-header h2 { margin: 0; font-size: 25px; letter-spacing: -.035em; }
.reference-header p { margin: 6px 0 0; color: #c6d0cb; font-size: 12px; }
.reference-header .icon-button { flex: 0 0 auto; color: white; border-color: #5b6862; }
.reference-header .icon-button:hover { background: #34423c; }
.reference-intro { margin: 16px 20px 10px; padding: 14px 16px; display: grid; grid-template-columns: minmax(270px, .8fr) 1.2fr; gap: 20px; align-items: center; border: 1px solid #bfd5cb; border-radius: 11px; background: var(--green-soft); }
.reference-intro span { display: block; margin-bottom: 5px; color: var(--green); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.reference-intro code, .api-reference code { font-family: 'Roboto Mono', monospace; }
.reference-intro code { color: var(--green-dark); font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.reference-intro p { margin: 0; color: #52615a; font-size: 11px; line-height: 1.55; }
.reference-filters { padding: 0 20px 10px; display: flex; gap: 6px; overflow-x: auto; }
.reference-filter { flex: 0 0 auto; padding: 7px 11px; border: 1px solid var(--line); border-radius: 20px; background: white; color: var(--muted); font-size: 10px; font-weight: 700; cursor: pointer; }
.reference-filter.active { color: white; border-color: var(--green); background: var(--green); }
.endpoint-list { flex: 1; min-height: 0; padding: 0 20px 22px; overflow-y: auto; }
.endpoint-card { margin-top: 8px; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: white; }
.endpoint-card[open] { border-color: #a8c8ba; box-shadow: 0 5px 18px rgba(24,52,41,.06); }
.endpoint-summary { padding: 12px 14px; display: grid; grid-template-columns: 62px minmax(210px, .8fr) 1.2fr; gap: 12px; align-items: center; cursor: pointer; list-style: none; }
.endpoint-summary::-webkit-details-marker { display: none; }
.method-badge { width: 58px; padding: 5px 6px; border-radius: 6px; color: white; text-align: center; font: 800 10px 'Roboto Mono', monospace; }
.method-get { background: #2077a3; }
.method-post { background: #168052; }
.method-put { background: #b36a00; }
.method-patch { background: #8062b3; }
.method-delete { background: #b33a35; }
.endpoint-path { font: 600 12px 'Roboto Mono', monospace; overflow-wrap: anywhere; }
.endpoint-title { color: var(--muted); font-size: 11px; }
.endpoint-body { padding: 0 14px 16px 88px; border-top: 1px solid #edf0ed; }
.endpoint-description { margin: 13px 0; color: #4d5a54; font-size: 12px; line-height: 1.55; }
.spec-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.spec-block { min-width: 0; padding: 11px 12px; border-radius: 8px; background: #f6f7f4; }
.spec-block.wide { grid-column: 1 / -1; }
.spec-block h3 { margin: 0 0 7px; color: var(--muted); font-size: 9px; letter-spacing: .09em; text-transform: uppercase; }
.spec-block p { margin: 4px 0; color: #44514b; font-size: 10px; line-height: 1.5; }
.spec-block pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--green-dark); font: 500 10px/1.55 'Roboto Mono', monospace; }
.response-chip { display: inline-block; margin: 2px 5px 2px 0; padding: 4px 7px; border: 1px solid #cbd2ce; border-radius: 6px; background: white; font: 600 10px 'Roboto Mono', monospace; }

@keyframes nudge { 0%,100% { transform: translateX(0); } 35% { transform: translateX(-3px); } 70% { transform: translateX(3px); } }

@media (max-width: 1050px) {
  .trainer-layout { grid-template-columns: 200px 260px minmax(420px, 1fr); }
  .workspace { padding-left: 22px; padding-right: 22px; }
  .challenge-card { grid-template-columns: 48px 1fr; }
  .challenge-card .help-button { grid-column: 2; margin: -8px 0 0; justify-self: start; }
}

@media (max-width: 800px) {
  .topbar { min-height: 62px; padding: 8px 14px; grid-template-columns: 1fr auto; gap: 12px; }
  .brand small { display: none; }
  .header-progress { grid-column: 1 / -1; grid-row: 2; grid-template-columns: auto 1fr; }
  .header-actions { grid-column: 2; grid-row: 1; }
  .mobile-tabs { position: sticky; top: calc(var(--mobile-topbar-height, 95px) - 1px); z-index: 15; display: grid; grid-template-columns: repeat(3, 1fr); margin-top: -1px; background: white; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .mobile-tabs button { padding: 11px 6px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: white; font-size: 11px; font-weight: 700; }
  .mobile-tabs button.active { border-bottom-color: var(--green); color: var(--green); }
  .trainer-layout { display: block; }
  .mobile-panel { display: none; }
  .mobile-panel.active { display: block; }
  .task-sidebar, .element-library { min-height: calc(100vh - 171px); border-right: 0; }
  .task-sidebar, .element-library, .workspace { padding: 20px 16px 26px; }
  .task-item { padding: 11px 9px; }
  .task-name { font-size: 12px; }
  .element-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  footer { padding: 10px 12px; }
  .reference-backdrop { padding: 0; }
  .api-reference { border-radius: 0; }
  .reference-intro { grid-template-columns: 1fr; gap: 9px; }
  .endpoint-summary { grid-template-columns: 60px 1fr; }
  .endpoint-title { grid-column: 2; }
  .endpoint-body { padding-left: 14px; }
}

@media (max-width: 520px) {
  .brand-mark { width: 42px; }
  .brand strong { font-size: 13px; }
  .reference-button { width: 38px; padding: 0; font-size: 0; }
  .reference-button span { margin: 0; font-size: 12px; }
  .workspace { padding: 17px 12px 24px; }
  .challenge-card { grid-template-columns: 40px 1fr; gap: 11px; }
  .challenge-number { width: 40px; height: 40px; font-size: 13px; }
  .challenge-card h1 { font-size: 21px; }
  .challenge-card p { font-size: 12px; }
  .builder-card { min-height: 280px; }
  .builder-header, .http-builder { padding-left: 13px; padding-right: 13px; }
  .request-line { grid-template-columns: 92px minmax(0, 1fr); gap: 7px; }
  .drop-slot { padding: 6px; }
  .placed-token { font-size: 10px; }
  .element-options { grid-template-columns: 1fr; }
  .action-row { display: grid; grid-template-columns: 1fr 1.35fr; }
  .action-row .next { grid-column: 1 / -1; }
  .primary-button, .secondary-button { padding: 0 10px; }
  .footer-dot { display: none; }
  .reference-header { padding: 17px 15px; }
  .reference-intro { margin: 12px 12px 8px; }
  .reference-filters { padding-left: 12px; padding-right: 12px; }
  .endpoint-list { padding-left: 12px; padding-right: 12px; }
  .spec-grid { grid-template-columns: 1fr; }
  .spec-block.wide { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
