:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #eef3fa;
  --text: #142137;
  --muted: #53647a;
  --border: #dbe3ee;
  --accent: #2459d3;
  --accent-soft: #e8efff;
  --shadow: 0 16px 45px rgba(20, 33, 55, .06);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #111d30;
  --surface-alt: #18263b;
  --text: #edf4ff;
  --muted: #a9b8cb;
  --border: #2a3a50;
  --accent: #8eb1ff;
  --accent-soft: #1b3158;
  --shadow: 0 16px 45px rgba(0, 0, 0, .18);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { color-scheme: dark; --bg: #0b1220; --surface: #111d30; --surface-alt: #18263b; --text: #edf4ff; --muted: #a9b8cb; --border: #2a3a50; --accent: #8eb1ff; --accent-soft: #1b3158; --shadow: 0 16px 45px rgba(0, 0, 0, .18); }
}
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: 'Open Sans', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 1.7; }
a { color: var(--accent); }
a:hover, a:focus { color: var(--accent); }
a:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
h1, h2, h3, h4, h5, h6 { color: var(--text); letter-spacing: -.035em; }
p { line-height: 1.75; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 9999; padding: 10px 15px; color: var(--text); background: var(--surface); border: 2px solid var(--accent); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.navbar-custom, .navbar-custom.top-nav-short { background: var(--bg); border-color: var(--border); padding: 8px 0; }
.navbar-custom .container-fluid { max-width: 1240px; margin: auto; padding-left: 30px; padding-right: 30px; }
.navbar-custom .avatar-container { display: none !important; }
.navbar-custom .navbar-brand, .navbar-custom .nav li a { color: var(--text); }
.navbar-custom .navbar-brand { font-weight: 800; letter-spacing: -.04em; font-size: 19px; }
.navbar-custom .nav li a { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 600; }
.navbar-custom .navbar-brand:hover, .navbar-custom .navbar-brand:focus, .navbar-custom .nav li a:hover, .navbar-custom .nav li a:focus { color: var(--accent); }
.navbar-custom .nav .navlinks-container .navlinks-children a { background: var(--surface); border-color: var(--border); color: var(--text); }
.navbar-custom .nav .navlinks-container .navlinks-children a:hover { color: var(--accent); }
.navbar-default .navbar-toggle { border-color: var(--border); }
.navbar-default .navbar-toggle .icon-bar { background: var(--text); }
.navbar-default .navbar-toggle:hover, .navbar-default .navbar-toggle:focus { background: var(--surface-alt); }
.theme-switch-item { display: flex; align-items: center; min-height: 50px; padding: 0 8px; }
.theme-switch { color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 100px; padding: 6px 12px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.theme-switch:hover { border-color: var(--accent); color: var(--accent); }
.theme-switch-icon { font-size: 16px; margin-right: 6px; vertical-align: -1px; }

.shell { width: min(1120px, calc(100% - 48px)); margin-left: auto; margin-right: auto; }
.portfolio-home { padding-top: 120px; }
.hero { display: grid; grid-template-columns: 1.15fr .85fr; align-items: center; gap: 70px; min-height: 460px; padding-top: 38px; padding-bottom: 55px; }
.eyebrow { margin: 0 0 18px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .14em; line-height: 1.4; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; background: #48bf99; border-radius: 50%; }
.hero h1 { max-width: 700px; margin: 0; font-size: clamp(40px, 5.4vw, 67px); line-height: 1.08; letter-spacing: -.055em; }
.hero h1 span { color: var(--accent); }
.hero-lead { max-width: 570px; margin: 25px 0 28px; color: var(--muted); font-size: 18px; }
.hero-actions, .hero-links { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.button { display: inline-flex; gap: 18px; align-items: center; justify-content: center; padding: 12px 19px; border: 1px solid transparent; border-radius: 9px; font-size: 13px; font-weight: 700; text-decoration: none !important; }
.button-primary, .button-primary:hover, .button-primary:focus { background: #2459d3; color: #fff; }
.button-secondary, .button-secondary:hover, .button-secondary:focus { border-color: var(--border); background: var(--surface); color: var(--text); }
.hero-links { margin-top: 25px; gap: 22px; }
.hero-links a { color: var(--muted); font-size: 12px; font-weight: 700; }
.hero-visual { padding: 25px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.visual-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.visual-dots { color: var(--accent); letter-spacing: .2em; }
.visual-center { display: flex; align-items: center; gap: 20px; margin: 30px 0; color: var(--muted); font-size: 17px; line-height: 1.45; }
.visual-center strong { color: var(--text); font-size: 24px; }
.visual-icon { display: grid; place-items: center; width: 74px; height: 74px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); font-size: 42px; }
.visual-row { display: flex; gap: 15px; align-items: center; padding: 13px 0; border-top: 1px solid var(--border); font-size: 13px; }
.visual-row > span:first-child { color: var(--muted); font-size: 11px; }
.visual-row > span:last-child { margin-left: auto; color: var(--accent); }
.home-section { padding-top: 65px; padding-bottom: 35px; border-top: 1px solid var(--border); }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 25px; margin-bottom: 27px; }
.section-heading h2, .contact-section h2 { margin: 0; font-size: clamp(28px, 3.2vw, 39px); line-height: 1.2; }
.section-heading > p { max-width: 265px; margin: 0; color: var(--muted); font-size: 13px; }
.section-link { font-size: 13px; font-weight: 700; white-space: nowrap; }
.focus-grid, .project-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.focus-card, .project-card, .article-card { min-width: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.focus-card, .project-card { padding: 26px; }
.focus-card h3, .project-card h3 { margin: 26px 0 10px; font-size: 19px; line-height: 1.3; }
.focus-card p, .project-card p { min-height: 75px; margin: 0 0 23px; color: var(--muted); font-size: 13px; }
.card-number, .project-type, .article-date { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.card-tags span { padding: 4px 8px; border-radius: 5px; background: var(--surface-alt); color: var(--muted); font-size: 10px; font-weight: 700; }
.project-card { position: relative; display: block; color: var(--text); text-decoration: none !important; transition: transform .2s, border-color .2s; }
.project-card:hover, .project-card:focus { color: var(--text); border-color: var(--accent); transform: translateY(-3px); }
.project-arrow { position: absolute; top: 23px; right: 24px; color: var(--accent); font-size: 18px; }
.writing-list { border-top: 1px solid var(--border); }
.writing-item { display: grid; grid-template-columns: 145px 1fr 25px; gap: 20px; align-items: center; padding: 21px 0; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none !important; }
.writing-item:hover { color: var(--accent); }
.writing-date { color: var(--muted); font-size: 12px; }
.writing-title { font-weight: 700; }
.writing-arrow { color: var(--accent); text-align: right; }
.contact-section { display: flex; justify-content: space-between; align-items: center; gap: 30px; margin-top: 45px; margin-bottom: 35px; padding: 40px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.contact-section p:not(.eyebrow) { margin: 12px 0 0; color: var(--muted); font-size: 14px; }

.intro-header { margin-top: 125px; margin-bottom: 35px; }
.intro-header .page-heading, .intro-header .post-heading { text-align: left; }
.intro-header .page-heading h1, .intro-header .post-heading h1 { font-size: clamp(34px, 5vw, 52px); line-height: 1.15; }
.intro-header .page-heading .page-subheading, .intro-header .post-heading .post-subheading { color: var(--muted); font-size: 19px; line-height: 1.5; }
.intro-header hr.small { margin-left: 0; border-color: var(--accent); border-width: 3px; }
.intro-header .post-heading .post-meta { color: var(--muted); }
.header-section.has-img .no-img { background: var(--surface); }
.blog-post { font-family: 'Lora', Georgia, serif; font-size: 17px; line-height: 1.8; overflow-wrap: break-word; }
.blog-post h2, .blog-post h3 { margin-top: 1.8em; line-height: 1.3; }
.blog-post img { height: auto; border-radius: 8px; }
.blog-post blockquote { color: var(--muted); border-color: var(--accent); }
.blog-post pre { overflow-x: auto; background: #f3f5f9; color: #172033; border: 1px solid var(--border); border-radius: 8px; }
.blog-post code { overflow-wrap: normal; }
.blog-post table { display: block; max-width: 100%; overflow-x: auto; }
.blog-post th, .blog-post td { padding: 8px 12px; border: 1px solid var(--border); }
.blog-post th { background: var(--surface-alt); }
.projects-page [role="main"] h2 { margin-top: 54px; margin-bottom: 20px; font-size: 26px; }
.projects-page [role="main"] h3 { margin: 16px 0 0; padding: 22px 24px 0; border: 1px solid var(--border); border-bottom: 0; border-radius: 12px 12px 0 0; background: var(--surface); font-size: 19px; }
.projects-page [role="main"] h3 + p { margin: 0; padding: 12px 24px 22px; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 12px 12px; background: var(--surface); color: var(--muted); font-size: 14px; }
.projects-page [role="main"] hr { border-color: var(--border); }
.blog-tags { color: var(--muted); }
.pager li > a, .pager li > span { background: var(--surface); color: var(--text); border-color: var(--border); }
.pager li > a:hover, .pager li > a:focus { background: var(--accent-soft); color: var(--accent); }
.blog-intro { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 28px; }
.blog-intro p { margin: 0; color: var(--muted); }
.article-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.article-card { overflow: hidden; }
.article-image { display: block; height: 170px; overflow: hidden; background: var(--surface-alt); }
.article-image img { width: 100%; height: 100%; object-fit: cover; }
.article-body { padding: 22px; }
.article-date { margin: 0 0 10px; }
.article-body h2 { margin: 0 0 10px; font-size: 19px; line-height: 1.35; }
.article-body h2 a { color: var(--text); }
.article-body h2 a:hover { color: var(--accent); }
.article-summary { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.article-read { display: inline-block; margin-top: 18px; font-size: 12px; font-weight: 700; }
footer { border-color: var(--border); background: var(--surface); }
footer p.text-muted, footer a { color: var(--muted); }
footer a:hover { color: var(--accent); }

@media (max-width: 767px) {
  .navbar-custom .container-fluid { padding-left: 18px; padding-right: 18px; }
  .navbar-custom .navbar-collapse { border-color: var(--border); }
  .theme-switch-item { padding: 8px 15px; }
  .portfolio-home { padding-top: 85px; }
  .hero { grid-template-columns: 1fr; gap: 30px; padding-top: 20px; padding-bottom: 45px; }
  .hero-lead { font-size: 16px; }
  .focus-grid, .project-grid { grid-template-columns: 1fr; }
  .focus-card p, .project-card p { min-height: 0; }
  .section-heading { align-items: start; flex-direction: column; gap: 12px; }
  .writing-item { grid-template-columns: 1fr 25px; gap: 5px 15px; }
  .writing-date { grid-column: 1 / -1; }
  .contact-section { flex-direction: column; align-items: flex-start; padding: 27px; }
  .intro-header { margin-top: 105px; }
  .blog-intro { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 520px) {
  .shell { width: calc(100% - 36px); }
  .article-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .project-card { transition: none; }
}
