:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #5c6670;
  --border: #ccd3db;
  --accent: #1769aa;
  --accent-dark: #0f4d7d;
  --error-bg: #fff1f1;
  --error-text: #9b1c1c;
  --result-bg: #f8fafc;
}

* {
  box-sizing: border-box;
}

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

.page {
  width: min(920px, calc(100% - 32px));
  margin: 48px auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
}

h1,
h2 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  margin-bottom: 8px;
}

h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.filter-form {
  display: grid;
  gap: 12px;
}

.source-note {
  color: var(--muted);
  margin: 0 0 24px;
}

.source-note a {
  color: var(--accent);
  font-weight: 600;
}

.source-note a:hover {
  color: var(--accent-dark);
}

.field-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

textarea {
  min-height: 260px;
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  color: var(--text);
  font: inherit;
}

textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(23, 105, 170, 0.18);
}

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

button {
  min-width: 96px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 10px 18px;
}

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

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.loader {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.loader[hidden] {
  display: none;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid #d9e1e8;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.message {
  border-radius: 8px;
  margin: 18px 0 0;
  padding: 12px 14px;
}

.error {
  background: var(--error-bg);
  color: var(--error-text);
}

.result {
  border-top: 1px solid var(--border);
  margin-top: 28px;
  padding-top: 24px;
}

pre {
  min-height: 96px;
  margin: 0;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--result-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font: 15px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100% - 20px, 920px);
    margin: 20px auto;
  }

  .panel {
    padding: 18px;
  }

  h1 {
    font-size: 24px;
  }

  textarea {
    min-height: 220px;
  }
}
