:root {
  color-scheme: light;
  --page-bg: #f7f7f5;
  --surface: #ffffff;
  --surface-subtle: #f1f1ee;
  --text: #242421;
  --text-muted: #686862;
  --border: #d9d9d3;
  --border-strong: #b9b9b1;
  --accent: #176b5b;
  --accent-hover: #105447;
  --accent-soft: #e6f2ef;
  --danger: #b42318;
  --danger-soft: #fef0ed;
  --success: #18794e;
  --success-soft: #e9f6ef;
  --focus: rgba(23, 107, 91, 0.24);
  --shadow: 0 1px 2px rgba(30, 30, 26, 0.06), 0 8px 28px rgba(30, 30, 26, 0.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-synthesis: none;
  line-height: 1.6;
  color: var(--text);
  background: var(--page-bg);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page-bg);
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--page-bg);
}

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

button,
select,
input[type="checkbox"],
input[type="radio"],
input[type="file"] {
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

img,
svg {
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

#app {
  width: min(100% - 40px, 920px);
  margin-inline: auto;
  padding-block: 32px 64px;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  margin-bottom: 42px;
  border-bottom: 1px solid var(--border);
  gap: 20px;
}

.nav a {
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
}

.nav a:hover {
  color: var(--accent);
}

.nav ul,
.nav-links {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
  gap: 20px;
}

main:not(.share-page) {
  width: min(100%, 760px);
  margin-inline: auto;
}

h1,
h2,
h3 {
  margin-top: 0;
  color: var(--text);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(1.85rem, 5vw, 2.65rem);
  font-weight: 720;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.35rem;
}

p {
  margin-block: 0 1em;
}

.lead,
.subtitle,
.description,
.help-text,
.hint,
small {
  color: var(--text-muted);
}

.lead,
.subtitle {
  max-width: 65ch;
  margin-bottom: 32px;
  font-size: 1.05rem;
}

form,
.form-section {
  margin-block: 24px;
}

fieldset {
  min-width: 0;
  margin: 0 0 26px;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 12px;
  font-weight: 650;
}

label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.925rem;
  font-weight: 620;
}

.form-group,
.field,
.form-row {
  margin-bottom: 20px;
}

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

.form-row > * {
  min-width: 0;
  margin-bottom: 0;
}

input[type="text"],
input[type="url"],
input[type="search"],
input[type="email"],
select,
textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

textarea {
  min-height: 220px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.55;
  tab-size: 2;
}

#json-textarea,
#md-textarea {
  min-height: 300px;
}

input::placeholder,
textarea::placeholder {
  color: #94948d;
  opacity: 1;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

input[type="file"] {
  display: block;
  width: 100%;
  padding: 8px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 7px;
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 7px 12px;
  color: var(--text);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 5px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
  width: 17px;
  height: 17px;
  margin: 0 7px 0 0;
  vertical-align: -3px;
  accent-color: var(--accent);
}

label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
  display: flex;
  align-items: baseline;
  font-weight: 500;
}

.btn,
button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-weight: 620;
  line-height: 1.25;
  text-decoration: none;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 80ms ease;
}

.btn:hover,
button:hover,
input[type="submit"]:hover {
  color: var(--text);
  background: var(--surface-subtle);
  border-color: #96968f;
}

.btn:active,
button:active,
input[type="submit"]:active {
  transform: translateY(1px);
}

.btn:focus-visible,
button:focus-visible,
a:focus-visible,
input[type="submit"]:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

#submit-btn,
.btn-primary,
button[type="submit"] {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

#submit-btn:hover,
.btn-primary:hover,
button[type="submit"]:hover {
  color: #ffffff;
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger,
.delete-btn {
  color: var(--danger);
  border-color: #e3aaa4;
}

.btn-danger:hover,
.delete-btn:hover {
  color: #8f1c13;
  background: var(--danger-soft);
  border-color: #d98d85;
}

.copy-btn {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.84rem;
}

.tabs,
.format-tabs,
.format-options {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 22px;
  padding-bottom: 1px;
  border-bottom: 1px solid var(--border);
  gap: 4px 20px;
}

.tabs button,
.format-tabs button {
  margin-bottom: -1px;
  padding-inline: 2px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
}

.tabs button[aria-selected="true"],
.format-tabs button[aria-selected="true"],
.tabs .active,
.format-tabs .active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

#result,
.alert,
.error,
.success {
  margin-top: 24px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 5px;
  overflow-wrap: anywhere;
}

#result:empty {
  display: none;
}

#result a {
  font-weight: 620;
}

#result code,
.token,
.delete-token {
  display: inline-block;
  max-width: 100%;
  padding: 2px 6px;
  background: var(--surface-subtle);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.84rem;
  overflow-wrap: anywhere;
  user-select: all;
}

.error,
.alert-error,
[role="alert"] {
  color: #8f1c13;
  background: var(--danger-soft);
  border-color: #f2c1bb;
  border-left-color: var(--danger);
}

.success,
.alert-success {
  color: #10653f;
  background: var(--success-soft);
  border-color: #b7dfc9;
  border-left-color: var(--success);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--text-muted);
  background: var(--surface-subtle);
  font-size: 0.79rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #fafaf8;
}

.empty-state {
  padding: 48px 20px;
  color: var(--text-muted);
  text-align: center;
}

.spinner,
[aria-busy="true"]::before {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

@media (max-width: 768px) {
  #app {
    width: min(100% - 28px, 100%);
    padding-block: 18px 40px;
  }

  .nav {
    min-height: 50px;
    margin-bottom: 30px;
  }

  .nav ul,
  .nav-links {
    gap: 12px;
  }

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

  .form-row > * {
    margin-bottom: 18px;
  }

  #json-textarea,
  #md-textarea {
    min-height: 240px;
  }

  th,
  td {
    padding: 10px;
    white-space: nowrap;
  }
}

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