/* ============================================================
   ZeroPass · 简化版  v7.8
   高度自动，由内容撑开，支持滚动
   ============================================================ */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg: #f0f2f6;
    --surface: #ffffff;
    --surface-alt: #f7f8fc;
    --input-bg: #f1f3f8;
    --border: #e6e9f0;
    --border-focus: #d0d4e0;
    --text: #181b2a;
    --text-secondary: #5c6075;
    --text-tertiary: #8e93a8;
    --brand: #4f46e5;
    --brand-hover: #4338ca;
    --brand-light: #6366f1;
    --brand-subtle: rgba(79, 70, 229, 0.055);
    --brand-subtle-hover: rgba(79, 70, 229, 0.11);
    --radius-app: 28px;
    --radius-card: 18px;
    --radius-input: 12px;
    --radius-btn: 10px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --font:
        -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto,
        "Inter", system-ui, sans-serif;
    --font-mono:
        "SF Mono", "Fira Code", "JetBrains Mono", "Cascadia Code", ui-monospace,
        monospace;
    --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 28px;
    margin: 0;
    overflow-y: auto;
}

/* ---------- 应用容器：高度自动，由内容撑开 ---------- */
.app {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius-app);
    padding: clamp(24px, 4vw, 34px) clamp(20px, 3vw, 28px)
        clamp(20px, 3vw, 26px);
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 2.5vw, 20px);
    position: relative;
    border: 1px solid var(--border);
}

/* ---------- 顶部 ---------- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    padding-bottom: 2px;
    flex-shrink: 0;
}

.logo {
    width: clamp(30px, 5vw, 34px);
    height: clamp(30px, 5vw, 34px);
    display: block;
    flex-shrink: 0;
}

.app-header h1 {
    font-size: clamp(1.25rem, 2.5vw, 1.375rem);
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
    line-height: 1.2;
}
.app-header h1 span {
    color: var(--brand);
    font-weight: 800;
}

/* ---------- 主内容 ---------- */
.main {
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 2vw, 18px);
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ---------- 输入区 ---------- */
.input-group {
    display: flex;
    border-radius: var(--radius-input);
    overflow: hidden;
    background: var(--input-bg);
    border: 1.5px solid transparent;
    transition:
        border-color var(--transition-fast),
        background var(--transition-fast);
    flex-shrink: 0;
}
.input-group:focus-within {
    border-color: var(--brand);
    background: #fff;
}

.identity-input {
    flex: 1;
    min-width: 0;
    padding: clamp(10px, 1.2vw, 13px) clamp(14px, 1.6vw, 18px);
    border: none;
    outline: none;
    font-size: 1rem;
    font-family: var(--font);
    font-weight: 500;
    background: transparent;
    color: var(--text);
    letter-spacing: 0.01em;
    transition: color var(--transition-fast);
    line-height: 1.4;
}
.identity-input::placeholder {
    color: var(--text-tertiary);
    font-weight: 400;
    letter-spacing: 0;
}
.identity-input:focus::placeholder {
    color: transparent;
}

.generate-btn {
    padding: 0 clamp(16px, 2vw, 24px);
    border: none;
    background: var(--brand);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    white-space: nowrap;
    transition:
        background var(--transition-fast),
        transform var(--transition-fast);
    letter-spacing: 0.2px;
    position: relative;
    overflow: hidden;
    min-width: clamp(60px, 8vw, 72px);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.4;
    flex-shrink: 0;
}
.generate-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.08);
    opacity: 0;
    transition: opacity var(--transition-fast);
}
.generate-btn:hover {
    background: var(--brand-hover);
}
.generate-btn:hover::after {
    opacity: 1;
}
.generate-btn:active {
    transform: scale(0.95);
    transition: all 0.1s ease;
}
.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}
.generate-btn:disabled::after {
    opacity: 0;
}

/* ---------- 密码卡片 ---------- */
.password-card {
    background: var(--surface-alt);
    border-radius: var(--radius-card);
    padding: clamp(16px, 2.5vw, 24px) clamp(16px, 2.5vw, 22px)
        clamp(14px, 2vw, 18px);
    border: 1px solid var(--border);
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: border-color var(--transition-smooth);
    flex-shrink: 0;
}
.password-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(
        90deg,
        var(--brand),
        var(--brand-light),
        #818cf8,
        var(--brand)
    );
    border-radius: 3px 3px 0 0;
    opacity: 0.5;
    transition: opacity var(--transition-smooth);
}
.password-card:has(.password-display:not(:empty))::before {
    opacity: 0.85;
}

.password-display {
    font-size: clamp(1.25rem, 3.5vw, 1.625rem);
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--brand);
    letter-spacing: 0.05em;
    padding: 4px 0 clamp(10px, 1.5vw, 14px);
    word-break: break-all;
    line-height: 1.45;
    min-height: clamp(38px, 6vw, 52px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.password-meta {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    color: var(--text-tertiary);
    letter-spacing: 0.2px;
    padding-top: clamp(10px, 1.5vw, 12px);
    border-top: 1px solid var(--border);
    font-weight: 500;
    gap: 10px;
}
.password-meta span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- 操作按钮 ---------- */
.actions {
    display: flex;
    gap: clamp(10px, 1.5vw, 12px);
    justify-content: center;
    flex-shrink: 0;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: clamp(8px, 1vw, 10px) clamp(14px, 2vw, 22px);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-btn);
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--surface);
    color: var(--text-secondary);
    letter-spacing: 0.1px;
    white-space: nowrap;
    flex: 1;
    justify-content: center;
    line-height: 1.4;
}
.action-btn:hover {
    background: var(--brand-subtle);
    border-color: var(--brand);
    color: var(--brand);
}
.action-btn:active {
    transform: scale(0.94);
    transition: all 0.08s ease;
}
.action-btn i {
    font-size: 1.1em;
    flex-shrink: 0;
}
.action-btn.copied {
    color: #10b981;
    border-color: #a7f3d0;
    background: #f0fdf6;
    pointer-events: none;
    cursor: default;
}
.action-btn.copied:hover {
    background: #f0fdf6;
    color: #10b981;
    border-color: #a7f3d0;
    transform: none;
}

/* ---------- 历史记录 ---------- */
.history-section {
    border-top: 1px solid var(--border);
    padding-top: clamp(12px, 1.5vw, 16px);
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1vw, 10px);
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.history-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.2px;
    text-transform: uppercase;
}

.history-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.85rem;
}
.history-clear-btn:hover {
    background: var(--brand-subtle);
    color: var(--brand);
}
.history-clear-btn:active {
    transform: scale(0.92);
}
.history-clear-btn i {
    font-size: 0.9rem;
}

.history-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.history-scroll::-webkit-scrollbar {
    width: 3px;
}
.history-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.history-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-full);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: clamp(6px, 0.8vw, 8px);
    padding-bottom: 2px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: clamp(8px, 1vw, 10px) clamp(12px, 1.5vw, 14px);
    background: var(--surface-alt);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: all var(--transition-fast);
    cursor: pointer;
    gap: 8px;
}
.history-item:hover {
    background: var(--brand-subtle);
    border-color: var(--brand);
}
.history-item:active {
    transform: scale(0.98);
}

.history-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.history-item-identity {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.1px;
}
.history-item-password {
    font-size: 0.85rem;
    font-family: var(--font-mono);
    color: var(--brand);
    font-weight: 600;
    letter-spacing: 0.03em;
    word-break: break-all;
}
.history-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.history-item-copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.85rem;
}
.history-item-copy-btn:hover {
    background: var(--brand-subtle);
    color: var(--brand);
}
.history-item-copy-btn:active {
    transform: scale(0.9);
}
.history-item-copy-btn i {
    font-size: 0.9rem;
}
.history-item-copy-btn.copied {
    color: #10b981;
}

.history-empty {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    text-align: center;
    padding: clamp(12px, 1.5vw, 16px) 0;
}

/* ---------- 底部 ---------- */
.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: clamp(12px, 1.8vw, 14px);
    border-top: 1px solid var(--border);
    gap: 12px;
    flex-shrink: 0;
}

.footer-links {
    display: flex;
    gap: 14px;
    align-items: center;
}

.footer-link {
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
    text-decoration: none;
    font-size: 1rem;
    line-height: 1;
    padding: 4px;
    border-radius: 6px;
}
.footer-link:hover {
    color: var(--brand);
    background: var(--brand-subtle);
}

.footer-copyright {
    font-size: 1rem;
    color: var(--text-tertiary);
    margin: 0;
    font-weight: 500;
    letter-spacing: 0.1px;
    line-height: 1.4;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: clamp(28px, 4vw, 40px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: clamp(10px, 1.2vw, 11px) clamp(20px, 3vw, 28px);
    background: #1a1d2a;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.2px;
    white-space: nowrap;
    line-height: 1.4;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- 响应式 ---------- */
@media (max-width: 480px) {
    body {
        padding: 0;
        background: var(--surface);
        align-items: stretch;
    }

    .app {
        max-width: 100%;
        border-radius: 0;
        border: none;
        padding: 20px 16px 16px;
        gap: 16px;
    }

    .app-header h1 {
        font-size: 1.25rem;
    }
    .logo {
        width: 28px;
        height: 28px;
    }

    .identity-input {
        font-size: 1rem;
        padding: 10px 12px;
    }
    .generate-btn {
        font-size: 1rem;
        min-width: 56px;
        padding: 0 14px;
    }

    .password-display {
        font-size: 1.25rem;
        min-height: 40px;
        padding: 2px 0 10px;
    }
    .password-card {
        padding: 14px 12px 12px;
    }
    .password-meta {
        font-size: 1rem;
        padding-top: 8px;
    }

    .action-btn {
        font-size: 1rem;
        padding: 8px 10px;
        gap: 4px;
    }
    .action-btn i {
        font-size: 1em;
    }

    .history-item {
        padding: 8px 10px;
    }
    .history-item-password {
        font-size: 0.8rem;
    }

    .footer-copyright {
        font-size: 1rem;
    }
    .footer-link {
        font-size: 1rem;
    }

    .toast {
        bottom: 24px;
        font-size: 1rem;
        padding: 10px 20px;
    }
}

@media (max-width: 380px) {
    .app {
        padding: 16px 10px 12px;
        gap: 12px;
    }
    .app-header h1 {
        font-size: 1.125rem;
    }
    .logo {
        width: 24px;
        height: 24px;
    }

    .identity-input {
        font-size: 1rem;
        padding: 8px 8px;
    }
    .generate-btn {
        font-size: 1rem;
        min-width: 48px;
        padding: 0 10px;
    }

    .password-display {
        font-size: 1.125rem;
        min-height: 36px;
        letter-spacing: 0.03em;
    }
    .password-card {
        padding: 12px 10px 10px;
    }
    .password-meta {
        font-size: 1rem;
        padding-top: 6px;
    }

    .actions {
        gap: 6px;
        flex-wrap: wrap;
    }
    .action-btn {
        font-size: 1rem;
        padding: 6px 8px;
        gap: 3px;
        border-radius: var(--radius-sm);
    }
    .action-btn i {
        font-size: 0.9em;
    }

    .input-group {
        border-radius: var(--radius-sm);
    }

    .history-item-password {
        font-size: 0.7rem;
    }

    .footer-copyright {
        font-size: 1rem;
    }
}
