/* PassAfer — 共享布局 / 基础组件 */

/* PassAfer — MVP 样式 */

:root {
    --bg: #0f172a;
    --bg-elevated: #1e293b;
    --bg-input: #0c1222;
    --border: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --accent: #22d3ee;
    --accent-dim: rgba(34, 211, 238, 0.15);
    --success: #34d399;
    --danger: #f87171;
    --radius: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    --mono: ui-monospace, "Cascadia Code", "Roboto Mono", monospace;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

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

html { font-size: 16px; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

.grid-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(34, 211, 238, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(34, 211, 238, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black, transparent);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.is-hidden { display: none !important; }

/* ── Topbar ── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
}

.topbar-inner {
    position: relative;
    max-width: 1180px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    flex-shrink: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #0891b2);
    color: var(--bg);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 1rem; }
.brand-sub { font-size: 0.7rem; color: var(--text-muted); letter-spacing: 0.04em; }
.brand-sub:empty,
.footer-brand-sub:empty { display: none; }

.tagline {
    flex: 1;
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    display: none;
}

@media (min-width: 640px) {
    .tagline { display: block; }
}

/* ── Top navigation ── */
/* Flex middle slot (not absolute center) so long EN/JA labels cannot overlap brand / user. */
.topnav {
    position: static;
    left: auto;
    transform: none;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    gap: 2px;
    min-width: 0;
    margin-left: 0;
}

.topnav-link {
    padding: 8px 10px;
    border-radius: 7px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.topnav-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.topnav-link.is-active {
    color: var(--accent);
    background: var(--accent-dim);
}

.topbar-spacer { display: none; }

/* ── Main ── */
.main {
    max-width: 880px;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 24px;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

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

.tab.is-active {
    background: var(--bg);
    color: var(--accent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* ── Panel ── */
.panel { display: none; }
.panel.is-active { display: block; }

.panel-head { margin-bottom: 20px; }

.panel-head h1 {
    margin: 0 0 6px;
    font-size: 1.5rem;
    font-weight: 700;
}

.panel-desc {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ── Mode switch ── */
.mode-switch {
    display: flex;
    gap: 8px;
    margin: 0 0 20px;
    padding: 0;
    border: none;
}

.mode-option {
    flex: 1;
    cursor: pointer;
}

.mode-option input { position: absolute; opacity: 0; pointer-events: none; }

.mode-option span {
    display: block;
    padding: 10px 14px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: border-color 0.15s, background 0.15s;
}

.mode-option input:checked + span {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--accent);
}

/* ── Config ── */
.config-block {
    padding: 20px;
    margin-bottom: 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.config-block.is-hidden { display: none; }

.field-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.field-row:last-child { margin-bottom: 0; }

.field-row label {
    min-width: 88px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.field-inline {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 200px;
}

.field-inline input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
}

.input-num,
.input-text {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
}

.input-num { width: 72px; }
.input-text { flex: 1; min-width: 120px; }
.input-short { max-width: 80px; }

.input-num:focus,
.input-text:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

.check input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--accent);
    color: var(--bg);
}

.btn-primary:hover { background: #06b6d4; }

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

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

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
    padding: 8px 16px;
}

.btn-ghost:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

#btn-login { margin-left: 0; }

.user-area {
    margin-left: 0;
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.user-menu.is-hidden { display: none; }

#btn-login.is-hidden { display: none; }

.user-avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 2px solid var(--accent);
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--accent);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.user-avatar:hover { background: rgba(34, 211, 238, 0.25); }
.user-avatar:active { transform: scale(0.96); }

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    padding: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 150;
}

.user-dropdown-email {
    margin: 4px 10px 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    word-break: break-all;
}

.user-dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.user-dropdown-item:hover { background: var(--bg); }
.user-dropdown-danger { color: var(--danger); }

.tab-auth-only.is-hidden { display: none; }

.tabs:has(.tab-auth-only:not(.is-hidden)) .tab:not(.tab-auth-only) {
    flex: 1;
}

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-overlay[hidden] { display: none; }

.modal {
    position: relative;
    width: 100%;
    max-width: 420px;
    padding: 28px 24px 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.modal-sm { max-width: 380px; }

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover { color: var(--text); background: var(--bg); }

.modal-title {
    margin: 0 0 8px;
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-desc {
    margin: 0 0 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.auth-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    padding: 4px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.auth-tab {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.auth-tab.is-active {
    background: var(--bg-elevated);
    color: var(--accent);
}

.auth-form.is-hidden { display: none; }

.field-col {
    flex-direction: column;
    align-items: stretch;
}

.field-col label { min-width: unset; margin-bottom: 4px; }

.auth-error {
    margin: 0 0 12px;
    font-size: 0.85rem;
    color: var(--danger);
}

.auth-error[hidden] { display: none; }

.btn-block { width: 100%; }

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 8px;
}

/* ── Footer ── */
.footer {
    margin-top: 72px;
    border-top: 1px solid rgba(51, 65, 85, 0.85);
    background:
        linear-gradient(180deg, rgba(15, 23, 42, 0) 0%, rgba(12, 18, 34, 0.55) 28%, #0b1220 100%);
    text-align: left;
}

.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 56px 28px 28px;
}

.footer-main {
    display: grid;
    grid-template-columns: minmax(220px, 1.45fr) repeat(3, minmax(120px, 1fr));
    gap: 40px 36px;
    padding-bottom: 44px;
}

.footer-brand-link {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.footer-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.footer-brand-name {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.footer-brand-sub {
    margin-top: 2px;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.footer-desc {
    max-width: 280px;
    margin: 18px 0 0;
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--text-muted);
}

.footer-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-col-title {
    margin: 0 0 4px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: #64748b;
}

.footer-col a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    line-height: 1.45;
    transition: color 0.15s;
}

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

.footer-mail {
    color: var(--text-muted) !important;
    word-break: break-all;
}

.footer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-top: 22px;
    border-top: 1px solid rgba(51, 65, 85, 0.7);
}

.footer-copy {
    margin: 0;
    font-size: 0.82rem;
    color: #64748b;
}

.footer-bottom .footer-mail {
    font-size: 0.82rem;
    text-decoration: none;
}

.footer-bottom .footer-mail:hover {
    color: var(--accent) !important;
}

@media (max-width: 900px) {
    .footer-main {
        grid-template-columns: 1fr 1fr;
        gap: 32px 28px;
    }

    .footer-brand {
        grid-column: 1 / -1;
    }

    .footer-desc { max-width: 420px; }
}

@media (max-width: 560px) {
    .footer-inner { padding: 44px 20px 24px; }

    .footer-main {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .footer-bottom {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    padding: 10px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    box-shadow: var(--shadow);
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 200;
    pointer-events: none;
}

.toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Responsive ── */
@media (max-width: 1100px) {
    .topnav-link { padding: 7px 7px; font-size: 0.8rem; }
}

/* Wrap nav early enough for longer EN/JA labels + language switcher. */
@media (max-width: 920px) {
    .topbar-inner { flex-wrap: wrap; row-gap: 10px; }
    .topnav {
        order: 3;
        flex: 1 1 100%;
        width: 100%;
        margin-left: 0;
        padding-top: 4px;
        border-top: 1px solid var(--border);
        justify-content: center;
    }
    .topnav-link { flex: 1; text-align: center; font-size: 0.8rem; padding: 8px 6px; }
}

@media (max-width: 480px) {
    .user-area { margin-left: 0; width: 100%; display: flex; justify-content: flex-end; }
    #btn-login { width: auto; }
    .field-row { flex-direction: column; align-items: stretch; }
    .field-row label { min-width: unset; }
}

/* ── Language switcher ── */
.lang-switcher {
    position: relative;
    margin-right: 10px;
    flex-shrink: 0;
}

.lang-switcher-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 28px 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(12, 18, 34, 0.72);
    color: var(--text-muted);
    font: inherit;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
}

.lang-switcher-trigger:hover {
    border-color: rgba(34, 211, 238, 0.45);
    color: var(--text);
    background: var(--accent-dim);
}

.lang-switcher.is-open .lang-switcher-trigger,
.lang-switcher-trigger:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
    outline: none;
}

.lang-switcher-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.lang-switcher-icon svg { display: block; }

.lang-switcher-label {
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.2;
    white-space: nowrap;
}

.lang-switcher-chevron {
    position: absolute;
    right: 10px;
    top: 50%;
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-65%) rotate(45deg);
    pointer-events: none;
    opacity: 0.85;
    color: inherit;
    transition: transform 0.15s;
}

.lang-switcher.is-open .lang-switcher-chevron {
    transform: translateY(-20%) rotate(225deg);
}

.lang-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 160;
    min-width: 100%;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.lang-menu[hidden] { display: none; }

.lang-menu-item {
    display: block;
    padding: 9px 12px;
    border-radius: 6px;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.lang-menu-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.lang-menu-item.is-active {
    color: var(--accent);
    background: var(--accent-dim);
}

/* ── Shared tool UI (gate / IO) ── */
.crypto-gate-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.crypto-hint {
    margin: -8px 0 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.crypto-hint.is-hidden { display: none; }

.field-secret { position: relative; }

.field-secret .input-text { padding-right: 44px; }

.field-secret .toggle-secret {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    min-width: 36px;
}

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

.crypto-io-col label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.crypto-textarea {
    width: 100%;
    min-height: 200px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
}

.crypto-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.crypto-gate {
    text-align: center;
    padding: 48px 20px;
}

.crypto-gate-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.crypto-gate .panel-desc {
    max-width: 480px;
    margin: 0 auto 28px;
}

.crypto-gate-box {
    max-width: 400px;
    margin: 0 auto;
    padding: 28px 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.crypto-gate-box p { margin: 0 0 10px; }

.crypto-gate-note {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px !important;
}

.crypto-gate h1 {
    margin: 0 0 6px;
    font-size: 1.5rem;
    font-weight: 700;
}

.hint {
    margin: 0 0 16px;
    font-size: 0.85rem;
    color: #fbbf24;
}

@media (max-width: 640px) {
    .crypto-io { grid-template-columns: 1fr; }
}
