:root {
    --bg-dark: hsl(240, 20%, 10%);
    --bg-card: hsla(240, 20%, 15%, 0.6);
    --accent-primary: hsl(260, 100%, 65%);
    /* Vibrant Purple */
    --accent-secondary: hsl(320, 100%, 60%);
    /* Pink */
    --success: hsl(150, 80%, 40%);
    /* --danger is global now, but we can override if needed */

    --spacing-xs: 8px;
    --spacing-sm: 16px;
    --spacing-md: 24px;
    --spacing-lg: 32px;

    /* Effects */
    --glass-border: 1px solid hsla(0, 0%, 100%, 0.1);
    --glass-shadow: 0 8px 32px 0 hsla(0, 0%, 0%, 0.3);
    --blur-amt: 20px;

    --font-main: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    overflow-x: hidden;
}

/* Background Blobs for Atmosphere */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 20s infinite alternate ease-in-out;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: var(--accent-primary);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 400px;
    height: 400px;
    background: var(--accent-secondary);
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: var(--success);
    top: 40%;
    left: 40%;
    opacity: 0.3;
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(30px, 50px) scale(1.1);
    }
}

/* Layout */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.app-header {
    text-align: center;
    margin-bottom: var(--spacing-sm);
}

.app-header h1 {
    font-size: 3rem;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.session-manager {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
}

.session-select {
    width: auto;
    /* Override 100% width from general input styling */
    min-width: 150px;
    padding: 6px 12px;
    font-size: 0.9rem;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.9rem;
}

.app-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(var(--blur-amt));
    -webkit-backdrop-filter: blur(var(--blur-amt));
    border: var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: var(--glass-shadow);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    border-color: hsla(0, 0%, 100%, 0.2);
}

.card.hidden {
    opacity: 0.5;
    pointer-events: none;
    filter: grayscale(1);
    transform: scale(0.98);
}

.card.hidden:hover {
    transform: scale(0.98);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.step-indicator {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: hsla(0, 0%, 100%, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
}

/* Forms & Inputs */
.input-group {
    display: flex;
    gap: var(--spacing-xs);
}

input,
select {
    background: hsla(0, 0%, 0%, 0.3);
    border: 1px solid hsla(0, 0%, 100%, 0.1);
    color: white;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    width: 100%;
    transition: all 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: hsla(0, 0%, 0%, 0.5);
}

.form-input {
    margin-bottom: var(--spacing-sm);
}

/* Buttons */
.btn {
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    font-size: 1rem;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 4px 15px hsla(260, 100%, 65%, 0.3);
}

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

.btn-secondary {
    background: hsla(0, 0%, 100%, 0.1);
    color: white;
}

.btn-secondary:hover {
    background: hsla(0, 0%, 100%, 0.2);
}

.btn-accent {
    background: var(--success);
    color: white;
    width: 100%;
    /* In header context usually wants auto, but for results button good */
}

.card-header .btn-accent {
    width: auto;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-text {
    background: none;
    color: var(--accent-primary);
    padding: 4px 8px;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
}

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

.btn-danger-outline {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    width: 100%;
}

.btn-danger-outline.btn-sm {
    width: auto;
}

.btn-danger-outline:hover {
    background: var(--danger);
    color: white;
}

.full-width {
    width: 100%;
}

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

.form-actions-row .btn {
    flex: 1;
}

.hidden {
    display: none !important;
}

/* Edit Mode styling overrides */
.edit-mode .btn-secondary {
    background: var(--accent-primary);
    /* Use primary color for "Update" action */
    box-shadow: 0 4px 15px hsla(260, 100%, 65%, 0.3);
}


/* People Chips */
.people-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-sm);
}

.chip {
    background: hsla(0, 0%, 100%, 0.1);
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease;
}

.chip .remove {
    cursor: pointer;
    opacity: 0.5;
    font-weight: bold;
}

.chip .remove:hover {
    opacity: 1;
    color: var(--danger);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

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

.empty-state {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.9rem;
}

/* Checkbox Group */
.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--spacing-xs);
    margin: var(--spacing-xs) 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    user-select: none;
}

.checkbox-label input {
    width: auto;
    accent-color: var(--accent-primary);
}

/* Item List */
.items-list {
    margin: var(--spacing-sm) 0;
    max-height: 200px;
    overflow-y: auto;
}

.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid hsla(0, 0%, 100%, 0.1);
}

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

.item-details {
    display: flex;
    flex-direction: column;
}

.item-name {
    font-weight: 600;
}

.item-shared-by {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Summary Inputs */
.summary-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* Changed to 2x2 grid */
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.label-text {
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Results */
.result-group {
    margin-bottom: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: hsla(0, 0%, 0%, 0.2);
    border-radius: var(--radius-md);
}

/* Receipt List & Editor */
.receipts-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.receipt-card {
    background: hsla(0, 0%, 100%, 0.05);
    border: 1px solid hsla(0, 0%, 100%, 0.1);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    position: relative;
    color: var(--text-primary);
}

.receipt-card:hover {
    background: hsla(0, 0%, 100%, 0.1);
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}

.receipt-card h3 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.receipt-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.editor-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    background: hsla(0, 0%, 0%, 0.2);
    padding: 12px;
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
}

.receipt-name-input {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    width: auto;
    border-bottom: 2px solid transparent;
}

.receipt-name-input:focus {
    outline: none;
    border-bottom-color: var(--accent-primary);
    background: transparent;
}

.result-header {
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: var(--spacing-xs);
}

.debt-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.95rem;
}

.total-per-person {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid hsla(0, 0%, 100%, 0.05);
}

.actions-footer {
    text-align: center;
    opacity: 0.6;
}

.actions-footer:hover {
    opacity: 1;
}

/* Responsive */
@media (max-width: 480px) {
    .app-header h1 {
        font-size: 2.5rem;
    }

    .summary-inputs {
        grid-template-columns: 1fr;
    }
}