:root {
    --primary: #00b894;
    --primary-light: #55efc4;
    --primary-dark: #00a381;
    --accent: #fd79a8;
    --accent-light: #fdcb6e;
    --ocean: #74b9ff;
    --ocean-dark: #0984e3;
    --sand: #ffeaa7;
    --sand-dark: #fdcb6e;
    --bg: #f0faf5;
    --bg-card: #ffffff;
    --text: #2d3436;
    --text-light: #636e72;
    --text-muted: #b2bec3;
    --danger: #ff7675;
    --overclock: #e17055;
    --shadow: 0 4px 15px rgba(0, 184, 148, 0.15);
    --shadow-lg: 0 8px 30px rgba(0, 184, 148, 0.2);
    --radius: 16px;
    --radius-sm: 10px;
}

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

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    padding-bottom: 80px;
}

#app {
    max-width: 500px;
    margin: 0 auto;
    position: relative;
}

/* Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    z-index: 100;
}

.nav-btn {
    background: none;
    border: none;
    font-family: 'Poppins', sans-serif;
    font-size: 11px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
}

.nav-btn.active {
    color: var(--primary);
    background: rgba(0, 184, 148, 0.1);
    font-weight: 600;
}

/* Pages */
.page {
    display: none;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

/* Tropical Header */
.tropical-header {
    text-align: center;
    padding: 20px 0 10px;
}

.tropical-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.tropical-header .subtitle {
    color: var(--text-light);
    font-size: 14px;
    margin-top: 4px;
}

/* Dopamine Stats Bar */
.dopamine-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: 50px;
    padding: 10px 24px;
    box-shadow: var(--shadow);
    margin: 8px 0 12px;
    gap: 16px;
}

.dopa-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.dopa-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.dopa-label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dopa-divider {
    width: 1px;
    height: 30px;
    background: #e0f5ed;
}

/* Achievement Banner */
.achievement-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
    border-radius: var(--radius);
    padding: 12px 18px;
    margin: 8px 0;
    animation: slideDown 0.5s ease, glowPulse 2s infinite;
    font-size: 13px;
    font-weight: 600;
    color: #2d3436;
}

.achievement-icon {
    font-size: 24px;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(253, 203, 110, 0.3); }
    50% { box-shadow: 0 4px 25px rgba(253, 203, 110, 0.6); }
}

/* Milestone Card */
.milestone-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px 18px;
    box-shadow: var(--shadow);
    margin: 8px 0;
}

.milestone-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}

.milestone-name {
    color: var(--primary);
    font-weight: 700;
}

.milestone-progress-bar {
    height: 8px;
    background: #e0f5ed;
    border-radius: 50px;
    overflow: hidden;
    margin-bottom: 6px;
}

.milestone-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 50px;
    transition: width 0.8s ease;
}

.milestone-detail {
    font-size: 11px;
    color: var(--text-muted);
}

/* Timer */
.timer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
}

.timer-ring {
    position: relative;
    width: 240px;
    height: 240px;
    margin: 8px 0;
}

.timer-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: #e0f5ed;
    stroke-width: 8;
}

.ring-progress {
    fill: none;
    stroke: var(--primary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 565.48;
    stroke-dashoffset: 565.48;
    transition: stroke-dashoffset 0.5s ease, stroke 0.3s ease;
}

.ring-progress.overclock {
    stroke: var(--overclock);
}

.timer-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

#timerText {
    font-size: 48px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.timer-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 4px;
}

.timer-label.overclock-label {
    color: var(--overclock);
}

.goal-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    padding: 8px 18px;
    border-radius: 50px;
    box-shadow: var(--shadow);
    margin: 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
}

.overclock-badge {
    background: linear-gradient(135deg, var(--overclock), #e17055);
    color: white;
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    animation: pulse 1s infinite;
    margin: 6px 0;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.timer-controls {
    margin-top: 14px;
    display: flex;
    gap: 12px;
}

/* Quick Stats */
.quick-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 16px 0;
}

.quick-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.2s ease;
}

.quick-card:active {
    transform: scale(0.97);
}

.quick-card-icon {
    font-size: 22px;
    margin-bottom: 4px;
}

.quick-card-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}

.quick-card-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Weekly Heatmap */
.weekly-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px 18px;
    box-shadow: var(--shadow);
    margin: 8px 0;
}

.weekly-header {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}

.weekly-dots {
    display: flex;
    justify-content: space-between;
    gap: 6px;
}

.week-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.week-day-label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
}

.week-day-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e0f5ed;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.week-day-dot.completed {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 2px 8px rgba(0, 184, 148, 0.4);
}

.week-day-dot.today {
    border: 2px solid var(--primary);
}

.week-day-dot.overclocked {
    background: linear-gradient(135deg, var(--overclock), #fab1a0);
    color: white;
    box-shadow: 0 2px 8px rgba(225, 112, 85, 0.4);
}

/* Quote Card */
.quote-card {
    background: linear-gradient(135deg, rgba(0, 184, 148, 0.08), rgba(85, 239, 196, 0.08));
    border-radius: var(--radius);
    padding: 16px 20px;
    margin: 12px 0;
    border-left: 4px solid var(--primary);
}

.quote-text {
    font-size: 13px;
    font-style: italic;
    color: var(--text-light);
    line-height: 1.5;
}

/* Buttons */
.btn {
    font-family: 'Poppins', sans-serif;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    padding: 14px 40px;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.btn-start {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 4px 15px rgba(0, 184, 148, 0.4);
}

.btn-stop {
    background: linear-gradient(135deg, var(--danger), #fab1a0);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 118, 117, 0.4);
}

.btn-dismiss {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(0, 184, 148, 0.4);
}

.btn-action {
    background: var(--bg-card);
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 10px 20px;
    font-size: 13px;
    border-radius: 50px;
}

.btn-send {
    background: var(--primary);
    color: white;
    padding: 12px 18px;
    border-radius: 50px;
    font-size: 18px;
}

.btn-danger {
    background: var(--danger);
    color: white;
    padding: 10px 24px;
    font-size: 13px;
}

.btn-export {
    background: var(--ocean);
    color: white;
    padding: 10px 24px;
    font-size: 13px;
}

.hidden {
    display: none !important;
}

/* Good Job Overlay */
.good-job-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(240, 250, 245, 0.97);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.5s ease;
}

.good-job-content {
    text-align: center;
    padding: 30px;
}

.palm-trees {
    font-size: 48px;
    margin-bottom: 10px;
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.good-job-content h2 {
    font-size: 36px;
    color: var(--primary);
    margin-bottom: 8px;
}

.good-job-content p {
    color: var(--text-light);
    font-size: 16px;
}

.good-job-stats {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 20px;
}

.good-job-stats .stat {
    background: var(--bg-card);
    padding: 14px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.good-job-stats .stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.good-job-stats .stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.good-job-xp {
    margin-top: 16px;
}

.xp-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--ocean), var(--ocean-dark));
    color: white;
    padding: 8px 24px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 18px;
    animation: popIn 0.4s ease 0.3s both;
}

@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.good-job-achievement {
    margin-top: 12px;
    animation: popIn 0.4s ease 0.6s both;
}

.good-job-achievement span {
    display: inline-block;
    background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
    color: #2d3436;
    padding: 8px 20px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 14px;
}

/* Stats Overview */
.stats-overview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 16px 0;
}

.stat-card {
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.stat-card-label {
    font-size: 12px;
    color: var(--text-muted);
}

/* Chart */
.chart-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin: 16px 0;
    height: 200px;
}

#progressChart {
    width: 100%;
    height: 100%;
}

/* History List */
.history-list {
    margin-top: 16px;
}

.history-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item-left {
    display: flex;
    flex-direction: column;
}

.history-date {
    font-size: 12px;
    color: var(--text-muted);
}

.history-time {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.history-goal {
    font-size: 11px;
    color: var(--text-light);
}

.history-badge {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 50px;
    font-weight: 600;
}

.badge-hit {
    background: rgba(0, 184, 148, 0.15);
    color: var(--primary);
}

.badge-overclock {
    background: rgba(225, 112, 85, 0.15);
    color: var(--overclock);
}

.badge-miss {
    background: rgba(255, 118, 117, 0.15);
    color: var(--danger);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 16px;
}

/* Chat */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 240px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.chat-message {
    margin-bottom: 12px;
    display: flex;
}

.chat-message.bot {
    justify-content: flex-start;
}

.chat-message.user {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.chat-message.bot .message-bubble {
    background: var(--bg-card);
    color: var(--text);
    box-shadow: var(--shadow);
    border-bottom-left-radius: 4px;
}

.chat-message.user .message-bubble {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.system .message-bubble {
    background: linear-gradient(135deg, rgba(116, 185, 255, 0.15), rgba(9, 132, 227, 0.15));
    color: var(--ocean-dark);
    font-size: 12px;
    font-weight: 600;
    max-width: 100%;
    text-align: center;
    border-radius: var(--radius);
}

.chat-actions {
    display: flex;
    gap: 8px;
    padding: 10px 0;
    flex-wrap: wrap;
}

.chat-input-container {
    display: flex;
    gap: 8px;
    padding: 10px 0;
}

#chatInput {
    flex: 1;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    padding: 12px 18px;
    border: 2px solid #e0f5ed;
    border-radius: 50px;
    outline: none;
    background: var(--bg-card);
    color: var(--text);
    transition: border-color 0.3s ease;
}

#chatInput:focus {
    border-color: var(--primary);
}

.no-api-warning {
    text-align: center;
    padding: 20px;
    background: rgba(253, 203, 110, 0.2);
    border-radius: var(--radius);
    margin-top: 10px;
    color: var(--text-light);
    font-size: 14px;
}

/* Settings */
.settings-list {
    margin-top: 10px;
}

.setting-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.setting-label {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.setting-label span:first-child {
    font-weight: 600;
    font-size: 14px;
}

.setting-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.setting-input {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    padding: 10px 14px;
    border: 2px solid #e0f5ed;
    border-radius: var(--radius-sm);
    outline: none;
    background: var(--bg);
    color: var(--text);
    width: 100%;
    max-width: 250px;
    transition: border-color 0.3s ease;
}

.setting-input:focus {
    border-color: var(--primary);
}

select.setting-input {
    cursor: pointer;
}

.danger-zone {
    border: 2px solid rgba(255, 118, 117, 0.3);
}

/* Toggle */
.toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #dfe6e9;
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.toggle input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 4px; }

@media (max-width: 380px) {
    #timerText { font-size: 40px; }
    .timer-ring { width: 200px; height: 200px; }
    .good-job-stats { flex-direction: column; align-items: center; }
    .quick-stats { grid-template-columns: 1fr 1fr; gap: 8px; }
}
