:root {
  --ink: #172033;
  --muted: #65708a;
  --line: #d9dee8;
  --soft: #f5f7fb;
  --paper: #ffffff;
  --accent: #1163ff;
  --accent-dark: #0b48bd;
  --good: #0c7a43;
  --warn: #a95a00;
  --bad: #b42318;
  --shadow: 0 18px 45px rgba(28, 42, 76, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  min-width: 0;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 16px clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.language-switcher {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.language-status {
  color: #8b95aa;
  font-size: 11px;
  font-weight: 750;
}

.language-switcher select {
  min-width: 116px;
  padding: 8px 10px;
}

.brand,
.nav a {
  color: var(--ink);
  text-decoration: none;
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  flex: 0 0 auto;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  color: white;
  background: var(--accent);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  flex: 1 1 auto;
  justify-content: center;
  gap: 22px;
  font-size: 14px;
  font-weight: 650;
  min-width: 0;
}

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

.hero-band,
.content-band,
.examples-band,
.faq-band,
.tool-band {
  padding: 76px clamp(20px, 5vw, 72px);
}

.hero-band {
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.hero {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(480px, 1.08fr);
  gap: 56px;
  align-items: center;
  max-width: 1180px;
  margin: 0 auto;
}

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

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

h1 {
  max-width: 720px;
  margin-bottom: 20px;
  font-size: clamp(40px, 4.7vw, 64px);
  line-height: 1.04;
  letter-spacing: 0;
  text-wrap: balance;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.06;
}

h3 {
  margin-bottom: 8px;
  font-size: 19px;
  line-height: 1.18;
}

.lede {
  max-width: 620px;
  color: var(--muted);
  font-size: 19px;
}

.hero-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.button {
  display: inline-flex;
  flex: 1 1 auto;
  min-width: fit-content;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 18px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  font-weight: 750;
  white-space: normal;
}

.button.primary {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.secondary {
  color: var(--ink);
  background: white;
}

.button.secondary:hover {
  border-color: #aeb8ca;
}

.hero-envelope,
.mini-envelope {
  position: relative;
  overflow: hidden;
  border: 1px solid #cfd6e3;
  background:
    linear-gradient(transparent calc(100% - 78px), rgba(17, 99, 255, 0.07) calc(100% - 78px), rgba(17, 99, 255, 0.07) calc(100% - 32px), transparent calc(100% - 32px)),
    #fff;
  box-shadow: var(--shadow);
}

.hero-envelope {
  min-height: 380px;
  border-radius: 10px;
}

.stamp,
.mini-stamp {
  position: absolute;
  right: 28px;
  top: 26px;
  display: grid;
  place-items: center;
  border: 2px dashed #b8c2d5;
  color: #8b95aa;
  font-size: 12px;
  font-weight: 800;
}

.stamp {
  width: 82px;
  height: 66px;
}

.return-sample {
  position: absolute;
  left: 28px;
  top: 28px;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.25;
}

.recipient-sample {
  position: absolute;
  left: 42%;
  right: 142px;
  top: 45%;
  transform: translateY(-50%);
  font-size: clamp(18px, 1.9vw, 26px);
  font-weight: 850;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}

.barcode-zone {
  position: absolute;
  right: 28px;
  bottom: 39px;
  color: #7b8498;
  font-size: 13px;
  font-style: italic;
}

.tool-band {
  background: var(--soft);
}

.section-heading {
  max-width: 860px;
  margin: 0 auto 28px;
  text-align: center;
}

.section-heading p:not(.eyebrow) {
  color: var(--muted);
  font-size: 17px;
}

.section-heading.compact {
  margin-bottom: 32px;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto;
}

.formatter-panel,
.result-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  box-shadow: var(--shadow);
}

.formatter-panel {
  padding: 22px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 20px;
  padding: 5px;
  border-radius: 8px;
  background: #eef2f8;
}

.tab {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.tab.active {
  color: var(--ink);
  background: white;
  box-shadow: 0 1px 3px rgba(28, 42, 76, 0.12);
}

label,
legend {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: #303a50;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd6e3;
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: white;
  outline: none;
}

textarea {
  resize: vertical;
}

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

.row {
  display: grid;
  gap: 12px;
}

.row.two {
  grid-template-columns: 1fr 1fr;
}

.row.three {
  grid-template-columns: 1fr 0.75fr 0.8fr;
}

.scenario {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 12px 0 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.scenario legend {
  display: block;
  padding: 0 6px;
  margin-bottom: 0;
}

.scenario label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
}

.scenario input {
  width: auto;
}

.hint {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.extra-fields {
  margin-top: 14px;
}

.return-editor {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.return-editor summary {
  margin-bottom: 12px;
}

.return-editor:not([open]) summary {
  margin-bottom: 0;
}

.toggle-line {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 9px;
}

.toggle-line input {
  width: auto;
}

.hidden {
  display: none !important;
}

.result-panel {
  padding: 24px;
}

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.result-header h2 {
  margin-bottom: 0;
  font-size: 28px;
}

.status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--good);
  background: #eaf8f0;
  font-size: 12px;
  font-weight: 850;
}

.formatted {
  min-height: 122px;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fbfcff;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: clamp(19px, 2vw, 26px);
  font-weight: 800;
  line-height: 1.25;
}

.address-language-note {
  margin: -8px 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.compare-grid h3 {
  margin-bottom: 7px;
  color: #303a50;
  font-size: 13px;
  text-transform: uppercase;
}

.compare-box {
  min-height: 86px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: #414c63;
  background: #fbfcff;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.3;
}

.checklist {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.check-item.pass {
  color: var(--good);
  background: #eaf8f0;
}

.check-item.warn {
  color: var(--warn);
  background: #fff6e8;
}

.check-item.fail {
  color: var(--bad);
  background: #fff0ee;
}

.notes {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 14px;
}

.notes p {
  margin: 0;
}

.mini-envelope {
  min-height: 310px;
  border-radius: 8px;
  box-shadow: none;
}

.mini-stamp {
  width: 62px;
  height: 50px;
}

.mini-return {
  position: absolute;
  left: 22px;
  right: 120px;
  top: 22px;
  color: #4d5870;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.mini-recipient {
  position: absolute;
  left: 40%;
  right: 18px;
  top: 43%;
  transform: translateY(-50%);
  max-width: none;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: clamp(15px, 2.2vw, 23px);
  font-weight: 900;
  line-height: 1.25;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.mini-zone {
  position: absolute;
  left: 50%;
  bottom: 43px;
  transform: translateX(-50%);
  color: #818ba0;
  font-size: 12px;
  font-style: italic;
  white-space: nowrap;
}

.content-band,
.faq-band {
  background: white;
}

.ad-band {
  padding: 14px clamp(20px, 5vw, 72px);
  background: white;
}

.ad-band.soft {
  background: #f8fbff;
}

.ad-slot {
  display: grid;
  place-items: center;
  overflow: hidden;
  max-width: 1180px;
  margin: 0 auto;
  border: 1px solid #edf1f7;
  border-radius: 8px;
  color: #a0a9b8;
  background: #fbfcff;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ad-slot-wide {
  min-height: 90px;
}

.ad-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
}

.ad-slot-card {
  min-height: 120px;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
}

.rule-grid article {
  border-top: 3px solid var(--accent);
  padding-top: 18px;
}

.rule-grid span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.rule-grid p,
.faq-list p {
  color: var(--muted);
}

.examples-band {
  background: #f8fbff;
}

.examples {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  max-width: 1180px;
  margin: 0 auto;
}

.example {
  display: grid;
  gap: 8px;
  min-height: 116px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--ink);
  background: white;
  cursor: pointer;
  text-align: left;
  min-width: 0;
  overflow-wrap: anywhere;
}

.example:hover {
  border-color: var(--accent);
}

.example span {
  color: var(--muted);
  font-size: 13px;
}

.faq-list {
  display: grid;
  gap: 10px;
  max-width: 850px;
  margin: 0 auto;
}

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
  background: white;
}

summary {
  cursor: pointer;
  font-weight: 850;
}

details p {
  margin: 12px 0 0;
}

.footer {
  padding: 28px clamp(20px, 5vw, 72px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #fbfcff;
  text-align: center;
  font-size: 14px;
}

html[dir="rtl"] .nav {
  justify-content: center;
}

html[dir="rtl"] .example {
  text-align: right;
}

html[dir="rtl"] .mini-return {
  left: 120px;
  right: 22px;
}

html[dir="rtl"] .mini-recipient {
  left: 18px;
  right: 40%;
}

@media (max-width: 980px) {
  .hero,
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .site-header {
    align-items: flex-start;
  }

  .nav {
    order: 3;
    flex-basis: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .hero-envelope {
    min-height: 330px;
  }

  .recipient-sample {
    left: 34%;
  }

  .rule-grid,
  .examples {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 860px) {
  .actions,
  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .site-header {
    position: static;
    display: grid;
    gap: 14px;
  }

  .language-switcher {
    justify-content: start;
  }

  .nav {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .hero-band,
  .content-band,
  .examples-band,
  .faq-band,
  .tool-band {
    padding: 48px 18px;
  }

  h1 {
    font-size: 38px;
    line-height: 1.04;
  }

  h2 {
    font-size: 30px;
  }

  .hero-envelope {
    min-height: 286px;
  }

  .recipient-sample {
    left: 24px;
    right: 24px;
    top: 50%;
    font-size: 20px;
    white-space: normal;
  }

  .barcode-zone {
    left: 24px;
    right: auto;
  }

  .row.two,
  .row.three,
  .scenario,
  .ad-grid,
  .rule-grid,
  .examples {
    grid-template-columns: 1fr;
  }

  .result-header {
    display: grid;
  }

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

  .mini-recipient {
    left: 22px;
    right: 20px;
    max-width: none;
    font-size: 16px;
  }

  .mini-return {
    right: 96px;
  }

  html[dir="rtl"] .mini-return {
    left: 96px;
    right: 22px;
  }

  html[dir="rtl"] .mini-recipient {
    left: 20px;
    right: 22px;
  }
}

@media (max-width: 460px) {
  .site-header,
  .hero-band,
  .content-band,
  .examples-band,
  .faq-band,
  .tool-band,
  .ad-band,
  .footer {
    padding-left: 14px;
    padding-right: 14px;
  }

  h1 {
    font-size: 34px;
  }

  .formatter-panel,
  .result-panel {
    padding: 16px;
  }

  .scenario {
    padding: 12px;
  }

  .formatted {
    padding: 14px;
    font-size: 17px;
  }

  .mini-envelope {
    min-height: 290px;
  }

  .mini-stamp {
    right: 14px;
    top: 14px;
    width: 54px;
    height: 44px;
    font-size: 10px;
  }

  .mini-return {
    left: 14px;
    right: 78px;
    top: 14px;
    font-size: 10px;
  }

  html[dir="rtl"] .mini-return {
    left: 78px;
    right: 14px;
  }

  .mini-zone {
    max-width: calc(100% - 28px);
    white-space: normal;
    text-align: center;
  }
}

@media print {
  body * {
    visibility: hidden;
  }

  .mini-envelope,
  .mini-envelope * {
    visibility: visible;
  }

  .mini-envelope {
    position: absolute;
    inset: 0 auto auto 0;
    width: 9.5in;
    min-height: 4.125in;
    border: 1px solid #000;
    box-shadow: none;
  }
}
