:root {
    /* Color Palette - Cute & Cozy */
    --primary-color: #FF9A9E;
    --primary-dark: #FF6B6B;
    --secondary-color: #A18CD1;
    --accent-color: #FBC2EB;
    --bg-color: #FFF5F5;
    --card-bg: #FFFFFF;
    --text-main: #4A4A4A;
    --text-light: #888888;
    --success: #84FAB0;
    --warning: #FDC830;
    --danger: #FF6B6B;

    /* Spacing & Radius */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 999px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    /* Layout */
    --nav-height: 60px;
    --header-height: 70px;
}

/* Themes */
body.green {
    --primary-color: #84FAB0;
    --primary-dark: #48c774;
    --secondary-color: #8FD3F4;
    --accent-color: #D4FC79;
    --bg-color: #F0FFF4;
}

body.sunny {
    --primary-color: #FFD200;
    --primary-dark: #F7971E;
    --secondary-color: #FBD786;
    --accent-color: #C6FFDD;
    --bg-color: #FFFDE7;
}

body.cozy {
    --primary-color: #D4A5A5;
    --primary-dark: #9E7676;
    --secondary-color: #E3CAA5;
    --accent-color: #FFDAC1;
    --bg-color: #FAF3F0;
}

body.night {
    --primary-color: #764BA2;
    --primary-dark: #667EEA;
    --secondary-color: #8E2DE2;
    --accent-color: #4A00E0;
    --bg-color: #1a1a2e;
    --card-bg: #16213e;
    --text-main: #e94560;
    /* Cyberpunk accent */
    --text-light: #a2a8d3;
}

body.night .app-bar,
body.night .bottom-nav {
    background: rgba(22, 33, 62, 0.9);
    color: white;
}

body.night .card {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Global Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Nunito', 'Zcool KuaiLe', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

/* App Container */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 600px;
    /* Mobile-first constraint for desktop view */
    margin: 0 auto;
    background-color: var(--bg-color);
    position: relative;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
}

/* Header */
.app-bar {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

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

.logo-area h1 {
    font-size: 1.2rem;
    color: var(--primary-dark);
    font-weight: 800;
}

.logo-area p {
    font-size: 0.75rem;
    color: var(--text-light);
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-full);
    transition: transform 0.2s;
}

.icon-btn:active {
    transform: scale(0.9);
    background-color: rgba(0, 0, 0, 0.05);
}

/* Main Content */
#main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: calc(var(--nav-height) + 20px);
    /* Space for nav */
}

.tab-view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-view.active {
    display: block;
}

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

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

/* Bottom Navigation */
.bottom-nav {
    height: var(--nav-height);
    background: white;
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    z-index: 100;
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    cursor: pointer;
    width: 100%;
    height: 100%;
    transition: all 0.2s;
}

.nav-icon {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 600;
}

.nav-item.active {
    color: var(--primary-dark);
}

.nav-item.active .nav-icon {
    transform: scale(1.1);
}

/* Common Components */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:active {
    transform: scale(0.99);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
    cursor: pointer;
    width: 100%;
    transition: transform 0.2s;
}

.btn-primary:active {
    transform: scale(0.95);
}

/* Modal */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

#modal-overlay.hidden {
    display: none;
}

#modal-container {
    background: white;
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-lg);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Utilities */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-2 {
    margin-bottom: 8px;
}

.mb-4 {
    margin-bottom: 16px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-main);
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #eee;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input:focus,
textarea:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* Species Selector */
.species-selector {
    display: flex;
    gap: 10px;
}

.radio-card {
    flex: 1;
    border: 2px solid #eee;
    border-radius: var(--radius-md);
    padding: 10px;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.radio-card input {
    position: absolute;
    opacity: 0;
}

.radio-card .emoji {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.radio-card:has(input:checked) {
    border-color: var(--primary-color);
    background-color: var(--bg-color);
    color: var(--primary-dark);
}

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}

/* Pet Card Styles */
.pet-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pet-avatar {
    width: 60px;
    height: 60px;
    background-color: var(--bg-color);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.pet-info h3 {
    margin-bottom: 4px;
    color: var(--text-main);
}

.pet-info p {
    font-size: 0.85rem;
    color: var(--text-light);
}

.pet-tags {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.tag {
    background-color: var(--bg-color);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    color: var(--text-light);
}

.fab-add {
    position: fixed;
    bottom: calc(var(--nav-height) + 20px);
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--primary-dark);
    color: white;
    border: none;
    font-size: 2rem;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90;
}

/* Pet Switcher */
.pet-switcher {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.pet-chip {
    background: white;
    border: 1px solid #eee;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.pet-chip.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* Tracking Grid */
.tracking-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.tracking-card .card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.tracking-card .icon {
    font-size: 1.2rem;
}

.tracking-card h4 {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Controls */
.counter-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-color);
    border-radius: var(--radius-full);
    padding: 4px;
}

.counter-control button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: white;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    font-weight: bold;
    color: var(--primary-dark);
}

.counter-control .value {
    font-weight: 700;
    font-size: 0.9rem;
}

.segment-control {
    display: flex;
    background: var(--bg-color);
    border-radius: var(--radius-md);
    padding: 4px;
}

.segment-control button {
    flex: 1;
    border: none;
    background: none;
    padding: 6px 0;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-light);
}

.segment-control button.active {
    background: white;
    color: var(--primary-dark);
    box-shadow: var(--shadow-sm);
    font-weight: 700;
}

.mood-selector {
    display: flex;
    justify-content: space-between;
}

.mood-selector button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.5;
    transition: transform 0.2s;
}

.mood-selector button.active {
    opacity: 1;
    transform: scale(1.2);
}

input[type="range"] {
    width: 100%;
    margin-bottom: 4px;
}

.range-value {
    display: block;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-dark);
}

/* Card Library */
.category-title {
    margin-bottom: 12px;
    color: var(--text-light);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.library-card {
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    border: 2px solid transparent;
}

.library-card.active {
    border-color: var(--success);
    background-color: #F0FFF4;
}

.library-card.locked {
    opacity: 0.7;
    background-color: #f9f9f9;
}

.card-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    border-radius: var(--radius-md);
}

.card-content {
    flex: 1;
}

.card-content h5 {
    margin-bottom: 4px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-content p {
    font-size: 0.8rem;
    color: var(--text-light);
}

.premium-badge {
    background: var(--warning);
    color: white;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 800;
}

.card-action {
    font-size: 1.2rem;
    color: var(--text-light);
}

.library-card.active .card-action {
    color: var(--success);
}

/* Active Card Forms */
.active-card-form {
    border-top: 4px solid var(--secondary-color);
}

.remove-card-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.2rem;
    cursor: pointer;
}

.form-group-sm {
    margin-bottom: 12px;
}

.form-group-sm label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.form-group-sm input,
.form-group-sm select {
    padding: 8px;
    font-size: 0.9rem;
}

/* Timeline */
.timeline-card {
    border-left: 4px solid var(--primary-color);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 700;
    color: var(--text-main);
}

.timeline-body .summary-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.timeline-body .summary-chips span {
    background: var(--bg-color);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-light);
}

.mini-tag {
    display: inline-block;
    background: #FFF0F5;
    color: var(--primary-dark);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    margin-right: 4px;
    margin-bottom: 4px;
}

/* Insights */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stat-card {
    text-align: center;
    padding: 12px;
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary-dark);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-light);
}

.tip-card {
    background: linear-gradient(135deg, #fff, #f0f4ff);
    border: 1px solid #e0e7ff;
}

.tip-card h4 {
    color: var(--secondary-color);
    margin-bottom: 8px;
}

.tip-card p {
    font-size: 0.9rem;
    color: var(--text-main);
}

/* Settings */
.settings-section {
    margin-bottom: 24px;
}

.settings-section h3 {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 12px;
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.text-sm {
    font-size: 0.8rem;
}

.text-light {
    color: var(--text-light);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--primary-color);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked+.slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.btn-outline {
    background: white;
    border: 2px solid #eee;
    color: var(--text-main);
    padding: 10px;
    border-radius: var(--radius-md);
    width: 100%;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-dark);
}

.btn-outline.danger {
    color: var(--danger);
    border-color: #ffebee;
}

.btn-outline.danger:hover {
    background-color: #ffebee;
    border-color: var(--danger);
}