:root {
  --portfolio-width: 760px;
  --portfolio-gap: clamp(3.6rem, 8vw, 6.5rem);
}

body { min-height: 100vh; }

.portfolio-nav {
  position: sticky;
  top: 14px;
  z-index: 100;
  width: min(calc(100% - 2rem), var(--portfolio-width));
  margin: 14px auto 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur-slow) var(--ease), box-shadow var(--dur-slow) var(--ease);
}

.portfolio-nav.scrolled { border-color: var(--border-strong); box-shadow: var(--shadow); }
.portfolio-nav-inner { min-height: 56px; padding: .45rem .55rem .45rem 1rem; display: flex; align-items: center; gap: 1rem; }
.portfolio-nav .brand { font-size: .96rem; white-space: nowrap; }
.portfolio-nav .brand .dot { width: 9px; height: 9px; box-shadow: 0 0 0 3px var(--accent-soft); }
.portfolio-links { margin-left: auto; display: flex; align-items: center; gap: 1.25rem; }
.portfolio-links a { color: var(--text-muted); font-size: .88rem; font-weight: var(--weight-medium); transition: color var(--dur-fast) var(--ease); }
.portfolio-links a:hover { color: var(--text); }
.portfolio-actions { display: flex; align-items: center; gap: .45rem; }
.portfolio-actions .icon-btn { width: 36px; height: 36px; }
.compact-cta { padding: .62rem 1rem; font-size: .88rem; }
.theme-moon, :root[data-theme="dark"] .theme-sun { display: none; }
:root[data-theme="dark"] .theme-moon { display: block; }

.portfolio-shell {
  width: min(calc(100% - 2.5rem), var(--portfolio-width));
  margin-inline: auto;
  padding: clamp(4rem, 9vw, 6.5rem) 0 7rem;
}

.profile-section { scroll-margin-top: 100px; }
.profile-head { display: flex; align-items: center; gap: 1.15rem; }
.profile-avatar { width: 74px; height: 74px; border-radius: 50%; object-fit: cover; object-position: 50% 22%; border: 3px solid var(--bg-elev); box-shadow: var(--shadow); }
.profile-head h1 { font-size: clamp(1.55rem, 4vw, 2rem); }
.profile-head p { color: var(--text-muted); margin-top: .25rem; line-height: 1.45; }
.profile-copy { margin-top: 2.4rem; max-width: 68ch; }
.profile-links { margin-top: 1.7rem; display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; }
.profile-links a, .profile-links span { display: inline-flex; align-items: center; gap: .45rem; color: var(--text-muted); font-size: .92rem; }
.profile-links a { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.profile-links img { width: 17px; height: 17px; opacity: .8; }
:root[data-theme="dark"] .profile-links img { filter: brightness(0) invert(1); }

.portfolio-section { padding-top: var(--portfolio-gap); scroll-margin-top: 86px; }
.portfolio-section > h2, .contact-panel h2 { font-size: clamp(1.65rem, 4vw, 2.2rem); margin-bottom: 2rem; }
.compact-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; margin-bottom: 2rem; }
.compact-section-head h2 { font-size: clamp(1.65rem, 4vw, 2.2rem); }
.text-link { color: var(--text-muted); font-size: .9rem; font-weight: var(--weight-medium); white-space: nowrap; }
.text-link span { color: var(--accent); }

.project-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem 1rem; }
.project-card { display: block; color: inherit; }
.project-card:hover { color: inherit; }
.project-image { position: relative; overflow: hidden; aspect-ratio: 4 / 3; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: transform var(--dur-slow) var(--ease), border-color var(--dur-slow) var(--ease), box-shadow var(--dur-slow) var(--ease); }
.project-card:hover .project-image { transform: translateY(var(--lift-card)); border-color: var(--border-strong); box-shadow: var(--shadow); }
.project-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
.project-card:hover .project-image img { transform: scale(1.025); }
.project-image.screenshot img { object-position: left top; }
.project-image.softwarewende-shot img { object-position: 50% 0; }
.project-arrow { position: absolute; top: .7rem; right: .7rem; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--accent-ink); background: var(--accent); box-shadow: var(--shadow-sm); opacity: 0; transform: translate(-4px, 4px); transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
.project-card:hover .project-arrow { opacity: 1; transform: none; }
.project-caption { display: flex; justify-content: space-between; gap: 1rem; padding: .85rem .15rem 0; }
.project-caption strong, .project-caption span { display: block; }
.project-caption strong { font-family: var(--font-display); font-size: 1rem; line-height: 1.25; }
.project-caption div > span, .project-status { color: var(--text-faint); font-size: .82rem; margin-top: .16rem; }
.project-status { white-space: nowrap; }

.skill-list { border-top: 1px solid var(--border); }
.skill-list > div { display: grid; grid-template-columns: 160px 1fr; gap: 1.5rem; padding: 1.15rem 0; border-bottom: 1px solid var(--border); }
.skill-list dt { font-family: var(--font-display); font-weight: var(--weight-semibold); }
.skill-list dd { color: var(--text-muted); }
.portfolio-tools { margin-top: 1.5rem; }
.portfolio-tools .tool { padding-top: .45rem; padding-bottom: .45rem; }

.timeline { position: relative; }
.timeline::before { content: ""; position: absolute; top: 18px; bottom: 20px; left: 19px; width: 1px; background: var(--border); }
.timeline-item { position: relative; display: grid; grid-template-columns: 40px 1fr; gap: 1.25rem; padding-bottom: 2.2rem; }
.timeline-marker { position: relative; z-index: 1; width: 40px; height: 40px; border-radius: var(--radius-input); border: 1px solid var(--border); background: var(--bg-elev); display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.timeline-marker span { font-family: var(--font-display); color: var(--accent); font-size: .78rem; font-weight: var(--weight-bold); }
.timeline-item time { display: block; color: var(--text-faint); font-size: .84rem; margin-bottom: .2rem; }
.timeline-item h3 { font-size: 1.08rem; }
.timeline-item p { color: var(--text-muted); font-size: .96rem; margin-top: .4rem; max-width: 62ch; }

.notes-list { border-top: 1px solid var(--border); }
.notes-list a { display: grid; grid-template-columns: minmax(0, 1fr) 140px 24px; gap: 1rem; align-items: center; padding: 1.15rem 0; border-bottom: 1px solid var(--border); transition: color var(--dur-fast) var(--ease), padding var(--dur-fast) var(--ease); }
.notes-list a:hover { padding-left: .4rem; }
.notes-list small { color: var(--text-faint); }
.notes-list b { color: var(--accent); font-weight: var(--weight-medium); }

.contact-panel { margin-top: var(--portfolio-gap); padding: clamp(1.7rem, 5vw, 2.6rem); border: 1px solid var(--border); border-radius: var(--radius-lg); background: linear-gradient(120deg, var(--accent-soft), transparent 60%), var(--bg-elev); }
.contact-panel h2 { margin-bottom: .8rem; }
.contact-panel p { color: var(--text-muted); max-width: 48ch; }
.contact-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.6rem; }

.portfolio-footer { border-top: 1px solid var(--border); }
.portfolio-footer > div { width: min(calc(100% - 2.5rem), var(--portfolio-width)); margin-inline: auto; min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; color: var(--text-faint); font-size: .9rem; }
.portfolio-footer nav { display: flex; gap: 1.2rem; }

.listing-page,
.detail-page { padding-top: clamp(4.5rem, 9vw, 7rem); }

.page-head { max-width: 660px; margin-bottom: clamp(2.8rem, 7vw, 4.8rem); }
.page-head h1 { margin-top: .5rem; font-size: clamp(2.45rem, 8vw, 4.8rem); line-height: .98; letter-spacing: -.045em; }
.page-head > p { max-width: 54ch; margin-top: 1.2rem; color: var(--text-muted); font-size: clamp(1.04rem, 2.4vw, 1.2rem); }

.back-link { display: inline-flex; margin-bottom: 2.4rem; color: var(--text-muted); font-size: .92rem; font-weight: var(--weight-medium); }
.back-link:hover { color: var(--text); }
.detail-head { margin-bottom: 2.2rem; }

.detail-meta { display: flex; flex-wrap: wrap; gap: 1.25rem 3rem; margin-top: 2rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }
.detail-meta div { min-width: 130px; }
.detail-meta dt { color: var(--text-faint); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.detail-meta dd { margin-top: .2rem; font-family: var(--font-display); font-weight: var(--weight-semibold); }

.detail-hero { overflow: hidden; margin: 0 0 clamp(3rem, 7vw, 5rem); aspect-ratio: 16 / 10; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.detail-hero img { width: 100%; height: 100%; object-fit: cover; }
.detail-body { max-width: 660px; }
.detail-body > :first-child { margin-top: 0; }
.detail-body h2 { margin-top: 3.1rem; font-size: clamp(1.45rem, 4vw, 1.9rem); }
.detail-body h3 { margin-top: 2.5rem; }
.detail-body h4 { margin-top: 2.1rem; }
.detail-body :is(h2, h3, h4) + :is(p, ul, ol) { margin-top: 1.05rem; }
.detail-body p + :is(ul, ol),
.detail-body :is(ul, ol) + p { margin-top: 1.3rem; }
.detail-body ul, .detail-body ol { padding-left: 1.45rem; }
.detail-body li { padding-left: .2rem; line-height: 1.65; }
.detail-body li + li { margin-top: .6rem; }
.detail-body a:not(.btn) { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.detail-action { margin-top: 2.4rem; }

.notes-index a { grid-template-columns: minmax(0, 1fr) 150px 24px; align-items: start; padding-block: 1.4rem; }
.notes-index span { display: grid; gap: .35rem; }
.notes-index strong { font-family: var(--font-display); font-size: 1.04rem; }
.notes-index small { max-width: 54ch; line-height: 1.45; }
.notes-index time { color: var(--text-faint); font-size: .84rem; }
.note-date { display: block; margin-top: 1.4rem; color: var(--text-faint); font-size: .88rem; }
.note-page .detail-body { font-size: 1.08rem; }

.legal-page .page-head { margin-bottom: 3.2rem; }
.legal-body h2:first-child { margin-top: 0; }
.legal-body p { max-width: 62ch; }
.muted-box { margin: 2rem 0; padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: var(--radius-input); color: var(--text-muted); background: var(--surface); font-size: .92rem; }
.not-found { min-height: 55vh; display: grid; align-content: center; }

@media (max-width: 760px) {
  .portfolio-links { display: none; }
  .portfolio-actions { margin-left: auto; }
  .project-grid { gap: 1.4rem .8rem; }
}

@media (max-width: 600px) {
  .portfolio-nav .brand { font-size: .9rem; }
  .compact-cta { display: none; }
  .portfolio-shell { padding-top: 3.5rem; }
  .project-grid { grid-template-columns: 1fr; }
  .compact-section-head { align-items: flex-start; flex-direction: column; }
  .skill-list > div { grid-template-columns: 1fr; gap: .3rem; }
  .notes-list a { grid-template-columns: 1fr 24px; }
  .notes-list small { grid-row: 2; }
  .notes-list b { grid-column: 2; grid-row: 1 / span 2; }
  .notes-index a { grid-template-columns: 1fr 24px; }
  .notes-index time { grid-column: 1; grid-row: 2; }
  .notes-index b { grid-column: 2; grid-row: 1 / span 2; }
  .page-head h1 { font-size: clamp(2.35rem, 13vw, 3.6rem); }
  .detail-hero { aspect-ratio: 4 / 3; border-radius: var(--radius); }
  .portfolio-footer > div { align-items: flex-start; flex-direction: column; padding-block: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .project-image img, .project-arrow, .notes-list a, .portfolio-nav { transition: none; }
}
