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

/* ── Tema Claro (padrão) ── */
:root {
    --bg-body: #ffffff;
    --text-primary: #1c1c1b;
    --text-heading: #1c1c1b;
    --text-subtitle: #6b6b6b;
    --text-muted: #9e9b95;
    --text-footer: #6b6b6b;
    --border-color: #e0ddd8;
    --card-bg: #ffffff;
    --avatar-bg: #dbeafe;
    --avatar-color: #1d4ed8;
    --badge-bg: #dbeafe;
    --badge-color: #1e40af;
    --dot-empty: #d4d2cc;
    --dot-filled: #1d4ed8;
    --toggle-bg: #f0eee9;
    --toggle-hover: #e0ddd8;
    --toggle-shadow: rgba(0, 0, 0, 0.08);
}

/* ── Tema Escuro ── */
[data-theme="dark"] {
    --bg-body: #0f0f11;
    --text-primary: #e4e4e7;
    --text-heading: #f4f4f5;
    --text-subtitle: #a1a1aa;
    --text-muted: #71717a;
    --text-footer: #a1a1aa;
    --border-color: #27272a;
    --card-bg: #18181b;
    --avatar-bg: #1e293b;
    --avatar-color: #60a5fa;
    --badge-bg: #1e293b;
    --badge-color: #93c5fd;
    --dot-empty: #3f3f46;
    --dot-filled: #6366f1;
    --toggle-bg: #27272a;
    --toggle-hover: #3f3f46;
    --toggle-shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.4s ease, color 0.4s ease;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.portfolio {
    max-width: 780px;
    width: 100%;
    margin: 0 auto;
    padding: clamp(1.25rem, 4vw, 3rem) clamp(1rem, 3vw, 2rem);
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

main {
    flex: 1;
}

/* ── Theme Toggle Button ── */
.theme-toggle {
    position: absolute;
    top: clamp(1rem, 3vw, 2rem);
    right: clamp(1rem, 3vw, 2rem);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--toggle-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: background-color 0.3s ease, border-color 0.3s ease, 
                transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 8px var(--toggle-shadow);
    z-index: 10;
    overflow: hidden;
}

.theme-toggle:hover {
    background: var(--toggle-hover);
    transform: scale(1.1);
    box-shadow: 0 4px 16px var(--toggle-shadow);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Ícones do toggle */
.theme-icon {
    position: absolute;
    transition: opacity 0.35s ease, transform 0.35s ease;
    line-height: 1;
}

.theme-icon.sun {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.theme-icon.moon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

/* Quando dark mode está ativo */
[data-theme="dark"] .theme-icon.sun {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

[data-theme="dark"] .theme-icon.moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ── Header ── */
header {
    text-align: center;
    margin-bottom: clamp(1.5rem, 4vw, 3rem);
    padding-bottom: clamp(1.25rem, 3vw, 2rem);
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.4s ease;
}

.avatar {
    width: clamp(56px, 10vw, 80px);
    height: clamp(56px, 10vw, 80px);
    border-radius: 50%;
    background: var(--avatar-bg);
    color: var(--avatar-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(20px, 4vw, 28px);
    font-weight: 600;
    margin: 0 auto 1rem;
    transition: background-color 0.4s ease, color 0.4s ease;
}

header h1 {
    font-size: clamp(1.25rem, 3.5vw, 1.75rem);
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-heading);
    transition: color 0.4s ease;
}

header p {
    font-size: clamp(0.85rem, 2.2vw, 1rem);
    color: var(--text-subtitle);
    transition: color 0.4s ease;
}

/* ── Section title ── */
.section-title {
    font-size: clamp(0.65rem, 1.5vw, 0.75rem);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    transition: color 0.4s ease;
}

/* ── Badge ── */
.badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--badge-bg);
    color: var(--badge-color);
    margin-bottom: 1rem;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* ── Skills grid ── */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
    gap: clamp(8px, 1.5vw, 14px);
    margin-bottom: clamp(1.5rem, 4vw, 3rem);
}

.skill-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: clamp(0.9rem, 2vw, 1.25rem);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.4s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.skill-card.active {
    border-color: var(--dot-filled);
    box-shadow: 0 2px 16px rgba(99, 102, 241, 0.1);
}

.skill-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.skill-header h3 {
    font-size: clamp(0.85rem, 1.8vw, 0.95rem);
    font-weight: 600;
    margin: 0;
    color: var(--text-heading);
    transition: color 0.4s ease;
}

.chevron {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: transform 0.35s ease, color 0.35s ease;
    flex-shrink: 0;
    line-height: 1;
}

.skill-card.active .chevron {
    transform: rotate(90deg);
    color: var(--dot-filled);
}

.skill-desc {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    margin: 0;
    font-size: clamp(0.75rem, 1.6vw, 0.82rem);
    line-height: 1.55;
    color: var(--text-subtitle);
    transition: max-height 0.4s ease, opacity 0.35s ease, margin 0.4s ease;
}

.skill-card.active .skill-desc {
    max-height: 200px;
    opacity: 1;
    margin-top: 0.75rem;
}

.skill-level {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: clamp(0.72rem, 1.6vw, 0.8rem);
    color: var(--text-subtitle);
    transition: color 0.4s ease;
}

.dots {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dot-empty);
    transition: transform 0.3s ease, background-color 0.4s ease;
}

.dot.filled {
    background: var(--dot-filled);
}

.dot.filled:hover {
    transform: scale(1.3);
}

/* ── Contacts ── */
.contacts-list {
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.5vw, 10px);
    margin-bottom: clamp(1.5rem, 4vw, 3rem);
}

.contact-item {
    display: flex;
    align-items: center;
    gap: clamp(10px, 2vw, 14px);
    padding: clamp(0.75rem, 2vw, 1rem) clamp(0.9rem, 2vw, 1.25rem);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.25s ease, background-color 0.4s ease;
}

.contact-item:hover {
    border-color: var(--dot-filled);
    box-shadow: 0 2px 16px rgba(99, 102, 241, 0.1);
    transform: translateX(4px);
}

.contact-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--avatar-bg);
    color: var(--avatar-color);
    flex-shrink: 0;
    transition: background-color 0.4s ease, color 0.4s ease;
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.contact-label {
    font-size: clamp(0.7rem, 1.5vw, 0.75rem);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    transition: color 0.4s ease;
}

.contact-value {
    font-size: clamp(0.82rem, 1.8vw, 0.9rem);
    color: var(--text-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.4s ease;
}

.contact-arrow {
    font-size: 1.1rem;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color 0.3s ease, transform 0.3s ease;
}

.contact-item:hover .contact-arrow {
    color: var(--dot-filled);
    transform: translateX(3px);
}

/* ── Footer ── */
footer {
    border-top: 1px solid var(--border-color);
    padding-top: clamp(1rem, 2vw, 1.5rem);
    padding-bottom: env(safe-area-inset-bottom, 0);
    margin-top: auto;
    text-align: center;
    font-size: clamp(0.75rem, 1.8vw, 0.85rem);
    color: var(--text-footer);
    transition: border-color 0.4s ease, color 0.4s ease;
}

/* ══════════════════════════════
   RESPONSIVIDADE
   ══════════════════════════════ */

/* ── Desktop grande / Ultra-wide (1200px+) ── */
@media (min-width: 1200px) {
    .portfolio {
        max-width: 860px;
    }

    .skills-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ── Tablet landscape (até 1024px) ── */
@media (max-width: 1024px) {
    .skills-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    }
}

/* ── Tablet portrait (até 768px) ── */
@media (max-width: 768px) {
    .skills-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Mobile grande (até 480px) ── */
@media (max-width: 480px) {
    .skills-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .skill-card {
        padding: 0.85rem;
    }

    .badge {
        font-size: 0.7rem;
        padding: 3px 10px;
    }
}

/* ── Mobile pequeno (até 360px) ── */
@media (max-width: 360px) {
    .skills-grid {
        grid-template-columns: 1fr;
    }

    .skill-level {
        flex-wrap: wrap;
        gap: 4px;
    }

    .theme-toggle {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }
}

/* ── Landscape mobile ── */
@media (max-height: 500px) and (orientation: landscape) {
    .portfolio {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    header {
        margin-bottom: 1rem;
        padding-bottom: 1rem;
    }

    .avatar {
        width: 48px;
        height: 48px;
        font-size: 18px;
        margin-bottom: 0.5rem;
    }

    .skills-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        margin-bottom: 1rem;
    }
}

/* ── Hover para dispositivos que suportam ── */
@media (hover: hover) and (pointer: fine) {
    .skill-card:hover {
        border-color: var(--dot-filled);
        box-shadow: 0 2px 12px rgba(99, 102, 241, 0.08);
    }
}

/* ── Safe area para iPhones com notch ── */
@supports (padding: env(safe-area-inset-bottom)) {
    .portfolio {
        padding-left: max(clamp(1rem, 3vw, 2rem), env(safe-area-inset-left));
        padding-right: max(clamp(1rem, 3vw, 2rem), env(safe-area-inset-right));
    }
}