:root {
  --bg: #f7f5f2;
  --text: #1a1a1a;
  --muted: #6b6560;
  --fab-size: 56px;
  --panel-w: 380px;
  --panel-h: 500px;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --user-bubble: #2d2d2d;
  --ai-bubble: rgba(255, 255, 255, 0.92);
  --glass: rgba(255, 255, 255, 0.55);
  --shadow-lg: 0 18px 50px rgba(15, 15, 20, 0.12);
  --shadow-fab: 0 8px 24px rgba(99, 102, 241, 0.35);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Top navigation */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  padding: 0.85rem 1.25rem;
  background: transparent;
  transition:
    background 0.28s ease,
    backdrop-filter 0.28s ease,
    box-shadow 0.28s ease,
    border-color 0.28s ease;
  border-bottom: 1px solid transparent;
}

.top-nav.is-scrolled {
  background: rgba(247, 245, 242, 0.55);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border-bottom-color: rgba(0, 0, 0, 0.06);
  box-shadow: 0 8px 24px rgba(15, 15, 20, 0.04);
}

.top-nav__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.top-nav__link {
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: var(--text);
  transition: color 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

.top-nav__link:hover,
.top-nav__link:focus-visible {
  opacity: 0.7;
  outline: none;
}

.top-nav__link.is-active {
  opacity: 1;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.06);
  padding: 0.3rem 0.65rem;
  margin: -0.3rem -0.65rem;
  border-radius: 6px;
}

#projects {
  scroll-margin-top: 4.75rem;
}

#home {
  scroll-margin-top: 0;
}

.page {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem clamp(0.75rem, 2vw, 2rem) 6rem;
}

.page--with-nav {
  padding-top: 5.5rem;
}

.page-about .top-nav,
.page-projects .top-nav {
  background: rgba(247, 245, 242, 0.55);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.page-about .top-nav__link,
.page-projects .top-nav__link {
  color: var(--text);
  text-shadow: none;
}

.hero {
  width: 100%;
  height: 0;
  padding-top: 4.25rem;
  overflow: hidden;
  scroll-margin-top: 0;
}

.hero__eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.hero__title {
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 600;
  margin: 0 0 0.65rem;
  letter-spacing: -0.03em;
}

.hero__tagline {
  margin: 0;
  max-width: 42rem;
  font-size: 0.9375rem;
  line-height: 1.7;
  color: #9a948c;
  font-weight: 400;
}

.section-title {
  margin: 0 0 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.about {
  margin-top: 0.5rem;
  width: 100%;
  max-width: none;
  scroll-margin-top: 4.75rem;
}

.about__panel {
  background: #fff;
  border-radius: 8px;
  padding: 2rem 1.75rem 2.25rem;
  margin-bottom: 2.5rem;
  box-shadow: 0 4px 24px rgba(15, 15, 20, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.04);
  width: 100%;
  box-sizing: border-box;
}

.about__resume {
  width: 100%;
  box-sizing: border-box;
  background: #fff;
  border-radius: 8px;
  padding: 2rem 1.75rem 2.25rem;
  box-shadow: 0 4px 24px rgba(15, 15, 20, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.about__panel-title {
  margin: 0 0 1.75rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  text-align: left;
}

.about__intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: 0;
}

.about__portrait {
  margin: 0;
  width: min(200px, 46vw);
  border-radius: 4px;
  overflow: hidden;
  background: #ebe8e4;
}

.about__portrait img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: center 18%;
}

.about__name {
  margin: 1.15rem 0 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.about__blurb {
  margin: 0.55rem 0 0;
  max-width: 36rem;
  font-size: 0.9rem;
  line-height: 1.7;
  color: #6f6962;
}

.about__subtitle {
  margin: 0 0 1.5rem;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
}

.about__block {
  margin-bottom: 1.75rem;
}

@media (max-width: 560px) {
  .about__panel,
  .about__resume {
    padding: 1.5rem 1.15rem 1.75rem;
  }

  .about__panel-title {
    font-size: 1.25rem;
  }
}

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

.about__heading {
  margin: 0 0 0.55rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.about__block > p,
.about__list {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.7;
  color: #6f6962;
}

.about__list {
  padding-left: 1.2rem;
}

.about__list li + li {
  margin-top: 0.55rem;
}

.about__role {
  margin: 0 0 0.65rem !important;
  color: var(--text) !important;
  font-weight: 500;
}

.about__label {
  display: inline-block;
  margin-right: 0.35rem;
  font-weight: 600;
  color: #8a847c;
}

.about__block > p + p {
  margin-top: 0.65rem;
}

.home-welcome {
  max-width: 36rem;
  padding: 2rem 0 3rem;
}

.home-welcome__eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.home-welcome__title {
  margin: 0 0 0.75rem;
  font-size: clamp(2.25rem, 6vw, 3.25rem);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.home-welcome__lead {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  line-height: 1.65;
  color: #6f6962;
}

.home-welcome__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.home-welcome__btn {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: background 0.2s ease, transform 0.2s var(--spring);
}

.home-welcome__btn--primary {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.home-welcome__btn:hover,
.home-welcome__btn:focus-visible {
  transform: translateY(-2px);
  outline: none;
}

.works {
  margin-top: 0;
}

.works__title {
  margin: 0 0 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding: 2.5rem clamp(0.75rem, 2vw, 2rem) 5.5rem;
}

.site-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
}

.site-footer__label {
  margin: 0 0 1.1rem;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #b0aaa3;
}

.contact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 2.5rem;
}

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #8f897f;
  transition: color 0.2s ease, transform 0.25s var(--spring);
}

.contact-link:hover,
.contact-link:focus-visible {
  color: #6a645c;
  outline: none;
  transform: translateY(-2px);
}

.contact-link__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.035);
  color: #a8a29a;
  transition: background 0.2s ease, color 0.2s ease;
}

.contact-link:hover .contact-link__icon,
.contact-link:focus-visible .contact-link__icon {
  background: rgba(0, 0, 0, 0.055);
  color: #7d776f;
}

.contact-link__text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.contact-link__name {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b5afa7;
}

.contact-link__value {
  font-size: 0.9375rem;
  color: inherit;
}

.works__grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1rem, 2.5vw, 2.75rem) clamp(0.85rem, 2vw, 2.75rem);
}

.works__grid > li {
  margin: 0;
  min-width: 0;
}

.work-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
  color: inherit;
  cursor: default;
  box-shadow: 0 2px 10px rgba(15, 15, 20, 0.06);
  transition:
    transform 0.3s var(--ease-out),
    box-shadow 0.3s ease;
}

@media (hover: hover) {
  .work-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 16px 36px rgba(15, 15, 20, 0.12);
  }
}

.work-card__media {
  position: relative;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  background: #ebe8e4;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.work-card__stack {
  display: flex;
  flex-direction: row;
  height: 100%;
  width: 100%;
  transition: transform 0.35s var(--ease-out);
  will-change: transform;
}

.work-card__stack img {
  display: block;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}

.work-card__dots {
  position: absolute;
  left: 50%;
  bottom: 0.7rem;
  top: auto;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  gap: 0.4rem;
  z-index: 1;
  opacity: 1;
  padding: 0.35rem 0.5rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(6px);
}

.work-card__dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: none;
  transition: background 0.2s ease, transform 0.2s ease;
}

.work-card__dots span.is-active {
  background: #fff;
  transform: scale(1.2);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.work-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1rem 1.05rem 1.15rem;
}

.work-card__pdf {
  color: #7a746e;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.work-card__pdf:hover,
.work-card__pdf:focus-visible {
  color: var(--text);
}

.work-card__name {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
  color: var(--text);
}

.work-card__desc {
  margin: 0.45rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: #7a746e;
}

.work-card__meta {
  margin: auto 0 0;
  padding-top: 0.9rem;
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
  color: #a39e98;
}

@media (max-width: 560px) {
  .works__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.75rem;
  }

  .work-card__media {
    touch-action: pan-y;
  }
}

/* FAB */
.fab {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: var(--fab-size);
  height: var(--fab-size);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #6366f1, #8b5cf6);
  color: #fff;
  box-shadow: var(--shadow-fab);
  transition: transform 0.35s var(--spring), box-shadow 0.25s ease;
}

.fab:hover,
.fab:focus-visible {
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(99, 102, 241, 0.45);
  outline: none;
}

.fab__icon svg {
  width: 26px;
  height: 26px;
}

.fab__tooltip {
  position: absolute;
  right: calc(100% + 12px);
  white-space: nowrap;
  padding: 0.45rem 0.75rem;
  font-size: 0.8125rem;
  background: rgba(26, 26, 26, 0.92);
  color: #fff;
  border-radius: 8px;
  opacity: 0;
  transform: translateX(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.25s var(--ease-out);
}

.fab:hover .fab__tooltip,
.fab:focus-visible .fab__tooltip {
  opacity: 1;
  transform: translateX(0);
}

.fab__badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #fff;
  animation: badge-pulse 2s ease-in-out infinite;
}

.fab__badge.is-hidden {
  display: none;
}

@keyframes badge-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.15);
    opacity: 0.75;
  }
}

/* Backdrop (mobile) */
.chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 20, 0.35);
  backdrop-filter: blur(4px);
  z-index: 1001;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.chat-backdrop.is-visible {
  opacity: 1;
}

/* Chat panel */
.chat-panel {
  position: fixed;
  right: 1.25rem;
  bottom: calc(1.25rem + var(--fab-size) + 12px);
  width: var(--panel-w);
  height: var(--panel-h);
  max-height: calc(100vh - 2rem - var(--fab-size));
  z-index: 1002;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow-lg);
  transform-origin: right bottom;
  transform: scale(0.4) translate(20px, 20px);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.45s var(--spring),
    opacity 0.3s ease;
}

.chat-panel.is-open {
  transform: scale(1) translate(0, 0);
  opacity: 1;
  pointer-events: auto;
}

.chat-panel.is-closing {
  transition-duration: 0.22s;
  transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
  transform: scale(0.35) translate(24px, 24px);
  opacity: 0;
}

.chat-panel.is-minimized {
  transform: scale(0.08) translate(120px, 120px);
  opacity: 0;
  pointer-events: none;
}

.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.75rem;
  background: rgba(255, 255, 255, 0.35);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-header__identity {
  display: flex;
  gap: 0.75rem;
  min-width: 0;
}

.chat-header__avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.chat-header__avatar {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: cover;
  object-position: center 20%;
}

.chat-header__status {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
  animation: status-breathe 2.4s ease-in-out infinite;
}

@keyframes status-breathe {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0);
  }
}

.chat-header__title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.chat-header__subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.chat-header__actions {
  display: flex;
  gap: 0.25rem;
}

.icon-btn {
  border: none;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s ease;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.09);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  scroll-behavior: smooth;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.15) 0%,
    rgba(255, 255, 255, 0.05) 100%
  );
}

.msg {
  display: flex;
  margin-bottom: 0.75rem;
  animation: msg-in 0.35s var(--ease-out) both;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg--user {
  justify-content: flex-end;
}

.msg__bubble {
  max-width: 85%;
  padding: 0.65rem 0.85rem;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
}

.msg--user .msg__bubble {
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg--ai .msg__bubble {
  background: var(--ai-bubble);
  color: #2a2a2a;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.msg__cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: #6366f1;
  animation: cursor-blink 0.9s step-end infinite;
}

@keyframes cursor-blink {
  50% {
    opacity: 0;
  }
}

.thinking {
  display: flex;
  gap: 5px;
  padding: 0.65rem 0.85rem;
  background: var(--ai-bubble);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.thinking span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  animation: dot-bounce 1.2s ease-in-out infinite;
}

.thinking span:nth-child(2) {
  animation-delay: 0.15s;
}

.thinking span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes dot-bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

.chat-quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 1rem 0.75rem;
}

.chat-quick-prompts.is-empty {
  display: none;
}

.quick-prompt {
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: background 0.15s ease, transform 0.2s var(--spring);
}

.quick-prompt:hover {
  background: #fff;
  transform: scale(1.02);
}

.chat-input-area {
  padding: 0.65rem 1rem 0.75rem;
  background: rgba(255, 255, 255, 0.4);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 14px;
  padding: 0.35rem 0.35rem 0.35rem 0.85rem;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-input {
  flex: 1;
  border: none;
  resize: none;
  font-family: inherit;
  font-size: 0.875rem;
  line-height: 1.45;
  max-height: 120px;
  background: transparent;
  padding: 0.35rem 0;
  outline: none;
}

.send-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.06);
  color: #9ca3af;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s var(--spring);
}

.send-btn.is-active {
  background: linear-gradient(145deg, #6366f1, #8b5cf6);
  color: #fff;
}

.send-btn.is-active:hover {
  transform: scale(1.05);
}

.send-btn:disabled {
  cursor: not-allowed;
}

.chat-powered {
  margin: 0.45rem 0 0;
  text-align: center;
  font-size: 0.6875rem;
  color: rgba(0, 0, 0, 0.35);
}

@media (max-width: 480px) {
  .fab__tooltip {
    display: none;
  }

  .chat-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    transform-origin: center bottom;
  }

  .chat-panel.is-open {
    bottom: 0;
  }

  .fab {
    bottom: 1rem;
    right: 1rem;
  }
}

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