:root {
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-main: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.7);
    --accent: #FFD166;
    /* Sunny yellow */
    --accent-btn: rgba(255, 255, 255, 0.25);
    --danger: #FF6B6B;
    --font-stack: 'Outfit', sans-serif;

    --ease-elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

body {
    font-family: var(--font-stack);
    background: #0f2027;
    /* Fallback */
    color: var(--text-main);
    overflow: hidden;
    /* Prevent body scroll */
    height: 100vh;
    width: 100vw;
}

/* --- Dynamic Backgrounds --- */
.background-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    transition: background 1s ease;
}

.sky-gradient {
    position: absolute;
    width: 100%;
    height: 100%;
    transition: opacity 1s ease;
}

/* Morning */
.morning .sky-gradient {
    background: linear-gradient(to bottom, #FF9966, #FF5E62);
}

/* Day */
.day .sky-gradient {
    background: linear-gradient(to bottom, #2980B9, #6DD5FA, #FFFFFF);
}

/* Evening */
.evening .sky-gradient {
    background: linear-gradient(to bottom, #2C3E50, #4CA1AF);
    background: linear-gradient(to bottom, #0f2027, #203a43, #2c5364);
    /* Deep dusk */
}

/* Night */
.night .sky-gradient {
    background: linear-gradient(to bottom, #000000, #0f2027);
}

/* --- Weather Overrides --- */
.w-cloudy .sky-gradient {
    filter: grayscale(0.4) brightness(0.9);
}

.w-rain .sky-gradient {
    filter: grayscale(0.6) brightness(0.8) contrast(1.1);
}

.w-storm .sky-gradient {
    filter: grayscale(0.8) brightness(0.6) contrast(1.3);
}

.w-snow .sky-gradient {
    filter: grayscale(0.2) brightness(1.1);
}

.w-fog .sky-gradient {
    filter: grayscale(0.8) blur(2px) brightness(0.9);
}

.celestial-body {
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    filter: blur(5px);
    transition: all 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
}

.morning .celestial-body {
    background: #FFE082;
    box-shadow: 0 0 40px #FFD54F;
    top: 40%;
    left: 50%;
    transform: translate(-50%, 0);
}

.day .celestial-body {
    background: #FFEB3B;
    box-shadow: 0 0 60px rgba(255, 235, 59, 0.8);
    top: 10%;
    right: 10%;
}

.evening .celestial-body {
    background: #FFCC80;
    box-shadow: 0 0 30px #FFB74D;
    top: 30%;
    left: -20px;
}

.night .celestial-body {
    background: #E0E0E0;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    top: 15%;
    right: 15%;
    width: 80px;
    height: 80px;
}

/* --- Layout & View Handling --- */
#app {
    height: 100%;
    width: 100%;
    position: relative;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
    transition: opacity 0.4s ease, transform 0.4s ease;
    overflow: hidden;
}

.view.active {
    opacity: 1;
    pointer-events: all;
    transform: scale(1);
    z-index: 10;
}

.hidden {
    display: none !important;
}

/* --- Components --- */
.center-content {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 30px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

h1 {
    font-weight: 700;
    font-size: 32px;
    margin-bottom: 10px;
}

h2 {
    font-weight: 400;
    font-size: 18px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

p {
    font-weight: 300;
    line-height: 1.6;
}

input[type="text"] {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 12px 16px;
    color: white;
    font-family: inherit;
    font-size: 16px;
    width: 100%;
    margin: 20px 0;
    outline: none;
    transition: background 0.3s;
}

input[type="text"]:focus,
textarea.notes-input:focus {
    background: rgba(255, 255, 255, 0.2);
}

textarea.notes-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 12px;
    color: white;
    font-family: inherit;
    font-size: 14px;
    width: 100%;
    resize: none;
    outline: none;
    transition: background 0.3s;
}

.primary-btn {
    background: white;
    color: #333;
    border: none;
    border-radius: 12px;
    padding: 14px 24px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s;
    width: 100%;
}

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

.text-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    padding: 10px;
    cursor: pointer;
    text-decoration: underline;
}

.danger-btn {
    background: rgba(255, 0, 0, 0.2);
    border: 1px solid rgba(255, 0, 0, 0.3);
    color: #ffcccc;
    padding: 8px 16px;
    border-radius: 8px;
    margin-top: 20px;
}

/* --- Home View --- */
#home-view {
    justify-content: space-between;
}

.top-bar {
    display: flex;
    justify-content: center;
    padding-top: 20px;
}


.weather-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.weather-pill {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    padding: 8px 20px;
    border-radius: 30px;
    font-weight: 500;
    font-size: 16px;
    display: flex;
    gap: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.location-label {
    font-size: 13px;
    font-weight: 400;
    opacity: 0.9;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.center-stage {
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#time-display {
    font-size: 72px;
    font-weight: 200;
    letter-spacing: -2px;
    line-height: 1;
    margin-bottom: 0;
}

#date-display {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 14px;
    margin-top: 10px;
}

.quote-container {
    margin-top: 40px;
    padding: 0 20px;
    font-style: italic;
    opacity: 0.9;
}

.bottom-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding-bottom: 80px;
    /* Push higher up */
}

.fab-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s var(--ease-elastic);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.secondary-pill-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    color: white;
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.secondary-pill-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* --- Visibility Fixes for Light Backgrounds --- */
body.day .fab-btn,
body.morning .fab-btn {
    background: var(--accent);
    color: #333;
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 10px 25px rgba(255, 209, 102, 0.4);
}

body.day .secondary-pill-btn,
body.morning .secondary-pill-btn {
    background: white;
    color: #333;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

body.day .secondary-pill-btn:hover,
body.morning .secondary-pill-btn:hover {
    background: #f8f8f8;
    transform: translateY(-2px);
}

body.day .fab-btn:hover,
body.morning .fab-btn:hover {
    background: #ffe082;
    transform: scale(1.1);
}

.fab-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.45);
}

/* --- Tracker & Archive --- */
.glass-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 10px 0;
}

.back-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
}

.scroll-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 40px;
}

.form-group {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 12px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Bristol Grid */
.bristol-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
}

.bristol-option {
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.bristol-option:hover {
    background: rgba(0, 0, 0, 0.2);
}

.bristol-option.selected {
    border-color: var(--accent);
    background: rgba(255, 209, 102, 0.1);
}

.bristol-option span {
    display: block;
    font-weight: 600;
    margin-top: 5px;
    font-size: 14px;
}

.bristol-option small {
    display: block;
    font-size: 10px;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 4px;
}

/* Visuals for Bristol (CSS shapes) */
.visual {
    width: 40px;
    height: 40px;
    background: #8D6E63;
    margin-bottom: 5px;
}

.type-1 {
    border-radius: 50%;
    box-shadow: 10px 0 0 #8D6E63, -10px 5px 0 #8D6E63;
    width: 10px;
    height: 10px;
    margin: 15px auto;
}

/* Peas */
.type-2 {
    border-radius: 20px;
    width: 50px;
    height: 20px;
    border: 2px dashed rgba(0, 0, 0, 0.2);
}

.type-3 {
    border-radius: 20px;
    width: 50px;
    height: 20px;
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.3);
}

.type-4 {
    border-radius: 20px;
    width: 60px;
    height: 15px;
}

/* Smooth snake */
.type-5 {
    opacity: 0.8;
    border-radius: 5px;
    width: 15px;
    height: 15px;
    box-shadow: 20px 0 0 #8D6E63;
}

.type-6 {
    filter: blur(2px);
    border-radius: 10px;
}

.type-7 {
    filter: blur(4px);
    height: 10px;
    width: 60px;
}

/* Color Selector */
.color-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.color-opt {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--c);
    cursor: pointer;
    position: relative;
    border: 3px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.2s;
}

.color-opt:hover {
    transform: scale(1.1);
}

.color-opt input {
    display: none;
}

.color-opt:has(input:checked) {
    border-color: white;
    transform: scale(1.2);
}

/* Range Slider */
input[type="range"] {
    width: 100%;
    background: transparent;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-top: 5px;
    color: rgba(255, 255, 255, 0.5);
}

/* Size Chips */
.size-selector {
    display: flex;
    gap: 10px;
}

.chip {
    flex: 1;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 10px;
    text-align: center;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.chip input {
    display: none;
}

.chip:has(input:checked) {
    background: white;
    color: #333;
    font-weight: 600;
}

/* Archive Items */
.archive-item {
    background: var(--glass-bg);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.archive-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

.archive-details {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.archive-meta {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.archive-notes {
    font-size: 13px;
    margin-top: 8px;
    background: rgba(0, 0, 0, 0.1);
    padding: 8px;
    border-radius: 6px;
    font-style: italic;
    color: rgba(255, 255, 255, 0.8);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    color: #333;
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 500;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
    z-index: 100;
}

.toast.hidden {
    opacity: 0;
    transform: translate(-50%, 20px);
    pointer-events: none;
}

@media (min-width: 768px) {

    .glass-panel,
    .center-stage {
        max-width: 600px;
        margin: 0 auto;
    }
}