:root {
    color-scheme: light;
    /* Color Tokens (HSL for engine consistency) */
    --bg-primary: hsl(48, 20%, 97%);   /* #FAF9F5 */
    --bg-secondary: hsl(0, 0%, 100%);  /* #FFFFFF */
    --text-primary: hsl(0, 0%, 10%);   /* #1A1A1A */
    --text-secondary: hsl(0, 0%, 33%); /* #555555 */
    --accent-sage: hsl(156, 11%, 60%); /* #8DA399 */
    --accent-sage-dark: hsl(153, 19%, 30%); /* #3E5A4D */
    --accent-clay: hsl(30, 52%, 64%);  /* #D4A373 */
    --border-light: hsl(0, 0%, 88%);   /* #E0E0E0 */
    --bg-glass: hsla(0, 0%, 100%, 0.7);
    --accent-sage-text: hsl(152, 11%, 40%); /* #5A7367 */

    /* Geometry Tokens (rem for accessible scaling) */
    --radius-sm: 0.75rem; /* 12px */
    --radius-md: 1.5rem;  /* 24px */
    --radius-lg: 1.75rem; /* 28px */
    --radius-full: 9999px;

    --space-xs: 0.25rem; /* 4px */
    --space-sm: 0.5rem;  /* 8px */
    --space-md: 1rem;    /* 16px */
    --space-lg: 1.5rem;  /* 24px */
    --space-xl: 2rem;    /* 32px */
    --space-xxl: 5rem;   /* 80px */
}

@media (prefers-color-scheme: dark) {
    body {
        filter: none !important;
    }
}

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

html,
body {
    height: 100%;
    width: 100%;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
}

html {
    height: 100dvh;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    padding: var(--space-md);
    padding-top: var(--space-xxl);
    padding-bottom: env(safe-area-inset-bottom, var(--space-xl));
    overflow-x: hidden;
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 10% 0%, hsla(156, 11%, 60%, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 90% 100%, hsla(30, 52%, 64%, 0.12) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    max-width: 30rem; /* 480px */
    margin: auto;
    -webkit-font-smoothing: antialiased;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

input, textarea, .drop-input, #note-desc {
    -webkit-user-select: auto !important;
    user-select: auto !important;
}


body::-webkit-scrollbar,
html::-webkit-scrollbar,
#notes-container::-webkit-scrollbar {
    display: none;
}

body,
html,
#notes-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#notes-container {
    min-height: 80vh;
}

body,
#root,
.app-container {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    -webkit-text-size-adjust: 100%;
}

h1 {
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 900;
    letter-spacing: -0.05em;
    font-size: clamp(2rem, 8vw, 2.8rem);
    margin-bottom: var(--space-xs);
    color: var(--text-primary);
    font-display: swap;
}

.sub-header {
    text-align: center;
    font-size: clamp(0.9rem, 4vw, 1.1rem);
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    font-weight: 500;
    max-width: 25rem;
    margin-left: auto;
    margin-right: auto;
}



@keyframes weight-pulse {
    0% { font-weight: 300; }
    50% { font-weight: 900; }
    100% { font-weight: 300; }
}



.radar-status {
    text-align: center;
    color: var(--accent-sage-dark);
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.interactive-location {
    cursor: pointer;
    color: var(--accent-sage-dark) !important;
}

.radar-status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #2e7d32;
    border-radius: 50%;
    box-shadow: 0 0 8px #2e7d32;
    animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }

    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

/* Leaning Pulse: Directional nudge in No Man's Land */
.radar-status.liminal::before {
    background-color: #A0A0A0; /* Desaturated */
    box-shadow: 0 0 0.5rem #A0A0A0;
    animation: leaning-pulse 3s infinite ease-in-out;
}

@keyframes leaning-pulse {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    50% { transform: translate(3px, -2px) scale(1.1); opacity: 0.7; } /* Slight lean */
    100% { transform: translate(0, 0) scale(1); opacity: 1; }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.welcome-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.4s ease;
    cursor: pointer;
}

/* Strip native OS styling from all form elements */
.drop-input, 
.category-btn, 
#note-desc {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    box-sizing: border-box;
    font-family: inherit;
    border-radius: 12px; /* Smoother premium radius */
}

/* Force 16px to prevent iOS Safari auto-zoom on focus */
.drop-input, 
#note-desc {
    font-size: 16px; 
    border: 1px solid var(--border-light); 
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    width: 100%;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02), 0 2px 8px rgba(0,0,0,0.02);
}

.drop-input:focus, 
#note-desc:focus {
    outline: none;
    border-color: var(--accent-sage);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02), 0 0 0 4px hsla(156, 11%, 60%, 0.2);
    transform: translateY(-1px);
}

/* Remove default iOS inner shadows on textareas */
#note-desc {
    box-shadow: none; 
}

.drop-input {
    padding: var(--space-md);
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

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

.note-card {
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    padding: 1rem;
    position: relative;
    border-radius: 1.75rem;
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.03), 
        0 10px 24px -5px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        inset 0 -1px 0 rgba(255, 255, 255, 0.2);
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.7);
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease, filter 0.4s ease;
    will-change: opacity, transform;
}

.note-card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 
        0 12px 20px -5px rgba(0, 0, 0, 0.06), 
        0 20px 40px -10px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 1);
}

.note-card.poof-exit {
    opacity: 0;
    transform: scale(0.95) translateY(0.625rem); /* 10px */
    pointer-events: none;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }

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

#mist-layer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 1500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1s ease;
    filter: blur(20px);
    will-change: opacity, filter;
}

#mist-layer.active {
    opacity: 0.8;
    pointer-events: all;
}

.pulsing-skeleton {
    display: inline-block;
    width: 120px;
    height: 12px;
    background: rgba(141, 163, 153, 0.3);
    border-radius: 6px;
    animation: pulse-opacity 1.5s ease-in-out infinite;
}

@keyframes pulse-opacity {
    0% {
        opacity: 0.4;
    }

    50% {
        opacity: 0.8;
    }

    100% {
        opacity: 0.4;
    }
}

.price-tag {
    font-weight: 800;
    color: var(--text-primary);
    margin-right: 0.75rem; /* 12px */
}

/* --- Drop Zone & Form Architecture --- */
.drop-zone {
    display: none;
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 25rem; /* 400px */
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius-md);
    box-shadow: 0 1.25rem 3.75rem rgba(0, 0, 0, 0.2);
    z-index: 1001;
    box-sizing: border-box;
    max-height: calc(100dvh - 2rem);
    display: flex;
    flex-direction: column;
}

.drop-form-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 2rem;
    -webkit-overflow-scrolling: touch;
}

.drop-form-footer {
    flex-shrink: 0;
    background: transparent;
    border-top: none;
    margin: 0;
    padding: 0.5rem 1rem 1.5rem 1rem;
}

.field-group {
    margin-bottom: 1rem;
    text-align: left;
}

.field-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.char-counter {
    text-align: right;
    font-size: 0.65rem;
    color: #999;
    margin-top: 0.25rem;
    font-weight: 700;
}

/* The box wrapping the switch */
.switch-group {
    margin-top: 30px;
    padding: 20px 15px 15px 15px;
    border: 1px solid #EAEAEA; /* Matches the drop-input border */
    border-radius: 8px;
    position: relative;
    background: transparent;
    display: flex;
    justify-content: space-between; /* Keeps toggle and text aligned */
    align-items: center;
}

/* The text sitting on the border */
.manifesto-label {
    position: absolute;
    top: -8px; /* Pulls the text up onto the border line */
    left: 15px;
    background: #FFFFFF; /* Essential: creates the cutout effect over the line */
    padding: 0 8px;
    font-size: 10px;
    font-weight: 500;
    font-style: italic;
    color: #8DA399; /* Sage green aesthetic */
    letter-spacing: 0.3px;
}

.switch-label {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--accent-sage-dark);
}

#broadcast-btn {
    width: 100%;
    background: var(--accent-sage-dark);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.125rem;
    padding: 0.65rem;
    font-size: 0.8rem;
    transition: transform 0.1s, background 0.2s;
}

#broadcast-btn:active {
    transform: scale(0.98);
}

/* --- Drop Form Typography & Spacing --- */
.drop-title {
    font-weight: 800;
    letter-spacing: -0.05em;
    margin-block-start: 0;
    margin-block-end: 0.125rem; /* ~2px */
    font-size: 1.4rem;
}

.drop-subtitle {
    font-size: 0.8rem;
    color: hsl(0, 0%, 40%); /* Replaces #666 */
    margin-block-end: 0.5rem; /* ~8px */
}

/* --- Switch Group Elements --- */
.switch-text-stack {
    display: flex;
    flex-direction: column;
    gap: 0.25rem; /* ~4px */
}

.switch-helper {
    display: block;
    margin-block-start: 0.25rem;
    font-size: 0.7rem;
    color: hsl(0, 0%, 40%);
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1.4;
}

/* --- Premium Upload & Boost Bridge --- */
.image-upload-wrapper {
    margin-block-start: 1rem; /* ~15px */
}

.premium-helper {
    font-size: 0.65rem;
    color: var(--accent-clay);
    margin-block-start: 0.35rem; /* ~5px */
    font-weight: bold;
    text-transform: uppercase;
}

.boost-bridge-container {
    margin-block-end: 1rem; /* ~15px */
    text-align: center;
}

.quick-boost-btn {
    background: hsla(148, 14%, 60%, 0.1); /* Translates rgba(141, 163, 153, 0.1) */
    border: 1px dashed var(--accent-sage);
    color: var(--accent-sage);
    padding: 0.625rem 1rem; /* ~10px 15px */
    border-radius: 0.75rem; /* ~12px */
    width: 100%;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.quick-boost-btn:hover {
    background: hsla(148, 14%, 60%, 0.2);
}

.privacy-manifesto {
    font-size: 0.7rem;
    color: hsl(0, 0%, 60%); /* Replaces #999 */
    margin-block-start: 0.5rem; /* ~8px */
    font-weight: 500;
    font-style: italic;
}

/* --- Welcome Overlay Geometry --- */
.welcome-card {
    background: var(--bg-glass);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    padding: 2.5rem 2.5rem;
    border-radius: var(--radius-lg);
    max-width: 92%;
    width: 440px;
    text-align: center;
    box-shadow: 
        0 24px 60px rgba(0,0,0,0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        inset 0 -1px 0 rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.6);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.trust-hook {
    background: rgba(141, 163, 153, 0.08);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    border: 1px solid rgba(62, 90, 77, 0.1);
}

.trust-hook-text {
    color: var(--accent-sage-dark);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 0;
}

.welcome-button-stack {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: 1.5rem;
    align-items: center;
    width: 100%;
}

.welcome-button-primary {
    width: 100%;
    max-width: 320px;
    padding: 1.1rem;
    font-size: 1.1rem;
    border-radius: var(--radius-full);
    background: var(--accent-sage-dark);
    color: var(--bg-secondary);
    border: none;
    border-radius: var(--radius-full);
    box-shadow: 0 0.25rem 1rem rgba(141, 163, 153, 0.3);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s ease;
}

.welcome-button-primary:active {
    transform: scale(0.96);
}

.welcome-button-secondary {
    background: transparent;
    color: #555555;
    border: none;
    padding: 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: var(--radius-full);
    transition: opacity 0.2s;
}

.welcome-button-secondary:hover {
    opacity: 0.7;
}

/* --- Drop Zone Desktop Fixes --- */
@media (min-width: 768px) {
    .drop-zone {
        max-height: 85vh;
        width: 500px;
        left: 50%;
        transform: translate(-50%, 0);
        top: 2rem;
        padding: 2rem;
        border-radius: var(--radius-md);
    }
    
    .drop-form-footer {
        padding: 1.25rem 2rem;
        margin: 0 -2rem -2rem -2rem;
    }
}
/* --- Category Selector in Form --- */
.category-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 0.5rem;
}

.category-btn {
    flex: 1;
    min-width: calc(50% - 4px);
    padding: 10px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 800;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.category-btn.active {
    background: var(--accent-sage-dark);
    color: white;
    border-color: var(--accent-sage-dark);
    box-shadow: 0 4px 12px rgba(62, 90, 77, 0.2);
}

.category-btn:active {
    transform: scale(0.96);
}

@media (min-width: 480px) {
    .category-btn {
        min-width: calc(25% - 6px);
    }
}

/* === CLS Prevention: Footer (Critical Path) === */
footer { text-align: center; margin-top: auto; padding-bottom: 20px; padding-top: 40px; border-top: 1px solid rgba(0, 0, 0, 0.05); min-height: 120px; }
.footer-links { margin-bottom: 20px; display: flex; flex-direction: column; align-items: center; gap: 0; }
.footer-links a { color: #A0A0A0; text-decoration: none; font-size: 0.75em; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; display: block; padding: 10px 12px; min-height: 44px; line-height: 1.5; box-sizing: border-box; }
.copyright { color: #707070; font-size: 0.7em; letter-spacing: 0.5px; margin-bottom: 16px; }

/* === CLS Prevention: FAB (Critical Path) === */
.fab { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); background: linear-gradient(135deg, var(--accent-clay), hsl(30, 42%, 54%)); color: white; padding: 18px 36px; border-radius: 99px; display: flex; align-items: center; justify-content: center; flex-wrap: nowrap; white-space: nowrap; gap: 12px; font-weight: 800; font-size: clamp(0.9em, 4vw, 1.05em); text-transform: uppercase; letter-spacing: 2px; box-shadow: 0 12px 24px hsla(30, 52%, 64%, 0.4), 0 4px 8px rgba(0, 0, 0, 0.1), inset 0 1px 0 hsla(0, 0%, 100%, 0.4); cursor: pointer; z-index: 1000; overflow: hidden; transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); border: 1px solid hsla(30, 52%, 64%, 0.8); }
.fab::before { content: ''; position: absolute; top: 0; left: -100%; width: 50%; height: 100%; background: linear-gradient(to right, transparent, rgba(255,255,255,0.3), transparent); transform: skewX(-20deg); animation: shine 4s infinite cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes shine { 0% { left: -100%; } 20% { left: 200%; } 100% { left: 200%; } }
.fab:hover { transform: translateX(-50%) translateY(-4px) scale(1.02); box-shadow: 0 16px 32px hsla(30, 52%, 64%, 0.5), 0 8px 16px rgba(0, 0, 0, 0.15), inset 0 1px 0 hsla(0, 0%, 100%, 0.5); }
.fab:active { transform: translateX(-50%) scale(0.96); }

/* === CLS Prevention: Note Images === */
.note-image { 
    width: 100%; 
    height: auto; 
    max-height: 350px;
    aspect-ratio: 4 / 3;
    object-fit: cover; 
    border-radius: 12px; 
    margin: 12px 0; 
    display: block; 
    background: rgba(0, 0, 0, 0.02); 
}

/* === Unified Base Card Class for Forms & Panels === */
.panel-card {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 0.875rem; /* ~14px tight padding */
    border-radius: var(--radius-sm); /* 12px */
    box-shadow: 0 0.25rem 0.375rem -0.06rem rgba(0, 0, 0, 0.05), 0 1.25rem 1.56rem -0.3rem rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-sizing: border-box;
}

/* Tightened margins for inputs inside panel cards */
.panel-card .field-group,
.panel-card .checkbox-container {
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
}

.panel-card .drop-input,
.panel-card .modern-input,
.panel-card input[type="text"],
.panel-card select,
.panel-card textarea {
    padding: 0.5rem 0.75rem; /* Compact padding */
    box-sizing: border-box;
}

/* Description textarea bounds constraints */
#seed-desc {
    min-height: 5rem; /* ~80px */
    max-height: 9.375rem; /* ~150px */
    resize: vertical;
}

/* Form container size limits and horizontal centering */
#seed-tab .panel-card {
    width: 100%;
    max-width: 30rem; /* 480px */
    margin: 0 auto 1.25rem auto;
}

/* Checkbox Alignment & Visibility Fixes */
.checkbox-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
}

.checkbox-container label {
    cursor: pointer;
    user-select: none;
    flex: 1;
}

.checkbox-container input[type="checkbox"] {
    -webkit-appearance: auto !important;
    appearance: auto !important;
    width: 1.25rem;
    height: 1.25rem;
    min-width: 1.25rem;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--accent-sage);
    margin: 0;
    padding: 0;
}
