:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #15191d;
  --muted: #68727d;
  --line: #d8e0e6;
  --accent: #1267b1;
  --accent-strong: #0d4d86;
  --surface: #eef4f9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Hiragino Sans", sans-serif;
  color: var(--text);
  background: linear-gradient(145deg, #f6f9fb 0%, #eef4f7 100%);
}

button,
input {
  font: inherit;
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.tool {
  width: min(760px, 100%);
  display: grid;
  gap: 1rem;
  padding: clamp(1rem, 4vw, 1.5rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(21, 25, 29, 0.1);
}

.header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

h1 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.2;
}

p {
  margin: 0.4rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.primary-action,
.result-row button {
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.primary-action {
  min-height: 44px;
  padding: 0.7rem 1.2rem;
}

.primary-action:active,
.result-row button:active {
  background: var(--accent-strong);
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.field,
fieldset,
.check {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.field {
  display: grid;
  gap: 0.45rem;
  padding: 0.8rem;
}

.field-wide {
  grid-column: 1 / -1;
}

.field span,
legend {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  background: #ffffff;
}

fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0;
  padding: 0.8rem;
}

legend {
  padding: 0 0.25rem;
}

label {
  line-height: 1.35;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.8rem;
}

.message {
  min-height: 1.5em;
  margin: 0;
}

.results {
  display: grid;
  gap: 0.65rem;
}

.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

output {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0;
}

.result-row button {
  min-height: 38px;
  padding: 0.5rem 0.8rem;
}

@media (max-width: 620px) {
  .header,
  .result-row {
    grid-template-columns: 1fr;
  }

  .header {
    display: grid;
  }

  .primary-action {
    width: 100%;
  }

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