:root {
  --page: #f2f2f2;
  --card: #ffffff;
  --soft: #f5f5f5;
  --soft-strong: #eeeeee;
  --line: #d9d9d9;
  --line-strong: #c9c9c9;
  --text: #1f2937;
  --muted: #6b7280;
  --green: #55b95a;
  --blue: #2f7fbe;
  --blue-dark: #256ba1;
  --cyan: #d9f0fb;
  --cyan-text: #236f94;
  --danger: #d64b3c;
  --focus: rgba(47, 127, 190, 0.28);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 18px 48px rgba(15, 23, 42, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
}

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

button,
summary,
.file-button {
  cursor: pointer;
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::before,
[data-tooltip]::after {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition:
    opacity 140ms ease,
    transform 140ms ease;
  z-index: 20;
}

[data-tooltip]::before {
  content: "";
  border: 6px solid transparent;
  border-top-color: #111827;
  bottom: calc(100% - 4px);
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  width: max-content;
  max-width: min(280px, calc(100vw - 32px));
  padding: 8px 10px;
  border-radius: 6px;
  background: #111827;
  color: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
  white-space: normal;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::before,
[data-tooltip]:focus-visible::after,
[data-tooltip]:focus-within::before,
[data-tooltip]:focus-within::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

a {
  color: #1d6cb8;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.page-shell {
  width: min(1260px, calc(100vw - 44px));
  margin: 38px auto 54px;
}

.tool-card {
  padding: 52px 36px 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.site-head {
  display: grid;
  gap: 14px;
}

.title-line {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 4px;
  background: var(--green);
  color: #fff;
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

h1 {
  margin: 0;
  color: #1f2937;
  font-size: clamp(27px, 3.2vw, 38px);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: 0;
}

h1 span {
  color: var(--muted);
  font-size: 22px;
  font-weight: 400;
}

.converter {
  margin-top: 26px;
}

.field-label {
  display: inline-flex;
  margin: 0 0 12px;
  color: #111827;
  font-size: 19px;
  line-height: 1.35;
}

textarea {
  width: 100%;
  min-height: 194px;
  padding: 15px 16px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  outline: none;
  background: #fff;
  color: #111827;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", "Microsoft YaHei UI", monospace;
  font-size: 15px;
  line-height: 1.65;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
}

textarea:focus {
  border-color: #7ab4de;
  box-shadow: 0 0 0 3px var(--focus), inset 0 1px 2px rgba(15, 23, 42, 0.05);
}

#outputText {
  min-height: 198px;
}

.action-bar {
  margin: 14px 0 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.button-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.action-button,
.ghost-button {
  min-height: 50px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: #111827;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    transform 150ms ease;
}

.action-button {
  padding: 0 24px;
  font-size: 18px;
  font-weight: 500;
}

.action-button.compact {
  padding: 0 16px;
}

.action-button.primary,
.action-button.is-active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  font-weight: 700;
}

.action-button:hover,
.ghost-button:hover,
.file-button:hover {
  transform: translateY(-1px);
}

.action-button.primary:hover,
.action-button.is-active:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.shortcut-hint {
  color: var(--muted);
  font-size: 16px;
}

kbd {
  min-width: 42px;
  padding: 3px 7px;
  border-radius: 4px;
  background: #111827;
  color: #fff;
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  font-weight: 700;
}

.select-after {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #111827;
  font-size: 18px;
  font-weight: 700;
}

.select-after input,
.switch-line input {
  width: 17px;
  height: 17px;
  accent-color: var(--blue);
}

.advanced {
  margin: 8px 0 12px;
}

.advanced summary {
  width: fit-content;
  color: #1d6cb8;
  font-size: 15px;
  user-select: none;
}

.advanced-grid {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--soft);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.switch-line,
.select-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #374151;
  font-size: 15px;
}

.select-line select {
  min-height: 34px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: #111827;
}

.result-head {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.result-head .field-label {
  margin-bottom: 0;
}

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

.ghost-button {
  min-height: 36px;
  padding: 0 13px;
  color: #1f2937;
  font-size: 14px;
}

.ghost-button:hover {
  border-color: #9fb9cc;
  background: #f6fbff;
}

.ghost-button.danger {
  color: var(--danger);
}

.message {
  margin-top: 16px;
  min-height: 74px;
  padding: 20px 22px;
  border: 1px solid #b9e4f6;
  border-radius: 5px;
  background: var(--cyan);
  color: var(--cyan-text);
  display: flex;
  align-items: center;
  font-size: 19px;
}

.message.is-error {
  border-color: #f4b9af;
  background: #fff1ef;
  color: #b42318;
}

.file-panel {
  margin-top: 16px;
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--soft);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: #111827;
  font-size: 19px;
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: #111827;
  font-size: 17px;
  font-weight: 600;
  transition:
    background 150ms ease,
    transform 150ms ease;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-name {
  color: #374151;
}

.site-foot {
  margin-top: 30px;
  padding-top: 25px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 15px;
}

.site-foot strong {
  margin-left: auto;
  color: #111827;
  font-weight: 600;
}

@media (max-width: 860px) {
  .page-shell {
    width: min(100vw - 24px, 720px);
    margin: 18px auto 30px;
  }

  .tool-card {
    padding: 28px 18px 22px;
  }

  .title-line {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 span {
    display: block;
    margin-top: 4px;
    font-size: 17px;
  }

  .action-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .button-group,
  .action-button,
  .select-after,
  .shortcut-hint {
    width: 100%;
  }

  .button-group {
    display: grid;
    grid-template-columns: 1fr;
  }

  .select-after {
    margin-left: 0;
  }

  .result-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .file-panel {
    align-items: stretch;
    flex-direction: column;
    font-size: 16px;
  }

  .file-button {
    width: fit-content;
  }

  .site-foot {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .site-foot strong {
    margin-left: 0;
  }
}

@media (max-width: 520px) {
  .page-shell {
    width: calc(100vw - 14px);
    margin-top: 7px;
  }

  .tool-card {
    padding: 22px 12px 18px;
  }

  .brand-pill {
    font-size: 17px;
  }

  h1 {
    font-size: 26px;
  }

  .field-label,
  .message,
  .file-panel {
    font-size: 16px;
  }

  textarea {
    min-height: 168px;
    font-size: 14px;
  }

  .advanced-grid {
    align-items: flex-start;
    flex-direction: column;
  }
}

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