:root {
  color-scheme: light dark;
  --canvas: #f3f6f4;
  --surface: #ffffff;
  --surface-subtle: #e9eeeb;
  --ink: #14201b;
  --muted: #53635b;
  --border: #bdc9c2;
  --border-strong: #7f9187;
  --route: #168556;
  --route-strong: #0d6841;
  --amber: #c77814;
  --blue: #315fce;
  --danger: #b23b33;
  --focus: #315fce;
  --shadow: 0 18px 50px rgba(20, 32, 27, 0.08);
  --radius: 8px;
  --sans: "Segoe UI Variable", "Segoe UI", "Noto Sans SC", sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border: 2px solid var(--focus);
  border-radius: 4px;
  background: var(--surface);
  transform: translateY(-160%);
}

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

.site-header,
main,
footer {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-strong);
}

.brand {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 720;
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #ffffff;
  background: var(--ink);
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
}

.service-state {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.state-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--route);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--route) 18%, transparent);
}

main {
  padding-block: 56px 40px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  align-items: end;
  gap: 48px;
  margin-bottom: 30px;
}

h1 {
  max-width: 720px;
  margin: 0;
  font-size: 46px;
  line-height: 1.08;
  font-weight: 760;
  letter-spacing: 0;
  text-wrap: balance;
}

.intro p {
  max-width: 620px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.route {
  min-height: 68px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
}

.route code {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 650;
}

.route code:last-child {
  color: var(--route-strong);
}

.route-line {
  position: relative;
  height: 2px;
  background: var(--border-strong);
}

.route-line::before,
.route-line::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  transform: translateY(-50%);
}

.route-line::before {
  left: -1px;
}

.route-line::after {
  right: -1px;
  border-color: var(--route);
  background: var(--route);
}

.route-line span {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 9px;
  height: 9px;
  border-top: 2px solid var(--route);
  border-right: 2px solid var(--route);
  transform: translateY(-50%) rotate(45deg);
}

.converter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.editor {
  min-width: 0;
  padding: 24px;
}

.output-editor {
  border-left: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-subtle) 45%, var(--surface));
}

.editor-header {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.editor-header label {
  font-size: 16px;
  font-weight: 720;
}

.text-button {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 5px;
  color: var(--blue);
  background: transparent;
  font-weight: 650;
  cursor: pointer;
}

.text-button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--blue) 9%, transparent);
}

.text-button:disabled {
  color: var(--muted);
  opacity: 0.48;
  cursor: default;
}

.code-field {
  position: relative;
}

.code-gutter {
  position: absolute;
  z-index: 1;
  top: 17px;
  left: 16px;
  color: var(--amber);
  font-family: var(--mono);
  font-weight: 700;
  pointer-events: none;
}

.output-gutter {
  color: var(--route);
}

textarea {
  width: 100%;
  min-height: 310px;
  display: block;
  resize: vertical;
  padding: 15px 16px 20px 42px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  color: var(--ink);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.65;
  tab-size: 2;
  caret-color: var(--route);
}

textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
}

textarea:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent);
}

textarea[readonly] {
  background: color-mix(in srgb, var(--route) 4%, var(--surface));
}

.field-message {
  min-height: 24px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.field-message.success {
  color: var(--route-strong);
}

.field-message.warning {
  color: var(--amber);
}

.field-message.error {
  color: var(--danger);
}

.action-bar {
  grid-column: 1 / -1;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
}

.support-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.support-list span {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 12px;
}

.primary-button {
  min-width: 136px;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--route-strong);
  border-radius: 6px;
  color: #ffffff;
  background: var(--route-strong);
  font-weight: 720;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

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

.primary-button:active:not(:disabled) {
  background: #095534;
}

.primary-button:disabled {
  border-color: var(--border-strong);
  background: var(--border-strong);
  opacity: 0.58;
  cursor: default;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 38%, transparent);
  outline-offset: 2px;
}

footer {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-strong);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

footer a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--blue);
}

@media (max-width: 820px) {
  .site-header,
  main,
  footer {
    width: min(100% - 28px, 680px);
  }

  main {
    padding-top: 36px;
  }

  .intro {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  h1 {
    font-size: 40px;
  }

  .route {
    max-width: 460px;
  }

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

  .output-editor {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  textarea {
    min-height: 240px;
  }
}

@media (max-width: 520px) {
  .site-header {
    min-height: 68px;
  }

  .brand {
    font-size: 18px;
  }

  .service-state {
    font-size: 0;
  }

  .service-state .state-dot {
    margin-right: 4px;
  }

  main {
    padding-block: 30px 28px;
  }

  h1 {
    font-size: 34px;
  }

  .intro p {
    font-size: 16px;
  }

  .route {
    min-height: 48px;
    gap: 10px;
  }

  .route code {
    font-size: 12px;
  }

  .editor {
    padding: 18px;
  }

  .action-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 16px 18px 18px;
  }

  .primary-button {
    width: 100%;
  }

  footer {
    min-height: 68px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #111714;
    --surface: #18211d;
    --surface-subtle: #202b26;
    --ink: #eef5f1;
    --muted: #b4c2ba;
    --border: #394a41;
    --border-strong: #607369;
    --route: #55c58e;
    --route-strong: #36a971;
    --amber: #edae52;
    --blue: #86a8ff;
    --danger: #ff9189;
    --focus: #86a8ff;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  }

  .brand-mark,
  .primary-button {
    color: #07120d;
  }

  .brand-mark {
    background: var(--route);
  }
}

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