:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f4f6f9;
  --panel: #ffffff;
  --border: #d7dde6;
  --text: #0e1116;
  --muted: #4b5563;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 18px 50px rgba(15, 23, 42, .16);
  --topbar-h: 62px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.topbar {
  height: var(--topbar-h);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.lang-select {
  width: auto;
  min-width: 104px;
  padding: 7px 28px 7px 10px;
  font-size: 13px;
  border-radius: 8px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235a6575' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: block;
  border-radius: 9px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .12);
  background: #0e1116;
}
.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .1px;
  margin-left: 2px;
  flex: none;
  color: var(--text);
  text-decoration: none;
}
.brand-name:hover { color: #000; }

/* Site navigation */
.topnav {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 10px;
}
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 550;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.topnav a:hover { background: var(--bg-soft); color: var(--text); }
.topnav a[aria-current="page"] { background: var(--bg-soft); color: var(--text); }

/* Site footer */
.site-foot {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 26px 20px 34px;
}
.foot-inner { max-width: 860px; margin: 0 auto; text-align: center; }
.foot-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  margin-bottom: 12px;
}
.foot-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 550;
}
.foot-nav a:hover { color: var(--text); text-decoration: underline; }
.foot-note {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  max-width: 60ch;
  margin: 0 auto;
}
.foot-copy {
  color: var(--muted);
  font-size: 12px;
  opacity: .8;
  margin: 12px 0 0;
}
.foot-resume {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.foot-resume a { color: var(--accent); text-decoration: none; margin-left: 6px; }
.foot-resume a:hover { text-decoration: underline; }

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #eef1f6; border-color: #c3cbd8; }
.btn:active { transform: scale(.97); }
.btn:disabled,
.btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
  background: var(--bg-soft);
  border-color: var(--border);
  color: var(--muted);
}
.btn:disabled:active,
.btn[disabled]:active { transform: none; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn-lg { padding: 12px 26px; font-size: 16px; border-radius: 12px; }

/* Drop zone */
.dropzone {
  min-height: calc(100dvh - var(--topbar-h));
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.dz-inner {
  text-align: left;
  max-width: 920px;
  width: 100%;
}
.dz-hero { max-width: 820px; margin: 0 auto; }
.dz-title {
  margin: 0 0 14px;
  font-size: 30px;
  line-height: 1.22;
  letter-spacing: -.3px;
}
.dz-sub { color: var(--muted); font-size: 16px; margin: 0 0 26px; max-width: 62ch; }
.preset-chip {
  display: inline-block;
  margin: 0 0 18px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(37, 99, 235, .1);
  color: var(--text);
  font-size: 13px;
}
.preset-chip::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 8px;
  vertical-align: 1px;
}
.hint { color: var(--muted); font-size: 13px; margin-top: 18px; white-space: pre-line; }

.dz-steps { margin: 48px auto 0; max-width: 820px; }
.dz-steps h2 {
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--muted);
  margin: 0 0 16px;
}
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  text-align: left;
}
.steps li {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.45;
}
.step-num {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.dz-features {
  margin: 16px auto 0;
  max-width: 820px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  text-align: left;
}
.feature {
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.feature-icon { font-size: 20px; line-height: 1; }
.feature h3 { margin: 9px 0 6px; font-size: 15px; }
.feature p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.dz-footnote {
  margin: 26px 0 0;
  max-width: 820px;
  font-size: 12px;
  color: var(--muted);
}
.dropzone.dragging {
  outline: 3px dashed var(--accent);
  outline-offset: -14px;
  border-radius: 18px;
  background: rgba(37, 99, 235, .06);
}

/* Editor */
.editor {
  height: calc(100dvh - var(--topbar-h));
  display: flex;
  gap: 0;
}

.stage-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  background:
    radial-gradient(circle at 50% 45%, rgba(37, 99, 235, .07), transparent 60%),
    var(--bg);
  touch-action: none;
}

#stage {
  width: 100%;
  height: 100%;
  display: block;
}

.stage-tools {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 12px rgba(15, 23, 42, .1);
}

.round-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  transition: background .15s, transform .05s;
}
.reset-btn {
  width: auto;
  padding: 0 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
}
.round-btn:hover { background: #eef1f6; }
.round-btn:active { transform: scale(.94); }
.zoom-label { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.tool-sep { width: 1px; height: 20px; background: var(--border); }

.stage-hint {
  position: absolute;
  right: 14px;
  bottom: 16px;
  color: var(--muted);
  font-size: 12px;
  background: rgba(255, 255, 255, .85);
  border-radius: 999px;
  padding: 5px 10px;
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(15, 23, 42, .1);
}

.pos-readout {
  position: absolute;
  top: 14px;
  left: 14px;
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  backdrop-filter: blur(6px);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .1);
}

/* Side panel */
.panel {
  width: 330px;
  flex: none;
  overflow-y: auto;
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 18px;
}

.panel-section { margin-bottom: 22px; }
.panel-section label {
  display: block;
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  margin-bottom: 7px;
}

select, input[type="number"], input[type="range"] {
  width: 100%;
}

select, input[type="number"] {
  appearance: none;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 14px;
  outline: none;
}
select:focus, input[type="number"]:focus, input[type="range"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .16);
}

.custom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.custom-row input { min-width: 0; flex: 1; }
.custom-row select { width: 74px; flex: none; }
.custom-times { color: var(--muted); }

input[type="range"] {
  accent-color: var(--accent);
  height: 28px;
  cursor: pointer;
}
.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-top: -2px;
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 7px 0 0;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}
.panel-section label.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  margin: 0;
  cursor: pointer;
}
.check input[type="checkbox"] {
  flex: none;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.sheet-options {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.sheet-options .field-label { margin-bottom: 7px; }
.sheet-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sheet-row select {
  flex: none;
  width: auto;
  min-width: 96px;
}
.sheet-watermark { margin-top: 10px; }

.output-row {
  display: flex;
  gap: 8px;
}
.output-row select { flex: 1; min-width: 0; }
.output-row .btn { flex: 1.6; white-space: nowrap; }

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

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}
.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-head h2 { margin: 0; font-size: 18px; }
.preview-wrap {
  background: repeating-conic-gradient(#e9edf3 0% 25%, #f6f8fb 0% 50%) 0 0 / 20px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 14px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
#previewCanvas {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
  box-shadow: 0 4px 18px rgba(15, 23, 42, .18);
}
.modal-card .muted { margin: 12px 0 16px; }
.modal-card a.btn { display: inline-block; text-decoration: none; }

/* Mobile */
@media (max-width: 880px) {
  .editor {
    flex-direction: column;
    height: auto;
    min-height: calc(100dvh - var(--topbar-h));
  }
  .stage-wrap {
    height: 52dvh;
    min-height: 320px;
    flex: none;
    width: 100%;
  }
  .panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .stage-hint { display: none; }
}

@media (max-width: 420px) {
  .topbar { padding: 0 12px; }
  .lang-select { min-width: 0; width: 86px; }
  .panel { padding: 14px; }
  .output-row { flex-direction: column; }
  .output-row .btn { width: 100%; }
}

@media (max-width: 760px) {
  .steps, .dz-features { grid-template-columns: 1fr; }
  .dz-steps { margin-top: 34px; }
}

/* RTL layout */
[dir="rtl"] .steps,
[dir="rtl"] .dz-features {
  text-align: right;
}
[dir="rtl"] .pos-readout,
[dir="rtl"] .stage-tools {
  left: auto;
  right: 14px;
}
[dir="rtl"] .stage-hint {
  right: auto;
  left: 14px;
}
[dir="rtl"] .lang-select {
  background-position: left 10px center;
  padding: 7px 10px 7px 28px;
}

/* ---------- About the app, landing page ---------- */
.dz-about { margin: 40px auto 0; max-width: 820px; text-align: left; }
.dz-about h2 {
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--muted);
  margin: 0 0 14px;
}
.dz-about p { color: var(--muted); font-size: 14.5px; line-height: 1.68; margin: 0 0 12px; }
.dz-about p strong, .about-points li strong { color: var(--text); }
.about-points { margin-top: 16px; }
.about-points li { color: var(--muted); font-size: 14px; }

/* ---------- Guide strip on the landing page ---------- */
.dz-guides { margin: 38px auto 0; max-width: 820px; text-align: left; }
.dz-guides h2 {
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--muted);
  margin: 0 0 14px;
}
.guide-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.guide-links a {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f7f9fc;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
}
.guide-links a:hover { background: #eef1f6; border-color: #c3cbd8; }
.guide-links a.more { color: var(--accent); }

/* ---------- Content pages ---------- */
.doc-page { background: var(--bg); }

.doc {
  max-width: 780px;
  margin: 0 auto;
  padding: 26px 20px 60px;
}
.doc h1 {
  font-size: 30px;
  line-height: 1.25;
  margin: 14px 0 12px;
  letter-spacing: -.2px;
}
.doc h2 { font-size: 18px; margin: 0 0 12px; }
.doc h3 { font-size: 13px; margin: 0 0 8px; }
.doc p { line-height: 1.65; }

.lede {
  font-size: 16.5px;
  color: var(--muted);
  margin: 0 0 18px;
  max-width: 68ch;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--muted);
}
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }
.crumbs [aria-current="page"] { color: var(--text); }

.card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
}
.card > h2:first-child { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }

.doc-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 20px 0 6px;
}
.doc-cta .btn { text-decoration: none; display: inline-block; }
.cta-note { color: var(--muted); font-size: 12.5px; max-width: 40ch; }

.doc-note {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  margin: 12px 0 0;
}
.doc-note + .doc-note { margin-top: 8px; }

.updated {
  color: var(--muted);
  font-size: 12px;
  margin: 20px 0 26px;
}

.rules {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.rules li {
  position: relative;
  padding-left: 20px;
  font-size: 14.5px;
  line-height: 1.6;
}
.rules li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.rules.warn li::before { background: var(--danger); }
.rules strong { color: var(--text); }

ol.steps.numbered { margin: 0; padding-left: 20px; display: grid; gap: 10px; }
ol.steps.numbered li { font-size: 14.5px; line-height: 1.6; padding-left: 2px; }

.deflist { margin: 0; }
.deflist dt { font-weight: 600; font-size: 14px; margin-top: 14px; }
.deflist dt:first-child { margin-top: 0; }
.deflist dd { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.deflist.glossary dd { color: var(--text); opacity: .85; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-hint { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }

table.facts {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.facts th,
table.facts td {
  text-align: left;
  padding: 9px 12px 9px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.facts th {
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  padding-right: 18px;
}
table.facts tbody tr:last-child th,
table.facts tbody tr:last-child td { border-bottom: none; }
table.facts.countries { min-width: 640px; }
table.facts.countries th,
table.facts.countries td { padding-right: 16px; white-space: normal; }
table.facts.countries thead th {
  color: var(--text);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .6px;
}
table.facts a { color: var(--accent); text-decoration: none; }
table.facts a:hover { text-decoration: underline; }

.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.link-list li { font-size: 14.5px; line-height: 1.55; }
.link-list a { color: var(--accent); text-decoration: none; font-weight: 550; }
.link-list a:hover { text-decoration: underline; }
.link-list span { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }

.country-index .country-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 18px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin: 20px 0;
}
.card-link {
  display: block;
  margin: 0;
  text-decoration: none;
  color: inherit;
  transition: background .15s, border-color .15s, transform .05s;
}
.card-link:hover { background: #eef1f6; border-color: #c3cbd8; }
.card-link:active { transform: scale(.99); }
.card-link h2 { font-size: 16px; margin-bottom: 8px; }
.card-link p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.country-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.country-col a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
.country-col a:hover { color: var(--text); text-decoration: underline; }
.country-col a[aria-current="page"] { color: var(--text); font-weight: 600; }
.country-col h3 {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .7px;
  font-size: 12px;
}

@media (max-width: 760px) {
  .doc { padding: 20px 16px 48px; }
  .doc h1 { font-size: 25px; }
  .lede { font-size: 15.5px; }
  .card { padding: 16px; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 12px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 8px; }
  .brand-name { font-size: 15.5px; }
  .topnav { margin: 0 4px; }
  .topnav a { padding: 7px 8px; font-size: 12.5px; }
}

@media (max-width: 760px) {
  .dz-title { font-size: 24px; }
}

[dir="rtl"] .rules li { padding-left: 0; padding-right: 20px; }
[dir="rtl"] .rules li::before { left: auto; right: 4px; }
[dir="rtl"] table.facts th,
[dir="rtl"] table.facts td { text-align: right; }
[dir="rtl"] .crumbs { flex-direction: row-reverse; justify-content: flex-end; }
