:root {
    color-scheme: light;
    --page: #f5f5f5;
    --surface: #ffffff;
    --text: #333333;
    --muted: #666666;
    --line: #e1e1e1;
    --blue: #2196f3;
    --blue-dark: #1976d2;
    --green: #4caf50;
    --green-dark: #3d8b40;
    --red: #f44336;
    --warning: #f59e0b;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--page);
}

body {
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    color: var(--text);
    background: var(--page);
    font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

button {
    font: inherit;
}

[hidden] {
    display: none !important;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1100;
    padding: 8px 12px;
    color: #fff;
    background: var(--blue-dark);
    border-radius: 4px;
    transform: translateY(-160%);
}

.skip-link:focus {
    transform: translateY(0);
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 10px;
}

.header h1 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.2;
}

.header-tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.update-time {
    margin: 0;
    color: var(--muted);
    font-size: 0.94rem;
}

.btn {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    color: #fff;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.btn-primary {
    background: var(--blue);
    border-color: var(--blue);
}

.btn-primary:hover:not(:disabled) {
    background: var(--blue-dark);
    border-color: var(--blue-dark);
}

.btn-success {
    background: var(--green);
    border-color: var(--green);
}

.btn-success:hover:not(:disabled) {
    background: var(--green-dark);
    border-color: var(--green-dark);
}

.btn:focus-visible,
.skip-link:focus-visible {
    outline: 3px solid rgba(33, 150, 243, 0.28);
    outline-offset: 2px;
}

.btn:disabled {
    cursor: wait;
    opacity: 0.62;
}

.account-actions .btn:disabled {
    cursor: not-allowed;
}

.status-badge,
.country-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    color: #fff;
    background: var(--green);
    border-radius: 4px;
    font-size: 0.76rem;
    font-weight: 700;
}

.status-badge[data-tone="neutral"] {
    color: #555;
    background: #e7e7e7;
}

.status-badge[data-tone="warning"] {
    color: #6a4300;
    background: #ffe6a7;
}

.status-badge[data-tone="danger"] {
    color: #fff;
    background: var(--red);
}

.accounts-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.account-card {
    height: 100%;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid #ededed;
    border-left: 4px solid var(--green);
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 200ms ease, box-shadow 200ms ease;
}

.account-card:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transform: translateY(-5px);
}

.card-body {
    padding: 20px;
}

.card-title {
    margin: 0 0 15px;
    color: var(--text);
    font-size: 1.12rem;
    font-weight: 700;
}

.email-display {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    font-weight: 700;
    word-break: break-all;
}

.password-display {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
}

.password-label {
    flex: 0 0 auto;
    color: var(--muted);
}

.password-input {
    width: 100%;
    min-width: 0;
    padding: 8px 10px;
    color: var(--text);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
    font-family: Consolas, "SFMono-Regular", "Liberation Mono", monospace;
    line-height: 1.35;
    cursor: text;
}

.password-input:focus {
    border-color: var(--blue);
    outline: 2px solid rgba(33, 150, 243, 0.2);
    outline-offset: 1px;
}

.password-input::selection {
    color: #ffffff;
    background: var(--blue-dark);
}

.country-badge {
    background: var(--blue);
}

.account-label {
    margin: 0 0 8px;
}

.warning-text {
    margin: 0 0 14px;
    color: #e00000;
    font-size: 0.88rem;
    overflow-wrap: anywhere;
}

.account-detail {
    margin: 8px 0;
}

.account-detail-label {
    color: var(--muted);
}

.account-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.account-actions .btn {
    min-width: 96px;
}

.state-panel {
    min-height: 210px;
    padding: 40px 20px;
    color: var(--muted);
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.state-panel h2 {
    margin: 0 0 8px;
    color: var(--text);
    font-size: 1.2rem;
}

.state-panel p {
    margin: 0;
}

.state-panel .btn {
    margin-top: 16px;
}

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    margin-bottom: 10px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.state-error {
    color: var(--red);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.alert-box {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: min(390px, calc(100% - 40px));
    padding: 15px;
    color: #fff;
    background: var(--green);
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    font-weight: 600;
}

.alert-box[data-tone="danger"] {
    background: var(--red);
}

.alert-box[data-tone="warning"] {
    background: var(--warning);
}

.clipboard-helper {
    position: fixed;
    top: -1000px;
    left: -1000px;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.footer {
    max-width: 1200px;
    margin: 16px auto 0;
    padding: 0 20px;
    color: var(--muted);
    font-size: 0.84rem;
    text-align: center;
}

.footer p {
    margin: 0;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

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

    .header-tools {
        width: 100%;
        justify-content: space-between;
    }

    .accounts-container {
        grid-template-columns: 1fr;
    }

    .card-body {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 5px;
    }

    .header h1 {
        font-size: 1.55rem;
    }

    .header-tools {
        align-items: flex-start;
        flex-direction: column;
    }

    .refresh-btn {
        width: 100%;
    }

    .accounts-container {
        gap: 10px;
    }

    .account-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .account-actions .btn {
        min-width: 0;
        padding: 7px 8px;
        font-size: 0.88rem;
    }

    .alert-box {
        top: 10px;
        right: 10px;
        max-width: calc(100% - 20px);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
