:root {
  --background: #f5f7fa;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #172033;
  --muted: #5f6c80;
  --border: #d8e0ea;
  --border-strong: #c4d0dd;
  --primary: #ffa514;
  --primary-hover: #d0860f;
  --primary-soft: #e8f0ff;
  --success-bg: #e8f7ee;
  --success-text: #18603a;
  --error-bg: #fdecea;
  --error-text: #9f2d24;
  --loading-bg: #fff5db;
  --loading-text: #885f00;
  --radius: 4px;
  --shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--background);
}

button,
input,
select,
a {
  font: inherit;
}

.page {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 100vh;
  padding: 32px 0 48px;
  display: flex;
  flex-direction: column;
}

.page > section:first-child,

/* .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
} */

.card + .card {
  margin-top: 20px;
}

.search-card {
  flex: 1 0 auto;
}

.page-header {
  margin-bottom: 24px;
}

.site-footer {
  margin-top: 24px;
  color: var(--muted);
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.5;
}

.site-footer p {
  margin: 0;
}

.footer-love {
  display: inline-block;
  margin-left: 4px;
  color: var(--primary);
  font-size: 1.05em;
  line-height: 1;
}

.mode-switch {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius));
  background: var(--surface-muted);
}

.mode-toggle {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.mode-toggle.active,
.mode-toggle[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.kicker {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.page-header h1,
.output-top h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.2rem);
  line-height: 1.15;
}

.intro {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.mode-panel {
  display: contents;
}

.mode-panel[hidden] {
  display: none !important;
}

.field {
  display: grid;
  gap: 8px;
  position: relative;
}

.field label,
.checkbox-row span,
.checkbox-label {
  font-weight: 600;
}

.field-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.field-help-wrap {
  position: relative;
  flex-shrink: 0;
}

.info-button {
  width: 22px;
  min-width: 22px;
  min-height: 22px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
}

.info-button:hover,
.info-button[aria-expanded="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.field-help {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  z-index: 10;
  width: min(320px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #172033;
  color: #f8fafc;
  box-shadow: 0 10px 24px rgba(23, 32, 51, 0.18);
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.45;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    visibility 140ms ease;
}

.field-help strong,
.field-help span {
  display: block;
}

.field-help strong {
  margin-bottom: 6px;
}

.field-help span + span {
  margin-top: 6px;
}

.help-example {
  color: #cbd5e1;
}

.field-help code {
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  font-size: 0.82rem;
}

.field-help-wrap:hover .field-help,
.field-help-wrap:focus-within .field-help,
.field-help-wrap.is-open .field-help {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.field input::placeholder,
.helper-text {
  color: var(--muted);
}

.field input:focus,
.field select:focus,
button:focus,
a:focus,
.checkbox-row input:focus {
  outline: none;
  box-shadow: none;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.checkbox-row input {
  margin: 0;
}

.helper-text {
  margin: -4px 0 0;
  font-size: 0.94rem;
}

.checkbox-field,
.checkbox-row,
.helper-text,
.actions,
.status-banner {
  grid-column: 1 / -1;
}

.checkbox-field {
  display: grid;
  gap: 8px;
}

.actions,
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

button,
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    opacity 140ms ease;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--primary-hover);
}

.secondary-button {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--border);
}

.secondary-button:hover {
  background: #eef3f8;
  border-color: var(--border-strong);
}

button:disabled,
.disabled-link {
  opacity: 0.5;
  pointer-events: none;
}

.status-banner {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
}

.status-banner.neutral {
  background: var(--primary-soft);
  color: var(--primary);
}

.status-banner.loading {
  background: var(--loading-bg);
  color: var(--loading-text);
}

.status-banner.success {
  background: var(--success-bg);
  color: var(--success-text);
}

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

.query-output {
  margin: 0;
  min-height: 180px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #101828;
  color: #f8fafc;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  line-height: 1.6;
}

body.modal-open {
  overflow: hidden;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-shell[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 17, 31, 0.56);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  width: min(960px, 100%);
  max-height: min(92vh, 1080px);
  overflow: auto;
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%);
  box-shadow: 0 24px 64px rgba(10, 17, 31, 0.22);
}

.modal-header,
.result-label-row,
.modal-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-header {
  margin-bottom: 22px;
}

.modal-header h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.2rem);
  line-height: 1.15;
}

.modal-body {
  display: grid;
  gap: 18px;
}

.result-block {
  display: grid;
  gap: 10px;
}

.result-label-row h3 {
  margin: 0;
  font-size: 1rem;
}

.url-output {
  display: block;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  line-height: 1.55;
  word-break: break-all;
}

.url-output.is-empty {
  color: var(--muted);
  pointer-events: none;
}

.text-link {
  color: var(--primary-hover);
  font-weight: 600;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.button-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
}

.icon-button {
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
}

.icon-button:hover {
  background: #eef3f8;
  border-color: var(--border-strong);
}

.modal-actions {
  margin-top: 22px;
}

@media (max-width: 640px) {
  .page {
    width: min(100%, calc(100% - 20px));
    padding: 20px 0 28px;
  }

  .card {
    padding: 20px;
  }

  .form {
    grid-template-columns: 1fr;
  }

  .actions,
  .result-actions,
  .modal-actions,
  .modal-header,
  .result-label-row {
    flex-direction: column;
  }

  .mode-switch {
    display: grid;
    grid-template-columns: 1fr;
  }

  button,
  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .modal-shell {
    padding: 14px;
  }

  .modal-card {
    padding: 20px;
  }
}
