:root {
  color-scheme: light;
  --background: #f8faf9;
  --surface: #ffffff;
  --text: #1e272d;
  --muted: #68737b;
  --border: #d9e0e2;
  --border-strong: #b9c5c8;
  --accent: #07866f;
  --accent-dark: #056c5b;
  --accent-soft: #effaf7;
  --danger: #b53b35;
  --focus: rgba(7, 134, 111, 0.2);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

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

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

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  padding: 0 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

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

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 5px);
  grid-template-rows: repeat(2, 5px);
  gap: 3px;
  width: 21px;
}

.brand-mark i { width: 5px; height: 5px; background: var(--text); }
.brand-mark i:nth-child(3), .brand-mark i:nth-child(6) { background: var(--accent); }

.workspace {
  width: min(856px, calc(100% - 40px));
  margin: 0 auto;
  padding: 52px 0 36px;
}

.intro { margin-bottom: 32px; }
.intro h1 { margin: 0 0 10px; font-size: 34px; line-height: 1.2; font-weight: 760; }
.intro p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.7; }

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 14px;
  align-items: end;
}

.field label {
  display: block;
  margin-bottom: 9px;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 680;
}

input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  outline: none;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 16px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input::placeholder { color: #98a2a9; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(181, 59, 53, 0.12); }

.primary-button {
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 7px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

.primary-button:hover { background: var(--accent-dark); }
.primary-button:active { transform: translateY(1px); }
.primary-button:focus-visible, .icon-button:focus-visible, .text-button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.primary-button:disabled { cursor: wait; opacity: 0.65; }
.primary-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.primary-button.is-loading svg { display: none; }
.primary-button.is-loading::after {
  width: 17px;
  height: 17px;
  content: "";
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

.form-message {
  min-height: 22px;
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.form-message.error { color: var(--danger); }
.form-message.success { color: var(--accent-dark); }

.result-section { margin-top: 28px; }
.section-heading { min-height: 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 9px; }
.section-heading h2 { margin: 0; font-size: 16px; line-height: 1.4; font-weight: 720; }

.text-button {
  padding: 4px 0;
  color: var(--muted);
  background: none;
  border: 0;
  font-size: 13px;
  cursor: pointer;
}
.text-button:hover { color: var(--text); }

.result-box {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px 16px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
}

.result-box[data-state="success"] { background: var(--accent-soft); border-color: var(--accent); }
.result-box output { min-width: 0; overflow-wrap: anywhere; color: #8a949b; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 20px; line-height: 1.4; }
.result-box[data-state="success"] output { color: var(--accent-dark); font-weight: 700; }
.result-actions { flex: none; display: flex; align-items: center; gap: 14px; }

.success-state { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-dark); font-size: 13px; white-space: nowrap; }
.success-state svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}
.icon-button:hover { background: rgba(7, 134, 111, 0.08); border-color: rgba(7, 134, 111, 0.2); }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.history-section { margin-top: 42px; padding-top: 26px; border-top: 1px solid var(--border); }
.history-heading { margin-bottom: 12px; }
.history-table { width: 100%; }
.history-header, .history-row { display: grid; grid-template-columns: 1.05fr 1.25fr 56px; align-items: center; gap: 20px; }
.history-header { min-height: 38px; color: var(--muted); border-bottom: 1px solid var(--border); font-size: 12px; }
.history-header span:last-child { text-align: center; }
.history-row { min-height: 56px; border-bottom: 1px solid var(--border); font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 14px; }
.history-row code { min-width: 0; overflow-wrap: anywhere; color: var(--text); font: inherit; }
.history-row .icon-button { justify-self: center; }

footer { padding: 10px 20px 32px; color: var(--muted); text-align: center; font-size: 12px; }
[hidden] { display: none !important; }

@media (max-width: 640px) {
  .topbar { height: 62px; padding: 0 20px; }
  .brand { font-size: 17px; }
  .workspace { width: min(100% - 32px, 520px); padding-top: 34px; }
  .intro { margin-bottom: 26px; }
  .intro h1 { font-size: 28px; }
  .intro p { font-size: 14px; }
  .form-row { grid-template-columns: minmax(0, 1fr) 52px; gap: 10px; }
  .result-box { align-items: flex-start; padding: 16px; }
  .result-box output { padding-top: 7px; font-size: 16px; }
  .success-state { display: none; }
  .history-section { margin-top: 34px; }
  .history-header { display: none; }
  .history-row { grid-template-columns: minmax(0, 1fr) 44px; gap: 8px 12px; min-height: 78px; padding: 12px 0; }
  .history-row code:first-child { color: var(--muted); font-size: 12px; }
  .history-row code:nth-child(2) { grid-column: 1; font-size: 13px; }
  .history-row .icon-button { grid-column: 2; grid-row: 1 / 3; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
  .primary-button.is-loading::after { animation: none; }
}
