:root {
    --text: #1a1a1a;
    --text-secondary: #666666;
    --text-muted: #999999;
    --background: #f5f5f5;
    --surface: #ffffff;
    --border: #e0e0e0;
    --hover: #eeeeee;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --text: #f0f0f0;
        --text-secondary: #a0a0a0;
        --text-muted: #707070;
        --background: #0a0a0a;
        --surface: #1a1a1a;
        --border: #2a2a2a;
        --hover: #252525;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    padding-bottom: 70px;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, select {
    font-family: inherit;
    font-size: 1rem;
}

/* Container */
.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 1rem;
}

/* Card */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 44px;
}

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

.btn-primary:hover {
    opacity: 0.85;
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--hover);
}

.btn-ghost {
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--hover);
}

.btn-icon {
    padding: 0.5rem;
    border-radius: 50%;
}

.btn-block {
    width: 100%;
}

/* Input */
.input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.2s;
}

.input:focus {
    outline: none;
    border-color: var(--text-secondary);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Utility */
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 600; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Navigation */
.nav {
    display: flex;
    justify-content: space-around;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.5rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    min-width: 60px;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--hover);
}

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

.nav-item svg {
    width: 22px;
    height: 22px;
    margin-bottom: 0.2rem;
}

/* Activity Card */
.activity-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
}

.activity-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.activity-card:active {
    transform: translateY(0);
}

.activity-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.activity-goal {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.activity-progress {
    font-size: 1.25rem;
    font-weight: 600;
}

.activity-progress-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
}

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

/* Calendar */
.calendar {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.calendar-title {
    font-weight: 600;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.2rem;
    text-align: center;
}

.calendar-day-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.4rem 0;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.calendar-day:hover {
    background: var(--hover);
}

.calendar-day.today {
    border: 2px solid var(--text);
}

.calendar-day.selected {
    background: var(--text);
    color: var(--surface);
}

.calendar-day.has-activity {
    background: var(--border);
}

.calendar-day.has-activity.selected {
    background: var(--text);
}

.calendar-day.other-month {
    color: var(--text-muted);
    opacity: 0.4;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    font-size: 1.25rem;
}

/* Day Header */
.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--surface);
    margin-bottom: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.day-nav-btn {
    padding: 0.5rem;
    color: var(--text-secondary);
    border-radius: 50%;
}

.day-nav-btn:hover {
    background: var(--hover);
}

.day-title {
    font-weight: 600;
}

/* Log Item */
.log-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow);
}

.log-value {
    font-weight: 600;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state-clickable {
    cursor: pointer;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.empty-state-clickable:hover {
    background: var(--hover);
}

.empty-state-clickable:hover svg {
    opacity: 0.5;
}

/* Loading */
.loading {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-top-color: var(--text);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Section Title */
.section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

/* Manage List */
.manage-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow);
}

.manage-item-info h3 {
    font-size: 1rem;
    font-weight: 500;
}

.manage-item-info span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.manage-actions {
    display: flex;
    gap: 0.25rem;
}

/* Accordion */
.accordion-item {
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.accordion-header:hover {
    background: var(--hover);
}

.accordion-info {
    flex: 1;
}

.accordion-title {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.accordion-sum {
    font-size: 1.1rem;
    font-weight: 600;
}

.accordion-arrow {
    transition: transform 0.2s;
    color: var(--text-muted);
}

.accordion-item.expanded .accordion-arrow {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease-out;
}

.accordion-item.expanded .accordion-content {
    max-height: 500px;
}

.accordion-log-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
}

.accordion-log-item:first-child {
    border-top: 1px solid var(--border);
}

/* Day Activities */
.day-activities {
    margin-top: 1.5rem;
}

/* Safe area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .nav {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }
    body {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }
}
