:root {
  --ink: #1a2421;
  --muted: #5a6a64;
  --paper: #f3efe6;
  --panel: rgba(255, 252, 246, 0.88);
  --line: rgba(26, 36, 33, 0.12);
  --accent: #0f6b5c;
  --accent-2: #c45c26;
  --shadow: 0 18px 50px rgba(26, 36, 33, 0.12);
  --radius: 18px;
  --font: "Manrope", sans-serif;
  --display: "IBM Plex Serif", Georgia, serif;
  --warn-bg: rgba(196, 92, 38, 0.1);
  --danger: #9b2c2c;
  --sticky-fade: rgba(243, 239, 230, 0.96);
  --textarea-bg: rgba(255, 255, 255, 0.7);
  --pre-bg: rgba(26, 36, 33, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8efe9;
    --muted: #9aaba3;
    --paper: #121916;
    --panel: rgba(24, 34, 30, 0.92);
    --line: rgba(232, 239, 233, 0.12);
    --accent: #3cb89f;
    --accent-2: #e08a55;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    --warn-bg: rgba(224, 138, 85, 0.14);
    --danger: #f07178;
    --sticky-fade: rgba(18, 25, 22, 0.96);
    --textarea-bg: rgba(10, 14, 12, 0.55);
    --pre-bg: rgba(0, 0, 0, 0.28);
  }

  .bg {
    background:
      radial-gradient(900px 500px at 10% -10%, rgba(60, 184, 159, 0.16), transparent 60%),
      radial-gradient(700px 480px at 95% 5%, rgba(224, 138, 85, 0.12), transparent 55%),
      linear-gradient(160deg, #101612 0%, #151d19 50%, #121916 100%);
  }

  .tab.active, .rtab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #06221c;
  }

  .tab:hover, .rtab:hover, .ghost:hover {
    background: rgba(232, 239, 233, 0.08);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-tap-highlight-color: rgba(15, 107, 92, 0.12);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-only { display: none; }
.desktop-only { display: block; }

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(15, 107, 92, 0.18), transparent 60%),
    radial-gradient(700px 480px at 95% 5%, rgba(196, 92, 38, 0.16), transparent 55%),
    linear-gradient(160deg, #efe8da 0%, #f7f3ea 45%, #e7efe9 100%);
}

.shell {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.5rem 0 4rem;
  padding-left: max(1rem, env(safe-area-inset-left, 0));
  padding-right: max(1rem, env(safe-area-inset-right, 0));
}

.hero {
  margin-bottom: 1.75rem;
  animation: rise 0.7s ease both;
}

.brand {
  margin: 0 0 0.6rem;
  font-family: var(--display);
  font-size: clamp(2rem, 5vw, 3.1rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.hero h1 {
  margin: 0;
  max-width: 18ch;
  font-size: clamp(1.35rem, 2.6vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0.75rem 0 0;
  max-width: 52ch;
  color: var(--muted);
  font-size: 1.02rem;
}

.notice-fold {
  margin: 0.85rem 0 0;
  max-width: 58ch;
  border-left: 3px solid var(--accent-2);
  background: var(--warn-bg);
  padding: 0.55rem 0.85rem;
  font-size: 0.92rem;
}
.notice-fold summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  flex-wrap: wrap;
  min-height: 36px;
}
.notice-fold summary::-webkit-details-marker { display: none; }
.notice-summary-title {
  color: var(--accent-2);
  font-weight: 700;
}
.notice-summary-hint {
  color: var(--muted);
  font-size: 0.82rem;
}
.notice-body {
  margin: 0.45rem 0 0.2rem;
  color: var(--ink);
  line-height: 1.45;
}

.install-hint {
  margin: 0.75rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.88rem;
}

.howto {
  margin: 0 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.8rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.howto summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  min-height: 36px;
  display: flex;
  align-items: center;
}
.howto ol {
  margin: 0.5rem 0 0.25rem;
  padding-left: 1.15rem;
}
.howto li { margin: 0.35rem 0; }

.size-warn {
  margin: -0.35rem 0 0.85rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--accent-2);
  font-size: 0.9rem;
  line-height: 1.4;
}

.progress {
  margin: 0.75rem 0 0.25rem;
}
.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.35s ease;
}
.progress-steps {
  list-style: none;
  margin: 0.55rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}
.progress-steps li.active {
  color: var(--accent);
  font-weight: 700;
}
.progress-steps li.done { color: var(--ink); }
.progress-label {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.restore-btn {
  margin-top: 0.75rem;
  width: 100%;
}

.fineprint {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.site-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}
.site-footer p { margin: 0 0 0.35rem; }
.site-footer p:last-child { margin-bottom: 0; }
.site-footer a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }

.workbench {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 960px) {
  .workbench { grid-template-columns: 0.95fr 1.05fr; align-items: start; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 1.15rem;
  animation: rise 0.8s ease both;
  animation-delay: 0.08s;
}

.tabs, .result-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.tab, .rtab, .ghost, .cta {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 0.55rem 1rem;
  min-height: 44px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  touch-action: manipulation;
}

.tab.active, .rtab.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.tab:hover, .rtab:hover, .ghost:hover { background: rgba(26, 36, 33, 0.06); }
.cta {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 0.75rem 1.2rem;
  width: 100%;
}
.cta:hover { filter: brightness(1.05); transform: translateY(-1px); }
.cta:disabled { opacity: 0.55; cursor: wait; transform: none; }

.submit-bar {
  margin-top: 0.9rem;
}

.field {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
  font-weight: 500;
}

.field span { color: var(--muted); font-size: 0.92rem; font-weight: 500; }

textarea, input[type="file"] {
  width: 100%;
  font: inherit;
}

textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: var(--textarea-bg);
  resize: vertical;
  color: var(--ink);
  font-size: 16px; /* iOS: без зума при фокусе */
  max-width: 100%;
}

.drop {
  position: relative;
  border: 1.5px dashed rgba(15, 107, 92, 0.35);
  border-radius: 14px;
  padding: 1.6rem 1rem;
  min-height: 7.5rem;
  text-align: center;
  background: rgba(15, 107, 92, 0.04);
  transition: border-color 0.2s ease, background 0.2s ease;
  display: grid;
  align-content: center;
  gap: 0.15rem;
}
.drop.drag { border-color: var(--accent); background: rgba(15, 107, 92, 0.1); }
.drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.drop-title { display: block; font-weight: 600; color: var(--ink); }
.drop-hint, .filename { display: block; color: var(--muted); font-size: 0.88rem; margin-top: 0.25rem; }
.filename { color: var(--accent); font-weight: 600; }

.check {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.95rem;
  min-height: 44px;
  margin: 0.15rem 0 0.25rem;
}
.check input {
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
}

.status {
  min-height: 1.4em;
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.status.error { color: var(--danger); }
.status.ok { color: var(--accent); }

.results-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.results-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.35rem;
}
.actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.result-tabs {
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-left: -0.25rem;
  margin-right: -0.25rem;
  padding: 0 0.25rem 0.35rem;
}
.result-tabs::-webkit-scrollbar { display: none; }
.result-tabs .rtab {
  flex: 0 0 auto;
  white-space: nowrap;
}

.pane { display: none; }
.pane.active { display: block; animation: fade 0.35s ease; }

.pane h3 {
  margin: 1rem 0 0.4rem;
  font-size: 1rem;
}
.pane ul { margin: 0.25rem 0 0.75rem; padding-left: 1.15rem; }
.pane p { margin: 0.35rem 0; }

.task {
  border-top: 1px solid var(--line);
  padding: 0.85rem 0;
}
.task:first-child { border-top: 0; }
.task strong { color: var(--accent-2); }
.meta-line { color: var(--muted); font-size: 0.9rem; }

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.84rem;
  line-height: 1.45;
  background: var(--pre-bg);
  border-radius: 12px;
  padding: 0.9rem;
  max-height: 60vh;
  overflow: auto;
}

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

@media (max-width: 720px) {
  .shell {
    width: 100%;
    padding: 1.25rem 0 5.5rem;
    padding-left: max(0.85rem, env(safe-area-inset-left, 0));
    padding-right: max(0.85rem, env(safe-area-inset-right, 0));
  }

  .hero { margin-bottom: 1.1rem; }
  .brand { font-size: clamp(1.75rem, 8vw, 2.4rem); }
  .hero h1 {
    max-width: none;
    font-size: 1.2rem;
  }
  .lede { font-size: 0.95rem; margin-top: 0.5rem; }
  .notice-fold { max-width: none; font-size: 0.88rem; }

  .panel {
    border-radius: 14px;
    padding: 0.95rem;
    box-shadow: 0 10px 28px rgba(26, 36, 33, 0.1);
  }

  .mobile-only { display: block; }
  .desktop-only { display: none; }

  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .tab { width: 100%; text-align: center; }

  .actions {
    width: 100%;
  }
  .actions .ghost {
    flex: 1 1 auto;
    text-align: center;
    justify-content: center;
  }

  .results-head {
    flex-direction: column;
    align-items: stretch;
  }

  .submit-bar {
    position: sticky;
    bottom: calc(0.65rem + env(safe-area-inset-bottom, 0));
    z-index: 5;
    margin: 0.85rem -0.15rem 0;
    padding: 0.35rem 0.15rem;
    background: linear-gradient(180deg, transparent, var(--sticky-fade) 35%, var(--sticky-fade));
  }

  .cta {
    min-height: 50px;
    font-size: 1.05rem;
    border-radius: 14px;
  }

  pre {
    max-height: 50vh;
    font-size: 0.8rem;
  }

  .site-footer {
    font-size: 0.8rem;
    line-height: 1.4;
  }
}

@media (min-width: 721px) {
  .cta { width: auto; min-width: 10rem; }
  .submit-bar {
    display: flex;
    justify-content: flex-end;
  }
}
