* { box-sizing: border-box; }

:root {
  --bg: #f4f7fb;
  --panel: #fff;
  --text: #17212b;
  --muted: #617283;
  --brand: #0f3d63;
  --brand2: #1d6fa5;
  --success: #1f7a4d;
  --success-dark: #155c39;
  --error: #b42318;
  --warning: #9a6700;
  --border: #d8e1ea;
  --soft: #edf4f9;
}

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--brand);
  color: #fff;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 12px rgba(0,0,0,.14);
}

.brand { font-size: 1.35rem; font-weight: 850; }
.subtitle { font-size: .88rem; opacity: .9; }

.layout {
  width: min(100%, 1000px);
  margin: 0 auto;
  padding: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 17px;
  margin-bottom: 14px;
  box-shadow: 0 3px 10px rgba(34,52,70,.05);
}

.hero {
  background: linear-gradient(180deg, #ffffff, #f8fbfd);
}

h1, h2, h3 { margin-top: 0; }
h1 { font-size: clamp(1.55rem, 6vw, 2.35rem); margin-bottom: 10px; }
h2 { font-size: 1.2rem; }
p { line-height: 1.55; }

.badge, .eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-size: .73rem;
  font-weight: 800;
  color: var(--brand2);
  margin-bottom: 8px;
}

.muted { color: var(--muted); margin: 4px 0 0; }

.toolbar, .editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 11px;
  font-size: .98rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
}

button:hover { border-color: #aab9c8; }
button:active { transform: translateY(1px); }

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

button.success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

button.success:hover { background: var(--success-dark); }

button.ghost { background: transparent; }
button.light { color: white; border-color: rgba(255,255,255,.45); }

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.counter {
  background: var(--soft);
  color: var(--brand);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: .82rem;
  white-space: nowrap;
}

.quickbar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 11px;
  scrollbar-width: thin;
}

.quickbar button {
  white-space: nowrap;
  min-width: max-content;
  padding: 9px 12px;
}

textarea {
  width: 100%;
  min-height: 400px;
  resize: vertical;
  border: 1px solid #aebdcc;
  border-radius: 12px;
  padding: 14px;
  font: 1rem/1.55 Consolas, Monaco, "Courier New", monospace;
  background: #fbfdff;
  color: #15202b;
  tab-size: 4;
}

textarea:focus, input:focus {
  outline: 3px solid rgba(29,111,165,.17);
  border-color: var(--brand2);
}

.console {
  background: #101820;
  color: #e9f2f8;
  border-radius: 12px;
  padding: 14px;
  min-height: 150px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  font: .98rem/1.55 Consolas, Monaco, "Courier New", monospace;
}

.console.ok { border-left: 5px solid var(--success); }
.console.error { border-left: 5px solid var(--error); }
.console.waiting { border-left: 5px solid #d6a600; }

.input-panel {
  margin-top: 12px;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 12px;
  background: #fbfdff;
}

.input-panel label {
  display: block;
  font-weight: 750;
  margin-bottom: 7px;
}

.input-row { display: flex; gap: 8px; }

.input-row input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  border: 1px solid #aebdcc;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 16px;
}

.hidden { display: none !important; }

.exercise-banner {
  border-left: 5px solid var(--brand2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.feature-grid article {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.feature-grid span { color: var(--muted); font-size: .92rem; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.cards article {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

pre {
  overflow-x: auto;
  background: #f2f6fa;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 0;
  font-size: .9rem;
}

dialog {
  width: min(92vw, 760px);
  max-height: 88vh;
  overflow: auto;
  border: 0;
  border-radius: 17px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

dialog::backdrop { background: rgba(0,0,0,.46); }

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.exercise-list {
  display: grid;
  gap: 10px;
}

.exercise-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px;
}

.exercise-card h3 { margin-bottom: 6px; }
.exercise-card p { margin: 5px 0 12px; }
.exercise-card button { width: 100%; }

.help-list li { margin-bottom: 7px; }

.validation-box {
  margin-top: 10px;
  border-radius: 10px;
  padding: 10px 12px;
  background: #eaf7f0;
  color: #155c39;
  font-family: system-ui, sans-serif;
}

.validation-box.bad {
  background: #fff0ee;
  color: #922018;
}

footer {
  padding: 24px 12px 34px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 620px) {
  .layout { padding: 9px; }
  .panel { padding: 13px; border-radius: 13px; }

  textarea {
    min-height: 48vh;
    font-size: 16px;
  }

  .toolbar button {
    flex: 1 1 calc(50% - 8px);
  }

  .toolbar .primary,
  .toolbar .success {
    flex-basis: 100%;
  }

  .section-head {
    flex-direction: column;
  }

  .input-row {
    flex-direction: column;
  }

  .exercise-banner {
    flex-direction: column;
    align-items: stretch;
  }
}
