*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg: #0d1117;
    --card-bg: #161b22;
    --card-border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --accent-2: #bc8cff;
    --badge-bg: rgba(88, 166, 255, 0.1);
    --badge-border: rgba(88, 166, 255, 0.25);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --transition: 0.3s ease;
}

[data-theme="light"] {
    --bg: #f6f8fa;
    --card-bg: #ffffff;
    --card-border: #d0d7de;
    --text-primary: #1c2128;
    --text-secondary: #656d76;
    --accent: #0969da;
    --accent-2: #8250df;
    --badge-bg: rgba(9, 105, 218, 0.08);
    --badge-border: rgba(9, 105, 218, 0.2);
    --shadow: 0 8px 32px rgba(140, 149, 159, 0.2);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition), color var(--transition);
    position: relative;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    padding:
        env(safe-area-inset-top)
        env(safe-area-inset-right)
        env(safe-area-inset-bottom)
        env(safe-area-inset-left);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(var(--accent) 1px, transparent 1px),
        linear-gradient(90deg, var(--accent) 1px, transparent 1px);
    background-size: 60px 60px;
    opacity: 0.03;
    z-index: 0;
    pointer-events: none;
}

.container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: background-color var(--transition), border-color var(--transition), box-shadow var(--transition);
    animation: cardIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

.card-accent {
    height: 5px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.card-body {
    padding: 2.25rem 2rem 2rem;
    text-align: center;
}

.avatar {
    width: 90px;
    height: 90px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-radius: 50%;
    margin: 0 auto 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.05em;
    box-shadow: 0 4px 20px rgba(88, 166, 255, 0.3);
}

.name {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
    transition: color var(--transition);
}

.job-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--accent);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.divider {
    height: 1px;
    background: var(--card-border);
    margin: 1.5rem 0;
    transition: background-color var(--transition);
}

/* Contacts */
.contacts {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-secondary);
    border: 1px solid transparent;
    transition: all var(--transition);
    text-align: left;
}

.contact-item:hover {
    color: var(--accent);
    background: var(--badge-bg);
    border-color: var(--badge-border);
    transform: translateX(3px);
}

.contact-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}

.contact-icon svg {
    width: 18px;
    height: 18px;
}

.contact-text {
    font-size: 0.9rem;
    word-break: break-all;
}

/* Skills */
.skills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.badge {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--accent);
    background: var(--badge-bg);
    border: 1px solid var(--badge-border);
    border-radius: 20px;
    padding: 0.3rem 0.75rem;
    letter-spacing: 0.02em;
    transition: all var(--transition);
    cursor: default;
}

.badge:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* Social Links */
.socials {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

.social-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all var(--transition);
}

.social-btn svg {
    width: 20px;
    height: 20px;
}

.social-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--badge-bg);
    transform: translateY(-2px);
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 100;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    box-shadow: var(--shadow);
}

.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    position: absolute;
    transition: opacity 0.2s, transform 0.3s;
}

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

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

/* CV Button */
.cv-btn {
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background-color: transparent;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.cv-btn svg {
    width: 16px;
    height: 16px;
}

.cv-btn:hover {
    color: #4ade80;
    border-color: #4ade80;
    background: rgba(74, 222, 128, 0.06);
}

/* Terminal Overlay */
.terminal-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.terminal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.terminal-window {
    width: 100%;
    max-width: 640px;
    max-height: 82vh;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
    transform: translateY(16px);
    transition: transform 0.25s ease;
}

.terminal-overlay.open .terminal-window {
    transform: translateY(0);
}

.terminal-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
}

.terminal-dots {
    display: flex;
    gap: 6px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: opacity 0.15s;
}

.dot:hover { opacity: 0.75; }
.dot-red    { background: #ff5f57; }
.dot-yellow { background: #febc2e; }
.dot-green  { background: #28c840; cursor: default; }

.terminal-title {
    flex: 1;
    text-align: center;
    font-family: 'Fira Code', 'Cascadia Code', 'Courier New', monospace;
    font-size: 0.78rem;
    color: #6e7681;
    margin-right: 54px;
}

.terminal-body {
    padding: 1.25rem 1.5rem 1.5rem;
    overflow-y: auto;
    flex: 1;
    font-family: 'Fira Code', 'Cascadia Code', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.7;
    color: #e6edf3;
    scrollbar-width: thin;
    scrollbar-color: #30363d transparent;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.tline { white-space: pre; }
.tcmd .tprompt { color: #4ade80; }
.tcmd span:not(.tprompt) { color: #79c0ff; }
.tdim  { color: #6e7681; }
.tsep  { color: #388bfd; }

.tbar-label { color: #e6edf3; }
.tbar-track { color: #6e7681; }
.tbar-fill  { color: #4ade80; }
.tbar-pct   { color: #8b949e; }

.tblink {
    animation: blink 1s step-end infinite;
    color: #4ade80;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* ── Mobile (≤ 480px) ───────────────────────────────────── */
@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }

    .card-body {
        padding: 1.5rem 1.1rem 1.25rem;
    }

    .avatar {
        width: 72px;
        height: 72px;
        font-size: 1.5rem;
    }

    .name { font-size: 1.35rem; }

    /* Bigger tap targets */
    .contact-item {
        padding: 0.9rem 0.85rem;
        gap: 0.75rem;
    }

    .contact-text { font-size: 0.85rem; }

    .badge {
        font-size: 0.75rem;
        padding: 0.28rem 0.65rem;
    }

    .social-btn {
        width: 48px;
        height: 48px;
    }

    .cv-btn {
        padding: 0.85rem 1rem;
    }

    .theme-toggle {
        top: auto;
        bottom: 1.25rem;
        right: 1.25rem;
        left: auto;
        width: 38px;
        height: 38px;
    }

    /* Terminal: sheet slides up from bottom */
    .terminal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .terminal-window {
        max-width: 100%;
        width: 100%;
        max-height: 88vh;
        border-radius: 16px 16px 0 0;
    }

    .terminal-title { display: none; }

    .terminal-body {
        font-size: 0.75rem;
        padding: 1rem 1rem 1.25rem;
    }
}

/* ── Tablet (481px – 768px) ─────────────────────────────── */
@media (min-width: 481px) and (max-width: 768px) {
    .container { max-width: 460px; }

    .terminal-window {
        max-width: 520px;
        max-height: 80vh;
    }
}

/* ── Desktop (≥ 769px) ──────────────────────────────────── */
@media (min-width: 769px) {
    .container { max-width: 480px; }

    .card-body { padding: 2.75rem 2.5rem 2.25rem; }

    .avatar {
        width: 100px;
        height: 100px;
        font-size: 2rem;
    }

    .name { font-size: 1.8rem; }

    .contact-item { padding: 0.8rem 1.1rem; }

    .terminal-window {
        max-width: 680px;
        max-height: 78vh;
    }

    .terminal-body { font-size: 0.88rem; }
}

/* ── Large Desktop (≥ 1200px) ───────────────────────────── */
@media (min-width: 1200px) {
    .container { max-width: 520px; }

    .terminal-window { max-width: 740px; }
}

/* ── Touch feedback ─────────────────────────────────────── */
.contact-item:active {
    transform: translateX(3px) scale(0.98);
    opacity: 0.85;
}

.social-btn:active,
.cv-btn:active,
.theme-toggle:active {
    transform: scale(0.92);
    opacity: 0.8;
}

.badge:active {
    transform: translateY(-2px) scale(0.95);
}

/* ── Reduced motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
