:root {
    --bg-color: #00555a; /* Teal */
    --text-primary: #ffffff; /* White */
    --text-secondary: rgba(255, 255, 255, 0.7); /* Soft white */
    --accent-1: #ffc94b; /* Mimosa */
    --accent-hover: #e5b443;
    --card-bg: rgba(255, 255, 255, 0.08);
    --border-color: rgba(255, 255, 255, 0.15);
    --font-heading: 'Nunito', sans-serif;
    --font-body: 'Nunito', sans-serif;
    --font-serif: 'Lora', serif;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: var(--accent-1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Custom Text Selection */
::selection {
    background-color: var(--accent-1);
    color: #00454a;
}

/* Base UI */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 800;
}

.cozy-input, .cozy-select {
    background: rgba(0, 0, 0, 0.15);
    border: 2px solid var(--border-color);
    padding: 0.8rem 1rem;
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}
.cozy-input:focus, .cozy-select:focus {
    border-color: var(--accent-1);
}
.cozy-select { cursor: pointer; }
.cozy-select option { background: var(--bg-color); color: var(--text-primary); }

/* Topbar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px dashed var(--border-color);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.brand i {
    font-size: 2.2rem;
    color: var(--accent-1);
}

.brand h1 {
    font-size: 1.8rem;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.data-management {
    display: flex;
    gap: 0.5rem;
}

.stats-summary {
    display: flex;
    gap: 1rem;
}

.stat-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card-bg);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 2px solid var(--border-color);
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.stat-badge i.ph-plant { color: #81c784; font-size: 1.2rem; }
.stat-badge i.ph-clock-user { color: var(--accent-1); font-size: 1.2rem; }

/* Hero / Countdown & Goal */
.hero-panel {
    background: var(--card-bg);
    padding: 2rem;
    margin-bottom: 3rem;
    border-radius: 24px;
    border: 2px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.hero-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 6px;
    background: var(--accent-1);
}

.hero-top-row {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    align-items: center;
}

.hero-content {
    flex: 2;
    text-align: center;
}

.hero-content h2 {
    font-size: 1.4rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.countdown {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

.time-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    background: rgba(0,0,0,0.1);
    padding: 1rem;
    border-radius: 16px;
    border: 2px solid var(--border-color);
}

.time-block span {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-primary);
}

.time-block label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 700;
    margin-top: 0.5rem;
    text-transform: uppercase;
}

.separator {
    font-size: 2.5rem;
    color: var(--border-color);
    font-weight: 800;
    margin-top: -1.5rem;
}

/* Daily Goal Panel */
.daily-goal-panel {
    flex: 1;
    min-width: 280px;
    background: rgba(0, 0, 0, 0.15);
    padding: 1.5rem;
    border-radius: 20px;
    border: 2px solid var(--border-color);
    text-align: center;
}

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

.daily-goal-header h3 {
    font-size: 1.2rem;
    color: var(--accent-1);
}

.goal-text {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.8rem;
}

.goal-progress-bar {
    width: 100%;
    height: 12px;
    background: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.goal-progress-fill {
    height: 100%;
    background: var(--accent-1);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 6px;
}

.motivation-text {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-style: italic;
    color: var(--text-secondary);
}

/* Quick Start Widget */
.quick-start-widget {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px dashed var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    animation: fadeIn 0.5s;
}
.quick-start-widget p {
    font-weight: 600;
    color: var(--text-secondary);
}

/* Modules Section */
.section-title {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--text-primary);
}

.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.module-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 24px;
    border: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: transform 0.3s ease, border-color 0.3s ease;
    cursor: grab;
}

.module-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-1);
}
.module-card:active {
    cursor: grabbing;
}

/* SortableJS Premium Animation Classes */
.sortable-ghost {
    opacity: 0.4;
    background: rgba(0, 0, 0, 0.2) !important;
    border: 2px dashed var(--accent-1) !important;
    transform: scale(0.95);
    border-radius: 24px;
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sortable-chosen {
    z-index: 10;
}
.sortable-fallback {
    opacity: 0.95 !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3), 0 0 30px rgba(255, 201, 75, 0.15) !important;
    background: var(--card-bg) !important; 
    border-color: var(--accent-1) !important;
    cursor: grabbing !important;
    z-index: 99999 !important;
    rotate: 2.5deg;
    scale: 1.04;
    transition: rotate 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), 
                scale 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
                box-shadow 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}

.mod-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.mod-title {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.3;
    max-width: 80%;
}

/* Confidence Dots */
.confidence-toggle {
    display: flex;
    gap: 4px;
    cursor: pointer;
    padding: 4px;
    border-radius: 12px;
    transition: background 0.2s;
}
.confidence-toggle:hover {
    background: rgba(255,255,255,0.1);
}
.conf-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--border-color);
}
.conf-dot.active-low { background: #ff5252; box-shadow: 0 0 8px #ff5252; }
.conf-dot.active-med { background: #ffd740; box-shadow: 0 0 8px #ffd740; }
.conf-dot.active-high { background: #69f0ae; box-shadow: 0 0 8px #69f0ae; }


.mod-icon {
    font-size: 2rem;
    color: var(--accent-1);
}

.mod-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.mod-progress {
    width: 100%;
    height: 10px;
    background: var(--border-color);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--text-primary);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 5px;
}

.mod-actions {
    display: flex;
    gap: 0.8rem;
    margin-top: 0.5rem;
}

/* Buttons */
.btn {
    border: none;
    padding: 0.8rem 1.5rem;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1rem;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--accent-1);
    color: #00555a;
    flex: 1;
}
.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}
.btn-secondary:hover {
    background: var(--border-color);
}

.btn-icon {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 0.8rem;
    font-size: 1.2rem;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-icon:hover {
    background: var(--border-color);
}
.btn-sm { padding: 0.5rem; font-size: 1rem; }
.btn-full { width: 100%; }

/* Analytics Section */
.analytics-section {
    margin-top: 4rem;
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 24px;
    border: 2px solid var(--border-color);
}

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

.analytics-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.insights-container {
    margin-top: 2rem;
    padding: 1.5rem;
    background: rgba(0,0,0,0.15);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.insight-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--accent-1);
}

/* Modals Overlay Base */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    margin: auto;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    padding: 2.5rem;
    border-radius: 24px;
    position: relative;
    width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.btn-close {
    position: absolute;
    top: 1.5rem; right: 1.5rem;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 12px;
    color: var(--text-secondary);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex; align-items: center; gap: 0.5rem;
}
.btn-close:hover { 
    background: #ff5252; color: #fff; border-color: #ff5252;
}

/* Intent Prompt Modal */
.intent-modal {
    max-width: 450px;
    text-align: center;
}
.intent-subtitle {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}
.intent-modal textarea {
    margin-bottom: 1.5rem;
    resize: none;
}

/* Multi-purpose Module Modal */
.module-modal {
    max-width: 750px;
}
.module-modal h3 {
    font-size: 1.6rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.modal-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    overflow-x: auto;
}
.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s;
    display: flex; align-items: center; gap: 0.5rem;
    white-space: nowrap;
}
.tab-btn:hover { background: rgba(255,255,255,0.05); }
.tab-btn.active {
    background: var(--card-bg);
    color: var(--accent-1);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s; }

@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }

/* Tasks Tab */
.task-input-container { display: flex; gap: 0.8rem; margin-bottom: 1.5rem; }
.task-list { list-style: none; display: flex; flex-direction: column; gap: 0.8rem; max-height: 40vh; overflow-y: auto;}
.task-item {
    display: flex; align-items: center; gap: 1rem; padding: 1rem;
    background: rgba(0,0,0,0.1); border: 2px solid var(--border-color); border-radius: 16px;
}
.task-item.completed { opacity: 0.6; background: rgba(0,0,0,0.2); }
.task-item.completed .task-text { text-decoration: line-through; color: var(--text-secondary); }
.task-checkbox {
    width: 24px; height: 24px; border: 2px solid var(--text-primary); border-radius: 6px;
    cursor: pointer; display: flex; justify-content: center; align-items: center;
}
.task-item.completed .task-checkbox { background: var(--text-primary); border-color: var(--text-primary); }
.task-item.completed .task-checkbox::after { content: '✓'; color: #00555a; font-weight: bold; }
.task-text { flex: 1; font-weight: 600; }
.task-delete { background: none; border: none; color: #ff8a80; cursor: pointer; padding: 0.2rem; font-size: 1.4rem; border-radius: 8px; }
.task-delete:hover { background: #ff5252; color: #fff; }

/* Notes Tab */
.notes-textarea {
    height: 250px;
    resize: vertical;
    margin-bottom: 0.5rem;
}
.autosave-text {
    font-size: 0.85rem; color: #81c784; text-align: right;
    display: flex; justify-content: flex-end; align-items: center; gap: 0.3rem;
    opacity: 0; transition: opacity 0.3s;
}
.autosave-text.visible { opacity: 1; }

/* Resources Tab */
.resource-input-container { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.5rem; }
.resource-input-container .cozy-input { margin-bottom: 0; }
.resource-list { list-style: none; display: flex; flex-direction: column; gap: 0.8rem; max-height: 40vh; overflow-y: auto; }
.resource-item {
    display: flex; justify-content: space-between; align-items: center; padding: 1rem;
    background: rgba(0,0,0,0.1); border: 2px solid var(--border-color); border-radius: 16px;
}
.res-info { display: flex; flex-direction: column; gap: 0.2rem; overflow: hidden; flex: 1; }
.res-title { font-weight: 700; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.res-link { font-size: 0.85rem; color: var(--accent-1); text-decoration: none; }
.res-link:hover { text-decoration: underline; }

/* Logs Tab */
.log-list { list-style: none; display: flex; flex-direction: column; gap: 0.8rem; max-height: 40vh; overflow-y: auto; }
.log-item {
    display: flex; flex-direction: column; gap: 0.5rem; padding: 1rem;
    background: rgba(0,0,0,0.15); border: 2px solid var(--border-color); border-radius: 16px;
}
.log-item.distraction { border-left: 4px solid #ff5252; }
.log-item.study { border-left: 4px solid #69f0ae; }
.log-header { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-secondary); font-weight: 700; }
.log-body { font-weight: 600; color: var(--text-primary); }

/* Deep Focus & Calendar */
.deep-focus-toggle {
    display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.deep-focus-label { font-weight: 700; color: #ff5252; font-size: 0.95rem; display: flex; align-items: center; gap: 5px; }

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--border-color);
  transition: .4s;
}
.slider:before {
  position: absolute; content: "";
  height: 16px; width: 16px; left: 4px; bottom: 4px;
  background-color: white;
  transition: .4s;
}
input:checked + .slider {
  background-color: #ff5252;
}
input:checked + .slider:before {
  transform: translateX(20px);
}
.slider.round {
  border-radius: 24px;
}
.slider.round:before {
  border-radius: 50%;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 10px;
    margin-top: 1rem;
}
.cal-box {
    aspect-ratio: 1;
    background: rgba(0,0,0,0.15);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 800;
}
.cal-box.today {
    background: var(--accent-1);
    color: var(--bg-color);
    border-color: var(--accent-1);
    box-shadow: 0 0 15px rgba(255, 201, 75, 0.4);
}
.cal-box:hover {
    border-color: var(--accent-1);
}

/* Focus Overlay */
.focus-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 85, 90, 0.98);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
.focus-overlay.active { opacity: 1; pointer-events: all; }

.focus-container {
    width: 90%; max-width: 600px; margin: auto;
    background: var(--card-bg); padding: 3rem; border-radius: 32px;
    text-align: center; position: relative; border: 2px solid var(--border-color);
}

.audio-controls {
    position: absolute;
    top: 1.5rem; left: 1.5rem;
    display: flex;
    gap: 0.5rem;
}
.btn-audio {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    width: 40px; height: 40px;
    border-radius: 12px;
    cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    font-size: 1.2rem;
    transition: all 0.2s;
}
.btn-audio:hover {
    border-color: var(--accent-1); color: var(--accent-1);
}
.btn-audio.active {
    background: var(--accent-1); color: #00555a; border-color: var(--accent-1);
}

.focus-module-title { font-size: 2rem; margin-bottom: 1rem; color: var(--text-primary); }

.intent-display {
    display: inline-flex; align-items: center; gap: 0.5rem;
    background: rgba(255,201,75,0.15); border: 1px solid var(--accent-1);
    color: var(--accent-1); padding: 0.6rem 1.2rem; border-radius: 20px;
    font-weight: 600; margin-bottom: 2rem; max-width: 100%;
}
.intent-display span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.timer-display { position: relative; width: 300px; height: 300px; margin: 0 auto 2rem; }
.progress-ring__circle { transition: stroke-dashoffset 1s linear; transform: rotate(-90deg); transform-origin: 50% 50%; stroke-linecap: round; }
.progress-ring__circle-bg { transform: rotate(-90deg); transform-origin: 50% 50%; }
.time-left { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 5rem; font-weight: 800; letter-spacing: -2px; }

.timer-controls { display: flex; flex-direction: column; gap: 1.5rem; align-items: center; margin-bottom: 2rem; }
.timer-inputs { display: flex; align-items: center; gap: 0.5rem; background: rgba(0,0,0,0.15); padding: 0.5rem; border-radius: 16px; border: 2px solid var(--border-color); }
.timer-inputs input { width: 60px; text-align: center; font-family: var(--font-heading); font-weight: 700; font-size: 1.1rem; border: none; background: transparent; color: var(--text-primary); outline: none; }
.timer-inputs span { font-weight: 600; color: var(--text-secondary); padding-right: 0.5rem; }
.timer-main-actions { display: flex; gap: 1rem; }
.timer-main-actions .btn { min-width: 120px; }

.timer-presets { display: flex; gap: 0.5rem; background: rgba(0,0,0,0.15); padding: 0.4rem; border-radius: 16px; border: 2px solid var(--border-color); flex-wrap: wrap; justify-content: center; }
.btn-mode { background: none; border: none; color: var(--text-secondary); padding: 0.6rem 1.2rem; border-radius: 12px; cursor: pointer; font-family: var(--font-body); font-weight: 700; transition: all 0.2s; }
.btn-mode.active { background: var(--bg-color); color: var(--text-primary); border: 1px solid var(--border-color); }

.focus-warning { color: var(--text-secondary); font-weight: 600; font-size: 1.1rem; }

/* Responsive */
@media (max-width: 768px) {
    .hero-top-row { flex-direction: column; }
    .daily-goal-panel { width: 100%; }
    .time-block { min-width: 60px; padding: 0.8rem; }
    .time-block span { font-size: 2rem; }
    .separator { font-size: 2rem; margin-top: -1rem; }
    .focus-container { padding: 2rem 1.5rem; }
    .time-left { font-size: 4rem; }
    .timer-display { width: 250px; height: 250px; }
    .progress-ring { width: 250px; height: 250px; }
    .progress-ring__circle, .progress-ring__circle-bg { r: 115; cx: 125; cy: 125; }
    .modal { padding: 1.5rem; }
    .resource-input-container { flex-direction: column; }
}
