:root {
    /* 主要颜色 */
    --primary: #00ff88;
    --secondary: #00d4ff;
    --danger: #ff4d4d;
    --glow: 0 0 20px rgba(0, 255, 136, 0.3);

    /* 默认深色主题变量 */
    --bg-app: #0a0a0a;
    --bg-card: rgba(26, 26, 26, 0.8);
    --bg-input: rgba(26, 26, 26, 0.6);
    --text-main: #ffffff;
    --text-dim: #a0a0a0;
    --border-card: rgba(255, 255, 255, 0.1);
    --grad-bg: radial-gradient(circle at top right, #1a2a2a, transparent),
        radial-gradient(circle at bottom left, #1a1a2a, transparent);
}

[data-theme="light"] {
    --bg-app: #f0f2f5;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-input: #ffffff;
    --text-main: #1a202c;
    --text-dim: #718096;
    --border-card: rgba(0, 0, 0, 0.05);
    --grad-bg: radial-gradient(circle at top right, #e6fffa, transparent),
        radial-gradient(circle at bottom left, #ebf8ff, transparent);
    --glow: 0 4px 12px rgba(0, 255, 136, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Inter', -apple-system, sans-serif;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    background-image: var(--grad-bg);
}

#app {
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header {
    text-align: center;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1.5rem;
    letter-spacing: -1px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-container h1 {
    margin-bottom: 0;
    font-size: 2.2rem;
}

.view {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    animation: fadeIn 0.5s ease;
}

.hidden {
    display: none !important;
}

.status-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-card);
    padding: 1.5rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    width: 100%;
}

.status-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 40px rgba(0, 255, 136, 0.15);
    border-color: rgba(0, 255, 136, 0.3);
}

.status-card.status-safe {
    border-left: 4px solid var(--primary);
}

.status-card.status-danger {
    border-left: 4px solid var(--danger);
}

.status-info {
    flex: 1;
    text-align: left;
}

.status-info p {
    font-size: 1.1rem;
    font-weight: 600;
}

.status-info .small {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 0.2rem;
}

.status-msg {
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    box-shadow: var(--glow);
}

.pulse {
    animation: heartBeat 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes heartBeat {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
        box-shadow: 0 0 30px var(--primary);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.btn {
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-align: center;
    width: 100%;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #000;
    box-shadow: var(--glow);
}

.btn-primary:hover {
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.5);
    filter: brightness(1.1);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-card);
    color: var(--text-dim);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border-color: var(--primary);
}

.btn-danger {
    background: rgba(255, 77, 77, 0.1);
    color: var(--danger);
    border: 1px solid rgba(255, 77, 77, 0.2);
}

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-large {
    padding: 1.2rem;
    font-size: 1.1rem;
    border-radius: 16px;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 8px;
    width: auto;
}

/* 角色选择器遮罩 */
#role-selector {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3rem;
    padding: 2rem;
    background-image: radial-gradient(circle at center, #1a2a2a, var(--bg-dark));
}

#role-selector h2 {
    font-size: 2rem;
    text-align: center;
}

.role-options {
    display: flex;
    gap: 2rem;
    width: 100%;
    max-width: 600px;
}

.role-card {
    flex: 1;
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.role-card:hover {
    transform: translateY(-10px);
    border-color: var(--primary);
    box-shadow: var(--glow);
}

.role-card i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.help-link {
    font-size: 0.8rem;
    color: var(--accent-secondary);
    text-decoration: none;
    margin-top: 0.5rem;
    display: inline-block;
}

.help-link:hover {
    text-decoration: underline;
}

.help-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 24px;
    z-index: 1100;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    width: 90%;
    max-width: 400px;
}

.help-overlay ul {
    list-style: none;
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.help-overlay a {
    color: var(--text-main);
    text-decoration: none;
    display: flex;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.8rem;
    border-radius: 8px;
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1.5rem;
}

/* Obsolete styles removed */

/* --- Auth Views & Tabs --- */
.tabs {
    display: flex;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.4rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.tab-btn {
    flex: 1;
    padding: 0.8rem;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.user-id {
    font-size: 0.8rem;
    color: var(--text-dim);
    background: rgba(0, 255, 136, 0.1);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    border: 1px solid rgba(0, 255, 136, 0.2);
}

.user-id code {
    color: var(--primary);
    font-family: monospace;
}

.settings-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.binding-section {
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
}

.binding-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--accent-secondary);
}

.guardian-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn-small {
    padding: 0.6rem 1.2rem;
    font-size: 0.85rem;
    margin-top: 0.8rem;
}

.error {
    color: var(--danger);
    font-size: 0.8rem;
}

.request-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.8rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.action-btns {
    display: flex;
    gap: 0.5rem;
}

.btn-text {
    background: transparent;
    border: none;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
}

.btn-safe {
    color: var(--primary);
}

.btn-danger {
    color: var(--danger);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

label {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-left: 0.5rem;
}

input,
select {
    background: var(--bg-input);
    border: 1px solid var(--border-card);
    padding: 1rem;
    border-radius: 12px;
    color: var(--text-main);
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2300ff88' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2rem;
    padding-right: 3rem;
}

input:focus,
select:focus {
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 4px rgba(0, 255, 136, 0.1);
}

#check-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.record-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid var(--primary);
}

.record-date {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.hint-text {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-align: center;
    margin-top: -1rem;
}

.action-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.secondary-btn {
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: transparent;
    color: var(--text-dim);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border-color: rgba(255, 255, 255, 0.2);
}

.status-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.nickname b {
    color: var(--text-main);
    font-size: 1.1rem;
}

.nickname code {
    color: var(--text-dim);
    font-size: 0.8rem;
}

.btn-icon-tiny {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 4px 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-tiny:hover {
    background: rgba(0, 255, 136, 0.1);
    border-color: var(--primary);
}

/* 状态标签样式 (Phase 6) */
.status-badge {
    padding: 0.8rem 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    text-align: center;
    border: 1px solid var(--border-card);
    backdrop-filter: blur(8px);
}

.status-badge.safe {
    background: rgba(0, 255, 136, 0.1);
    color: var(--primary);
    border-color: rgba(0, 255, 136, 0.2);
}

.status-badge.warning {
    background: rgba(255, 77, 77, 0.1);
    color: var(--danger);
    border-color: rgba(255, 77, 77, 0.2);
}