:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --accent-orange: #f59e0b;
    --accent-indigo: #6366f1;
    --danger: #ef4444;

    --glass-blur: blur(12px);
    --shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', 'Noto Sans TC', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 90% 10%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 50% 90%, rgba(245, 158, 11, 0.1) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 480px; /* Mobile layout width */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: var(--shadow);
    background: rgba(15, 23, 42, 0.4);
}

/* Header */
.app-header {
    padding: 24px 20px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid var(--card-border);
}

.app-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    background: linear-gradient(to right, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 16px;
    letter-spacing: 1px;
}

.header-add-btn {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent-orange);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 6px 16px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.header-add-btn:active {
    transform: scale(0.95);
    background: rgba(245, 158, 11, 0.3);
}

.bottom-sheet {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    width: 100%;
    max-width: 480px;
    border-radius: 24px 24px 0 0;
    padding: 24px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
    position: absolute;
    bottom: 0;
}

#add-menu-modal.active .bottom-sheet {
    transform: translateY(0);
}

.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    margin: 0 auto 20px auto;
}

.date-picker-container {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px 16px;
    border: 1px solid var(--card-border);
}

.date-picker-container i {
    color: var(--accent-blue);
    margin-right: 12px;
    font-size: 1.2rem;
}

.date-picker {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1.1rem;
    width: 100%;
    outline: none;
    color-scheme: dark;
}

/* Main Content */
.content {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    padding-bottom: 100px;
}

/* Meal Sections */
.meal-section {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    overflow: hidden;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    transition: var(--transition);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    cursor: pointer;
    user-select: none;
}

.title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 1.2rem;
}

.breakfast-icon { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.lunch-icon { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.dinner-icon { background: rgba(99, 102, 241, 0.2); color: #818cf8; }

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.toggle-icon {
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.meal-section.active .toggle-icon {
    transform: rotate(180deg);
}

.section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0, 1, 0, 1);
    background: rgba(0, 0, 0, 0.2);
}

.meal-section.active .section-body {
    max-height: 2000px;
    transition: max-height 0.6s ease-in-out;
}

/* Task List */
.task-list {
    padding: 0 16px;
}

.task-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    position: relative;
    animation: slideIn 0.3s ease forwards;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.task-item.done {
    opacity: 0.6;
}

.task-item.done .task-store-text,
.task-item.done .task-items-text {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.task-title {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    flex: 1;
}

.checkbox {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    border: 2px solid var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: var(--transition);
    flex-shrink: 0;
}

.task-item.done .checkbox {
    background: var(--accent-blue);
    color: white;
}

.task-title-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 2px;
}

.task-store-text {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.task-items-text {
    font-size: 1rem;
    color: var(--accent-orange);
    line-height: 1.5;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 12px;
    border-radius: 8px;
    margin-top: 4px;
    white-space: pre-wrap;
}

textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    padding: 14px 16px;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.05rem;
    outline: none;
    transition: var(--transition);
    font-family: inherit;
    resize: vertical;
}

textarea:focus {
    border-color: var(--accent-blue);
    background: rgba(255, 255, 255, 0.08);
}

.task-actions {
    display: flex;
    gap: 12px;
    margin-left: 10px;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}

.action-btn:hover { color: var(--text-primary); }
.action-btn.delete:hover { color: var(--danger); }

.task-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-left: 36px;
}

.empty-state {
    text-align: center;
    padding: 30px 0;
    color: var(--text-secondary);
    display: none;
}

/* Roster Tags (Multiple Selection) */
.roster-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 4px;
}
.roster-tag {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    padding: 8px 14px;
    border-radius: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.roster-tag:active {
    transform: scale(0.95);
}
.roster-tag.selected {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 500;
}

.detail-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: var(--transition);
}

.detail-link i {
    color: var(--accent-blue);
    width: 16px;
    text-align: center;
}

.detail-link:hover, .detail-link:active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Add Button */
.add-btn {
    width: calc(100% - 32px);
    margin: 4px 16px 16px 16px;
    padding: 14px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px dashed var(--accent-blue);
    color: var(--accent-blue);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.add-btn:active {
    background: rgba(59, 130, 246, 0.2);
    transform: scale(0.98);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    width: 100%;
    max-width: 480px;
    border-radius: 24px 24px 0 0;
    padding: 24px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

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

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

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

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

.form-group label i {
    margin-right: 6px;
}

.form-group input, .form-group select {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    padding: 14px 16px;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1.05rem;
    outline: none;
    transition: var(--transition);
}

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f8fafc' 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 16px center;
    background-size: 16px;
}

.form-group select option {
    background: var(--bg-color);
    color: var(--text-primary);
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--accent-blue);
    background: rgba(255, 255, 255, 0.08);
}

.person-badge {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.9rem;
    margin-right: 8px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    vertical-align: middle;
}

.submit-btn {
    width: 100%;
    padding: 16px;
    margin-top: 16px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-indigo));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    transition: var(--transition);
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: linear-gradient(to right, #10b981, #059669);
    color: white;
    padding: 12px 24px;
    border-radius: 100px;
    font-weight: 500;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
    z-index: 1000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Desktop Scrollbar Styling */
@media (min-width: 480px) {
    ::-webkit-scrollbar { width: 8px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 10px;
    }
    ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }
}

/* Summary Container */
.summary-container {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
    border: 1px solid var(--accent-blue);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 8px;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
    padding-bottom: 12px;
}

.summary-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.summary-filter input[type="date"] {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
    color-scheme: dark;
}

.summary-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--accent-blue);
}

.copy-btn {
    background: rgba(59, 130, 246, 0.2);
    color: var(--text-primary);
    border: 1px solid var(--accent-blue);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.copy-btn:active {
    background: var(--accent-blue);
}

.summary-content {
    font-family: inherit;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.summary-block {
    margin-bottom: 16px;
}

.summary-block:last-child {
    margin-bottom: 0;
}

.summary-date {
    font-weight: 700;
    color: var(--accent-orange);
    margin-bottom: 4px;
}

.summary-item {
    padding-left: 0;
    margin-bottom: 4px;
    white-space: pre-wrap;
    color: var(--text-primary);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 8px 0;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--card-border);
}
.divider::before { margin-right: .5em; }
.divider::after { margin-left: .5em; }

.header-actions {
    display: flex;
    gap: 8px;
}

.price-qty-group {
    display: flex;
    gap: 16px;
}

.form-group.half {
    flex: 1;
}

.total-price-display {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent-orange);
    text-align: right;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.summary-grand-total {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed rgba(255, 255, 255, 0.2);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent-orange);
    text-align: right;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 8px;
}

.quick-btn {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.2));
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 16px 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

.quick-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.12);
}

.quick-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.full-screen-modal {
    max-height: 90vh;
    height: 90vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
}

.full-screen-modal .modal-header {
    margin-bottom: 16px;
}
