:root {
    --bg-color: #050505;
    --text-main: #f0f0f0;
    --text-muted: #888888;
    --accent: #ffffff;
    --glass-bg: rgba(20, 20, 20, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden; /* Prevent scrolling entirely */
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Space Grotesk', sans-serif;
    position: relative;
    overscroll-behavior: none; /* Prevent pull-to-refresh on mobile */
}

/* Background Canvas */
#bg-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: auto; /* Allow touch interaction with canvas */
}

/* UI Layer */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    pointer-events: none; /* Let touches pass through where there is no UI */
}

#ui-layer > * {
    pointer-events: auto; /* Re-enable for header, main, footer */
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -1px;
}

.logo span {
    color: var(--text-muted);
}

#menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    gap: 6px;
}

#menu-btn .bar {
    width: 24px;
    height: 2px;
    background-color: var(--text-main);
    transition: width 0.3s ease;
}

#menu-btn:active .bar {
    width: 16px;
}

/* Main Content */
main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 32px;
}

.content-wrapper {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

h1 {
    font-size: clamp(3rem, 10vw, 5rem);
    line-height: 1.1;
    font-weight: 500;
    letter-spacing: -2px;
    margin-bottom: 16px;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 40px;
    font-weight: 300;
    max-width: 80%;
}

/* Buttons */
.primary-btn {
    background-color: var(--accent);
    color: var(--bg-color);
    border: none;
    padding: 16px 32px;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    border-radius: 100px;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 100%;
    max-width: 300px;
}

.primary-btn:active {
    transform: scale(0.95);
}

.cta-group {
    position: relative;
    height: 60px; /* Reserve space to prevent layout shift */
}

#cta-message {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    color: #4ade80;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Footer */
footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.footer-links {
    display: flex;
    gap: 16px;
}

.text-link {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Modals */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

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

.modal-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
}

.modal-content {
    position: relative;
    z-index: 101;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 40px 32px;
}

/* Glassmorphism for content modal */
#content-modal .modal-bg {
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#content-modal .modal-content.glass {
    height: 80%;
    width: 90%;
    max-width: 500px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 32px;
    margin: auto;
    box-shadow: 0 24px 48px rgba(0,0,0,0.5);
    transform: translateY(20px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.close-btn {
    position: absolute;
    top: 24px;
    right: 24px;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    width: 44px;
    height: 44px;
    z-index: 102;
}

/* Menu Modal Specifics */
#nav-modal nav {
    margin: auto 0;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 3rem;
    font-weight: 500;
    text-align: left;
    letter-spacing: -1px;
    cursor: pointer;
    transition: color 0.2s;
    opacity: 0;
    transform: translateY(20px);
}

#nav-modal.active .nav-item {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

#nav-modal.active .nav-item:nth-child(1) { transition-delay: 0.1s; }
#nav-modal.active .nav-item:nth-child(2) { transition-delay: 0.2s; }
#nav-modal.active .nav-item:nth-child(3) { transition-delay: 0.3s; }

/* Content Modal Specifics */
.scroll-container {
    overflow-y: auto;
    height: 100%;
    padding-right: 10px;
    margin-top: 40px;
}

.scroll-container::-webkit-scrollbar { width: 4px; }
.scroll-container::-webkit-scrollbar-track { background: transparent; }
.scroll-container::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }

#content-title {
    font-size: 2rem;
    margin-bottom: 24px;
    font-weight: 500;
}

#content-body {
    color: var(--text-muted);
    line-height: 1.6;
    font-size: 1.1rem;
}

#content-body p { margin-bottom: 16px; }
#content-body ul { margin-left: 20px; margin-bottom: 16px; }
#content-body li { margin-bottom: 8px; }

/* Initial Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.fade-in { animation: fadeIn 1s ease forwards; }
.fade-in-up { animation: fadeInUp 1s cubic-bezier(0.16, 1, 0.3, 1) forwards; animation-delay: 0.3s; opacity: 0; }
.reveal-text { animation: fadeInUp 1s cubic-bezier(0.16, 1, 0.3, 1) forwards; opacity: 0; }

/* Environment Page Styles */
.env-layout { pointer-events: auto; }
.env-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--glass-border); padding: 16px 32px; background: rgba(5,5,5,0.8); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 20; position: relative; }
.view-toggles { display: flex; gap: 8px; background: rgba(255,255,255,0.05); padding: 4px; border-radius: 100px; }
.view-btn { background: none; border: none; color: var(--text-muted); padding: 8px 16px; border-radius: 100px; cursor: pointer; transition: all 0.3s ease; font-family: inherit; font-size: 0.9rem; }
.view-btn.active { background: var(--text-main); color: var(--bg-color); }
.env-main { flex-grow: 1; padding: 32px; overflow-y: auto; display: flex; flex-direction: column; align-items: center; }
.env-content-wrapper { width: 100%; max-width: 600px; animation: fadeIn 0.5s ease; }

/* Todo Items */
.todo-item { display: flex; align-items: flex-start; gap: 16px; padding: 16px 0; border-bottom: 1px solid rgba(255,255,255,0.05); transition: opacity 0.3s; }
.todo-item.completed { opacity: 0.4; }
.todo-item.completed .todo-title { text-decoration: line-through; }
.todo-checkbox { width: 20px; height: 20px; border: 1px solid var(--text-muted); border-radius: 50%; display: flex; justify-content: center; align-items: center; cursor: pointer; margin-top: 2px; transition: all 0.2s; flex-shrink: 0; }
.todo-item.completed .todo-checkbox { background: var(--text-muted); }
.todo-content { flex-grow: 1; }
.todo-title { font-size: 1.1rem; color: var(--text-main); margin-bottom: 4px; transition: all 0.2s; }
.todo-meta { font-size: 0.8rem; color: var(--text-muted); }

/* Hour View */
.hour-view { text-align: center; margin-top: 10vh; }
.hour-view .focus-label { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 2px; color: var(--text-muted); margin-bottom: 16px; }
.hour-view .focus-task { font-size: 3rem; line-height: 1.2; letter-spacing: -1px; margin-bottom: 32px; font-weight: 500; }
.timer-display { font-variant-numeric: tabular-nums; font-size: 4rem; font-weight: 300; margin-bottom: 32px; letter-spacing: -2px; }
.timer-controls button { background: none; border: 1px solid var(--text-main); color: var(--text-main); padding: 16px 32px; border-radius: 100px; cursor: pointer; font-family: inherit; font-size: 1rem; transition: all 0.2s; }
.timer-controls button:hover, .timer-controls button.active { background: var(--text-main); color: var(--bg-color); }

/* Week View */
.week-day { margin-bottom: 32px; }
.week-day h3 { font-size: 1rem; color: var(--text-muted); margin-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 8px; font-weight: 500; }

/* Layout fix for mobile */
@media (max-width: 600px) {
    .env-header { flex-direction: column; gap: 20px; padding: 20px 16px; }
    .hour-view .focus-task { font-size: 2.2rem; }
    .timer-display { font-size: 3.5rem; }
    .env-main { padding: 24px 16px; }
}

/* Sutra Theme Override */
body.sutra-theme {
    --bg-color: #161412;
    --text-main: #e8dcca;
    --text-muted: #8c7e6e;
    --accent: #d65d38;
    --glass-bg: rgba(22, 20, 18, 0.85);
    --glass-border: rgba(214, 93, 56, 0.15);
}

body.sutra-theme .env-header {
    border-bottom-color: var(--glass-border);
}

body.sutra-theme .focus-task {
    font-family: 'Times New Roman', Times, serif;
    font-style: italic;
    color: var(--accent);
    font-weight: 300;
    letter-spacing: 0;
}

body.sutra-theme .view-toggles {
    background: rgba(214, 93, 56, 0.05);
}

/* Log View Styles */
.log-list { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.log-entry { display: flex; justify-content: space-between; align-items: center; padding: 16px; background: rgba(255,255,255,0.03); border-left: 2px solid var(--accent); border-radius: 0 8px 8px 0; }
.log-entry-info { display: flex; flex-direction: column; gap: 4px; }
.log-entry-title { font-weight: 500; font-size: 1.1rem; color: var(--text-main); }
.log-entry-date { font-size: 0.8rem; color: var(--text-muted); }
.log-entry-duration { font-variant-numeric: tabular-nums; font-family: monospace; font-size: 1.2rem; color: var(--accent); }
.total-time { text-align: center; margin-bottom: 32px; font-size: 1.2rem; color: var(--text-muted); }
.total-time span { color: var(--accent); font-weight: 700; font-family: monospace; font-size: 1.5rem; }