:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --surface-3: #e9ecef;
  --text: #17191c;
  --text-soft: #5f666f;
  --text-muted: #7c848e;
  --line: #dfe3e8;
  --line-strong: #ccd2d9;
  --brand: #7e1d2d;
  --brand-strong: #671521;
  --brand-soft: #f7e9ec;
  --brand-glow: rgba(126, 29, 45, .15);
  --success: #127a54;
  --success-soft: #e8f6f0;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --info: #245ea8;
  --info-soft: #edf5ff;
  --shadow-sm: 0 4px 18px rgba(22, 25, 29, .06);
  --shadow-md: 0 18px 50px rgba(22, 25, 29, .10);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101214;
  --surface: #171a1e;
  --surface-2: #1d2126;
  --surface-3: #242930;
  --text: #f4f6f8;
  --text-soft: #b2bac4;
  --text-muted: #88929d;
  --line: #2d333b;
  --line-strong: #3a424c;
  --brand: #c14557;
  --brand-strong: #d45a6b;
  --brand-soft: #2e171c;
  --brand-glow: rgba(193, 69, 87, .18);
  --success: #4fc592;
  --success-soft: #153226;
  --danger: #ff756a;
  --danger-soft: #351a18;
  --info: #79aef1;
  --info-soft: #17283c;
  --shadow-sm: 0 5px 18px rgba(0, 0, 0, .16);
  --shadow-md: 0 22px 60px rgba(0, 0, 0, .30);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0%, var(--brand-glow), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); }
img { max-width: 100%; }
[hidden] { display: none !important; }

.container {
  width: min(100% - 32px, 1180px);
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(18px);
}
.header-inner {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}
.brand-logo-slot {
  width: 150px;
  height: 40px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 11px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--line) 76%, transparent);
  background: var(--surface);
}
.brand-logo-slot img { width: 100%; height: 100%; object-fit: contain; }
.brand-copy { display: grid; line-height: 1.15; }
.brand-title { color: var(--text); font-weight: 760; font-size: 14px; letter-spacing: -.01em; }
.brand-note { color: var(--text-muted); font-size: 11px; margin-top: 4px; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.control-select, .icon-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.control-select { padding: 0 34px 0 12px; cursor: pointer; }
.icon-button {
  min-width: 42px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.icon-button:hover { transform: translateY(-1px); border-color: var(--line-strong); background: var(--surface-2); }
.icon-button svg { width: 18px; height: 18px; }
.theme-label { font-size: 13px; font-weight: 650; }

.subnav-wrap { border-top: 1px solid color-mix(in srgb, var(--line) 72%, transparent); }
.subnav { display: flex; gap: 6px; overflow-x: auto; padding: 9px 0; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: 10px;
  transition: background .18s ease, color .18s ease;
}
.subnav a:hover { color: var(--text); background: var(--surface-2); }
.subnav a.active { color: var(--brand); background: var(--brand-soft); }

.page-main { padding: 42px 0 64px; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, .8fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}
.hero-copy, .hero-panel, .tool-card, .content-card {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-lg);
}
.hero-copy { padding: clamp(26px, 4vw, 44px); }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.eyebrow::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 5px var(--brand-soft); }
.hero h1 {
  margin: 0;
  max-width: 760px;
  color: var(--text);
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.07;
  letter-spacing: -.045em;
}
.hero-copy > p {
  max-width: 760px;
  margin: 18px 0 0;
  color: var(--text-soft);
  font-size: clamp(15px, 1.5vw, 18px);
  line-height: 1.72;
}
.hero-panel {
  padding: 22px;
  display: grid;
  align-content: center;
  gap: 12px;
  background:
    linear-gradient(145deg, var(--brand-soft), transparent 74%),
    var(--surface);
}
.feature-row { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 12px; align-items: start; padding: 10px; border-radius: 14px; }
.feature-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: var(--surface); color: var(--brand); border: 1px solid var(--line); }
.feature-icon svg { width: 20px; height: 20px; }
.feature-row strong { display: block; margin-top: 1px; color: var(--text); font-size: 14px; }
.feature-row span { display: block; color: var(--text-muted); font-size: 12.5px; line-height: 1.45; margin-top: 2px; }

.tool-card { padding: clamp(20px, 3vw, 34px); overflow: hidden; }
.tool-card > div > div > h2,
.tool-card h2:first-child {
  margin: 0 0 8px;
  color: var(--text);
  font-size: clamp(22px, 2.8vw, 30px);
  line-height: 1.25;
  letter-spacing: -.025em;
}
.tool-card h3 { margin: 30px 0 12px; font-size: 20px; color: var(--text); }
.tool-card p { color: var(--text-soft); }

.row {
  display: flex;
  flex-wrap: wrap;
  margin-inline: -8px;
}
.row > [class*="col-"] { width: 100%; padding-inline: 8px; }
.col-12 { flex: 0 0 100%; max-width: 100%; }
.col-4 { flex: 0 0 33.333%; max-width: 33.333%; }
@media (min-width: 768px) {
  .col-md-4, .col-sm-12.col-md-4 { flex: 0 0 33.333%; max-width: 33.333%; }
  .col-md-8, .col-sm-12.col-md-8 { flex: 0 0 66.666%; max-width: 66.666%; }
  .col-md-12 { flex: 0 0 100%; max-width: 100%; }
}
@media (min-width: 576px) {
  .col-sm-12 { flex: 0 0 100%; max-width: 100%; }
}

.form-group { margin: 0 0 18px; }
.form-group label, .checkbox label {
  display: block;
  margin: 0 0 7px;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.35;
  font-weight: 720;
}
.form-control {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .02);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.form-control:hover { border-color: color-mix(in srgb, var(--brand) 42%, var(--line-strong)); }
.form-control:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--brand-glow); }
textarea.form-control { min-height: 190px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.55; }
textarea.multiline { height: clamp(320px, 48vh, 540px); }
.field-help { display: block; margin: -2px 0 8px; color: var(--text-muted); font-size: 11.5px; line-height: 1.45; }
.checkbox { margin: 5px 8px 22px; }
.checkbox label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 650; }
.checkbox input[type="checkbox"] { appearance: none; width: 20px; height: 20px; margin: 0; flex: 0 0 auto; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface-2); display: grid; place-items: center; cursor: pointer; }
.checkbox input[type="checkbox"]::after { content: ""; width: 10px; height: 6px; border: solid white; border-width: 0 0 2px 2px; transform: rotate(-45deg) scale(0); margin-top: -2px; transition: transform .12s ease; }
.checkbox input[type="checkbox"]:checked { background: var(--brand); border-color: var(--brand); }
.checkbox input[type="checkbox"]:checked::after { transform: rotate(-45deg) scale(1); }

.btn {
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  padding: 10px 18px;
  font-weight: 760;
  font-size: 14px;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-strong)); box-shadow: 0 8px 22px var(--brand-glow); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 28px var(--brand-glow); }
.btn-primary:active { transform: translateY(0); }

.alert { border-radius: 13px; padding: 12px 14px; margin: 12px 0 20px; font-size: 13px; line-height: 1.55; }
.alert-info { background: var(--info-soft); border: 1px solid color-mix(in srgb, var(--info) 22%, var(--line)); color: var(--info); }
.alert-danger, .invalid-feedback { color: var(--danger); }
.alert-danger { background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 24%, var(--line)); }
.invalid-feedback { display: block; margin-top: 5px; font-size: 11.5px; }
.form-control.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 12%, transparent); }
.form-control.is-valid { border-color: color-mix(in srgb, var(--success) 70%, var(--line-strong)); }

hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
pre.wireguard-config, pre {
  max-width: 100%;
  overflow: auto;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0c0f12 !important;
  color: #e8edf2 !important;
  font: 12.5px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
code { color: var(--brand-strong); font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; }
table { width: 100%; border-collapse: collapse; margin: 6px 0 14px; font-size: 13px; }
td { padding: 8px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
td:first-child { width: 126px; color: var(--text-muted); font-weight: 650; }
canvas.pixelated { max-width: 100%; height: auto !important; border-radius: 14px; background: white; padding: 10px; border: 1px solid var(--line); }

button.download {
  width: auto;
  min-width: 150px;
  height: 48px;
  margin: 3px 0 14px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  vertical-align: middle;
}
button.download::before { content: "↓"; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-weight: 900; }
button.download span { position: static; background: transparent; color: inherit; padding: 0; font-size: 13px; font-weight: 760; text-transform: none; }
button.download span:first-child { display: inline; }
button.download span:last-child { margin-left: 0; color: var(--text-muted); }
button.download:hover { background: var(--surface-3); border-color: var(--line-strong); }

.content-card { padding: clamp(24px, 4vw, 40px); }
.content-card h1 { margin-top: 0; font-size: clamp(28px, 4vw, 42px); line-height: 1.15; letter-spacing: -.035em; }
.content-card h2 { margin: 30px 0 10px; font-size: 21px; }
.content-card p, .content-card li { color: var(--text-soft); }
.content-card ul { padding-left: 20px; }

.progress-popover {
  position: fixed;
  z-index: 100;
  inset: auto 22px 22px auto;
  width: min(420px, calc(100vw - 32px));
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px);
  animation: progress-in .2s ease both;
}
@keyframes progress-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.progress-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 10px; }
.progress-head strong { font-size: 13.5px; }
.progress-percent { color: var(--brand); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.progress-bar { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 65%, #ff9aa8)); transition: width .23s ease; }
.progress-status { margin-top: 9px; color: var(--text-muted); font-size: 11.5px; }

.site-footer { border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 55%, transparent); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 26px 0; }
.footer-brand strong { display: block; font-size: 13px; color: var(--text); }
.footer-brand span, .footer-legal { color: var(--text-muted); font-size: 11.5px; line-height: 1.55; }
.footer-legal { max-width: 620px; text-align: right; }

#test-qr-code, #ad-banner, .newsletter, [data-ui-removed="true"] { display: none !important; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .brand-copy { display: none; }
  .footer-inner { align-items: flex-start; flex-direction: column; }
  .footer-legal { text-align: left; }
}
@media (max-width: 767px) {
  .page-main { padding-top: 24px; }
  .header-inner { min-height: 66px; gap: 10px; }
  .brand-logo-slot { width: 118px; height: 34px; border-radius: 9px; }
  .control-select { width: 98px; min-height: 38px; font-size: 13px; }
  .icon-button { min-height: 38px; min-width: 38px; padding: 0 9px; }
  .theme-label { display: none; }
  .hero-copy, .hero-panel, .tool-card, .content-card { border-radius: 18px; }
  .hero-copy { padding: 24px; }
  .hero h1 { font-size: clamp(30px, 10vw, 42px); }
  .hero-copy > p { font-size: 15px; }
  .tool-card { padding: 20px; }
  .row { margin-inline: 0; }
  .row > [class*="col-"] { padding-inline: 0; flex: 0 0 100%; max-width: 100%; }
  .col-4 { flex: 0 0 100%; max-width: 100%; }
  .btn { width: 100%; }
  td:first-child { width: 98px; }
  .progress-popover { right: 16px; bottom: 16px; left: 16px; width: auto; }
}
@media (max-width: 430px) {
  .container { width: min(100% - 22px, 1180px); }
  .header-actions { gap: 6px; }
  .brand-logo-slot { width: 104px; }
  .control-select { width: 88px; padding-left: 9px; padding-right: 26px; }
  .hero-copy, .hero-panel, .tool-card, .content-card { border-radius: 16px; }
  .hero-copy, .tool-card { padding: 18px; }
  .feature-row { padding: 6px; }
  pre.wireguard-config, pre { font-size: 11.5px; padding: 13px; }
}
