:root {
    --bg-dark: #0f172a;
    /* Slate 900 */
    --surface: #1e293b;
    /* Slate 800 */
    --surface-light: #334155;
    /* Slate 700 */
    --primary: #6366f1;
    /* Indigo 500 */
    --primary-hover: #4f46e5;
    /* Indigo 600 */
    --text: #f8fafc;
    /* Slate 50 */
    --text-muted: #94a3b8;
    /* Slate 400 */
    --accent: #00ffa3;
    /* Antigravity Green */
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

#app {
    width: 100%;
    max-width: 480px;
    height: 100vh;
    position: relative;
    background: var(--bg-dark);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

/* Screens Setup */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateX(20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

/* Headers */
.app-header {
    padding: 40px 24px;
    text-align: center;
}

.app-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text), var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
    margin-bottom: 8px;
}

.app-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 500;
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.8rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.icon-btn:active {
    background: rgba(255, 255, 255, 0.1);
}

.top-nav h2 {
    font-size: 1.3rem;
    font-weight: 600;
}

/* Screen 1: Splits */
.split-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 0 24px;
    flex: 1;
}

.glass-card {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 30px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:active {
    transform: scale(0.96);
    background: rgba(30, 41, 59, 1);
}

.glass-card h2 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.glass-card ion-icon {
    font-size: 2.5rem;
    color: var(--primary);
}

/* Screen 2: Lists */
.list-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.list-container::-webkit-scrollbar {
    display: none;
}

.list-item {
    background: var(--surface);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.list-item:active {
    transform: scale(0.98);
    background: var(--surface-light);
}

.list-item ion-icon {
    color: var(--text-muted);
}

/* Swipe to Delete */
.swipe-container {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    margin-bottom: 12px;
}

.swipe-action {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 100%;
    background: var(--danger, #ff4d4f);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 24px;
    color: white;
    font-size: 1.5rem;
    border-radius: 16px;
    z-index: 1;
}

.swipe-content {
    position: relative;
    z-index: 2;
    transition: transform 0.2s ease-out;
    background: var(--surface);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
}

.swipe-content:active {
    transform: scale(0.98);
    background: var(--surface-light);
}

.swipe-content ion-icon {
    color: var(--text-muted);
}

:root.light-theme .swipe-content {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

:root.light-theme .swipe-content:active {
    background: rgba(255, 255, 255, 1);
}

/* Screen 3: Log */
.log-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 24px;
    gap: 30px;
    overflow-y: auto;
}

.use-last-bar {
    display: flex;
    gap: 12px;
}

.last-btn {
    flex: 1;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    border: 2px solid rgba(99, 102, 241, 0.3);
    padding: 14px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.last-btn:active {
    background: rgba(99, 102, 241, 0.3);
    transform: scale(0.95);
}

.modifier-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.mod-label {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: var(--surface);
    border-radius: 24px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.step-btn {
    width: 70px;
    height: 70px;
    border-radius: 20px;
    background: var(--surface-light);
    border: none;
    color: var(--text);
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.1s, transform 0.1s;
}

.step-btn:active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(0.9);
}

.step-val {
    font-size: 3.5rem;
    font-weight: 800;
    min-width: 120px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.action-dock {
    padding: 20px 24px 40px;
    background: linear-gradient(to top, var(--bg-dark) 80%, transparent);
}

.log-action-btn {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 22px;
    border-radius: 20px;
    font-size: 1.4rem;
    font-weight: 700;
    font-family: inherit;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
    transition: transform 0.1s, background 0.2s;
}

.log-action-btn:active {
    transform: scale(0.96);
    background: var(--primary-hover);
}

/* Toast */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: var(--bg-dark);
    padding: 16px 32px;
    border-radius: 40px;
    font-weight: 700;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 30px rgba(0, 255, 163, 0.4);
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
    pointer-events: none;
}

.toast.show {
    bottom: 50px;
}

/* Screen 4: Stats */
.stats-content {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.chart-container {
    height: 300px;
    padding: 20px;
    background: rgba(30, 41, 59, 0.4);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.summary-card {
    padding: 24px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(0, 255, 163, 0.1));
    text-align: center;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.summary-card h3 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-top: 8px;
    color: var(--accent);
}

.summary-card small {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

/* Bottom Navigation */
.bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-around;
    padding: 12px 0;
    padding-bottom: env(safe-area-inset-bottom, 12px);
    z-index: 50;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.2s;
    width: 80px;
}

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

.nav-btn span {
    font-size: 0.75rem;
    font-weight: 600;
}

/* --- LIGHT THEME OVERRIDES --- */
:root.light-theme {
    --bg-dark: #f0f4f8; 
    --surface: #ffffff;
    --surface-light: #e2e8f0;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --text: #0f172a;
    --text-muted: #64748b;
    --accent: #10b981; 
}

:root.light-theme .glass-card,
:root.light-theme .chart-container {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

:root.light-theme .glass-card:active {
    background: rgba(255, 255, 255, 1);
}

:root.light-theme .top-nav,
:root.light-theme .bottom-nav {
    border-color: rgba(0, 0, 0, 0.05);
}

:root.light-theme .bottom-nav {
    background: rgba(240, 244, 248, 0.95);
}

:root.light-theme .icon-btn:active,
:root.light-theme .step-btn:active {
    background: rgba(0, 0, 0, 0.05);
}

:root.light-theme .stepper {
    border-color: rgba(0, 0, 0, 0.05);
}

:root.light-theme input,
:root.light-theme select {
    background: rgba(255, 255, 255, 0.8) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    color: var(--text) !important;
}

:root.light-theme .summary-card {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(16, 185, 129, 0.05));
    border-color: rgba(0, 0, 0, 0.05);
}

:root.light-theme #theme-toggle-btn {
    background: rgba(0, 0, 0, 0.05) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    color: var(--text) !important;
}

:root.light-theme .toast {
    color: white;
}