/* ============================================
   Sleep Debt Tracker — Styles
   Dark mode default, calming sleep palette
   v5: UI/UX polish, animations, larger targets
   ============================================ */

:root {
    --bg-deep: #0b0820;
    --bg-deep-alt: #0e0b26;
    --bg-card: #151040;
    --bg-card-hover: #1c1555;
    --bg-input: #0a0618;
    --text-primary: #eae4ff;
    --text-secondary: #a99dd4;
    --text-muted: #6b5f8a;
    --accent: #7c5cfc;
    --accent-glow: rgba(124, 92, 252, 0.25);
    --accent-soft: rgba(124, 92, 252, 0.08);
    --accent-light: #a78bfa;
    --green: #4ade80;
    --green-bg: rgba(74, 222, 128, 0.08);
    --green-glow: rgba(74, 222, 128, 0.2);
    --yellow: #fbbf24;
    --yellow-bg: rgba(251, 191, 36, 0.08);
    --red: #f87171;
    --red-bg: rgba(248, 113, 113, 0.08);
    --border: rgba(124, 92, 252, 0.12);
    --border-light: rgba(124, 92, 252, 0.06);
    --nav-height: 72px;
    --header-height: 80px;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 1px 4px rgba(124, 92, 252, 0.05);
    --shadow-btn: 0 4px 16px rgba(124, 92, 252, 0.3);
    --transition-smooth: cubic-bezier(0.22, 0.68, 0, 1);
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.5;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
}

/* ============ Stars Background ============ */
#stars-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
}

#app > *:not(#stars-canvas) {
    position: relative;
    z-index: 1;
}

/* ============ Header ============ */
#app-header {
    padding: 18px 20px 14px;
    text-align: center;
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(20, 15, 50, 0.95) 0%, rgba(11, 8, 32, 0.85) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.header-icon {
    font-size: 26px;
    color: var(--accent-light);
    animation: moonFloat 4s ease-in-out infinite;
    display: inline-flex;
    align-items: center;
}

@keyframes moonFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-3px) rotate(-3deg); }
    75% { transform: translateY(2px) rotate(2deg); }
}

#app-header h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 3px;
    transition: opacity 0.3s ease;
}

/* ============ Main Content ============ */
#main-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 16px 20px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

#main-content::-webkit-scrollbar {
    width: 0;
}

/* ============ Tabs ============ */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: tabFadeIn 0.35s var(--transition-smooth);
}

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

/* ============ Cards ============ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s var(--transition-smooth), box-shadow 0.2s;
}

.card-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.card-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.2px;
}

.card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* ============ Today Summary ============ */
.today-summary {
    text-align: center;
    background: linear-gradient(135deg, #141050 0%, #1a1260 50%, #1e145a 100%);
    border-color: rgba(124, 92, 252, 0.2);
    position: relative;
    overflow: hidden;
}

.today-summary::before {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.today-summary::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: -20px;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(124, 92, 252, 0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.today-hours {
    font-size: 58px;
    font-weight: 800;
    letter-spacing: -3px;
    line-height: 1.1;
    margin: 10px 0;
    position: relative;
}

.today-debt {
    font-size: 14px;
    font-weight: 600;
    position: relative;
}

.debt-positive {
    color: var(--green);
}

.debt-negative {
    color: var(--red);
}

.debt-neutral {
    color: var(--text-secondary);
}

/* ============ Quick Log Slider ============ */
.slider-container {
    margin-bottom: 18px;
}

.slider-value {
    text-align: center;
    font-size: 34px;
    font-weight: 800;
    color: var(--accent-light);
    margin-bottom: 14px;
    letter-spacing: -1px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 10px;
    background: var(--bg-input);
    border-radius: 5px;
    outline: none;
    border: 1px solid var(--border-light);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow), 0 2px 8px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow), 0 2px 8px rgba(0,0,0,0.3);
    cursor: pointer;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ============ Time Inputs ============ */
.time-inputs {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.time-group {
    flex: 1;
}

.time-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

input[type="time"] {
    width: 100%;
    padding: 14px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 18px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s;
    min-height: 52px;
}

input[type="time"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Chrome time input icon */
input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7) sepia(1) saturate(3) hue-rotate(220deg);
    padding: 4px;
    cursor: pointer;
}

.time-separator {
    font-size: 20px;
    color: var(--text-muted);
    padding-top: 22px;
}

.calculated-hours {
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-light);
    margin-bottom: 16px;
    padding: 10px;
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

/* ============ Buttons ============ */
.btn-primary {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent) 0%, #6a4de0 100%);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s var(--transition-smooth);
    box-shadow: var(--shadow-btn);
    min-height: 52px;
    letter-spacing: -0.2px;
}

.btn-primary:active {
    transform: scale(0.96);
    box-shadow: 0 2px 8px rgba(124, 92, 252, 0.2);
}

.btn-secondary {
    width: 100%;
    padding: 14px;
    background: var(--accent-soft);
    color: var(--accent-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-bottom: 10px;
    transition: all 0.2s;
    min-height: 48px;
}

.btn-secondary:active {
    background: rgba(124, 92, 252, 0.15);
    transform: scale(0.97);
}

.btn-danger {
    width: 100%;
    padding: 14px;
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(248, 113, 113, 0.15);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 48px;
}

.btn-danger:active {
    background: rgba(248, 113, 113, 0.15);
    transform: scale(0.97);
}

/* ============ Recent Logs ============ */
.recent-logs {
    max-height: 320px;
    overflow-y: auto;
}

.log-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
    transition: opacity 0.2s;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-date {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.log-hours {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.log-debt {
    font-size: 12px;
    font-weight: 600;
    text-align: right;
}

.log-times {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.log-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.log-delete:active {
    background: var(--red-bg);
    color: var(--red);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    padding: 24px 0;
}

/* ============ Target Setting ============ */
.target-setting {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    margin-bottom: 18px;
}

.target-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 26px;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s var(--transition-smooth);
}

.target-btn:active {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(0.92);
}

.target-display {
    text-align: center;
}

.target-value {
    display: block;
    font-size: 46px;
    font-weight: 800;
    line-height: 1;
    color: var(--accent-light);
    letter-spacing: -2px;
}

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

.target-range {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.target-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}

.target-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-light) 100%);
    border-radius: 3px;
    transition: width 0.3s var(--transition-smooth);
}

/* ============ Debt Hero ============ */
.debt-hero {
    text-align: center;
    background: linear-gradient(135deg, #111050 0%, #1a1260 50%, #181058 100%);
    border-color: rgba(124, 92, 252, 0.18);
    position: relative;
    overflow: hidden;
}

.debt-hero::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 130px;
    height: 130px;
    background: radial-gradient(circle, rgba(124, 92, 252, 0.12) 0%, transparent 70%);
    border-radius: 50%;
}

.debt-hero::after {
    content: '';
    position: absolute;
    bottom: -30px;
    left: -30px;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.08) 0%, transparent 70%);
    border-radius: 50%;
}

.debt-hero-value {
    font-size: 58px;
    font-weight: 800;
    letter-spacing: -3px;
    line-height: 1.1;
    margin: 10px 0 8px;
    transition: color 0.4s;
    position: relative;
}

.debt-hero-msg {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    position: relative;
}

.debt-hero-sub {
    font-size: 12px;
    color: var(--text-muted);
    position: relative;
}

.debt-hero.severity-ok .debt-hero-value { color: var(--green); }
.debt-hero.severity-mild .debt-hero-value { color: var(--yellow); }
.debt-hero.severity-severe .debt-hero-value { color: var(--red); }
.debt-hero.severity-none .debt-hero-value { color: var(--text-secondary); }

/* ============ Debt Range Toggle ============ */
.debt-range-toggle {
    display: flex;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 3px;
    margin-bottom: 16px;
    border: 1px solid var(--border-light);
}

.range-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.25s var(--transition-smooth);
    min-height: 44px;
}

.range-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 12px rgba(124, 92, 252, 0.35);
}

/* ============ Debt Stats ============ */
.debt-stats {
    display: flex;
    gap: 8px;
}

.debt-stat {
    flex: 1;
    text-align: center;
    padding: 14px 8px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    transition: transform 0.2s;
}

.debt-stat-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.debt-stat-value {
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* ============ Weekly Bar Chart ============ */
.weekly-chart {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    height: 200px;
    padding-top: 8px;
}

.week-day {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    cursor: pointer;
    position: relative;
    min-width: 36px;
}

.week-day:active {
    opacity: 0.7;
}

.week-bar-track {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    position: relative;
}

.week-bar {
    width: 80%;
    border-radius: 8px 8px 3px 3px;
    min-height: 2px;
    transition: height 0.5s var(--transition-smooth);
    position: relative;
}

.week-bar.bar-green { background: linear-gradient(to top, #22c55e, #4ade80); box-shadow: 0 -2px 12px rgba(74, 222, 128, 0.15); }
.week-bar.bar-yellow { background: linear-gradient(to top, #d97706, #fbbf24); box-shadow: 0 -2px 12px rgba(251, 191, 36, 0.15); }
.week-bar.bar-red { background: linear-gradient(to top, #dc2626, #f87171); box-shadow: 0 -2px 12px rgba(248, 113, 113, 0.15); }
.week-bar.bar-empty { background: var(--bg-input); border: 1px dashed rgba(124, 92, 252, 0.15); min-height: 8px; }

.week-target-line {
    position: absolute;
    width: 100%;
    height: 1px;
    border-top: 2px dashed rgba(167, 139, 250, 0.25);
    left: 0;
    pointer-events: none;
}

.week-hours {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 4px;
    min-height: 16px;
}

.week-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 8px;
}

.week-day.today .week-label {
    color: var(--accent-light);
    font-weight: 800;
}

/* ============ Monthly Heatmap ============ */
.month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.month-nav .card-title {
    margin-bottom: 0;
    font-size: 16px;
}

.month-nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    min-width: 44px;
    min-height: 44px;
}

.month-nav-btn:active {
    background: var(--accent);
    transform: scale(0.92);
}

.month-heatmap {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    margin-bottom: 14px;
}

.heatmap-header {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: center;
    padding: 4px 0;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    min-width: 36px;
    min-height: 36px;
}

.heatmap-cell:active {
    transform: scale(0.88);
}

.heatmap-cell.empty {
    cursor: default;
    background: transparent;
}

.heatmap-cell.no-data {
    background: rgba(10, 6, 24, 0.6);
    border: 1px solid var(--border-light);
}

.heatmap-cell.heat-1 {
    background: rgba(248, 113, 113, 0.2);
    color: var(--red);
    border: 1px solid rgba(248, 113, 113, 0.1);
}

.heatmap-cell.heat-2 {
    background: rgba(251, 191, 36, 0.15);
    color: var(--yellow);
    border: 1px solid rgba(251, 191, 36, 0.08);
}

.heatmap-cell.heat-3 {
    background: rgba(74, 222, 128, 0.12);
    color: var(--green);
    border: 1px solid rgba(74, 222, 128, 0.06);
}

.heatmap-cell.heat-4 {
    background: rgba(74, 222, 128, 0.25);
    color: var(--green);
    font-weight: 800;
    border: 1px solid rgba(74, 222, 128, 0.12);
}

.heatmap-cell.today-cell {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.heatmap-cell.future {
    opacity: 0.25;
    cursor: default;
}

/* ============ Heatmap Legend ============ */
.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.legend-label {
    font-size: 10px;
    color: var(--text-muted);
    margin: 0 4px;
}

.legend-swatch {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.lg-none { background: rgba(10, 6, 24, 0.6); border: 1px solid var(--border-light); }
.lg-low { background: rgba(248, 113, 113, 0.2); }
.lg-mid { background: rgba(251, 191, 36, 0.15); }
.lg-good { background: rgba(74, 222, 128, 0.12); }
.lg-great { background: rgba(74, 222, 128, 0.25); }

/* ============ Edit Dialog ============ */
.edit-dialog {
    text-align: center;
}

.edit-dialog-title {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 4px;
}

.edit-dialog-date {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 18px;
}

.edit-slider-container {
    margin-bottom: 22px;
}

.edit-slider-container .slider-value {
    font-size: 30px;
}

/* ============ Recovery Card ============ */
.recovery-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, #161050 100%);
}

.recovery-empty {
    text-align: center;
    padding: 24px 0;
}

.recovery-icon {
    font-size: 40px;
    display: block;
    margin-bottom: 12px;
    color: var(--accent-light);
    animation: moonFloat 3s ease-in-out infinite;
}

.recovery-empty p {
    color: var(--text-muted);
    font-size: 14px;
}

.recovery-hero {
    text-align: center;
    margin-bottom: 16px;
}

.recovery-hero-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.recovery-hero-value {
    font-size: 42px;
    font-weight: 800;
    color: var(--accent-light);
    line-height: 1.1;
    letter-spacing: -2px;
}

.recovery-hero-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.recovery-suggestion {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    margin-top: 14px;
    border: 1px solid var(--border-light);
}

.recovery-suggestion-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.recovery-bedtime {
    font-size: 26px;
    font-weight: 800;
    color: var(--accent-light);
    letter-spacing: -0.5px;
}

.recovery-bedtime-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.recovery-ok {
    text-align: center;
    padding: 20px 0;
}

.recovery-ok-icon {
    font-size: 40px;
    display: block;
    margin-bottom: 10px;
    color: var(--green);
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.9; }
}

.recovery-ok-msg {
    font-size: 17px;
    font-weight: 700;
    color: var(--green);
}

.recovery-ok-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* ============ Trends Chart ============ */
.trends-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.trends-header .card-title {
    margin-bottom: 0;
}

.trends-range-toggle {
    display: flex;
    background: var(--bg-input);
    border-radius: 8px;
    padding: 2px;
    border: 1px solid var(--border-light);
}

.trends-range-btn {
    padding: 8px 14px;
    border: none;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.2s;
    min-height: 36px;
}

.trends-range-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(124, 92, 252, 0.3);
}

.trends-chart-wrapper {
    position: relative;
    width: 100%;
    height: 180px;
    margin-bottom: 12px;
}

#trends-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.trends-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
}

.trends-empty.hidden {
    display: none;
}

.trends-empty p {
    font-size: 14px;
    color: var(--text-muted);
}

.trends-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.trends-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot-accent {
    background: var(--accent);
}

.dot-target {
    background: var(--text-muted);
    border: 1px dashed var(--text-secondary);
}

/* ============ Insights ============ */
.insights-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.insight-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    transition: transform 0.2s;
}

.insight-icon {
    font-size: 22px;
    flex-shrink: 0;
    margin-top: 0;
    color: var(--accent-light);
    display: flex;
    align-items: center;
}

.insight-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
}

.insight-text strong {
    color: var(--accent-light);
    font-weight: 700;
}

/* ============ Bedtime Reminder ============ */
.reminder-setting {
    margin-top: 8px;
}

.reminder-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    min-height: 48px;
}

.reminder-label {
    font-size: 15px;
    font-weight: 600;
}

.toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-track {
    display: block;
    width: 52px;
    height: 30px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 15px;
    position: relative;
    transition: all 0.3s var(--transition-smooth);
}

.toggle-thumb {
    display: block;
    width: 24px;
    height: 24px;
    background: var(--text-muted);
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: all 0.3s var(--transition-smooth);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.toggle-btn.active .toggle-track {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

.toggle-btn.active .toggle-thumb {
    background: #fff;
    left: 24px;
}

.reminder-time-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.reminder-time-row.hidden {
    display: none;
}

.reminder-time-row label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.reminder-time-row input[type="time"] {
    width: auto;
    padding: 12px 14px;
    font-size: 16px;
    min-height: 48px;
}

.reminder-status {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    min-height: 18px;
}

/* ============ Bottom Navigation ============ */
#bottom-nav {
    display: flex;
    background: rgba(14, 10, 36, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding: 6px 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    flex-shrink: 0;
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 10px 4px 8px;
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.25s var(--transition-smooth);
    min-height: 56px;
    position: relative;
}

.nav-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 32px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--accent);
    transition: transform 0.25s var(--transition-smooth);
}

.nav-btn.active::before {
    transform: translateX(-50%) scaleX(1);
}

.nav-icon {
    font-size: 24px;
    color: var(--text-muted);
    transition: all 0.25s;
}

.nav-icon .ti {
    font-size: 24px;
}

.nav-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    transition: color 0.25s;
}

.nav-btn.active .nav-icon {
    color: var(--accent-light);
    transform: translateY(-1px);
}

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

/* ============ Toast ============ */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: linear-gradient(135deg, var(--accent) 0%, #6a4de0 100%);
    color: #fff;
    padding: 14px 28px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    transition: all 0.35s var(--transition-smooth);
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
    box-shadow: 0 6px 24px rgba(124, 92, 252, 0.4), 0 2px 8px rgba(0,0,0,0.3);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============ Confirm Dialog ============ */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    animation: overlayFadeIn 0.2s ease;
}

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

.confirm-overlay.hidden {
    display: none;
}

.confirm-dialog {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    max-width: 340px;
    width: 100%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    animation: dialogSlideUp 0.3s var(--transition-smooth);
}

@keyframes dialogSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.confirm-dialog p {
    font-size: 15px;
    margin-bottom: 22px;
    text-align: center;
    line-height: 1.5;
}

.confirm-buttons {
    display: flex;
    gap: 10px;
}

.confirm-buttons .btn-secondary,
.confirm-buttons .btn-danger {
    margin-bottom: 0;
}

/* ============ About ============ */
.about-card {
    text-align: center;
}

.about-text {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--accent-light);
}

.privacy-link {
    display: inline-block;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.privacy-link:hover, .privacy-link:active {
    opacity: 1;
    text-decoration: underline;
}

/* ============ PWA Install Banner ============ */
.install-banner {
    position: fixed;
    bottom: 72px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    padding: 12px 24px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(124, 58, 237, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: calc(100% - 32px);
}

.install-banner button {
    background: rgba(255,255,255,0.25);
    border: none;
    color: #fff;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    min-height: 36px;
}

.install-banner .dismiss-btn {
    background: transparent;
    padding: 6px 8px;
    font-size: 18px;
    opacity: 0.7;
    min-height: unset;
}

@keyframes slideUp {
    from { transform: translateX(-50%) translateY(100px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ============ Responsive ============ */
@media (min-width: 481px) {
    #app {
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
}

/* ============ Reduce motion ============ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
