:root {
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-strong: #f0f4f6;
  --text: #172126;
  --muted: #66747d;
  --line: #d9e0e3;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --notice: #166534;
  --error: #b42318;
  --warning-bg: #fff6db;
  --shadow: 0 18px 45px rgba(23, 33, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(246, 247, 243, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.nav {
  display: flex;
  gap: 8px;
  max-width: 940px;
  margin: 0 auto;
  padding: 12px 20px;
  overflow-x: auto;
}

.nav__link {
  flex: 0 0 auto;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.nav__link:hover,
.nav__link:focus-visible {
  color: var(--text);
  background: var(--surface-strong);
  outline: none;
}

.nav__link.is-active {
  color: #ffffff;
  background: var(--accent);
}

.container {
  width: min(900px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.intro,
.tool,
.rules,
.examples {
  margin-bottom: 28px;
}

.tool,
.rules,
.examples {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(32px, 6vw, 52px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 16px;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 18px;
}

.lead {
  max-width: 760px;
  margin-bottom: 14px;
  color: #304047;
  font-size: 18px;
}

.warning {
  margin-bottom: 0;
  padding: 14px 16px;
  background: var(--warning-bg);
  border: 1px solid #ead28d;
  border-radius: 8px;
  color: #5f4300;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  font-weight: 800;
}

textarea {
  display: block;
  width: 100%;
  min-height: 180px;
  padding: 14px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--text);
  font: 16px/1.55 Arial, Helvetica, sans-serif;
}

textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

#resultText {
  min-height: 160px;
  white-space: pre-wrap;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  margin: 8px 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.button-row {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
}

button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font: 800 15px/1 Arial, Helvetica, sans-serif;
}

button:hover,
button:focus-visible {
  background: var(--accent-dark);
  outline: none;
}

.button-secondary {
  background: #1f3a44;
  border-color: #1f3a44;
}

.button-secondary:hover,
.button-secondary:focus-visible {
  background: #142a32;
}

.button-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.button-ghost:hover,
.button-ghost:focus-visible {
  background: var(--surface-strong);
}

.message {
  font-weight: 700;
}

.message--error {
  color: var(--error);
  text-align: right;
}

.message--notice {
  min-height: 24px;
  margin-top: 10px;
  color: var(--notice);
}

.segmented {
  display: grid;
  gap: 10px;
  margin: 0 0 20px;
  padding: 0;
  border: 0;
}

.segmented legend {
  margin-bottom: 8px;
  font-weight: 800;
}

.segmented label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  cursor: pointer;
}

.segmented input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.muted {
  color: var(--muted);
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}

.rule-cell,
.example-grid div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  overflow-wrap: anywhere;
}

.rule-cell {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 800;
}

.rule-cell span:last-child {
  color: var(--accent-dark);
}

.example-grid {
  display: grid;
  gap: 8px;
}

.example-grid div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.example-grid span {
  color: var(--accent-dark);
  font-weight: 800;
  text-align: right;
}

.example-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 680px) {
  .container {
    width: min(100% - 24px, 900px);
    padding-top: 28px;
  }

  .nav {
    padding-inline: 12px;
  }

  .tool,
  .rules,
  .examples {
    padding: 16px;
  }

  .button-row {
    flex-direction: column;
  }

  button {
    width: 100%;
  }

  .meta-row,
  .example-grid div {
    align-items: flex-start;
    flex-direction: column;
  }

  .message--error,
  .example-grid span {
    text-align: left;
  }

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