/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #4A6CF7;
    --primary-dark: #3A56D4;
    --primary-light: #6B8AFF;
    --primary-bg: #EEF2FF;
    --bg: #F1F4F8;
    --card: #FFFFFF;
    --text: #0F172A;
    --text-secondary: #64748B;
    --text-light: #94A3B8;
    --border: #E2E8F0;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    --radius: 16px;
    --radius-sm: 10px;
    --safe-top: env(safe-area-inset-top, 20px);
    --safe-bottom: env(safe-area-inset-bottom, 12px);
    --header-h: 58px;
    --footer-h: 68px;
}

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
    background: var(--bg);
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
}

/* ===== HEADER ===== */
.app-header {
    flex-shrink: 0;
    height: var(--header-h);
    padding: 0 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.02);
    padding-top: var(--safe-top);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.header-logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.header-logo svg {
    width: 34px;
    height: 34px;
    display: block;
}

.header-brand {
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.3px;
    color: var(--text);
    white-space: nowrap;
}
.header-brand span {
    color: var(--primary);
}

.header-right {
    flex-shrink: 0;
}

.hamburger-btn {
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s;
}
.hamburger-btn:hover,
.hamburger-btn:active {
    background: var(--primary-bg);
    color: var(--primary);
}
.hamburger-btn i {
    font-size: 24px;
}

/* ===== MAIN ===== */
.app-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 16px 12px;
    padding-bottom: 0;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.app-main::-webkit-scrollbar {
    width: 3px;
}
.app-main::-webkit-scrollbar-track {
    background: transparent;
}
.app-main::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 20px;
}

/* ===== FOOTER ===== */
.app-footer {
    flex-shrink: 0;
    height: var(--footer-h);
    padding: 0 12px 8px;
    padding-bottom: calc(8px + var(--safe-bottom));
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.04);
    z-index: 100;
}

.footer-btn {
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
    height: 44px;
    padding: 0 12px;
    background: var(--bg);
    color: var(--text-secondary);
    flex: 1;
    white-space: nowrap;
}
.footer-btn:active {
    transform: scale(0.96);
}
.footer-btn i {
    font-size: 18px;
}

.footer-btn--primary {
    flex: 3;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(74, 108, 247, 0.35);
}
.footer-btn--primary:active {
    background: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(74, 108, 247, 0.25);
}
.footer-btn--primary i {
    font-size: 20px;
}

.footer-btn--outline {
    background: transparent;
    border: 1.5px solid var(--border);
}
.footer-btn--outline:active {
    background: var(--primary-bg);
    border-color: var(--primary-light);
}

/* ===== CARDS ===== */
.section-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px 16px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-title i {
    font-size: 16px;
}

/* ===== INPUT ===== */
.input-group {
    margin-bottom: 14px;
}
.input-group:last-child {
    margin-bottom: 0;
}

.input-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    transition: border-color 0.2s, background 0.2s;
}
.input-wrap:focus-within {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(74, 108, 247, 0.08);
}

.input-wrap input,
.input-wrap .combo-box input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 12px 14px;
    font-size: 15px;
    color: var(--text);
    outline: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    min-height: 46px;
}

.input-wrap input::placeholder {
    color: var(--text-light);
    font-weight: 400;
}

.input-wrap input.default-text {
    color: var(--text-light);
    font-style: italic;
    font-weight: 400;
}

/* ---- combo box ---- */
.combo-box {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.combo-box input {
    flex: 1;
    padding-right: 40px !important;
}

.combo-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}
.combo-toggle:hover,
.combo-toggle:active {
    background: rgba(0, 0, 0, 0.04);
}

.combo-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    max-height: 200px;
    overflow-y: auto;
    z-index: 50;
    display: none;
    padding: 6px 0;
    list-style: none;
}
.combo-menu.open {
    display: block;
}

.combo-menu li {
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
    color: var(--text);
    border-radius: 4px;
    margin: 0 4px;
}
.combo-menu li:hover,
.combo-menu li.active {
    background: var(--primary-bg);
    color: var(--primary);
}

/* ---- length input ---- */
.input-wrap--inline {
    display: flex;
    align-items: center;
    gap: 12px;
}
.input-wrap--inline input {
    flex: 1;
    min-width: 60px;
    text-align: center;
    font-weight: 500;
}
.input-wrap--inline .length-hint {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 400;
    white-space: nowrap;
}

/* ===== RESULT ===== */
#resultView {
    display: none;
}

#placeholderView {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    text-align: center;
    color: var(--text-secondary);
    min-height: 120px;
}
#placeholderView i {
    font-size: 44px;
    color: var(--border);
    margin-bottom: 12px;
}
#placeholderView p {
    font-size: 14px;
    color: var(--text-light);
    max-width: 220px;
}

.result-view {
    padding: 0;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.result-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}

.result-actions {
    display: flex;
    gap: 6px;
}

.action-btn {
    border: none;
    background: var(--bg);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.action-btn:hover,
.action-btn:active {
    background: var(--primary-bg);
    color: var(--primary);
}
.action-btn i {
    font-size: 15px;
}
.action-btn.copied {
    background: #D1FAE5;
    color: #065F46;
}

.result-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-row {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    gap: 12px;
    word-break: break-all;
}
.result-row .label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    min-width: 62px;
}
.result-row .value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    font-family: "SF Mono", "Menlo", "Monaco", monospace;
    letter-spacing: 0.2px;
}
.result-row .value.password {
    font-size: 15px;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* strength */
.strength-wrapper {
    margin-top: 4px;
    padding: 0 4px;
}

.strength-bar-track {
    width: 100%;
    height: 5px;
    background: var(--border);
    border-radius: 20px;
    overflow: hidden;
}
.strength-bar-fill {
    height: 100%;
    border-radius: 20px;
    background: var(--primary);
    transition: width 0.6s ease;
}

.strength-info {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-secondary);
}
.strength-label {
    font-weight: 500;
}
.strength-entropy {
    font-weight: 400;
}

/* ===== HISTORY (main) ===== */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.history-header .section-title {
    margin-bottom: 0;
}

.history-actions {
    display: flex;
    gap: 6px;
}

.history-btn {
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
    font-weight: 500;
}
.history-btn:hover,
.history-btn:active {
    background: var(--primary-bg);
    color: var(--primary);
}

#historyList {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 40px;
}

.history-empty {
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
    padding: 12px 0;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    gap: 10px;
}
.history-item:active {
    background: var(--primary-bg);
}

.h-left {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}
.h-domain {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.h-identity {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.h-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.h-pwd {
    font-size: 13px;
    font-family: "SF Mono", "Menlo", monospace;
    color: var(--text-secondary);
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.h-copy-btn {
    border: none;
    background: transparent;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.h-copy-btn:hover,
.h-copy-btn:active {
    background: var(--primary-bg);
    color: var(--primary);
}
.h-copy-btn.copied {
    color: #065F46;
    background: #D1FAE5;
}

/* 删除按钮（主界面） */
.h-delete-btn {
    border: none;
    background: transparent;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.h-delete-btn:hover,
.h-delete-btn:active {
    background: #fee2e2;
    color: #b91c1c;
}

/* ===== MODAL (全部历史) ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.25s ease;
}
.modal-overlay.active {
    display: flex;
}

.modal-sheet {
    background: var(--card);
    border-radius: var(--radius) var(--radius) 0 0;
    max-width: 480px;
    width: 100%;
    max-height: 80vh;
    padding: 20px 16px 28px;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.12);
    animation: slideUp 0.3s ease;
    display: flex;
    flex-direction: column;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-shrink: 0;
}
.modal-head h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}
.modal-close {
    border: none;
    background: var(--bg);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s;
}
.modal-close:hover,
.modal-close:active {
    background: var(--primary-bg);
    color: var(--primary);
}

#modalHistoryList {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}
#modalHistoryList::-webkit-scrollbar {
    width: 3px;
}
#modalHistoryList::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 20px;
}

/* 模态框内日期分组标题 */
.history-date-group .date-header {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

/* 模态框内 checkbox 样式 */
.history-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex-shrink: 0;
    cursor: pointer;
}

/* 模态框工具栏按钮复用 action-btn 样式，已在上面定义 */

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    pointer-events: none;
}
.toast {
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    padding: 10px 24px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    transform: translateY(20px);
    white-space: nowrap;
    max-width: 90%;
    pointer-events: none;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideUp {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .app {
        max-width: 100%;
        border-radius: 0;
    }
    .section-card {
        padding: 14px 14px 14px;
    }
    .result-row {
        padding: 8px 12px;
        gap: 8px;
    }
    .result-row .value {
        font-size: 13px;
    }
    .result-row .value.password {
        font-size: 14px;
    }
    .h-pwd {
        max-width: 60px;
        font-size: 12px;
    }
    .footer-btn {
        font-size: 12px;
        padding: 0 8px;
        height: 40px;
    }
    .footer-btn i {
        font-size: 16px;
    }
    .header-brand {
        font-size: 16px;
    }
}

@media (min-width: 481px) {
    .app {
        border-radius: 20px;
        margin-top: 20px;
        margin-bottom: 20px;
        height: calc(100% - 40px);
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
    }
    .toast-container {
        bottom: 100px;
    }
}

/* ===== UTILITY ===== */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
