:root {
  --bg: #111418;
  --surface: #1b1f26;
  --surface-2: #242a33;
  --border: #2e3540;
  --accent: #6ea9ff;
  --accent-hover: #8cbbff;
  --text: #e7ecf3;
  --muted: #9aa4b2;
  --error: #ff7a7a;
  --success: #7ed98a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

header { text-align: center; margin-bottom: 20px; }
h1 { margin: 0 0 4px; font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
.tagline { margin: 0; color: var(--muted); font-size: 14px; }
h2 { font-size: 14px; font-weight: 600; color: var(--muted); text-transform: uppercase;
     letter-spacing: 0.06em; margin: 0 0 10px; }

.difficulty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.d-label { color: var(--muted); font-size: 13px; }
.d-buttons { display: flex; gap: 6px; background: var(--surface); padding: 4px;
             border: 1px solid var(--border); border-radius: 10px; }
.d-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.d-btn:hover { color: var(--text); }
.d-btn.active {
  background: var(--accent);
  color: #0a1020;
  font-weight: 600;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 18px;
  background: var(--surface);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  touch-action: manipulation;
}
.dropzone:hover, .dropzone:focus, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--surface-2);
  outline: none;
}
.dz-icon {
  width: 56px; height: 56px; margin: 0 auto 14px;
  border-radius: 50%; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: var(--accent); font-weight: 300;
}
.dz-title { margin: 0 0 4px; font-size: 16px; font-weight: 500; }
.dz-sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; }

.paste-target {
  margin-top: 14px;
  padding: 18px;
  border: 2px dashed var(--accent);
  border-radius: 10px;
  min-height: 56px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  text-align: left;
  -webkit-user-select: text;
  user-select: text;
}
.paste-target:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  font-style: italic;
}
.paste-target:focus { outline: none; border-color: var(--accent-hover); }
.paste-target img { max-width: 100%; height: auto; display: block; }

.paste-btn, .reset-btn {
  background: var(--accent);
  color: #0a1020;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.paste-btn:hover, .reset-btn:hover { background: var(--accent-hover); }

.status {
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 14px;
  display: flex; align-items: center; gap: 10px;
  white-space: pre-wrap;
}
.status.error { border-color: var(--error); color: var(--error); }
.status.working::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--accent); border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.preview, .result, .rescue {
  margin-top: 24px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.preview img, .result img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
}
.result { text-align: center; }
.result .reset-btn { margin-top: 14px; }

.solution-count {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.rescue-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.rescue-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.rescue-btn {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.rescue-btn:hover { border-color: var(--accent); background: var(--surface); }

@media (max-width: 480px) {
  main { padding: 16px 12px 48px; }
  h1 { font-size: 24px; }
  .dropzone { padding: 32px 14px; }
}
