*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.hidden { display: none !important; }

:root {
    --bg:        #0f1117;
    --surface:   #1a1d27;
    --border:    #2e3147;
    --accent:    #5b7fff;
    --accent-hover: #7b9bff;
    --text:      #e2e4ef;
    --muted:     #9aa0c0;
    --copyright: #9aa0c0;
    --success:   #3ecf8e;
    --error:     #f56565;
    --radius:    10px;
    --font:      'Inter', system-ui, -apple-system, sans-serif;
    --mono:      'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --link:      #5b9fff;
    --link-hover: #7bb5ff;
    --btn-secondary-hover: #3a3e57;
}

[data-theme="light"] {
    --bg:        #f0f2f8;
    --surface:   #ffffff;
    --border:    #d0d5e8;
    --accent:    #4a6cf7;
    --accent-hover: #6a8cff;
    --text:      #1a1d2e;
    --muted:     #8890b8;
    --copyright: #8890b8;
    --success:   #2ea872;
    --error:     #e53e3e;
    --link:      #3565d8;
    --link-hover: #1a3a8a;
    --btn-secondary-hover: #e0e3f0;
}

a { color: var(--link); text-decoration: none; transition: color .15s; }
a:hover { color: var(--link-hover); }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 16px;
}

.container {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* Page header */

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

.title-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.site-logo {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
    line-height: 1.2;
}

.subtitle {
    font-size: 13px;
    color: var(--accent);
    margin-top: 3px;
}

/* Header controls */

.lang-switcher {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding-top: 4px;
}

.lang-sep {
    color: var(--muted);
    font-size: 13px;
}

.lang-btn {
    display: inline-flex;
    align-items: center;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    padding: 4px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    text-decoration: none;
}

.lang-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.lang-btn.active {
    border-color: var(--border);
    color: var(--accent);
}

.help-btn {
    display: inline-flex;
    align-items: center;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    padding: 4px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.help-btn:hover {
    border-color: var(--accent);
    color: #fff;
}

.home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
}

.theme-btn {
    display: inline-flex;
    align-items: center;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
    line-height: 1;
    padding: 4px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.theme-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

/* Search */

.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 9px;
    color: var(--muted);
    pointer-events: none;
    display: flex;
    align-items: center;
}

/* Unified form field — apply .form-field to any input/select/textarea
   to get site-wide consistent styling. Width is left to each form. */
.form-field {
    background: var(--surface);
    border: 1px solid #3d4160;
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    padding: 10px 14px;
    outline: none;
    box-sizing: border-box;
}
.form-field::placeholder { color: var(--muted); }
[data-theme="light"] .form-field { border-color: #b8becf; }

/* ── Global button styles ────────────────────────────────────────────────── */
/* All action buttons: transparent + border. Hover: accent border + white text. No blue fill.
   Exclusions: nav controls (.lang-btn, .theme-btn, .home-btn, .result-close, .help-btn) keep own styles. */
button:not(.lang-btn):not(.theme-btn):not(.home-btn):not(.result-close):not(.help-btn):not(.btn-sm):not(.site-tab):not(.danger):not(.share-action):not(.awg-version-pill):not(.ss-icon-btn):not(.icon-action-btn) {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--muted);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    cursor: pointer;
    transition: border-color .15s, color .15s;
    white-space: nowrap;
}
button:not(.lang-btn):not(.theme-btn):not(.home-btn):not(.result-close):not(.help-btn):not(.btn-sm):not(.site-tab):not(.danger):not(.share-action):not(.awg-version-pill):not(.ss-icon-btn):not(.icon-action-btn):hover:not(:disabled) {
    border-color: var(--accent);
    color: #fff;
}
button:not(.lang-btn):not(.theme-btn):not(.home-btn):not(.result-close):not(.help-btn):not(.btn-sm):not(.site-tab):not(.danger):not(.share-action):not(.awg-version-pill):not(.ss-icon-btn):not(.icon-action-btn):disabled {
    opacity: .4;
    cursor: default;
}

/* Square icon action button (copy, download, etc.) */
button.icon-action-btn {
    width: 36px; height: 36px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 0; background: none;
    color: var(--muted); border: 1px solid var(--border); border-radius: 7px;
    cursor: pointer; transition: border-color .15s, color .15s;
}
button.icon-action-btn:hover { border-color: var(--accent); color: var(--accent); }
button.icon-action-btn.copied { border-color: #3ecf8e; color: #3ecf8e; }

/* Small button — same height as lang-btn. Use for chips, type selectors, inline controls. */
button.btn-sm {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--muted);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
    white-space: nowrap;
    user-select: none;
}
button.btn-sm:hover:not(:disabled) {
    border-color: var(--accent);
    color: #fff;
}
button.btn-sm.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(91, 127, 255, .1);
}
button.btn-sm:disabled {
    opacity: .4;
    cursor: default;
}

/* Danger button — destructive/stop actions, red border + text, no fill */
button.danger {
    background: transparent;
    border: 1px solid var(--error);
    border-radius: 7px;
    color: var(--error);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
    white-space: nowrap;
}
button.danger:hover:not(:disabled) {
    background: rgba(245, 101, 101, .1);
}
button.danger:disabled {
    opacity: .4;
    cursor: default;
}
button.btn-sm.danger {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 5px;
}

/* Square icon button (e.g. clear/close with ✕) — same height as action buttons */
.btn-icon {
    padding: 10px !important;
    aspect-ratio: 1;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Section card — full-width tool wrapper ──────────────────────────────── */

.section-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.section-card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--radius) var(--radius) 0 0;
}

.section-card-header h2 {
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.7px;
    text-transform: uppercase;
}

.section-card-body {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Form layout rows ────────────────────────────────────────────────────── */

.form-row {
    display: grid;
    gap: 12px;
}
.form-row.col-2 { grid-template-columns: 1fr 1fr; }
.form-row.col-3 { grid-template-columns: repeat(3, 1fr); }
.form-row.col-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Field group: label + input ──────────────────────────────────────────── */

.field-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.field-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    user-select: none;
}

/* ── wg-confgen: key grid + bottom row ───────────────────────────────────── */

/* Desktop: gen button shows icon only */
.wg-gen-text { display: none; }

.wg-key-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: end;
}

.wg-bottom-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding-top: 4px;
}

/* ── Key row: monospace input + gen button ───────────────────────────────── */

.key-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
}
.key-row .form-field {
    flex: 1;
    min-width: 0;
    font-size: 11px;
}
#obfs-fields .key-row  { align-items: stretch; }
#gen-obfs {
    width: 38px;
    min-width: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
#gen-obfs .wg-gen-text { display: none; }
#gen-obfs .wg-gen-icon { display: inline-flex; align-items: center; justify-content: center; }

/* ── Config output pre block ─────────────────────────────────────────────── */

.config-pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.7;
    color: var(--text);
    white-space: pre;
    overflow-x: auto;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}
.h2-pre-wrap { position: relative; min-width: 0; }

/* ── Hysteria2 ───────────────────────────────────────────────────────────── */

.h2-result-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.h2-result-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.h2-result-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.h2-result-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: var(--accent);
}


.h2-reset-wrap {
    margin-top: 20px;
    text-align: center;
}

.h2-users-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.h2-users-header .field-label { margin-bottom: 0; font-size: 11px; color: var(--muted); }

.h2-user-card {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}
.h2-user-card:last-child { margin-bottom: 0; }
.h2-user-login { width: 130px; flex-shrink: 0; }
.h2-user-pass  { flex: 1; min-width: 0; font-family: var(--mono) !important; font-size: 11px !important; }

/* Compact page-header — only lang-switcher, no title row */
.page-header--compact {
    justify-content: flex-end;
}

.search-input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    padding: 5px 26px 5px 28px;
    width: 210px;
    outline: none;
    transition: border-color 0.15s;
}

.search-input::placeholder {
    color: var(--muted);
}

.search-input:focus {
    border-color: var(--accent);
}

.search-clear {
    position: absolute;
    right: 7px;
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    border-radius: 3px;
    transition: color 0.15s;
}

.search-clear:hover {
    color: var(--text);
}

.search-empty {
    color: var(--muted);
    font-size: 14px;
    text-align: center;
    padding: 40px 0;
}

/* Group sections */

.group-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 18px;
}
.group-block:last-child { margin-bottom: 0; }

.group-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--accent);
    padding: 13px 20px 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
}
.group-title:hover { color: color-mix(in srgb, var(--accent) 70%, white); }

.group-title--link,
.group-title--link:visited {
    text-decoration: none;
    color: var(--accent);
}

.group-toggle-arrow {
    margin-left: auto;
    flex-shrink: 0;
    color: var(--muted);
    transition: transform 0.2s;
}
.group-block.collapsed .group-toggle-arrow { transform: rotate(-90deg); }
.group-block.collapsed .group-content { display: none; }
.group-block.collapsed .group-title { border-bottom-color: transparent; }

.group-desc {
    margin: 0;
    padding: 8px 20px 10px;
    font-size: 12px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

/* Subgroup header inside .group-block */
.group-section {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 14px 20px 6px;
    border-bottom: 1px solid var(--border);
}
.group-block > .group-section + .projects-grid { padding-top: 12px; }

/* App cards */

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
    padding: 16px;
}

.app-card {
    background: var(--bg);
    border: 1px solid var(--border);
    text-decoration: none;
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.15s, background 0.15s;
}
.app-card:hover {
    border-color: var(--accent);
    background: var(--btn-secondary-hover);
}

.app-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
}

.app-card-logo {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.app-card-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.app-card-desc {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.6;
    margin: 0;
}

.app-card-badges {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
    justify-content: center;
}

.app-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--text);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

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

.app-badge--soon {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.app-badge--apk {
    opacity: 1;
    cursor: pointer;
    pointer-events: auto;
    background: transparent;
}

.app-badge svg { flex-shrink: 0; }

/* Projects grid */

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
    padding: 16px;
}

.project-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, background 0.15s;
}

.project-card:hover {
    border-color: var(--accent);
    background: var(--btn-secondary-hover);
}

.project-card--soon {
    opacity: 0.5;
    cursor: default;
}

.project-card--soon:hover {
    border-color: var(--border);
    box-shadow: none;
}

.project-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.project-logo {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 8px;
}

.project-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.project-desc {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.55;
}

/* Copyright footer — styles live in nav.css (shared with all pages) */

/* Help modal */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 1100px;
    max-width: calc(100% - 40px);
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modal-in 0.18s ease;
}
.modal::-webkit-scrollbar { width: 5px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--border) 60%, transparent);
    border-radius: 4px;
}
.modal::-webkit-scrollbar-thumb:hover {
    background: var(--border);
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}

.modal-title {
    font-size: 15px;
    font-weight: 600;
}

.result-close {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.15s;
}

.result-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
    font-size: 14px;
    color: var(--text);
    line-height: 1.6;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--border) 60%, transparent) transparent;
}
.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--border) 60%, transparent);
    border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover { background: var(--border); }

.modal-body p { margin-bottom: 12px; }
.modal-body p:last-child { margin-bottom: 0; }
.modal-body strong { color: var(--text); font-weight: 600; }
.modal-body h3 {
    font-size: 11px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase;
    color: var(--accent); margin: 20px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.modal-body h3:first-child { margin-top: 4px; }
.modal-body ul { padding-left: 20px; margin-bottom: 12px; }
.modal-body ol { padding-left: 20px; margin-bottom: 12px; }
.modal-body li { margin-bottom: 6px; }
.modal-body a { color: var(--link); }
.modal-body a:hover { color: var(--link-hover); }
.modal-body code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 12px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px;
}

/* Parameter reference — definition list used in help modals */
.help-dl {
    display: grid;
    grid-template-columns: minmax(130px, max-content) 1fr;
    column-gap: 20px;
    row-gap: 0;
    margin: 0 0 4px;
    padding: 0;
    align-items: start;
}
.help-dl dt {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px; font-weight: 600; color: var(--text);
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 3px; padding: 2px 7px; white-space: nowrap;
    justify-self: start; margin-top: 12px;
}
.help-dl dt:first-child { margin-top: 0; }
.help-dl dt:first-child + dd { margin-top: 0; }
.help-dl dd {
    margin: 12px 0 0; padding: 0 0 12px;
    line-height: 1.65;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.help-dl dd:last-child { border-bottom: none; padding-bottom: 0; }
@media (max-width: 600px) {
    .help-dl { grid-template-columns: 1fr; column-gap: 0; }
    .help-dl dt { margin-top: 16px; }
    .help-dl dt:first-child { margin-top: 0; }
    .help-dl dd { margin-top: 4px; }
}

/* Global tabs — unified style for all pages */
.site-tabs-block {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 16px;
}
.site-tabs {
    display: flex;
    gap: 0;
    background: var(--bg);
}
.site-tab {
    flex: 1;
    padding: 10px 0;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    background: var(--bg);
    border: none;
    border-radius: 0;
    border-right: 1px solid var(--border);
    border-bottom: 2px solid transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-bottom-color 0.15s;
}
.site-tab:last-child { border-right: none; }
.site-tab.active { background: var(--surface); color: var(--accent); border-bottom-color: var(--accent); }
.site-tab:hover:not(.active) { color: var(--text); }
.site-tab-panel {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 16px 20px;
}

/* Responsive */

/* ssh-confgen: collapse two-column layout on narrow screens */
@media (max-width: 900px) {
    .ssh-layout { grid-template-columns: 1fr; }
}

/* Touch devices: disable sticky :hover/:focus effects triggered by tap */
@media (hover: none), (pointer: coarse) {
    button:hover,
    button:focus {
        outline: none !important;
        box-shadow: none !important;
        border-color: var(--border) !important;
        color: var(--muted) !important;
        background: transparent !important;
    }
    /* Preserve intentional active/selected states */
    button.lang-btn.active:hover,
    button.lang-btn.active:focus   { color: var(--accent) !important; }
    button.btn-sm.active:hover,
    button.btn-sm.active:focus     { color: var(--accent) !important; border-color: var(--accent) !important; background: rgba(91,127,255,.1) !important; }
    button.site-tab.active:hover,
    button.site-tab.active:focus   { color: var(--accent) !important; border-bottom-color: var(--accent) !important; background: var(--surface) !important; }
    button.danger:hover,
    button.danger:focus             { color: var(--error) !important; border-color: var(--error) !important; }
    button.icon-action-btn.copied:hover,
    button.icon-action-btn.copied:focus { border-color: #3ecf8e !important; color: #3ecf8e !important; }
}

/* ── About page ─────────────────────────────────────────────────────────── */
.ab-rows { display: flex; flex-direction: column; gap: 20px; }
.ab-row-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.ab-row-val { font-size: .9rem; line-height: 1.65; color: var(--text); }
.ab-soon { color: var(--muted); border-bottom: 1px dashed var(--muted); text-decoration: none; cursor: default; transition: color .15s, border-color .15s; }
.ab-soon:hover { color: var(--text); border-color: var(--text); }

.ab-groups { display: flex; flex-direction: column; margin: 12px -24px -20px; }
.ab-groups-title { border-bottom: 1px solid var(--border); padding: 14px 24px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--accent); }
.ab-group { border-bottom: 1px solid var(--border); }
.ab-group-hdr { display: flex; align-items: center; justify-content: space-between; padding: 11px 24px; cursor: pointer; user-select: none; border-bottom: 1px solid transparent; }
.ab-group:not(.ab-collapsed) .ab-group-hdr { border-bottom-color: var(--border); }
.ab-group-hdr h3 { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 6px; margin: 0; transition: color .15s; }
.ab-group-hdr svg.ab-arrow { flex-shrink: 0; transition: transform .2s; color: var(--muted); }
.ab-group-hdr:hover h3 { color: var(--text); }
.ab-group-hdr:hover svg.ab-arrow { color: var(--text); }
.ab-group.ab-collapsed .ab-group-hdr svg.ab-arrow { transform: rotate(-90deg); }
.ab-group.ab-collapsed .ab-group-body { display: none; }
.ab-group-body { padding: 10px 24px 14px; }

.ab-sec-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 14px 0 7px; font-weight: 600; }
.ab-sec-label:first-child { margin-top: 0; }
.ab-cards { display: flex; flex-direction: column; gap: 5px; }
.ab-card { display: flex; align-items: flex-start; gap: 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; transition: border-color .15s, background .15s; }
.ab-card:hover { border-color: var(--accent); background: rgba(91,127,255,.05); }
.ab-card--nolink { cursor: default; }
.ab-card--nolink:hover { border-color: var(--border); background: none; }
.ab-card-logo { width: 40px; height: 40px; flex-shrink: 0; margin-top: 2px; }
.ab-card-info { flex: 1; min-width: 0; }
.ab-card-name { font-size: 13px; font-weight: 600; color: var(--text); }
.ab-card-desc { font-size: .9rem; color: var(--muted); line-height: 1.5; margin-top: 3px; }
.ab-card-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.ab-where { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; padding: 1px 6px; border-radius: 3px; margin-top: 6px; }
.ab-where--client { color: #3ecf8e; background: rgba(62,207,142,.1); border: 1px solid rgba(62,207,142,.25); }
.ab-where--server { color: #58a6ff; background: rgba(88,166,255,.1); border: 1px solid rgba(88,166,255,.25); }
.ab-help-icon { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--text); border-radius: 5px; color: var(--text); font-size: 12px; font-weight: 600; line-height: 1; padding: 2px 7px; vertical-align: middle; margin: 0 2px; }

/* ── Sitemap page ─────────────────────────────────────────────────────── */
.sm-search-wrap { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.sm-search-input { flex: 1; min-width: 0; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: .9rem; outline: none; transition: border-color .15s; box-sizing: border-box; }
.sm-search-input:focus { border-color: var(--accent); }
.sm-search-input::placeholder { color: var(--muted); }
.sm-clear-btn { flex-shrink: 0; }
.sm-loading { color: var(--muted); font-size: .9rem; padding: 10px 0; }
.sm-group { margin-bottom: 20px; }
.sm-group:last-child { margin-bottom: 0; }
.sm-group-hdr { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.sm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sm-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; transition: border-color .15s, background .15s; }
.sm-item:hover { border-color: var(--accent); background: rgba(91,127,255,.05); }
.sm-icon { width: 24px; height: 24px; flex-shrink: 0; }
.sm-icon-page { color: var(--muted); }
.sm-item-info { flex: 1; min-width: 0; }
.sm-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sm-url { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Sitemap tree view ─────────────────────────────────────────────────── */
.st-search-wrap { display: flex; align-items: stretch; gap: 8px; margin-bottom: 14px; }
.st-search-input { flex: 1; min-width: 0; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: .9rem; outline: none; transition: border-color .15s; box-sizing: border-box; }
.st-search-input:focus { border-color: var(--accent); }
.st-search-input::placeholder { color: var(--muted); }
.st-search-wrap .btn-sm { padding: 0; width: calc(2 * 8px + 2 * 1px + 0.9rem * 1.4); height: calc(2 * 8px + 2 * 1px + 0.9rem * 1.4); display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-sizing: border-box; }
.st-tree { display: flex; flex-direction: column; }
.st-group { border-bottom: 1px solid var(--border); }
.st-group:last-child { border-bottom: none; }
.st-group-hdr { display: flex; align-items: center; gap: 8px; padding: 10px 0; cursor: pointer; user-select: none; }
.st-group-hdr:hover .st-group-name { color: var(--text); }
.st-chevron { color: var(--muted); flex-shrink: 0; transition: transform .18s; }
.st-group.st-collapsed .st-chevron { transform: rotate(-90deg); }
.st-group-icon { display: inline-flex; align-items: center; color: var(--muted); flex-shrink: 0; opacity: .7; }
.st-group-name { flex: 1; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); transition: color .15s; }
.st-count { font-size: 10px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1px 6px; flex-shrink: 0; }
.st-group-body { padding: 2px 0 8px 18px; border-left: 1px solid var(--border); margin-left: 6px; }
.st-group.st-collapsed .st-group-body { display: none; }
.st-sec { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 8px 0 3px; opacity: .6; }
.st-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 5px; text-decoration: none; transition: background .1s; }
.st-item:hover { background: rgba(91,127,255,.06); }
.st-item-icon { width: 16px; height: 16px; flex-shrink: 0; }
.st-item-name { flex: 1; font-size: 13px; color: var(--text); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-item-path { font-size: 11px; color: var(--muted); font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace; white-space: nowrap; flex-shrink: 0; }
.st-page-icon { color: var(--muted); }

/* ── About page — compact app badges ─────────────────────────────────── */
.ab-card-badges .app-badge { padding: 3px 8px; font-size: 11px; border-radius: 5px; gap: 4px; }
.ab-card-badges .app-badge svg { width: 13px; height: 13px; }

@media (max-width: 600px) {

    body {
        padding: 28px 12px;
    }

    h1 {
        font-size: 18px;
    }

    .site-logo {
        width: 36px;
        height: 36px;
    }

    /* Stack page header vertically */
    .page-header {
        flex-direction: column;
        gap: 8px;
    }

    /* Lang-switcher: full width + centered, buttons on one line */
    .lang-switcher {
        padding-top: 0;
        gap: 4px;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }

    /* Search bar moves to its own row, separated from buttons above */
    .search-wrap {
        order: 99;
        width: 95%;
        margin-top: 6px;
        border-top: 1px solid var(--border);
        padding-top: 10px;
    }

    .search-input {
        width: 100%;
        transition: none;
    }

    .search-input:focus {
        width: 100%;
    }

    /* Hide | separators — buttons still visually distinct */
    .lang-sep {
        display: none;
    }

    /* Prevent iOS auto-zoom on input focus (requires font-size >= 16px) */
    input, select, textarea {
        font-size: 16px;
    }

    /* Modals: reduce side margin on mobile */
    .modal {
        max-width: calc(100% - 20px);
    }

    /* Section card mobile */
    .section-card-header { padding: 12px 16px; }
    .section-card-body { padding: 14px 16px; gap: 12px; }

    /* Global tabs mobile */
    .site-tabs { flex-wrap: wrap; }
    .site-tab { flex: 1 1 45%; font-size: 13px; padding: 9px 0; border-bottom: 1px solid var(--border); }
    .site-tab.active { border-bottom-color: var(--accent); }
    .site-tab-panel { padding: 12px 14px; }

    /* Single-column cards on mobile */
    .projects-grid {
        grid-template-columns: 1fr;
        padding: 12px;
        gap: 8px;
    }

    /* Fail2ban + Regex constructor mobile */
    .f2b-actions { flex-direction: column; }
    .f2b-actions button { width: 100%; }
    .f2b-token-table th:last-child,
    .f2b-token-table td:last-child { display: none; }
    .f2b-copy-wrap { flex-direction: column; }
    .f2b-copy-wrap button { width: 100%; }
    .f2b-fields-table th:nth-child(3),
    .f2b-fields-table td:nth-child(3) { display: none; }
    .f2b-rx-input { min-width: 120px; }

    /* Regex tester mobile — use .rx-pattern-row parent to beat inline <style> specificity */
    .rx-pattern-row { padding: 8px 12px; gap: 6px; }
    /* Line 1: /input/ — full width */
    .rx-pattern-row .rx-pattern-main { flex: 1 1 100%; }
    .rx-pattern-row .rx-pattern-input { font-size: 16px; }
    /* Line 2: flags — full width, each flag shares row equally */
    .rx-pattern-row .rx-flags { flex: 1 1 100%; }
    .rx-pattern-row .rx-flag { flex: 1; padding: 8px 4px; font-size: 13px; text-align: center; min-width: 0; }
    /* Lines 3-4: Copy / Clear — each on its own full-width line */
    .rx-pattern-row .rx-copy-btn { flex: 1 1 100%; width: 100%; padding: 10px; text-align: center; }
    .rx-presets-row { padding: 8px 12px; gap: 5px; }
    .rx-preset { font-size: 12px; padding: 5px 10px; }
    .rx-textarea { font-size: 16px; min-height: 120px; }
    .rx-highlighted { font-size: 12px; max-height: 180px; }
    .rx-table td, .rx-table th { padding: 5px 8px; font-size: 11px; }
    .rx-table .rx-td-groups, .rx-table th:nth-child(4) { display: none; }
    /* Cheatsheet: 1 column, higher specificity to beat inline <style> */
    .group-block .rx-cs-grid,
    .modal-body .rx-cs-grid { grid-template-columns: 1fr; }
    .rx-cs-table td { font-size: 11px; padding: 4px 6px; }
    .rx-cs-table td:first-child { padding-right: 8px; width: auto; }

    /* Form rows mobile — collapse to single column */
    .form-row.col-2,
    .form-row.col-3,
    .form-row.col-4 { grid-template-columns: 1fr; }

    /* Config pre mobile */
    .config-pre { font-size: 11px; padding: 10px 12px; }

    /* ssh-confgen mobile */
    .ssh-basic-grid { grid-template-columns: 1fr 1fr; }
    .ssh-adv-grid   { grid-template-columns: 1fr; }
    .ssh-toolbar    { flex-direction: column; }
    .ssh-toolbar button { width: 100%; }
    .ssh-check-group { gap: 12px; }

    /* wg-confgen key grid mobile — single column, explicit order for all children */
    .wg-key-grid { grid-template-columns: 1fr; }
    .wg-key-grid > div:empty { display: none; }
    .wg-key-grid .field-group { margin-top: 0 !important; }
    /* 1:privkey  2:pubkey  3:gen-btn  4:psk  5:keepalive */
    .wg-key-grid > .field-group:nth-child(1) { order: 1; }
    .wg-key-grid > .field-group:nth-child(3) { order: 2; }
    .wg-key-grid > button                    { order: 3; justify-self: center; }
    .wg-key-grid > .field-group:nth-child(4) { order: 4; }
    .wg-key-grid > .field-group:nth-child(6) { order: 5; }
    /* Gen button mobile: show icon + text */
    .wg-key-grid > button.btn-sm { padding: 4px 10px !important; width: auto !important; height: auto !important; }
    .wg-gen-text { display: inline; }
    .wg-gen-icon { display: none; }

    /* PSK row mobile: input full width, icon buttons below right */
    .peer-psk-row { flex-wrap: wrap; }
    .peer-psk-row .form-field { flex: 1 1 100%; }
    .peer-psk-row .peer-psk-gen { margin-left: auto; width: 28px !important; height: 28px !important; padding: 0 !important; border: 1px solid var(--border); border-radius: 6px; background: none; display: flex; align-items: center; justify-content: center; }
    .peer-psk-row .peer-psk-clear { width: 28px !important; height: 28px !important; padding: 0 !important; border: 1px solid var(--border); border-radius: 6px; background: none; display: flex; align-items: center; justify-content: center; }

    /* wg-confgen peer AllowedIPs/DNS on mobile */
    .peer-allowed-text-group .field-label { display: none; }
    .peer-allowed-text-group { margin-top: -4px; }
    .peer-dns-group { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }

    /* wg-confgen bottom row mobile — stack vertically */
    .wg-bottom-row { flex-direction: column; align-items: center; }

    /* icon-action-btn mobile — smaller */
    button.icon-action-btn { width: 28px; height: 28px; border-radius: 6px; }

/* hysteria2 mobile — proxy + bandwidth: left field stretches, right field fixed */
    #socks5-ip, #http-ip, #bw-down, #bw-up { min-width: 0; flex: 1; width: 1px; }
    #socks5-port, #http-port, #bw-down-unit, #bw-up-unit { flex: none; width: 90px !important; }

    /* hysteria2 mobile — user cards: login+del / pass+gen */
    .h2-user-card {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas: "login del" "pass gen";
        gap: 6px;
        padding: 8px;
        background: var(--surface-alt, var(--surface));
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 8px;
        align-items: center;
    }
    .h2-user-login { grid-area: login; width: auto; }
    .h2-user-pass  { grid-area: pass;  width: auto; flex: none; min-width: 0; }
    .h2-user-del   { grid-area: del; }
    .h2-user-gen   { grid-area: gen; }

    /* Sitemap page mobile */
    .sm-grid { grid-template-columns: 1fr; }
    .sm-item { padding: 10px 10px; min-height: 44px; }
    .sm-icon { width: 20px; height: 20px; }
    .sm-name { font-size: 12px; }
    .sm-url { font-size: 10px; }

    /* Sitemap tree mobile */
    .st-item { min-height: 36px; flex-wrap: wrap; align-items: flex-start; padding-top: 5px; padding-bottom: 5px; }
    .st-item-path { display: block; flex: 0 0 100%; padding-left: 24px; margin-top: 1px; font-size: 10px; white-space: normal; }
    .st-group-hdr { min-height: 40px; }

    /* About page — tool directory */
    .ab-groups { margin: 12px -16px -14px; }
    .ab-groups-title { padding: 12px 16px 10px; }
    .ab-group-hdr { padding: 11px 16px; }
    .ab-group-body { padding: 10px 16px 14px; }
    .ab-rows { gap: 14px; }
    /* Card: logo + name on row 1, desc + badge span full width on row 2 */
    .ab-card { display: grid; grid-template-columns: 30px 1fr; gap: 2px 8px; padding: 8px 10px; align-items: start; }
    .ab-card-logo { width: 30px; height: 30px; margin-top: 0; grid-row: 1; }
    .ab-card-info { display: contents; }
    .ab-card-name { grid-column: 2; grid-row: 1; align-self: center; }
    .ab-card-desc { grid-column: 1 / -1; grid-row: 2; margin-top: 2px; }
    .ab-card-info > div:last-child { grid-column: 1 / -1; }
    .ab-card-badges { grid-column: 1 / -1; margin-top: 6px; }
}
