:root {
  color-scheme: light;
  --background: #f5f7fa;
  --surface: #ffffff;
  --surface-subtle: #eef2f6;
  --text: #17202a;
  --muted: #526170;
  --border: #d9e0e7;
  --primary: #0b65d8;
  --primary-hover: #0757bc;
  --accent: #d74f13;
  --danger: #b42318;
  --focus: #0b65d8;
  --shadow: 0 8px 24px rgba(20, 35, 50, 0.08);
  --radius: 8px;
  --font: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--background);
}

body {
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: 0;
}

button,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  cursor: pointer;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 8px;
  z-index: 10;
  padding: 8px 12px;
  color: #fff;
  background: var(--primary);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar,
main,
footer {
  width: min(100% - 32px, 1040px);
  margin-inline: auto;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--primary);
  border-radius: 6px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  line-height: 1.2;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.protocol-badge {
  padding: 4px 8px;
  border: 1px solid #a9c7ec;
  border-radius: 4px;
  color: #174f91;
  background: #e9f2fd;
  font-size: 12px;
  font-weight: 700;
}

main {
  padding-block: 48px 64px;
}

.intro {
  max-width: 700px;
  margin-bottom: 32px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.15;
  letter-spacing: 0;
  text-wrap: balance;
}

h2 {
  margin-bottom: 4px;
  font-size: 20px;
  line-height: 1.3;
}

.intro > p:last-child,
.section-heading p,
#url-help,
footer {
  color: var(--muted);
}

.converter {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.section-heading p {
  margin-bottom: 0;
  font-size: 14px;
}

.origin-label {
  max-width: 48%;
  padding: 6px 8px;
  overflow-wrap: anywhere;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
  color: var(--muted);
  font: 12px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
}

label {
  display: inline-block;
  margin-bottom: 8px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 152px;
  resize: vertical;
  padding: 14px 16px;
  border: 1px solid #aeb9c4;
  border-radius: 6px;
  outline: none;
  color: var(--text);
  background: #fff;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(11, 101, 216, 0.18);
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
}

#url-help,
.form-message {
  margin-bottom: 0;
  font-size: 14px;
}

.form-message {
  min-height: 24px;
  margin-top: 8px;
  color: var(--danger);
}

.form-message[data-state="success"] {
  color: #137333;
}

.primary-button,
.secondary-button,
.row-button {
  border-radius: 6px;
  font-weight: 700;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.primary-button {
  min-width: 132px;
  padding: 10px 20px;
  border: 1px solid var(--primary);
  color: #fff;
  background: var(--primary);
}

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

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.secondary-button,
.row-button {
  padding: 8px 12px;
  border: 1px solid #aeb9c4;
  color: var(--text);
  background: var(--surface);
}

.secondary-button:hover:not(:disabled),
.row-button:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #f2f7fd;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(11, 101, 216, 0.35);
  outline-offset: 2px;
}

.results:not(:empty) {
  margin-top: 20px;
  border-top: 1px solid var(--border);
}

.result-row,
.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding-block: 16px;
  border-bottom: 1px solid var(--border);
}

.result-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.result-row.is-error {
  color: var(--danger);
}

.link-stack {
  min-width: 0;
}

.link-stack strong,
.link-stack a,
.link-stack span {
  display: block;
  overflow-wrap: anywhere;
}

.link-stack strong {
  margin-bottom: 2px;
  font-size: 13px;
}

.link-stack a {
  color: var(--primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.link-stack span {
  color: var(--muted);
  font-size: 13px;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.history {
  margin-top: 40px;
}

.history-content {
  border-top: 1px solid var(--border);
}

.history-row {
  grid-template-columns: minmax(0, 1fr) 110px 160px;
}

.metric {
  font-variant-numeric: tabular-nums;
}

.metric strong,
.metric span {
  display: block;
}

.metric strong {
  font-size: 20px;
}

.metric span,
.empty-state {
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-block: 24px 40px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

@media (max-width: 680px) {
  .topbar,
  main,
  footer {
    width: min(100% - 24px, 1040px);
  }

  main {
    padding-block: 32px 48px;
  }

  .section-heading,
  .form-footer,
  footer {
    align-items: stretch;
    flex-direction: column;
  }

  .origin-label {
    max-width: 100%;
  }

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

  .converter {
    padding: 20px 16px;
  }

  .result-row,
  .history-row {
    grid-template-columns: 1fr;
  }

  .history-row {
    gap: 8px;
  }

  .metric {
    display: flex;
    align-items: baseline;
    gap: 8px;
  }

  .row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

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