:root {
    --primary-color: #2196F3;
    --success-color: #4CAF50;
    --danger-color: #f44336;
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --text-color: #333;
    --transition-speed: 0.3s;
    --font-primary: 'Inter', system-ui, -apple-system, sans-serif;
    --warning-color: #FFA000;
}

:root[data-theme="light"] {
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --text-color: #333;
    --border-color: #e0e0e0;
    --input-background: #ffffff;
}

:root[data-theme="dark"] {
    --background-color: #1a1a1a;
    --card-background: #2d2d2d;
    --text-color: #ffffff;
    --border-color: #4d4d4d;
    --input-background: #3d3d3d;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: var(--font-primary);
    line-height: 1.6;
}

.container {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 0 20px;
}

.card {
    background: var(--card-background);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.1);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.header-section h1 {
    margin: 2.5rem 0 0 0;
    flex: 1;
}

.header-section h1 .material-icons-round {
    font-size: 2rem;
    color: var(--primary-color);
}

.summary-section h2 .material-icons-round {
    color: var(--primary-color);
}

.explanation {
    transition: all 0.3s ease-in-out;
}

.explanation.hidden {
    display: none;
}

.explanation-collapsed {
    background-color: rgba(33, 150, 243, 0.05);
    border-left: 4px solid var(--primary-color);
    padding: 0.5rem;
    border-radius: 0 16px 16px 0;
    margin-bottom: 2rem;
    transition: all 0.3s ease-in-out;
}

.explanation-collapsed.hidden {
    display: none;
}

.toggle-button-collapsed {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem 1rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    width: 100%;
    transition: all 0.3s ease;
}

.toggle-button-collapsed:hover {
    color: var(--primary-color);
}

.toggle-button-collapsed .material-icons-round {
    font-size: 1.5rem;
}

.toggle-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-color);
    opacity: 0.7;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-button:hover {
    opacity: 1;
    color: var(--primary-color);
}

.material-icons-round {
    font-size: 24px;
    transition: transform 0.3s ease;
    vertical-align: middle;
}

.explanation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
}

.explanation-content {
    max-height: none;
    opacity: 1;
    transition: all 0.3s ease-in-out;
    overflow: visible;
}

.toggle-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-color);
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.toggle-button:hover {
    opacity: 1;
}

.chevron-icon {
    transition: transform 0.3s ease;
}

.chevron-icon.rotated {
    transform: rotate(180deg);
}

.input-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    background: var(--card-background);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.input-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.input-group label .material-icons-round {
    color: var(--primary-color);
    font-size: 1.2rem;
}

.tax-note {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.5rem;
    font-style: italic;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-group input,
.input-group select {
    padding: 0.8rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all var(--transition-speed);
    width: 100%;
    max-width: 150px;
}

.input-group select {
    max-width: 200px;
}

.input-group input:focus,
.input-group select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2);
}

.transaction-bar {
    background: var(--card-background);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    animation: slideIn 0.3s ease-out;
}

.transaction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.transaction-values {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
}

.bar {
    height: 24px;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    margin: 0.5rem 0;
}

.economy-portion {
    background: var(--success-color);
    height: 100%;
    transition: width var(--transition-speed) ease-in-out;
}

.tax-portion {
    background: var(--danger-color);
    height: 100%;
    transition: width var(--transition-speed) ease-in-out;
}

.legend {
    display: flex;
    justify-content: center;
    gap: 2rem;
    padding: 1rem;
    background: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

/* Update legend colors to match bars exactly */
.legend-item:first-child .legend-color {
    background: var(--success-color);
}

.legend-item:last-child .legend-color {
    background: var(--danger-color);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .input-section {
        grid-template-columns: 1fr;
    }
    
    h1 {
        font-size: 2rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #1a1a1a;
        --card-background: #2d2d2d;
        --text-color: #ffffff;
    }
    
    .input-group input,
    .input-group select {
        background-color: #3d3d3d;
        border-color: #4d4d4d;
        color: white;
    }
    
    .tax-note {
        color: #aaa;
    }
    
    .explanation {
        background-color: rgba(33, 150, 243, 0.1);
    }
}

.header-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    margin-bottom: 2rem;
}

.theme-toggle-wrapper {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
}

.theme-toggle {
    background: var(--card-background);
    border: none;
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.theme-toggle .material-icons-round {
    font-size: 1.5rem;
    color: var(--text-color);
}

@media (max-width: 768px) {
    .theme-toggle-wrapper {
        bottom: 1rem;
        right: 1rem;
    }
    
    .theme-toggle {
        width: 2.5rem;
        height: 2.5rem;
    }
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

[data-theme="light"] .moon-icon,
[data-theme="dark"] .sun-icon {
    display: none;
}

.theme-toggle:hover svg {
    transform: rotate(15deg);
}

/* Update input styles for dark mode */
.input-group input,
.input-group select {
    background-color: var(--input-background);
    border-color: var(--border-color);
    color: var(--text-color);
}

.footer {
    margin-top: 4rem;
    padding: 2rem 0;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    text-align: center;
    color: var(--text-color);
    opacity: 0.6;
    font-size: 0.85rem;
}

.footer-links {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
}

.footer-links a {
    color: var(--text-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: opacity var(--transition-speed);
    opacity: 0.6;
}

.footer-links a:hover {
    opacity: 0.8;
}

.footer-links .material-icons-round {
    font-size: 1.2rem;
}

.github-icon {
    width: 18px;
    height: 18px;
    color: var(--text-color);
}

.footer-separator {
    opacity: 0.4;
}

/* Responsive footer */
@media (max-width: 768px) {
    .footer {
        margin-top: 2rem;
        padding: 1.5rem 0;
    }
    
    .footer-content {
        font-size: 0.9rem;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .footer-separator {
        display: none;
    }
}

.summary-section {
    margin-bottom: 2rem;
}

.summary-visualization {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    margin: 1rem 0;
}

.money-stack {
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.money-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    transition: transform 0.3s ease;
}

.money-icon.remaining {
    opacity: 0.5;
}

.money-icon.tax {
    animation: buildingPulse 2s infinite;
}

.money-label {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 0.5rem;
}

.money-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-color);
}

.arrow-animation {
    font-size: 2rem;
    animation: arrowPulse 1.5s infinite;
}

.impact-message, .total-loss-message {
    margin: 1rem 0;
    padding: 1rem;
    background-color: rgba(244, 67, 54, 0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1rem;
    color: #d32f2f;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    font-weight: 600;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.impact-message {
    text-align: center;
    font-size: 1.2rem;
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 8px;
    background-color: rgba(var(--danger-color-rgb), 0.1);
    color: var(--text-color);
}

.total-loss-message .material-icons-round {
    font-size: 1.3rem;
    color: #d32f2f;
}

[data-theme="dark"] .total-loss-message {
    background-color: rgba(244, 67, 54, 0.25);
    border-color: rgba(244, 67, 54, 0.4);
    color: #ff5252;
}

[data-theme="dark"] .total-loss-message .material-icons-round {
    color: #ff5252;
}

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

@keyframes arrowPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes buildingPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* Responsive design for summary section */
@media (max-width: 768px) {
    .summary-visualization {
        flex-direction: column;
        gap: 1rem;
    }
    
    .arrow-animation {
        transform: rotate(90deg);
    }
}

.share-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.share-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-speed);
    color: white;
    padding: 0;
}

.share-link .material-icons-round {
    font-size: 18px;
}

.share-link:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.share-link.x-social {
    background-color: #000000;
}

.share-link.linkedin {
    background-color: #0077B5;
}

.share-link.facebook {
    background-color: #1877F2;
}

.share-link.copy-link {
    background-color: var(--primary-color);
}

.x-icon {
    width: 14px;
    height: 14px;
}

/* Toast notification for copy link */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--card-background);
    color: var(--text-color);
    padding: 1rem 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
}

.toast-success {
    border-left: 4px solid var(--success-color);
}

.toast-info {
    border-left: 4px solid var(--primary-color);
}

.toast-warning {
    border-left: 4px solid #FFA000;
}

.toast-error {
    border-left: 4px solid var(--danger-color);
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .share-buttons {
        flex-direction: row !important;
        align-items: center !important;
        padding: 40px 0 10px 0 !important;
        margin-top: 1.5rem !important;
    }
}

.footer-credit {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.footer-credit .material-icons-round {
    font-size: 1rem;
    color: var(--primary-color);
}

.header-icon {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    margin-right: 12px;
    object-fit: cover;
}

.tax-flow {
    text-align: center;
    padding: 1.5rem;
    background: var(--card-background);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    line-height: 1.8;
}

.tax-note {
    color: var(--danger-color);
    font-size: 0.85rem;
    opacity: 0.8;
    font-style: italic;
}

[data-theme="dark"] .tax-flow {
    background: var(--background-color);
}

.explanation-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    align-items: start;
    margin: 2rem 0;
}

.explanation-text {
    padding-right: 1rem;
}

@media (max-width: 768px) {
    .explanation-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .explanation-text {
        padding-right: 0;
    }
    
    .tax-flow {
        margin: 0 auto;
        max-width: 300px;
    }
}

.disclaimer {
    margin: 2rem 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid var(--warning-color);
    background: color-mix(in srgb, var(--warning-color) 4%, var(--card-background));
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.8;
}

.disclaimer strong {
    color: var(--warning-color);
}

[data-theme="dark"] .disclaimer {
    background: color-mix(in srgb, var(--warning-color) 8%, var(--background-color));
}

/* Add styles for new elements */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(var(--background-color-rgb), 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--primary-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.share-prompt {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    text-align: center;
    margin: 1.5rem 0 1rem;
    padding: 0 1rem;
    color: var(--primary-color);
    font-size: 0.95rem;
    font-weight: 500;
}

.share-prompt p {
    margin: 0;
    color: inherit;
}

.share-prompt .material-icons-round {
    font-size: 1.2rem;
    color: var(--primary-color);
}

[data-theme="dark"] .share-prompt {
    color: color-mix(in srgb, var(--primary-color) 85%, white);
}

.quote-section {
    text-align: right;
    padding: 0.5rem 1rem;
    font-style: italic;
    background-color: transparent;
    max-width: 400px;
    margin: -0.5rem 0 0 0;
}

.quote-section .material-icons-round {
    color: var(--text-color);
    opacity: 0.4;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.quote-text {
    font-size: 1rem;
    line-height: 1.6;
    margin: 0 0 0.5rem 0;
    color: var(--text-color);
    opacity: 0.85;
    font-weight: 400;
    font-family: "Georgia", serif;
}

.quote-author {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.6;
    margin: 0;
    font-style: normal;
    font-weight: 400;
}

@media (max-width: 768px) {
    .quote-section {
        text-align: center;
        max-width: 100%;
    }
}

.top-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    gap: 2rem;
}

.header-section h1 {
    margin: 1.5rem 0 0 0;
    flex: 1;
}

.site-title {
    font-size: 2.5rem;
    margin: 0;
    flex: 1;
}

.theme-toggle-wrapper {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.header-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    margin-bottom: 2rem;
}

.header-section h1 {
    margin: 1.5rem 0 0 0;
    flex: 1;
}

.quote-section {
    text-align: right;
    padding: 0.5rem 1rem;
    font-style: italic;
    background-color: transparent;
    max-width: 400px;
    margin: -0.5rem 0 0 0;
}

@media (max-width: 768px) {
    .header-section {
        flex-direction: column;
        gap: 1rem;
    }
    
    .quote-section {
        text-align: center;
        max-width: 100%;
    }
}

/* Mobile-friendly styles */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }

    /* Make text more readable on small screens */
    p, li {
        font-size: 16px;
        line-height: 1.5;
    }

    /* Ensure images don't overflow */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Adjust container widths */
    .container {
        width: 100%;
        padding: 0 15px;
        box-sizing: border-box;
    }

    /* Stack elements vertically on mobile */
    .row {
        flex-direction: column;
    }

    /* Full width columns on mobile */
    .column {
        width: 100%;
        margin: 10px 0;
    }

    /* Adjust navigation for mobile */
    nav {
        padding: 10px;
    }

    nav ul {
        flex-direction: column;
        align-items: center;
    }

    nav li {
        margin: 5px 0;
    }

    /* Adjust buttons for better touch targets */
    button {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }

    .explanation.card {
        padding: 1.5rem;
    }

    .explanation-content {
        padding-bottom: 1rem;
    }

    .explanation-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .tax-flow {
        margin: 1rem auto;
        padding: 1rem;
        font-size: 0.9rem;
        line-height: 1.6;
    }

    .explanation-text {
        padding-right: 0;
    }

    .explanation-text ol {
        padding-left: 1.5rem;
    }

    .impact-message {
        font-size: 1rem;
        padding: 0.75rem;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        line-height: 1.4;
    }

    /* Adjust the transaction count and percentage to display better */
    #transaction-count,
    #tax-percentage {
        display: inline-block;
        font-weight: 600;
        color: var(--danger-color);
    }

    /* Add some spacing between the numbers and text */
    .impact-message span {
        margin: 0 0.2rem;
    }
}

/* Ensure proper touch target sizes */
a, button, input, select {
    min-height: 44px;
    min-width: 44px;
}

.social-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 0;
    -webkit-overflow-scrolling: touch; /* For smooth scrolling on iOS */
}

.social-button {
    flex: 0 0 auto; /* Prevent shrinking and growing */
}