/* ==========================================================================
   HabitForge AI 2.0 - Core Design System & Stylesheet
   Modern, Glassmorphic, Premium Responsive UI
   ========================================================================== */

/* Design Tokens & CSS Custom Properties */
:root {
    /* Color Palette - Vibrant Dark Mode (Default) */
    --bg-base: #0b0d17;
    --bg-surface: rgba(19, 23, 39, 0.82);
    --bg-surface-elevated: rgba(27, 33, 56, 0.9);
    --bg-card: rgba(22, 27, 47, 0.72);
    --bg-card-hover: rgba(30, 37, 65, 0.85);
    --bg-input: rgba(15, 19, 34, 0.85);

    /* Borders & Outlines */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-medium: rgba(255, 255, 255, 0.14);
    --border-glow: rgba(99, 102, 241, 0.4);

    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0b0d17;

    /* Brand Accents & Gradients */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    --primary-soft: rgba(99, 102, 241, 0.15);
    --primary-glow: 0 0 24px rgba(99, 102, 241, 0.35);

    --emerald: #10b981;
    --emerald-soft: rgba(16, 185, 129, 0.15);
    --emerald-gradient: linear-gradient(135deg, #10b981, #059669);

    --amber: #f59e0b;
    --amber-soft: rgba(245, 158, 11, 0.15);
    --amber-gradient: linear-gradient(135deg, #f59e0b, #ef4444);

    --rose: #f43f5e;
    --rose-soft: rgba(244, 63, 94, 0.15);

    --cyan: #06b6d4;
    --cyan-soft: rgba(6, 182, 212, 0.15);

    /* Elevation & Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.32);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 8px 32px rgba(99, 102, 241, 0.25);

    /* Layout & Geometry */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-pill: 9999px;

    /* Transitions */
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition-fast: 0.18s ease;
    --transition-smooth: 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Theme Variables */
body.light-theme {
    --bg-base: #f4f6fb;
    --bg-surface: rgba(255, 255, 255, 0.88);
    --bg-surface-elevated: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-card-hover: #ffffff;
    --bg-input: #f1f4f9;

    --border-subtle: rgba(0, 0, 0, 0.07);
    --border-medium: rgba(0, 0, 0, 0.12);
    --border-glow: rgba(99, 102, 241, 0.3);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.07);
    --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.1);
    --primary-soft: rgba(99, 102, 241, 0.1);
}

/* Base Resets */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    color-scheme: dark;
}

html.light-theme {
    color-scheme: light;
}

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.55;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    background-image:
        radial-gradient(circle at 15% 10%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 85% 20%, rgba(139, 92, 246, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 50% 90%, rgba(16, 185, 129, 0.07) 0%, transparent 50%);
    background-attachment: fixed;
    transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

/* Canvas Confetti */
.confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 99999;
}

/* Typography Headings */
h1,
h2,
h3,
h4 {
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.25;
}

p {
    color: var(--text-secondary);
}

/* Buttons and Controls */
button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: transparent;
    transition: all var(--transition-smooth);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   Header & Navbar
   ========================================================================== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    padding: 14px 6%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    transition: background-color var(--transition-smooth), border-color var(--transition-smooth);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--primary-gradient);
    display: grid;
    place-items: center;
    box-shadow: var(--primary-glow);
    transition: transform var(--transition-fast);
}

.brand:hover .brand-icon {
    transform: scale(1.05) rotate(4deg);
}

.brand-glyph {
    font-size: 22px;
    line-height: 1;
}

.brand-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-name {
    font-family: 'Outfit', sans-serif;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-badge {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.05em;
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    background: var(--primary-soft);
    color: var(--primary-light);
    border: 1px solid var(--border-glow);
}

.date-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    display: grid;
    place-items: center;
    font-size: 17px;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.icon-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-medium);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ==========================================================================
   Global Button System
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.45);
    filter: brightness(1.08);
}

.btn-glass {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.btn-glass:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-medium);
    transform: translateY(-2px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--primary-soft);
    border-color: var(--border-subtle);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
}

.btn-text-link {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-light);
    padding: 4px 8px;
}

.btn-text-link:hover {
    text-decoration: underline;
}

.danger-hover:hover {
    color: var(--rose) !important;
    background: var(--rose-soft) !important;
    border-color: rgba(244, 63, 94, 0.3) !important;
}

.danger-btn {
    color: var(--rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
    background: var(--rose-soft);
}

.danger-btn:hover {
    background: var(--rose);
    color: #ffffff;
}

/* ==========================================================================
   Layout Container
   ========================================================================== */
.container {
    width: min(1320px, 92%);
    margin: 32px auto 60px;
}

/* Hero Banner */
.hero-banner {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr);
    gap: 32px;
    align-items: center;
    padding: 38px 42px;
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    margin-bottom: 30px;
}

.hero-banner::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.22) 0%, transparent 70%);
    pointer-events: none;
}

.hero-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: var(--primary-light);
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    background: var(--primary-soft);
    border: 1px solid var(--border-glow);
    margin-bottom: 14px;
}

.pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--emerald);
    box-shadow: 0 0 10px var(--emerald);
    animation: pulseGlow 2s infinite ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.7; }
}

.hero-banner h1 {
    font-size: clamp(30px, 3.8vw, 44px);
    letter-spacing: -0.035em;
    margin-bottom: 14px;
    line-height: 1.18;
}

.gradient-text {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-desc {
    font-size: 15px;
    color: var(--text-secondary);
    max-width: 620px;
    margin-bottom: 24px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

/* Daily Quote Card in Hero */
.daily-quote-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-md);
    position: relative;
    backdrop-filter: blur(12px);
}

.quote-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.quote-badge {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: var(--amber);
}

.quote-refresh {
    font-size: 16px;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
}

.quote-refresh:hover {
    color: var(--text-primary);
    background: var(--primary-soft);
    transform: rotate(90deg);
}

.daily-quote-card blockquote {
    font-size: 14px;
    font-style: italic;
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 10px;
}

.daily-quote-card cite {
    font-size: 12px;
    font-style: normal;
    font-weight: 600;
    color: var(--text-muted);
    display: block;
    text-align: right;
}

/* ==========================================================================
   Statistics Row
   ========================================================================== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-medium);
    box-shadow: var(--shadow-md);
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.stat-icon-wrapper {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 16px;
}

.stat-icon-wrapper.purple {
    background: var(--primary-soft);
    color: var(--primary-light);
}

.stat-icon-wrapper.green {
    background: var(--emerald-soft);
    color: var(--emerald);
}

.stat-icon-wrapper.orange {
    background: var(--amber-soft);
    color: var(--amber);
}

.stat-icon-wrapper.pink {
    background: var(--rose-soft);
    color: var(--rose);
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.1;
    margin-bottom: 4px;
}

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

.stat-indicator {
    margin-top: 14px;
}

.mini-bar-track {
    width: 100%;
    height: 6px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

body.light-theme .mini-bar-track {
    background: rgba(0, 0, 0, 0.06);
}

.mini-bar-fill {
    height: 100%;
    border-radius: inherit;
    transition: width 0.4s ease;
}

.mini-bar-fill.purple {
    background: var(--primary-gradient);
}

.mini-bar-fill.green {
    background: var(--emerald-gradient);
}

.stat-badge-chip {
    margin-top: 12px;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    display: inline-block;
    align-self: flex-start;
}

.stat-badge-chip.orange {
    background: var(--amber-soft);
    color: var(--amber);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.stat-link-btn {
    margin-top: 10px;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-light);
    text-align: left;
}

.stat-link-btn:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Workspace Grid (Main + Side Columns)
   ========================================================================== */
.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr);
    gap: 28px;
    align-items: start;
}

.primary-column,
.secondary-column {
    display: grid;
    gap: 28px;
    min-width: 0;
}

.panel {
    background: var(--bg-surface);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    min-width: 0;
    position: relative;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.panel-eyebrow {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: var(--primary-light);
    display: block;
    margin-bottom: 4px;
}

.panel-header h2,
.panel-header h3 {
    font-size: 22px;
}

.panel-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pill-badge {
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    background: var(--primary-soft);
    color: var(--primary-light);
    border: 1px solid var(--border-glow);
    font-size: 12px;
    font-weight: 700;
}

/* ==========================================================================
   Add Habit Form & Toolbars
   ========================================================================== */
.add-habit-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 140px 125px auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
}

.input-wrap input,
.input-wrap select {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-wrap input:focus,
.input-wrap select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    outline: none;
}

.input-wrap input::placeholder {
    color: var(--text-muted);
}

.add-btn {
    height: 44px;
    padding: 0 20px;
}

/* Filter & Search Toolbar */
.habit-filter-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border-radius: var(--radius-pill);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 13px;
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.segmented-control {
    display: flex;
    background: var(--bg-input);
    padding: 3px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
}

.segment-btn {
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.segment-btn.active {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.sort-select {
    padding: 6px 10px;
    border-radius: var(--radius-pill);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Category Pills Bar */
.category-pills-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 18px;
    scrollbar-width: thin;
}

.category-pills-bar::-webkit-scrollbar {
    height: 4px;
}

.category-pills-bar::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

.cat-pill {
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.cat-pill:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.cat-pill.active {
    background: var(--primary-soft);
    color: var(--primary-light);
    border-color: var(--border-glow);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.2);
}

/* ==========================================================================
   Habit Cards List
   ========================================================================== */
.habit-list-container {
    display: grid;
    gap: 12px;
}

.habit-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.habit-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: transparent;
    transition: background-color var(--transition-fast);
}

.habit-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-medium);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.habit-card:hover::before {
    background: var(--primary-light);
}

/* Custom Checkbox */
.habit-check-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.custom-checkbox {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 2px solid var(--border-medium);
    background: var(--bg-input);
    display: grid;
    place-items: center;
    font-size: 15px;
    color: transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.habit-check-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.habit-check-input:checked + .custom-checkbox {
    background: var(--emerald-gradient);
    border-color: var(--emerald);
    color: #ffffff;
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.4);
    transform: scale(1.05);
}

.habit-card.completed {
    border-color: rgba(16, 185, 129, 0.25);
    background: rgba(16, 185, 129, 0.04);
}

.habit-card.completed::before {
    background: var(--emerald);
}

.habit-card.completed .habit-name {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* Habit Card Info */
.habit-details {
    flex: 1;
    min-width: 0;
}

.habit-name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    overflow-wrap: anywhere;
    margin-bottom: 4px;
}

.habit-tags-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.tag-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
}

.tag-badge.category {
    background: var(--primary-soft);
    color: var(--primary-light);
}

.tag-badge.time {
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.streak-counter {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    color: var(--amber);
}

/* Habit Card Actions */
.habit-card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.85;
}

.habit-card:hover .habit-card-actions {
    opacity: 1;
}

.action-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-size: 14px;
    color: var(--text-secondary);
    background: transparent;
}

.action-btn:hover {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    transform: scale(1.08);
}

.action-btn.ai-btn:hover {
    color: var(--primary-light);
    background: var(--primary-soft);
}

.action-btn.delete-btn:hover {
    color: var(--rose);
    background: var(--rose-soft);
}

/* Empty State Card */
.empty-state-card {
    text-align: center;
    padding: 44px 20px;
    background: var(--bg-card);
    border: 1px dashed var(--border-medium);
    border-radius: var(--radius-md);
}

.empty-icon {
    font-size: 44px;
    margin-bottom: 12px;
}

.empty-state-card h3 {
    font-size: 18px;
    margin-bottom: 6px;
}

.empty-state-card p {
    font-size: 13px;
    max-width: 400px;
    margin: 0 auto 18px;
}

/* ==========================================================================
   Analytics: 30-Day Heatmap & 7-Day Chart
   ========================================================================== */
.heatmap-wrapper {
    margin-bottom: 30px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(15, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    position: relative;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.heatmap-cell:hover {
    transform: scale(1.25);
    z-index: 10;
    box-shadow: var(--shadow-md);
}

.heatmap-cell.lvl-0 {
    background: rgba(255, 255, 255, 0.03);
}

body.light-theme .heatmap-cell.lvl-0 {
    background: rgba(0, 0, 0, 0.04);
}

.heatmap-cell.lvl-1 {
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(16, 185, 129, 0.35);
}

.heatmap-cell.lvl-2 {
    background: rgba(16, 185, 129, 0.5);
    border-color: rgba(16, 185, 129, 0.6);
}

.heatmap-cell.lvl-3 {
    background: rgba(16, 185, 129, 0.75);
    border-color: rgba(16, 185, 129, 0.85);
}

.heatmap-cell.lvl-4 {
    background: #10b981;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
    border-color: #34d399;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.legend-cell {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}

/* Weekly 7-Day Chart */
.weekly-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.weekly-header h3 {
    font-size: 16px;
}

.weekly-summary {
    font-size: 12px;
    font-weight: 600;
    color: var(--emerald);
}

.weekly-chart {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 14px;
    min-height: 160px;
    align-items: end;
    padding-top: 10px;
}

.chart-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    height: 150px;
}

.chart-track {
    width: min(34px, 100%);
    height: 105px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: flex-end;
    overflow: hidden;
    position: relative;
}

.chart-fill {
    width: 100%;
    min-height: 4px;
    border-radius: 8px;
    background: var(--primary-gradient);
    transition: height 0.5s var(--ease-out-back);
}

.chart-day.today .chart-fill {
    background: var(--emerald-gradient);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.chart-day span {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

.chart-day.today span {
    color: var(--primary-light);
    font-weight: 700;
}

.chart-day strong {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
}

/* ==========================================================================
   Side Column: AI Coach, Badges, Category Balance
   ========================================================================== */
.ai-coach-panel {
    background: linear-gradient(170deg, var(--bg-surface) 0%, rgba(30, 27, 75, 0.3) 100%);
    border-color: rgba(99, 102, 241, 0.25);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.12);
}

.coach-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}

.coach-icon-bubble {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--primary-gradient);
    display: grid;
    place-items: center;
    font-size: 22px;
    box-shadow: var(--primary-glow);
    flex-shrink: 0;
}

.coach-status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: var(--primary-soft);
    color: var(--primary-light);
    margin-bottom: 4px;
}

.status-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-indicator.online {
    background: var(--emerald);
    box-shadow: 0 0 8px var(--emerald);
}

.coach-banner-info h3 {
    font-size: 18px;
}

.coach-tagline {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 18px;
    line-height: 1.5;
}

.coach-action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}

/* Coach Loader */
.coach-loader {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 13px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Coach Output Feed */
.coach-feed {
    display: grid;
    gap: 12px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
}

.coach-feed::-webkit-scrollbar {
    width: 4px;
}

.coach-feed::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

.coach-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    animation: fadeIn 0.3s ease;
}

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

.coach-card-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.coach-card-body h4 {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.coach-card-body p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.coach-welcome-prompt {
    padding: 16px;
    text-align: center;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-muted);
}

/* Badges Mini Grid */
.badges-mini-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.badge-item {
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.badge-item:hover {
    transform: translateY(-2px);
    border-color: var(--border-medium);
}

.badge-item.unlocked {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.08);
}

.badge-item.locked {
    opacity: 0.45;
    filter: grayscale(1);
}

.badge-icon {
    font-size: 24px;
    line-height: 1;
}

.badge-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Category Bars Breakdown */
.category-bars-list {
    display: grid;
    gap: 12px;
}

.cat-bar-row {
    display: grid;
    gap: 6px;
}

.cat-bar-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
}

.cat-bar-track {
    height: 7px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

body.light-theme .cat-bar-track {
    background: rgba(0, 0, 0, 0.06);
}

.cat-bar-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--primary-gradient);
    transition: width 0.4s ease;
}

/* Quick Tools */
.quick-tools-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.file-import-label {
    cursor: pointer;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
    margin-top: 50px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-glyph-sm {
    color: var(--primary-light);
    font-size: 16px;
}

/* ==========================================================================
   Dialog Modals (HTML5 Native <dialog>)
   ========================================================================== */
.app-modal {
    margin: auto;
    border: none;
    background: transparent;
    padding: 0;
    max-width: min(560px, 92vw);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
    overflow: visible;
}

.app-modal::backdrop {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: backdropIn 0.2s ease;
}

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

.modal-card {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 28px;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s var(--ease-out-back);
}

.modal-lg .modal-card {
    max-width: 680px;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-title-with-icon {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sparkle-icon,
.trophy-icon {
    font-size: 26px;
}

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

.modal-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--text-muted);
    font-size: 16px;
}

.modal-close-btn:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.modal-form,
.modal-body {
    display: grid;
    gap: 18px;
}

.form-group {
    display: grid;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input,
.form-group select {
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 10px;
}

/* Settings Modal Specifics */
.settings-section {
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    display: grid;
    gap: 12px;
}

.settings-section h4 {
    font-size: 15px;
}

.settings-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.key-input-row {
    display: flex;
    gap: 8px;
}

.key-input-row input {
    flex: 1;
}

.key-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.api-status-msg {
    font-size: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}

.api-status-msg.success {
    background: var(--emerald-soft);
    color: var(--emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.api-status-msg.error {
    background: var(--rose-soft);
    color: var(--rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.setting-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.toggle-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Atomic Habit Breakdown Content */
.breakdown-step-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.step-num-badge {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.step-content h4 {
    font-size: 14px;
    margin-bottom: 3px;
}

.step-content p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Badges Full Modal Grid */
.badges-full-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 6px;
}

.badge-card-full {
    display: flex;
    gap: 14px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    align-items: center;
}

.badge-card-full.unlocked {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.07);
}

.badge-card-full.locked {
    opacity: 0.5;
    filter: grayscale(1);
}

.badge-card-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.badge-card-info h4 {
    font-size: 14px;
    margin-bottom: 2px;
}

.badge-card-info p {
    font-size: 12px;
    color: var(--text-secondary);
}

.badge-date-unlocked {
    font-size: 10px;
    font-weight: 700;
    color: var(--amber);
    display: block;
    margin-top: 4px;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1080px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .hero-banner {
        grid-template-columns: 1fr;
        padding: 28px;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .add-habit-bar {
        grid-template-columns: 1fr;
    }

    .habit-filter-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .segmented-control {
        width: 100%;
        justify-content: space-around;
    }

    .sort-select {
        width: 100%;
    }

    .heatmap-grid {
        grid-template-columns: repeat(10, minmax(0, 1fr));
    }

    .stats-row {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .coach-action-buttons {
        grid-template-columns: 1fr;
    }
}

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