:root {
  --brand: #1667f7;
  --brand2: #12c2f7;
  --ink: #0f1729;
  --muted: #5a6478;
  --line: #e3e8f0;
  --bg: #eef2f8;
  --card: #ffffff;
  --radius: 18px;
}

* { box-sizing: border-box; }

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

body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -280px, rgba(18,194,247,.20), transparent 60%),
    var(--bg);
  min-height: 100dvh;
  display: grid;
  place-items: start center;
  padding: clamp(16px, 4vw, 40px);
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(15, 23, 41, .08);
  padding: clamp(18px, 5vw, 28px);
}

.head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.logo { border-radius: 13px; box-shadow: 0 3px 10px rgba(22,103,247,.28); }
h1 { font-size: 1.35rem; margin: 0; letter-spacing: -0.01em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

input[type="text"], input[type="password"], select {
  width: 100%;
  font-size: 1rem;
  color: var(--ink);
  background: #f7f9fc;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  padding: 12px 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22,103,247,.15);
}

.pwwrap { position: relative; display: block; }
.pwwrap input { padding-right: 66px; }
.ghost {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--brand);
  font-weight: 600; font-size: .85rem; padding: 8px 10px; cursor: pointer; border-radius: 8px;
}
.ghost:hover { background: rgba(22,103,247,.08); }

.row { display: flex; gap: 12px; align-items: flex-end; }
.grow { flex: 1; }
.check {
  display: flex; align-items: center; gap: 7px;
  font-size: .9rem; color: var(--muted); font-weight: 600;
  padding-bottom: 12px; white-space: nowrap; cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

.qrbox { text-align: center; margin-top: 6px; }
#qr {
  width: 260px; height: 260px; max-width: 100%;
  image-rendering: pixelated;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.scan { margin: 12px 0 4px; color: var(--muted); }
.scan strong { color: var(--ink); }

.actions { display: flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.btn {
  font: inherit; font-weight: 650; cursor: pointer;
  border: 0; border-radius: 11px; padding: 12px 18px;
  color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand2));
  box-shadow: 0 6px 16px rgba(22,103,247,.30);
}
.btn:active { transform: translateY(1px); }
.ghostbtn { background: #eef3fe; color: var(--brand); box-shadow: none; }

.hint { text-align: center; color: var(--muted); font-size: .92rem; margin: 14px 0 0; }
.foot {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: .8rem; line-height: 1.5; text-align: center;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eaf0fb; --muted: #97a2ba; --line: #24304a;
    --bg: #0b1220; --card: #121a2c;
  }
  input[type="text"], input[type="password"], select { background: #0d1523; color: var(--ink); }
  .ghostbtn { background: #17233c; }
  #qr { background: #fff; }
}

/* ---------- landing page ---------- */
body { display: block; padding: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 14px clamp(16px,4vw,32px); max-width: 1000px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-weight: 700; }
.brand img { border-radius: 7px; }
.brand span { font-size: 1.02rem; letter-spacing: -.01em; }
.repo { text-decoration: none; color: var(--brand); font-weight: 650; font-size: .92rem; padding: 8px 12px; border-radius: 9px; }
.repo:hover { background: rgba(22,103,247,.08); }

.hero { max-width: 660px; margin: 0 auto; padding: clamp(14px,4vw,40px) 20px 6px; text-align: center; }
.hero-icon { border-radius: 18px; box-shadow: 0 8px 26px rgba(22,103,247,.32); }
.hero h1 { font-size: clamp(1.7rem,5vw,2.6rem); line-height: 1.1; letter-spacing: -.02em; margin: 16px 0 10px; text-wrap: balance; }
.lede { font-size: 1.06rem; color: var(--muted); max-width: 52ch; margin: 0 auto; text-wrap: pretty; }
.lede strong { color: var(--ink); }
.badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 18px 0 4px; }
.badges span { font-size: .78rem; font-weight: 600; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; }

.card.tool { margin: 22px auto; }
.cardh { margin: 0 0 16px; font-size: 1.05rem; }
.privacy { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; line-height: 1.5; text-align: center; }

.install { max-width: 920px; margin: 24px auto; padding: clamp(20px,5vw,36px); display: grid; grid-template-columns: 1.1fr .9fr; gap: clamp(20px,5vw,40px); align-items: center; }
.install h2 { font-size: clamp(1.4rem,4vw,1.9rem); letter-spacing: -.02em; margin: 0 0 10px; }
.install p { color: var(--muted); margin: 0 0 16px; }
.install p strong { color: var(--ink); }
.dl { display: flex; flex-wrap: wrap; gap: 10px; }
.dlbtn { text-decoration: none; }
.dlnote { font-size: .82rem; margin-top: 14px; }
.preview img { width: 100%; max-width: 320px; border-radius: 16px; box-shadow: 0 16px 50px rgba(15,23,41,.16); border: 1px solid var(--line); display: block; margin: 0 auto; }
.preview figcaption { text-align: center; color: var(--muted); font-size: .82rem; margin-top: 10px; }

.why { max-width: 920px; margin: 10px auto 8px; padding: 0 clamp(20px,5vw,36px); }
.why h2 { font-size: 1.3rem; letter-spacing: -.01em; margin: 0 0 16px; text-align: center; }
.whygrid { display: grid; grid-template-columns: repeat(auto-fit,minmax(210px,1fr)); gap: 14px; }
.whygrid div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.whygrid b { display: block; margin-bottom: 5px; }
.whygrid span { color: var(--muted); font-size: .92rem; }
.whygrid code { background: rgba(22,103,247,.10); color: var(--brand); padding: 1px 5px; border-radius: 5px; font-size: .85em; }

.siteFoot { max-width: 920px; margin: 30px auto; padding: 22px clamp(20px,5vw,36px) 40px; border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: .86rem; }
.siteFoot a { color: var(--brand); text-decoration: none; font-weight: 600; }

@media (max-width: 640px) { .install { grid-template-columns: 1fr; } .preview { order: -1; } }
.dlbtn small { opacity: .8; font-weight: 500; margin-left: 3px; }
.dlnote a { color: var(--brand); text-decoration: none; font-weight: 600; }
.dlnote code { background: rgba(22,103,247,.10); color: var(--brand); padding: 1px 5px; border-radius: 5px; }

/* OS download buttons */
.osrow { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; }
.osbtn { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; background: #17181c; color: #fff; border: 1px solid rgba(255,255,255,.10); border-radius: 12px; padding: 10px 18px 10px 15px; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.osbtn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(0,0,0,.25); background: #24262c; }
.oslogo { width: 25px; height: 25px; fill: #fff; flex: none; }
.oslabel { display: flex; flex-direction: column; line-height: 1.14; text-align: left; }
.oslabel small { font-size: .68rem; opacity: .72; font-weight: 500; }
.oslabel b { font-size: 1.02rem; font-weight: 650; }
.dlnote { margin-top: 22px; }

/* Language picker (flag + 2-letter code trigger → pop-in grid mega menu) + RTL */
.topbar-right { display: flex; align-items: center; gap: 12px; }
.langpicker { position: relative; }

.langtrigger {
  display: inline-flex; align-items: center; gap: 7px; line-height: 1;
  font: inherit; font-size: .84rem; font-weight: 650; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px 10px; cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.langtrigger:hover { border-color: var(--brand); }
.langtrigger[aria-expanded="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22,103,247,.15); }
.lt-flag { font-size: 1.05rem; line-height: 1; }
.lt-code { letter-spacing: .02em; }
.lt-caret { color: var(--muted); transition: transform .2s cubic-bezier(.22,1,.36,1); }
.langtrigger[aria-expanded="true"] .lt-caret { transform: rotate(180deg); }

.langmenu {
  position: fixed; z-index: 60;                 /* above the topbar; below any future modal/toast */
  margin: 0; padding: 8px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  width: min(360px, calc(100vw - 24px));
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15,23,41,.20), 0 2px 8px rgba(15,23,41,.08);
  transform-origin: top center;
  opacity: 0; transform: translateY(-6px) scale(.97); pointer-events: none;
  transition: opacity .18s cubic-bezier(.22,1,.36,1), transform .18s cubic-bezier(.22,1,.36,1);
}
.langmenu.open { opacity: 1; transform: none; pointer-events: auto; }
.langmenu[hidden] { display: none; }

.lang-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font: inherit; cursor: pointer; text-align: center; color: var(--ink);
  background: transparent; border: 1px solid transparent; border-radius: 11px;
  padding: 9px 4px 7px;
  transition: background .12s ease, border-color .12s ease, transform .08s ease;
}
.lang-item:hover { background: rgba(22,103,247,.07); }
.lang-item:active { transform: scale(.95); }
.lang-item.is-current { background: rgba(22,103,247,.10); border-color: rgba(22,103,247,.30); }
.li-flag { font-size: 1.5rem; line-height: 1; }
.li-cc { font-size: .72rem; font-weight: 700; letter-spacing: .03em; color: var(--muted); }
.lang-item.is-current .li-cc { color: var(--brand); }
.li-name { font-size: .74rem; line-height: 1.15; color: var(--muted); }
.lang-item.is-current .li-name { color: var(--ink); }

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

@media (prefers-reduced-motion: reduce) {
  .langmenu { transform: none; transition: opacity .12s linear; }
  .langmenu.open { transform: none; }
  .lt-caret, .lang-item { transition: none; }
}

/* Print — isolate just the QR card (hide the whole marketing page), for a clean "Scan to join" sheet. */
.print-only { display: none; }

@media print {
  html, body { background: #fff !important; }
  body > * { display: none !important; }
  body > main.tool { display: block !important; border: 0; box-shadow: none; background: none; margin: 0 auto; padding: 0; max-width: 100%; }
  main.tool > * { display: none !important; }
  main.tool > #qrbox:not([hidden]) { display: block !important; text-align: center; margin-top: 14mm; }
  #qrbox .scan, #qrbox .actions { display: none !important; }
  .print-only { display: block !important; }
  #qr {
    width: 92mm; height: 92mm; max-width: none;
    border: 0; padding: 0; background: #fff; image-rendering: pixelated;
  }
  .ptitle { font-size: 15pt; color: #555; margin: 0 0 4pt; }
  .pnet { font-size: 24pt; font-weight: 800; letter-spacing: -0.01em; margin: 0 0 14pt; color: #000; }
  .pinstr { font-size: 13pt; color: #333; margin-top: 12pt; }
  .pfoot { font-size: 9pt; color: #aaa; margin-top: 26pt; }
}
