@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Google+Sans+Flex:opsz,slnt,wdth,wght,GRAD,ROND@6..144,-10..0,25..151,1..1000,0..100,0..100&display=swap');

:root {
    /* Consistent Color variables mapped from palette.css */
    --background: #121016;
    --surface: #1d1b20;
    --surface-variant: #2d2a33;
    --primary: #8859ff;
    --primary-container: #4527a0;
    --on-primary: #ffffff;
    --on-surface: #e6e1e5;
    --on-surface-variant: #cac4d0;
    --outline: #49454f;
    --highlight-color: #8859ff;
    --highlight-bg: #f2edff;
    --cell-background: rgba(0, 0, 0, 0.15);
}

:root.light-mode {
    --cell-background: rgba(0, 0, 0, 0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Google Sans Flex', sans-serif;
    -webkit-user-drag: none;
}

img {
    -webkit-user-select: none;
    -webkit-user-drag: none;
    user-select: none;
}

::placeholder {
    -webkit-user-select: none;
    user-select: none;
}

*::selection {
    color: var(--highlight-color);
    background: var(--highlight-bg);
}

/* Custom Scrollbars - Theme Responsive & Rounded */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--on-surface, #e6e1e5) 18%, transparent);
    border-radius: 9999px;
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: background-color 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary, #8859ff);
    border: 1px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-corner {
    background: transparent;
}

:root.light-mode ::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--on-surface, #1d1b20) 22%, transparent);
    border: 2px solid transparent;
    background-clip: padding-box;
}

:root.light-mode ::-webkit-scrollbar-thumb:hover {
    background: var(--primary, #8859ff);
    border: 1px solid transparent;
    background-clip: padding-box;
}

* {
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--on-surface, #e6e1e5) 18%, transparent) transparent;
}

:root.light-mode * {
    scrollbar-color: color-mix(in srgb, var(--on-surface, #1d1b20) 22%, transparent) transparent;
}

.back-link,
.pfp-wrapper,
.portal-title,
.control-label,
.text-action-btn,
.action-btn,
.stat-lbl,
.stat-val,
button {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

body {
    min-height: 100vh;
    background: var(--background);
    color: var(--on-surface);
    font-family: 'Google Sans Flex', sans-serif;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 0; margin: 0; margin: 0;
    
}

.pfp-wrapper {
    margin-top: 40px;
    margin-bottom: -10px;
    width: clamp(80px, 8vw, 100px);
    height: clamp(80px, 8vw, 100px);
    clip-path: url('#active-clip');
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    cursor: pointer;
}

.pfp-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.pfp-icon-content {
    width: 100%;
    height: 100%;
    background: var(--primary-container); /* Theme-responsive icon background */
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
}

.pfp-icon-content svg {
    width: 42%;
    height: 42%;
    color: var(--on-primary-container, #ffffff);
}

.portal-container {
    padding: 40px 15px 30px;
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.back-link {
    position: absolute;
    top: calc(var(--astrong-header-height, 61.6px) + var(--astrong-header-spacing, 17.2px));
    left: var(--astrong-header-left, 1.5rem);
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--on-surface-variant);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.back-link:hover {
    color: var(--on-surface);
}

.portal-header {
    text-align: center;
}

.portal-title {
    font-size: 2.25rem;
    font-weight: 800;
    font-variation-settings: 'ROND' 100, 'wdth' 85;
    color: var(--on-surface);
}

/* Material 3 Card Container */
.generator-card {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: 28px;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

.control-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Action text triggers (Clear/Copy) */
.text-action-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.2s ease;
}

.text-action-btn:hover {
    color: var(--on-surface);
}

/* Textarea elements styling */
textarea {
    width: 100%;
    height: 120px;
    background: var(--cell-background);
    border: 1px solid var(--outline);
    border-radius: 16px;
    padding: 1rem;
    color: var(--on-surface);
    font-size: 0.95rem;
    font-weight: 500;
    resize: vertical;
    line-height: 1.5;
    transition: border-color 0.2s ease;
}

textarea:focus {
    border-color: var(--primary);
}

/* Custom Scrollbars for Textarea */
textarea::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

textarea::-webkit-scrollbar-track {
    background: var(--cell-background);
    border-radius: 0 16px 16px 0;
}

textarea::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--on-surface, #e6e1e5) 18%, transparent);
    border-radius: 9999px;
}

textarea::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

textarea::-webkit-scrollbar-corner {
    background: transparent;
}

/* Custom Resize Handle */
textarea::-webkit-resizer {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M10 0 L0 10 M10 4 L4 10 M10 7 L7 10' stroke='%237a7a7a' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: bottom right;
}

textarea::-webkit-resizer:hover {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M10 0 L0 10 M10 4 L4 10 M10 7 L7 10' stroke='%238859ff' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
}


#output-text {
    background: var(--cell-background);
    color: var(--on-surface-variant);
}

/* Operations & transformations buttons */
.operations-section {
    display: flex;
    flex-direction: column;
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--outline);
    color: var(--on-surface);
    border-radius: 12px;
    padding: 0.65rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

:root.light-mode .action-btn {
    background: rgba(0, 0, 0, 0.03);
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--on-surface-variant);
}

:root.light-mode .action-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

.action-btn:active {
    background: var(--primary-container);
    border-color: var(--primary);
    color: var(--on-primary-container, #ffffff);
}

/* Stats panel */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    background: var(--cell-background);
    border: 1px solid var(--outline);
    border-radius: 20px;
    padding: 1rem;
    text-align: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-val {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-lbl {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Toast popup styling */
.toast-popup {
    position: fixed;
    bottom: 2rem;
    background: var(--surface-variant);
    border: 1px solid var(--outline);
    color: var(--on-surface);
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.toast-popup.show {
    opacity: 1;
    transform: translateY(0);
}

/* Responsiveness */
@media (max-width: 768px) {
    body {
        padding-top: 0;
    }

    .back-link {
        position: relative;
        top: auto;
        left: auto;
        align-self: flex-start;
        width: auto;
        margin: 0.6rem 0.85rem 0.4rem;
    }
}

@media (max-width: 580px) {
    .actions-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 440px) {
    .actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-panel {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}