:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c222b;
  --line: #2a313c;
  --text: #e8ecf1;
  --muted: #8b95a3;
  --yellow: #ffd54a;
  --yellow-dark: #f0c22c;
  --blue: #5aa2ff;
  --code-bg: #11151b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(900px 420px at 85% -10%, rgba(90, 162, 255, .16), transparent 60%),
    radial-gradient(700px 380px at -10% 10%, rgba(255, 213, 74, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
.page {
  max-width: 820px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 36px 16px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

/* Шапка */
.top { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.mark { flex: none; border-radius: 12px; box-shadow: 0 6px 24px rgba(255, 213, 74, .25); }
h1 { font-size: 28px; line-height: 1.15; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
.lead { color: var(--muted); margin: 0; }

/* Панели */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 18px;
}
.panel-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.label { font-weight: 600; }
.count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
textarea {
  display: block;
  width: 100%;
  min-height: 160px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--code-bg);
  transition: border-color .15s, box-shadow .15s;
}
textarea::placeholder { color: #5d6774; }
textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(90, 162, 255, .18); }

/* Кнопки */
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .08s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: #232a35; border-color: #36404d; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.btn.primary {
  margin-left: auto;
  min-width: 140px;
  background: var(--yellow);
  border-color: var(--yellow);
  color: #14181f;
}
.btn.primary:hover { background: var(--yellow-dark); border-color: var(--yellow-dark); }
.btn:disabled { cursor: default; opacity: .75; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn.small.done { background: rgba(90, 200, 120, .15); border-color: rgba(90, 200, 120, .5); color: #8fe3a8; }
.spin {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(20, 24, 31, .25);
  border-top-color: #14181f;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn.loading .spin { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.msg { margin: 12px 0 0; color: var(--muted); font-size: 15px; }
.msg.error { color: #ff7b72; }

/* Результат */
.result { animation: rise .35s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.window {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.window-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.dots { display: flex; gap: 6px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; background: #3a4350; }
.dots i:nth-child(1) { background: #ff6b6b; }
.dots i:nth-child(2) { background: var(--yellow); }
.dots i:nth-child(3) { background: #4fd18b; }
.file { color: var(--muted); font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin-right: auto; }
.code-body { display: flex; }
.gutter, .code {
  margin: 0;
  padding: 16px 0;
  font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  tab-size: 4;
}
.gutter {
  flex: none;
  padding-left: 14px;
  padding-right: 12px;
  text-align: right;
  color: #4a5361;
  border-right: 1px solid #1f252e;
  user-select: none;
}
.code { flex: 1; min-width: 0; overflow-x: auto; padding-left: 14px; padding-right: 16px; color: #dfe5ec; }
.code .kw { color: #ff9f6e; }
.code .bi { color: var(--blue); }
.code .st { color: #a5e08b; }
.code .nu { color: #d7a8ff; }
.code .cm { color: #6c7686; font-style: italic; }

.steps h2 { margin-bottom: 14px; }
.explain { list-style: none; counter-reset: step; margin: 0; padding: 0; }
.explain li {
  counter-increment: step;
  position: relative;
  padding: 2px 0 12px 42px;
}
.explain li:last-child { padding-bottom: 0; }
.explain li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--yellow);
  background: rgba(255, 213, 74, .12);
}

/* Плашка снизу */
.credit { margin-top: auto; padding-top: 28px; display: flex; justify-content: center; }
.credit-pill {
  display: inline-block;
  text-align: center;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 213, 74, .35);
  background: rgba(255, 213, 74, .08);
  color: #f3dc8c;
  font-size: 14px;
  font-weight: 600;
}

@media (max-width: 520px) {
  .page { padding-top: 22px; }
  h1 { font-size: 22px; }
  .lead { font-size: 15px; }
  .mark { width: 38px; height: 38px; }
  .panel { padding: 14px; }
  .row .btn.ghost { flex: 1 1 0; padding: 11px 8px; font-size: 14px; white-space: nowrap; }
  .row .btn.ghost svg { display: none; }
  .btn.primary { flex-basis: 100%; margin-left: 0; padding: 13px 16px; }
  .gutter, .code { font-size: 13px; }
  .credit-pill { font-size: 13px; border-radius: 14px; }
}
