* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Fredoka', sans-serif;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #e73c7e 25%, #ee7752 50%, #f7c948 100%);
    background-size: 400% 400%;
    animation: gradientBG 12s ease infinite;
    color: #1a1a2e;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ═══════════════════════════════════════════
   CORNER MASCOTS
   ═══════════════════════════════════════════ */

.corner-mascots {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.corner-mascot {
    position: absolute;
    font-size: 5rem;
    opacity: 0.5;
    transition: opacity 0.6s ease, transform 0.6s ease;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}

.corner-mascot:hover {
    opacity: 0.8;
}

/* Top-left — peeking from upper left */
.corner-tl {
    top: -8px;
    left: -8px;
    transform: rotate(15deg);
    animation: peekTL 4s ease-in-out infinite;
}

/* Top-right — peeking from upper right */
.corner-tr {
    top: -8px;
    right: -8px;
    transform: rotate(-15deg);
    animation: peekTR 5s ease-in-out infinite;
}

/* Bottom-left — peeking from lower left */
.corner-bl {
    bottom: -8px;
    left: -8px;
    transform: rotate(-10deg);
    animation: peekBL 4.5s ease-in-out infinite;
}

/* Bottom-right — peeking from lower right */
.corner-br {
    bottom: -8px;
    right: -8px;
    transform: rotate(10deg);
    animation: peekBR 5.5s ease-in-out infinite;
}

@keyframes peekTL {
    0%, 100% { transform: rotate(15deg) translate(-5px, -5px); }
    50% { transform: rotate(20deg) translate(8px, 8px); }
}

@keyframes peekTR {
    0%, 100% { transform: rotate(-15deg) translate(5px, -5px); }
    50% { transform: rotate(-20deg) translate(-8px, 8px); }
}

@keyframes peekBL {
    0%, 100% { transform: rotate(-10deg) translate(-5px, 5px); }
    50% { transform: rotate(-15deg) translate(8px, -8px); }
}

@keyframes peekBR {
    0%, 100% { transform: rotate(10deg) translate(5px, 5px); }
    50% { transform: rotate(15deg) translate(-8px, -8px); }
}

/* Pop animation when mascots change */
.corner-pop {
    animation: cornerPop 0.4s ease-out;
}

@keyframes cornerPop {
    0% { transform: scale(0.5); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.container {
    max-width: 700px;
    position: relative;
    z-index: 1;
    margin: 0 auto;
    padding: 30px 20px;
}

/* ═══════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════ */

header {
    text-align: center;
    margin-bottom: 25px;
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    position: relative;
}

.header-actions {
    position: absolute;
    right: 0;
    top: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

h1 {
    font-size: 2.8rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.2);
}

.subtitle {
    color: rgba(255,255,255,0.9);
    font-size: 1.1rem;
    margin-top: 5px;
}

/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */

.small-btn {
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    transition: background 0.2s;
}
.small-btn:hover { background: rgba(255,255,255,0.3); }

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    transition: transform 0.2s;
}
.icon-btn:hover { transform: scale(1.15); }

.btn-primary {
    background: linear-gradient(135deg, #a855f7, #ec4899);
    color: white;
    border: none;
    padding: 14px 30px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(168,85,247,0.4); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-primary.full-width { width: 100%; margin-top: 10px; }

#user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}
#user-email {
    color: rgba(255,255,255,0.9);
    font-size: 0.8rem;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════
   CARD
   ═══════════════════════════════════════════ */

.card {
    background: #fff;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    position: relative;
    overflow: visible;
}

/* ═══════════════════════════════════════════
   HANGING MASCOT
   ═══════════════════════════════════════════ */

.card-mascot {
    position: absolute;
    top: -35px;
    right: 30px;
    z-index: 10;
    animation: mascotSwing 3s ease-in-out infinite;
    transform-origin: top center;
    cursor: pointer;
    user-select: none;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}

.mascot-character {
    font-size: 3.2rem;
    display: block;
    transition: transform 0.3s ease;
}

.card-mascot:hover .mascot-character {
    transform: scale(1.3) rotate(10deg);
}

/* Swing animation — like hanging off the edge */
@keyframes mascotSwing {
    0%, 100% { transform: rotate(-8deg); }
    25% { transform: rotate(5deg); }
    50% { transform: rotate(-5deg); }
    75% { transform: rotate(3deg); }
}

/* Pop-in when mascot changes */
.mascot-pop {
    animation: mascotPop 0.4s ease-out;
}

@keyframes mascotPop {
    0% { transform: scale(0) rotate(0deg); }
    50% { transform: scale(1.4) rotate(15deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* ═══════════════════════════════════════════
   AUTH MODAL
   ═══════════════════════════════════════════ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal[hidden] {
    display: none !important;
}

.modal-content {
    background: #fff;
    border-radius: 20px;
    padding: 35px 30px 30px;
    width: 90%;
    max-width: 380px;
    position: relative;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.auth-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: #1a1a2e;
}

.auth-subtitle {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 20px;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form[hidden] {
    display: none !important;
}

.auth-switch {
    font-size: 0.85rem;
    color: #888;
    margin-top: 4px;
}

.auth-switch a {
    color: #a855f7;
    font-weight: 600;
    text-decoration: none;
}
.auth-switch a:hover {
    text-decoration: underline;
}

.auth-form input {
    padding: 12px 16px;
    border: 2px solid #eee;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}
.auth-form input:focus {
    outline: none;
    border-color: #a855f7;
}

.auth-error {
    color: #ef4444;
    font-size: 0.9rem;
    text-align: center;
}

/* ═══════════════════════════════════════════
   INPUT / CONTROLS
   ═══════════════════════════════════════════ */

.input-section {
    margin-bottom: 20px;
}

.input-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 1rem;
}

textarea {
    width: 100%;
    padding: 14px;
    border: 2px solid #eee;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    transition: border-color 0.2s;
}
textarea:focus {
    outline: none;
    border-color: #a855f7;
}

.mode-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.controls {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    margin-bottom: 15px;
}

.dialect-picker {
    flex: 1;
}

.dialect-picker label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

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

select {
    width: 100%;
    padding: 12px;
    border: 2px solid #eee;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    background: #fff;
    cursor: pointer;
}
select:focus {
    outline: none;
    border-color: #a855f7;
}

#surprise-btn {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    border: none;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s;
}
#surprise-btn:hover { transform: scale(1.1); }

#translate-btn {
    background: linear-gradient(135deg, #a855f7, #ec4899);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    min-width: 140px;
    transition: transform 0.2s, box-shadow 0.2s;
}
#translate-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(168,85,247,0.4); }
#translate-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Compare controls */
.compare-pickers {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

/* ═══════════════════════════════════════════
   OPTIONS ROW
   ═══════════════════════════════════════════ */

.options-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.option-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: #555;
}

.toggle-group {
    display: inline-flex;
    border: 2px solid #eee;
    border-radius: 10px;
    overflow: hidden;
}

.toggle-btn {
    padding: 8px 16px;
    border: none;
    background: #fff;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    color: #888;
}
.toggle-btn.active {
    background: linear-gradient(135deg, #a855f7, #ec4899);
    color: white;
}

.nsfw-toggle, .provider-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Switch */
.switch {
    position: relative;
    width: 44px;
    height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ddd;
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.3s;
}
.switch-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}
.switch input:checked + .switch-slider { background: #ef4444; }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }

/* ═══════════════════════════════════════════
   SLIDERS
   ═══════════════════════════════════════════ */

.slider-section {
    margin-bottom: 15px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.level-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #a855f7;
    background: rgba(168,85,247,0.1);
    padding: 2px 10px;
    border-radius: 20px;
}

input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: #eee;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a855f7, #ec4899);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(168,85,247,0.3);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #999;
    margin-top: 4px;
}

/* ═══════════════════════════════════════════
   OUTPUT
   ═══════════════════════════════════════════ */

.output-section {
    margin-top: 20px;
    padding: 20px;
    background: #faf5ff;
    border-radius: 12px;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

#output-label {
    font-weight: 600;
    font-size: 1rem;
}

.output-actions {
    display: flex;
    gap: 6px;
}

.output-text {
    font-size: 1.1rem;
    line-height: 1.6;
    padding: 10px;
    border-left: 4px solid #a855f7;
}

/* ═══════════════════════════════════════════
   COMPARE GRID
   ═══════════════════════════════════════════ */

.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
}

.compare-card {
    background: #faf5ff;
    border-radius: 12px;
    padding: 15px;
    border-top: 4px solid #a855f7;
}

.compare-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.85rem;
}

.compare-card-text {
    font-size: 0.95rem;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════
   SIDE PANELS (History / Admin)
   ═══════════════════════════════════════════ */

.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: #fff;
    box-shadow: -5px 0 20px rgba(0,0,0,0.15);
    z-index: 900;
    overflow-y: auto;
    padding: 20px;
}

.panel-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

.panel-header h2 {
    font-size: 1.3rem;
    width: 100%;
    margin-bottom: 8px;
}

.panel-tabs {
    display: flex;
    gap: 8px;
}

.panel-tab {
    background: #f3f4f6;
    border: none;
    padding: 6px 14px;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}
.panel-tab.active {
    background: #a855f7;
    color: white;
}

/* History items */
.history-item {
    padding: 12px;
    border-bottom: 1px solid #f3f4f6;
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.history-dialect {
    font-weight: 600;
    font-size: 0.85rem;
}

.history-time {
    font-size: 0.75rem;
    color: #999;
}

.history-input {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 4px;
}

.history-output {
    font-size: 0.9rem;
    color: #333;
    font-style: italic;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-style: italic;
}

/* ═══════════════════════════════════════════
   ADMIN
   ═══════════════════════════════════════════ */

.admin-section {
    margin-bottom: 25px;
}

.admin-section h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: #555;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.admin-table th, .admin-table td {
    padding: 8px 6px;
    text-align: left;
    border-bottom: 1px solid #eee;
}
.admin-table th {
    font-weight: 600;
    color: #666;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.analytics-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
}

.stat-card {
    background: #f3f4f6;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    flex: 1;
}

.stat-num {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #a855f7;
}

.stat-label {
    font-size: 0.8rem;
    color: #666;
}

.popular-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.popular-item {
    background: #f3f4f6;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
}

/* ═══════════════════════════════════════════
   ERROR
   ═══════════════════════════════════════════ */

.error-section {
    margin-top: 15px;
    padding: 15px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    color: #dc2626;
    text-align: center;
}

/* ═══════════════════════════════════════════
   SPINNER
   ═══════════════════════════════════════════ */

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s ease infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════ */

footer {
    text-align: center;
    margin-top: 20px;
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
}

#version-badge {
    background: rgba(255,255,255,0.2);
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    .container { padding: 15px 10px; }
    .card { padding: 20px 15px; }
    .controls { flex-direction: column; }
    #translate-btn { width: 100%; }
    .compare-pickers { grid-template-columns: 1fr; }
    .compare-grid { grid-template-columns: 1fr; }
    .options-row { flex-direction: column; align-items: flex-start; }
    .header-actions { position: static; justify-content: center; }
    .header-top { flex-direction: column; }
    .side-panel { width: 100%; }
}
