:root {
  color-scheme: dark;
  --bg: #0f1419;
  --panel: #151b22;
  --panel-2: #10161d;
  --panel-3: #1d2630;
  --border: #2b3642;
  --text: #edf2f7;
  --muted: #94a3b8;
  --green: #22c55e;
  --green-dark: #16a34a;
  --amber: #f6c343;
  --blue: #38bdf8;
  --danger: #fb7185;
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button,
textarea {
  font: inherit;
}

.home {
  width: min(480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 28px;
}

.home-hero {
  padding: 10px 4px 18px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--amber);
  color: #151b22;
  font-weight: 900;
}

h1 {
  margin: 14px 0 8px;
  font-size: 31px;
  letter-spacing: 0;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.language-grid {
  display: grid;
  gap: 10px;
}

.language-grid a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 66px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.language-grid span {
  color: var(--muted);
  font-size: 13px;
  direction: ltr;
}

.app {
  width: min(520px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 10px 12px;
  background: #111820;
  border-bottom: 1px solid var(--border);
}

.back-link {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-3);
  color: var(--text);
  font-size: 22px;
}

.app-title {
  min-width: 0;
  flex: 1;
}

.app-title strong,
.app-title span {
  display: block;
}

.app-title span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.run-button {
  min-width: 74px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #07120a;
  font-weight: 900;
}

.lesson-card,
.tasks-card,
.mission-card,
.editor-card,
.output-card,
.preview-card {
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.lesson-card {
  padding: 14px;
}

.tasks-card {
  padding: 12px;
}

.section-title {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
}

.task-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.task-tab {
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-3);
  color: var(--text);
  font-weight: 800;
}

.task-tab.active {
  background: var(--amber);
  color: #151b22;
  border-color: var(--amber);
}

.mission-card {
  padding: 12px 14px 14px;
}

.mission-card p {
  margin: 8px 0 12px;
}

.difference-box {
  display: grid;
  gap: 5px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
}

.difference-box strong {
  color: var(--blue);
  font-size: 13px;
}

.difference-box span {
  color: var(--text);
  line-height: 1.7;
  font-size: 14px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 12px;
}

.lesson-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
  letter-spacing: 0;
}

.editor-toolbar,
.output-toolbar {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.reset-button {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel-3);
  color: var(--text);
  padding: 7px 10px;
}

textarea {
  width: 100%;
  min-height: 38vh;
  display: block;
  resize: vertical;
  border: 0;
  outline: none;
  padding: 14px;
  background: #0c1117;
  color: #dbe7f3;
  direction: ltr;
  text-align: left;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.65;
  tab-size: 2;
}

pre {
  margin: 0;
  min-height: 170px;
  max-height: 38vh;
  overflow: auto;
  padding: 14px;
  background: #0b1116;
  color: #c8f7d3;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.6;
}

.status {
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.status.success {
  color: var(--green);
}

.preview-card {
  display: none;
}

.preview-card.show {
  display: block;
}

iframe {
  width: 100%;
  min-height: 240px;
  border: 0;
  background: white;
}

@media (min-width: 760px) {
  body {
    background: #0b0f14;
  }
}
