:root {
  color-scheme: light;
  --background: #f5f7f8;
  --surface: #ffffff;
  --text: #17211b;
  --muted: #627069;
  --border: #dce3df;
  --accent: #176b45;
  --accent-hover: #115738;
  --accent-soft: #e8f4ed;
  --danger: #a93636;
  --danger-soft: #fff0f0;
  --shadow: 0 18px 50px rgba(30, 50, 39, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
}

button, input { font: inherit; }

a { color: var(--accent); }

.shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 80px;
}

.page-header { max-width: 720px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: white;
}

h1 {
  margin: 52px 0 14px;
  font-size: clamp(38px, 6vw, 64px);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.page-header > p {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
}

.request-panel, .result-panel, .error-panel {
  margin-top: 36px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.request-panel { padding: 24px; }

label {
  display: block;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 650;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
}

input {
  min-width: 0;
  height: 48px;
  padding: 0 15px;
  border: 1px solid #cbd5cf;
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 69, 0.13);
}

.button {
  height: 48px;
  padding: 0 19px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 700;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: 0.58; }
.button-primary { background: var(--accent); color: white; }
.button-primary:hover:not(:disabled) { background: var(--accent-hover); }
.button-secondary { border-color: var(--border); background: white; color: var(--text); }
.button-secondary:hover:not(:disabled) { border-color: #b9c7bf; background: #fafcfb; }
.button-small { height: 40px; padding: 0 14px; font-size: 14px; }

.status {
  align-items: center;
  gap: 10px;
  margin: 24px 4px 0;
  color: var(--muted);
  font-size: 14px;
}

.status:not([hidden]) { display: flex; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #c9d5ce;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

.error-panel {
  padding: 24px;
  border-color: #f0c7c7;
  background: var(--danger-soft);
  box-shadow: none;
}

.error-panel h2 { margin: 5px 0 8px; font-size: 20px; }
.error-panel p { margin: 0; color: #6d3d3d; line-height: 1.55; }
.error-code { font: 700 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; }

.result-panel { overflow: hidden; }

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
}

.result-header h2 { margin: 4px 0 0; font-size: 23px; letter-spacing: -0.025em; }
.result-label { margin: 0; color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }

.metadata {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  padding: 18px 28px;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfb;
}

.metadata div { min-width: 0; }
.metadata dt { margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 650; }
.metadata dd { margin: 0; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }

.source {
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.markdown-body {
  padding: 30px 40px 48px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 1.5em 0 0.55em; font-family: var(--ui-font, Inter, ui-sans-serif, system-ui, sans-serif); line-height: 1.2; letter-spacing: -0.025em; }
.markdown-body h1 { font-size: 32px; }
.markdown-body h2 { font-size: 25px; }
.markdown-body h3 { font-size: 20px; }
.markdown-body img { max-width: 100%; height: auto; border-radius: 10px; }
.markdown-body pre { overflow: auto; padding: 16px; border-radius: 10px; background: #17211b; color: #eaf1ed; font-size: 14px; }
.markdown-body code { font-size: 0.88em; }
.markdown-body blockquote { margin-left: 0; padding-left: 18px; border-left: 3px solid var(--border); color: var(--muted); }

.url-list { margin: 0; padding: 10px 28px 24px; list-style-position: inside; }
.url-list li { padding: 12px 0; border-bottom: 1px solid #edf1ef; overflow-wrap: anywhere; }
.url-list li:last-child { border-bottom: 0; }
.url-list a { font-size: 14px; text-underline-offset: 3px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 680px) {
  .shell { width: min(100% - 20px, 1040px); padding-top: 24px; }
  h1 { margin-top: 38px; }
  .request-panel { padding: 16px; }
  .input-row { grid-template-columns: 1fr 1fr; }
  .input-row input { grid-column: 1 / -1; }
  .result-header { align-items: flex-start; padding: 20px; }
  .metadata { grid-template-columns: 1fr; padding: 16px 20px; gap: 13px; }
  .markdown-body { padding: 24px 20px 36px; font-size: 16px; }
  .url-list { padding-inline: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
