:root {
    --color-bg-dark: #000000;
    --color-text-dark: #ffffff;
    --color-bg-light: #f5f5f5;
    --color-text-light: #1a1a1a;

    /* Default to Dark */
    --color-bg: var(--color-bg-dark);
    --color-text: var(--color-text-dark);
    --color-card-bg: rgba(255, 255, 255, 0.05);
    /* For dark mode */
    --color-card-border: transparent;
    --color-ring-bg: rgba(255, 255, 255, 0.1);

    --color-text-muted: #888888;

    /* Chart Colors */
    --color-chart-grid: rgba(255, 255, 255, 0.05);
    --color-chart-label: rgba(255, 255, 255, 0.3);
    --color-chart-before: rgba(255, 255, 255, 0.15);
    --color-chart-legend: rgba(255, 255, 255, 0.5);

    /* Calm Theme */
    --color-calm-primary: #FF69B4;
    --color-calm-secondary: #FF1493;

    /* Energy Theme */
    --color-energy-primary: #FF69B4;
    --color-energy-secondary: #FF1493;

    --theme-primary: var(--color-calm-primary);
    --theme-secondary: var(--color-calm-secondary);

    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --border-radius: 12px;
    --transition-speed: 0.3s;
}

[data-theme="light"] {
    --color-bg: var(--color-bg-light);
    --color-text: var(--color-text-light);
    --color-card-bg: rgba(0, 0, 0, 0.05);
    --color-card-border: rgba(0, 0, 0, 0.1);
    --color-ring-bg: rgba(0, 0, 0, 0.1);
    --color-text-muted: #666666;

    /* Chart Colors Light Mode */
    --color-chart-grid: rgba(0, 0, 0, 0.05);
    --color-chart-label: rgba(0, 0, 0, 0.4);
    --color-chart-before: rgba(0, 0, 0, 0.1);
    --color-chart-legend: rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] {
    --color-bg: var(--color-bg-dark);
    --color-text: var(--color-text-dark);
    --color-card-bg: rgba(255, 255, 255, 0.05);
    --color-card-border: transparent;
    --color-ring-bg: rgba(255, 255, 255, 0.1);
}

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

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-family);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s, color 0.3s;
    /* Smooth theme transition */
}

#app {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Response Container for centered PC/Tablet view */
.view {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    max-width: 600px;
    /* Tablet/PC limit */
    margin: 0 auto;
    /* Center horizontally */
    position: relative;
}

/* Override for larger screens if needed */
@media (min-width: 768px) {
    .view {
        justify-content: center;
        /* Center vertically on desktop if content is short */
        padding: 40px;
    }
}

/* Typography */
h1 {
    font-weight: 600;
    margin-bottom: 1vh;
    font-size: clamp(1.5rem, 4vh, 2.5rem);
    line-height: 1.2;
}

h2,
h3 {
    font-weight: 600;
    margin-bottom: 1vh;
    font-size: clamp(1.2rem, 3vh, 1.8rem);
}

p {
    line-height: 1.4;
    margin-bottom: 1.5vh;
    color: var(--color-text-muted);
    font-size: clamp(0.9rem, 2vh, 1.1rem);
}

/* Buttons */
button {
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
    font-family: inherit;
    color: inherit;
}

.btn-primary {
    background: linear-gradient(90deg, var(--theme-secondary), var(--theme-primary));
    color: white;
    padding: 1.5vh 2rem;
    border-radius: 50px;
    font-size: clamp(1rem, 2.2vh, 1.3rem);
    font-weight: 600;
    width: 100%;
    max-width: 350px;
    margin: 1vh auto;
    display: block;
    box-shadow: 0 0 12px rgba(255, 180, 50, 0.5);
    /* Yellow-orange shimmer */
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

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

.icon-btn {
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    color: var(--theme-primary);
    /* Accent color for icons */
}

.icon-btn:hover {
    background-color: var(--color-card-bg);
    box-shadow: 0 0 10px rgba(255, 105, 180, 0.3);
    /* Default pinkish glow */
}

.theme-energy .btn-primary,
.theme-energy .ritual-card.selected,
.theme-energy .icon-btn:hover {
    box-shadow: 0 0 15px #FFA500;
    /* Strong Orange Glow (Constant) */
}

/* Global Mute Button */
/* Global Mute Button */
#global-mute {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    right: 20px;
    z-index: 1000;
    color: var(--color-text);
    background: rgba(var(--color-bg-rgb), 0.5);
    /* Semi-transparent background for visibility */
    backdrop-filter: blur(5px);
    border-radius: 50%;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.icon {
    width: 24px;
    height: 24px;
}

/* Views */
.view {
    padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)) 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly;
    height: 100%;
    width: 100%;
    text-align: center;
    animation: fadeIn var(--transition-speed) ease-out;
}

.view.hidden {
    display: none;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dashboard */
.dashboard-header {
    margin-bottom: 1vh;
    flex-shrink: 0;
}

.ritual-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 2vh;
    flex-shrink: 0;
    width: 100%;
    justify-content: center;
}

.ritual-card {
    background: var(--color-card-bg);
    padding: 2vh;
    border-radius: var(--border-radius);
    cursor: pointer;
    border: 2px solid var(--color-card-border);
    transition: all 0.2s;
    width: 40%;
    max-width: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ritual-card.selected {
    border-color: var(--theme-primary);
    background: rgba(var(--theme-primary-rgb), 0.1);
    /* Fallback/hack if rgb vars aren't there, actually just use direct opacity? 
       Using card-bg + border is safer logic for theming
    */
    box-shadow: 0 0 12px rgba(255, 165, 0, 0.6);
    /* Orange glow */
}

.ritual-icon {
    width: 8vh;
    height: 8vh;
    max-width: 60px;
    max-height: 60px;
    margin-bottom: 1vh;
    stroke: var(--theme-primary);
}

/* Timer Display */
.timer-container {
    position: relative;
    width: 50vmin;
    height: 50vmin;
    max-width: 300px;
    max-height: 300px;
    margin: 2vh auto;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.progress-ring {
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
    width: 100%;
    height: 100%;
}

.progress-ring__circle {
    transition: stroke-dashoffset 1s linear;
    stroke: var(--theme-primary);
}

.timer-icon-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-icon {
    width: 40%;
    height: 40%;
    stroke: var(--theme-primary);
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-top: 3vh;
    flex-shrink: 0;
    z-index: 10;
}

.play-pause-btn {
    width: 8vh;
    height: 8vh;
    max-width: 64px;
    max-height: 64px;
    background-color: var(--theme-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    /* Always white icons on colored buttons */
}

/* Stats */
.time-selector .icon-btn {
    width: 50px;
    height: 50px;
    font-size: 2rem;
    /* Larger + and - symbols */
    background: var(--color-card-bg);
    /* visible background even before hover */
}

.stats-container {
    background: var(--color-card-bg);
    border-radius: var(--border-radius);
    padding: 1.5vh;
    width: 100%;
    max-width: 400px;
    margin-top: 1vh;
    flex-shrink: 1;
    overflow-y: auto;
    min-height: 0;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 1vh;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
    font-size: clamp(0.8rem, 1.8vh, 1rem);
}

.stat-item:last-child {
    border-bottom: none;
}

/* Language Toggle (Obsolete) */
.lang-toggle {
    display: none;
}

/* Utilities */
.text-gradient {
    background: linear-gradient(90deg, var(--theme-secondary), var(--theme-primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Scrollable Content */
.scroll-content {
    overflow-y: auto;
    flex-shrink: 1;
    min-height: 0;
    padding: 0 10px;
    width: 100%;
    max-width: 500px;
    scrollbar-width: thin;
    scrollbar-color: rgba(128, 128, 128, 0.3) transparent;
}

/* Settings Modal */
.modal-content {
    background: var(--color-bg);
    padding: 2rem;
    border-radius: 12px;
    width: 80%;
    max-width: 300px;
    border: 1px solid var(--color-card-border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    color: var(--color-text);
}

.theme-btn {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--theme-primary);
    border-radius: 6px;
    color: var(--color-text);
    font-size: 0.8rem;
}

.theme-btn.active {
    background-color: var(--theme-primary);
    color: white;
}

/* Ritual Tiles (Dashboard) */
.ritual-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.2rem;
    border-radius: 16px;
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
    width: 100%;
    min-height: 140px;
}

.ritual-tile:active {
    transform: scale(0.96);
}

.ritual-tile:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.rating-container {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    margin: 1.5vh 0 2.5vh;
}

.rating-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.1rem;
    font-weight: 600;
}

.rating-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
}

.rating-btn.selected {
    background: var(--theme-primary);
    border-color: var(--theme-primary);
    color: white;
    box-shadow: 0 0 15px var(--theme-primary);
}

.stat-card {
    background: var(--color-card-bg);
    padding: 1.5vh;
    border-radius: 12px;
    border: 1px solid var(--color-card-border);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 85px;
    /* Ensure uniform height */
}

.stat-label {
    font-size: 0.7rem;
    opacity: 0.5;
    text-transform: uppercase;
    min-height: 2.2em;
    /* Ensure multi-line labels don't push values down */
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: auto;
}

.info-box {
    background: rgba(var(--theme-primary-rgb, 128, 128, 128), 0.1);
    color: var(--theme-primary);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(var(--theme-primary-rgb, 128, 128, 128), 0.2);
    font-size: 0.85rem;
    line-height: 1.4;
    text-align: left;
    margin: 10px 0 20px 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.info-box::before {
    content: "ⓘ";
    font-weight: bold;
    font-size: 1.1rem;
}