:root {
    --primary-color: #4a90e2;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-secondary: #888888;
    --accent-color: #ffcc00;
    --success-color: #2ecc71;
    --danger-color: #e74c3c;
    --nav-height: 70px;
    --header-height: 60px;
    --transition-speed: 0.3s;
    --safe-area-bottom: env(safe-area-inset-bottom);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 500px;
    margin: 0 auto;
    background: var(--bg-color);
    position: relative;
}

.app-header {
    height: var(--header-height);
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    z-index: 100;
}

.app-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
}

#content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    padding-bottom: calc(var(--nav-height) + 20px);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 500px;
    height: calc(var(--nav-height) + var(--safe-area-bottom));
    background: var(--card-bg);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    padding-bottom: var(--safe-area-bottom);
    z-index: 100;
}

.nav-item {
    border: none;
    background: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--transition-speed);
    flex: 1;
}

.nav-item i {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.nav-item span {
    font-size: 0.75rem;
}

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

/* Components */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* UI Elements */
.input-group {
    margin-bottom: 15px;
}

.input-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

select,
input,
textarea {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: var(--card-bg);
    font-size: 1rem;
    color: var(--text-color);
    outline: none;
    transition: border var(--transition-speed);
}

select:focus,
input:focus {
    border-color: var(--primary-color);
}

.btn {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

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

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

/* Record List */
.record-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.record-item:last-child {
    border-bottom: none;
}

.record-info h4 {
    font-size: 1rem;
    font-weight: 500;
}

.record-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.rating {
    color: var(--accent-color);
}

/* Food Grid */
.food-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.food-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border-radius: 12px;
    background: var(--bg-color);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.food-item i {
    font-size: 1.5rem;
    margin-bottom: 5px;
    color: var(--text-secondary);
}

.food-item span {
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

.food-item.active {
    background: #eef5ff;
    border-color: var(--primary-color);
}

.food-item.active i {
    color: var(--primary-color);
}

/* Star Rating */
.star-rating {
    display: flex;
    gap: 10px;
    font-size: 1.8rem;
    justify-content: center;
    margin: 15px 0;
}

.star-rating i {
    cursor: pointer;
    color: #ddd;
    transition: color 0.2s;
}

.star-rating i.active {
    color: var(--accent-color);
}

/* Night Mode */
body.night-mode {
    --bg-color: #000000;
    --card-bg: #1a1a1a;
    --text-color: #ffffff;
    --text-secondary: #aaaaaa;
}

body.night-mode .nav-item {
    color: #666;
}

body.night-mode .nav-item.active {
    color: #4a90e2;
}

body.night-mode .timeline-content,
body.night-mode .status-chip,
body.night-mode .filter-chip,
body.night-mode input[type="date"],
body.night-mode select,
body.night-mode input,
body.night-mode textarea {
    background: #222;
    color: #eee;
    border-color: #333;
}

body.night-mode .status-chip.active {
    background: var(--primary-color);
    color: white;
}

body.night-mode .timeline-dot {
    border-color: #222;
}

body.night-mode .history-timeline::before {
    background: #333;
}

body.night-mode .record-item {
    border-bottom-color: #333;
}

body.night-mode .food-item {
    background: #222;
}

body.night-mode .food-item.active {
    background: #1a2a3a;
}

/* Circular Pee Button with Wave Animation */
.pee-circle-container {
    display: flex;
    justify-content: center;
    margin: 30px 0;
}

.pee-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 4px solid var(--primary-color);
    position: relative;
    overflow: hidden;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.pee-circle i {
    font-size: 2.5rem;
    color: var(--primary-color);
    z-index: 3;
    transition: color 0.3s;
}

.pee-circle.pressing i {
    color: white;
}

.water-wave {
    position: absolute;
    bottom: -100%;
    /* Start below */
    left: -50%;
    width: 200%;
    height: 200%;
    background: var(--primary-color);
    border-radius: 40%;
    z-index: 2;
    transition: bottom 0s linear;
}

.pee-circle.pressing .water-wave {
    bottom: -20%;
    /* Fill up */
    transition: bottom 3s linear;
    animation: waveRotate 2s infinite linear;
}

@keyframes waveRotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Ripple Wave Animation for Pee Button */
.pee-circle .ripple-wave {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, var(--primary-color) 0%, transparent 70%);
    border-radius: 50%;
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

.pee-circle.pressing .ripple-wave {
    animation: rippleEffect 1.5s infinite ease-out;
}

@keyframes rippleEffect {
    0% {
        transform: scale(0.5);
        opacity: 0.8;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* Poo Validation and Selected States */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #ccc;
}

.status-chip {
    padding: 10px 16px;
    border-radius: 12px;
    background: var(--bg-color);
    color: var(--text-color);
    border: 2px solid transparent;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-weight: 500;
}

.status-chip.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(1.08);
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.2);
}

/* Custom Water Input */
.custom-input-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 12px;
    margin-top: 15px;
    display: none;
    border-left: 4px solid var(--primary-color);
}


/* Emoji Style */
.food-item .emoji {
    font-size: 2rem;
    margin-bottom: 5px;
}

/* History Filters Multi-row Layout */
.history-filters {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 25px;
    align-items: center;
}

.filter-row {
    display: flex;
    gap: 30px;
    justify-content: center;
    width: 100%;
}

.filter-chip {
    padding: 8px 18px;
    border-radius: 25px;
    background: var(--card-bg);
    border: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    color: var(--text-color);
}

.filter-chip.active {
    background: linear-gradient(135deg, var(--primary-color), #64b5f6);
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

/* Date Picker Style */
.date-picker-container {
    margin: 10px 0 25px 0;
    display: flex;
    justify-content: center;
}

input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
    padding: 10px 20px;
    border-radius: 20px;
    border: 1px solid #ddd;
    background: var(--card-bg);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-color);
    outline: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

input[type="date"]:focus {
    border-color: var(--primary-color);
}

/* Record List Enhancements */
.record-list-mini {
    margin-top: 15px;
    border-top: 1px solid #f0f0f0;
    padding-top: 10px;
}

.record-item-mini {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 0.85rem;
    border-bottom: 1px dashed #f5f5f5;
}

.record-item-mini:last-child {
    border-bottom: none;
}


/* Git Graph Styles */
.history-timeline {
    position: relative;
    padding-left: 30px;
    margin-top: 20px;
}

.history-timeline::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e0e0e0;
}

.timeline-item {
    position: relative;
    margin-bottom: 12px;
}

.timeline-dot {
    position: absolute;
    left: -24px;
    top: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid white;
    z-index: 1;
}

.timeline-content {
    background: var(--card-bg);
    padding: 8px 12px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.timeline-content strong {
    font-size: 0.9rem;
}

.timeline-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 4px;
}

/* Poo Timer */
.timer-display {
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    margin: 10px 0;
}

/* Auth Page (Full-screen) */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: var(--bg-color);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 360px;
    padding: 40px 30px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

.auth-card h2 {
    font-size: 1.8rem;
    margin-bottom: 30px;
    color: var(--text-color);
    font-weight: 700;
}

.auth-input-container {
    margin-bottom: 20px;
}

.auth-input {
    width: 100%;
    padding: 15px 20px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
}

.auth-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.1);
}

.auth-submit-btn {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: none;
    background: var(--primary-color);
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
    transition: all 0.3s;
}

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

.auth-toggle {
    margin-top: 25px;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.auth-toggle span {
    color: var(--primary-color);
    cursor: pointer;
    font-weight: bold;
    margin-left: 5px;
}

.error-msg {
    color: var(--danger-color);
    font-size: 0.85rem;
    background: rgba(231, 76, 60, 0.1);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: left;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 5px 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.btn-text:hover {
    background: rgba(74, 144, 226, 0.05);
}

.app-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    height: var(--header-height);
    padding: 0 20px !important;
    background: var(--card-bg);
}

#user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#username-display {
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}