* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1fa2ed;
    --primary-dark: #0d8dd6;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-light: #999999;
    --success-color: #00c853;
    --warning-color: #ff9800;
    --danger-color: #f44336;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 50%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 100%;
    padding: 0 16px;
}

header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 20px 16px;
    border-radius: 0 0 24px 24px;
    box-shadow: var(--shadow-md);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
}

.header-subtitle {
    font-size: 12px;
    opacity: 0.9;
}

.main-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 24px 16px;
}

.device-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.device-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.device-name {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.device-state {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #e8f5e9;
    border-radius: 20px;
    font-size: 13px;
    color: var(--success-color);
}

.device-state.offline {
    background: #fafafa;
    color: var(--text-light);
}

.device-state .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.switch-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
}

.switch-button {
    position: relative;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: linear-gradient(145deg, #e6e6e6, #ffffff);
    box-shadow: 
        8px 8px 16px rgba(0, 0, 0, 0.1),
        -8px -8px 16px rgba(255, 255, 255, 0.8),
        inset 0 0 0 0 rgba(0, 0, 0, 0);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    outline: none;
}

.switch-button.active {
    background: linear-gradient(145deg, var(--primary-color), var(--primary-dark));
    box-shadow: 
        8px 8px 16px rgba(31, 162, 237, 0.3),
        -8px -8px 16px rgba(255, 255, 255, 0.2),
        inset 0 0 40px rgba(0, 0, 0, 0.1);
}

.switch-button:hover {
    transform: scale(1.02);
}

.switch-button:active {
    transform: scale(0.98);
}

.switch-inner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(145deg, #f0f0f0, #e0e0e0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        inset 4px 4px 8px rgba(0, 0, 0, 0.1),
        inset -4px -4px 8px rgba(255, 255, 255, 0.8);
}

.switch-button.active .switch-inner {
    background: linear-gradient(145deg, #ffffff, #e6f4ff);
    box-shadow: 
        inset 4px 4px 8px rgba(0, 0, 0, 0.05),
        inset -4px -4px 8px rgba(255, 255, 255, 0.9);
}

.switch-icon {
    width: 60px;
    height: 60px;
    transition: all 0.4s ease;
}

.switch-button.active .switch-icon {
    filter: drop-shadow(0 2px 4px rgba(31, 162, 237, 0.4));
}

.switch-status-text {
    margin-top: 20px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.switch-button.active + .switch-status-text {
    color: var(--primary-color);
}

.info-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.info-item {
    text-align: center;
    padding: 12px 8px;
    border-radius: var(--radius-md);
    background: #fafafa;
}

.info-item .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.info-item .label {
    font-size: 12px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item.highlight .value {
    color: var(--primary-color);
}

.timer-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.section-action {
    font-size: 13px;
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.timer-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: var(--radius-md);
}

.timer-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.timer-unit {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 4px;
}

.timer-divider {
    font-size: 24px;
    color: var(--text-light);
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.quick-action-btn {
    padding: 12px 8px;
    border: none;
    background: #f5f5f5;
    border-radius: var(--radius-md);
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.quick-action-btn:hover {
    background: #e8e8e8;
}

.quick-action-btn.active {
    background: var(--primary-color);
    color: white;
}

.quick-action-btn svg {
    width: 20px;
    height: 20px;
}

.history-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #fafafa;
    border-radius: var(--radius-sm);
}

.history-time {
    font-size: 14px;
    color: var(--text-secondary);
}

.history-state {
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 12px;
}

.history-state.on {
    background: #e8f5e9;
    color: var(--success-color);
}

.history-state.off {
    background: #fafafa;
    color: var(--text-light);
}

.footer-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
    display: flex;
    justify-content: space-around;
    max-width: 600px;
    margin: 0 auto;
}

.footer-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-light);
    font-size: 11px;
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 4px 16px;
}

.footer-item.active {
    color: var(--primary-color);
}

.footer-item svg {
    width: 24px;
    height: 24px;
}

.main-wrapper {
    max-width: 600px;
    margin: 0 auto;
    padding-bottom: 80px;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.loading {
    animation: pulse 1.5s infinite;
}

@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }

    header {
        padding: 16px 12px;
        border-radius: 0 0 20px 20px;
    }

    .header-title {
        font-size: 16px;
    }

    .device-card {
        padding: 24px 16px;
    }

    .switch-button {
        width: 160px;
        height: 160px;
    }

    .switch-inner {
        width: 124px;
        height: 124px;
    }

    .switch-icon {
        width: 50px;
        height: 50px;
    }

    .info-grid {
        gap: 8px;
    }

    .info-item .value {
        font-size: 20px;
    }

    .info-item .label {
        font-size: 10px;
    }

    .quick-actions {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .quick-action-btn {
        padding: 10px 4px;
        font-size: 11px;
    }

    .footer-item {
        padding: 4px 12px;
        font-size: 10px;
    }
}

@media (min-width: 768px) {
    .main-content {
        padding: 32px 24px;
    }

    .device-card {
        padding: 40px 32px;
    }

    .switch-button {
        width: 200px;
        height: 200px;
    }

    .switch-inner {
        width: 156px;
        height: 156px;
    }

    .info-grid {
        gap: 24px;
    }

    .info-item .value {
        font-size: 28px;
    }
}
