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

:root {
    --bg: #1a1d23;
    --bg-card: #1e2028;
    --bg-elevated: #22252d;
    --bg-sheet: #262a33;
    --bg-input: #2a2d35;
    --border: #2a2d35;
    --border-strong: #374151;
    --text: #e5e7eb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    --accent: #10b981;
    --accent-hover: #059669;
    --btn-bg: #374151;
    --btn-border: #4b5563;
    --overlay: rgba(0,0,0,0.6);
}

[data-theme="light"] {
    --bg: #f3f4f6;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;
    --bg-sheet: #f9fafb;
    --bg-input: #f9fafb;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text: #1f2937;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --text-dim: #9ca3af;
    --accent: #059669;
    --accent-hover: #047857;
    --btn-bg: #e5e7eb;
    --btn-border: #d1d5db;
    --overlay: rgba(0,0,0,0.4);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding-top: 48px;
    padding-bottom: 72px;
    min-height: 100vh;
}

/* Top header */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

.top-brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

#top-page-title {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 15px;
}

.top-profile {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.undo-btn {
    background: var(--btn-bg);
    border: 1px solid var(--btn-border);
    color: var(--text);
    font-size: 18px;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}
.undo-btn:active { background: var(--btn-border); }

/* AI Usage Stats */
.ai-stat-box {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}
.ai-stat-val {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}
.ai-stat-label {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
}
.ai-user-row {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.ai-user-email {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.ai-user-stats {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-dim);
}
.ai-user-stats span:first-child {
    color: var(--accent);
    font-weight: 600;
}
.ai-user-types {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.ai-type-chip {
    font-size: 11px;
    background: var(--bg-input);
    color: var(--text-muted);
    padding: 1px 6px;
    border-radius: 3px;
}

/* Feedback attachment preview */
.fb-preview-wrap {
    position: relative;
    display: inline-block;
    margin-top: 8px;
}
.fb-preview-wrap img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 6px;
    border: 1px solid var(--border-strong);
}
.fb-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 500;
    padding: 8px 16px;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item .nav-icon {
    width: 28px;
    height: 28px;
}

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

/* Center + button */
.bottom-nav-add {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    margin-top: -24px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    transition: transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-add:active { transform: scale(0.92); }

.bottom-nav-add svg {
    width: 28px;
    height: 28px;
}

/* Loading bar */
#loading-bar {
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(16, 185, 129, 0.2);
    z-index: 101;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s;
}

#loading-bar.active { opacity: 1; }

#loading-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -40%;
    width: 40%;
    height: 100%;
    background: #10b981;
    animation: loading-slide 1s ease-in-out infinite;
}

@keyframes loading-slide {
    0% { left: -40%; }
    100% { left: 100%; }
}

/* Route views */
.route-view { display: none; }
.route-view.active { display: block; }

/* Container */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

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

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary { background: var(--bg-input); color: var(--text-secondary); }
.btn-secondary:hover { background: var(--btn-bg); }

.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
    color: var(--text);
}

.btn-icon:hover { opacity: 1; }

/* Empty state */
.empty-state {
    text-align: center;
    color: var(--text-dim);
    padding: 40px 20px;
    font-size: 15px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

/* Form inputs */
input[type="text"],
input[type="number"],
input[type="date"],
select {
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    font-size: 16px;
    background: var(--bg-input);
    color: var(--text);
    width: 100%;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}

/* Section headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

h2 { color: var(--text); }

/* Add Menu Bottom Sheet */
.add-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.add-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.add-sheet {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-sheet);
    border-radius: 20px 20px 0 0;
    padding: 28px 24px 40px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.add-overlay.open .add-sheet {
    transform: translateY(0);
}

.add-sheet-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    max-width: 450px;
    margin: 0 auto;
}

.add-sheet-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    padding: 8px 0;
    -webkit-tap-highlight-color: transparent;
}

.add-sheet-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}

.add-sheet-item:active .add-sheet-icon {
    transform: scale(0.9);
}

.add-sheet-icon svg {
    width: 26px;
    height: 26px;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-content {
    background: var(--bg-elevated);
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 600;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.form-row {
    display: flex;
    gap: 12px;
}

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

textarea {
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text);
    width: 100%;
    resize: vertical;
    font-family: inherit;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

/* Feedback list */
.feedback-item {
    cursor: pointer;
    transition: border-color 0.2s;
}

.feedback-item:hover {
    border-color: var(--border-strong);
}

.fb-item-header {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.fb-item-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    margin-bottom: 4px;
}

.fb-item-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
    white-space: pre-wrap;
    max-height: 60px;
    overflow: hidden;
}

.fb-item-meta {
    font-size: 12px;
    color: var(--text-dim);
}

/* Feedback badges */
.fb-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

.fb-type-bug { background: rgba(239,68,68,0.15); color: #f87171; }
.fb-type-feature { background: rgba(59,130,246,0.15); color: #60a5fa; }
.fb-type-question { background: rgba(156,163,175,0.15); color: #9ca3af; }

.fb-priority-critical { background: rgba(239,68,68,0.2); color: #f87171; }
.fb-priority-high { background: rgba(239,68,68,0.15); color: #fca5a5; }
.fb-priority-medium { background: rgba(245,158,11,0.15); color: #fbbf24; }
.fb-priority-low { background: rgba(156,163,175,0.1); color: #9ca3af; }

.fb-status-open { background: rgba(59,130,246,0.15); color: #60a5fa; }
.fb-status-in-progress { background: rgba(245,158,11,0.15); color: #fbbf24; }
.fb-status-resolved { background: rgba(16,185,129,0.15); color: #34d399; }
.fb-status-closed { background: rgba(156,163,175,0.15); color: #9ca3af; }

/* Filter chips */
.fb-filter-chip {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 9999px;
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
}
.fb-filter-chip.active {
    background: rgba(16,185,129,0.15);
    color: #34d399;
    border-color: rgba(16,185,129,0.3);
}

/* Settings row */
.settings-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-row label {
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 14px;
}

.settings-row input {
    flex: 1;
}

/* Diet profile blocks */
.diet-blocks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.diet-block {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-strong);
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.diet-block:active {
    transform: scale(0.95);
}

.diet-block.active {
    border-color: #06b6d4;
    background: rgba(6, 182, 212, 0.15);
    color: #22d3ee;
}

/* Theme toggle */
.theme-toggle {
    display: flex;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-strong);
}

.theme-opt {
    padding: 4px 14px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.theme-opt.active {
    background: var(--accent);
    color: #fff;
}

/* Mobile responsive */
@media (max-width: 640px) {
    .container { padding: 12px 8px; }
}

@media (max-width: 374px) {
    .bottom-nav-item { padding: 8px 8px; font-size: 10px; }
    .bottom-nav-add { width: 48px; height: 48px; margin-top: -20px; }
    .bottom-nav-add svg { width: 24px; height: 24px; }
    .add-sheet-grid { gap: 8px; }
    .add-sheet-icon { width: 48px; height: 48px; }
    .add-sheet-item { font-size: 11px; }
}
