:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --primary: #0f172a;
    --accent: #2563eb;
    --accent-light: #dbeafe;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --radius: 12px;
    --max-width: 1200px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 16px;
}

/* ── Navigation ── */

nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--primary);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}

.nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.nav-brand span {
    color: #60a5fa;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    list-style: none;
}

.nav-links a {
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.15s;
}

.nav-links a:hover {
    color: white;
}

/* ── Ukraine stripe (inner pages) ── */

.ukraine-stripe {
    height: 5px;
    background: linear-gradient(90deg, #005BBB 50%, #FFD500 50%);
}

/* ── Home page header with flag ── */

.page-header-home {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.ukraine-flag {
    height: 80px;
    width: auto;
    flex-shrink: 0;
    border-radius: 4px;
}

@media (max-width: 600px) {
    .page-header-home {
        flex-direction: column;
        text-align: center;
    }
    .ukraine-flag {
        height: 60px;
    }
}

/* ── Page header (inner pages) ── */

.page-header {
    background: var(--primary);
    color: white;
    padding: 3rem 1.5rem;
}

.page-header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
}

.page-header p {
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.9375rem;
}

/* ── Main container ── */

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

/* ── Two-column page grid ── */

.page-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 2rem;
    align-items: start;
}

/* ── Cards ── */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow 0.2s;
    margin-bottom: 1.5rem;
}

.card:last-child {
    margin-bottom: 0;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-img {
    width: 100%;
    display: block;
    max-height: 320px;
    object-fit: cover;
    object-position: center top;
}

.card-header {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.card-body {
    padding: 1.5rem 1.75rem;
}

.card-body p {
    font-size: 0.9375rem;
}

.card-body p + p {
    margin-top: 0.75rem;
}

/* ── Divider ── */

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

/* ── Tech section items ── */

.tech-item {
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border);
}

.tech-item:first-child {
    padding-top: 0;
}

.tech-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.tech-item h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.tech-item p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.tech-logo {
    margin-top: 0.875rem;
}

.tech-logo img {
    height: 50px;
    width: auto;
    display: block;
    transition: opacity 0.15s;
}

.tech-logo img:hover {
    opacity: 0.75;
}

/* ── Skills grid ── */

.skills-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.875rem;
    margin-top: 1.25rem;
}

.skill-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.625rem;
    padding: 1.25rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.15s;
    text-align: center;
}

.skill-card:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.skill-card img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.skill-card span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* ── Quick links list ── */

.links-list {
    list-style: none;
}

.links-list li {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: color 0.15s;
}

.links-list li:last-child {
    border-bottom: none;
}

.links-list li:hover .link-label {
    color: var(--accent);
}

.links-list img {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.link-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    display: block;
    transition: color 0.15s;
}

.link-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
    display: block;
}

/* ── Sticky sidebar ── */

.sidebar {
    position: sticky;
    top: 76px;
}

.sidebar .card {
    margin-bottom: 1.5rem;
}

.bio-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.75;
}

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    transition: all 0.15s;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.btn-outline:hover {
    background: var(--bg);
}

/* ── Links ── */

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── GitHub button wrapper ── */

.gh-btn {
    margin: 0.75rem 0 0.25rem;
}

/* ── Books page ── */

.books-list .book-item {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border);
}

.books-list .book-item:first-child {
    padding-top: 0;
}

.books-list .book-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.book-item h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.4rem;
    line-height: 1.4;
}

.book-item p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.65;
}

/* ── Policy pages ── */

.policy-content h4,
.policy-content h5 {
    font-size: 0.9375rem;
    font-weight: 700;
    margin: 1.5rem 0 0.5rem;
    color: var(--primary);
}

.policy-content h4:first-child,
.policy-content h5:first-child {
    margin-top: 0;
}

.policy-content p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.75;
    margin-bottom: 0.75rem;
}

.policy-content ul {
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.policy-content li {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.7;
    margin-bottom: 0.4rem;
}

/* ── Cookie detail tables ── */

.cookie-table-wrapper {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin: 0.75rem 0 1rem;
}

.cookie-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.cookie-table tr {
    border-bottom: 1px solid var(--border);
}

.cookie-table tr:last-child {
    border-bottom: none;
}

.cookie-table td {
    padding: 0.5rem 0.875rem;
    vertical-align: top;
    line-height: 1.5;
}

.cookie-table td:first-child {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    width: 110px;
}

.cookie-table td:last-child {
    color: var(--text-muted);
}

/* ── Contact form ── */

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}

.form-group input,
.form-group textarea {
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 140px;
}

.btn-submit {
    align-self: flex-start;
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

.form-success,
.form-error {
    text-align: center;
    padding: 2rem;
    font-weight: 600;
    font-size: 1.1rem;
}

.form-success { color: #16a34a; }
.form-error   { color: #dc2626; }

/* ── Error pages ── */

.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 55vh;
    text-align: center;
    padding: 4rem 1.5rem;
}

.error-code {
    font-size: 6rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    letter-spacing: -0.05em;
    margin-bottom: 1rem;
}

.error-message {
    font-size: 1.15rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* ── Footer ── */

footer {
    background: var(--primary);
    padding: 2.5rem 1.5rem;
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.footer-links {
    display: flex;
    gap: 2rem;
    list-style: none;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.15s;
}

.footer-links a:hover {
    color: white;
    text-decoration: none;
}

.footer-copy {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.3);
}

/* ── Responsive ── */

@media (max-width: 900px) {
    .page-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

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

    .nav-links {
        display: none;
    }
}

@media (max-width: 480px) {
    .footer-links {
        gap: 1rem;
    }

    .error-code {
        font-size: 4.5rem;
    }
}
